Does Actionscript Have An Equivalent To...?
Javascript has the setTimeout() method. Does Actionscript 5 have an equivalent? It would be nice so I can control a couple movie clips.
Thanks!
FlashKit > Flash Help > Flash ActionScript
Posted on: 06-24-2002, 09:25 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
_root Equivalent For This Actionscript
Howdy. I'm following a tutorial made in actionscript 2 and naturally the code is gelling well with my actionscript 3 document. I guess I have two questions. Is it easy to start a new document with what I've done non-code wise already in Flash 9 but using actionscript 2 instead of 3? Or would it be easier to redo the actionscript in 3 format?
Below is the original actionscript I'm using from the tutorial. It checks to see if a user has rolled their mouse over within 50 pixels of the left side of the screen. I just need the actionscript 3 equivalent since the whole _root issue has changed dramatically in from 2 to 3.
_root.onEnterFrame = function(){
if(_root._xmouse<50) {
imgBar.prevFrame();
}
}
Thanks in advance for any help you could offer!
- MythProd
(John David Hutton)
Actionscript Equivalent Of PHP's Explode()
I remember that in PHP, there was a nice little function that breaks apart a string. For example:
$string = "1||2||3";
var_dump(explode('||', $string));
How would I do this in Actionscript? Here's what I have so far:
Code:
xVals = new Array();
newstuff = new Array();
xVals[1] = 20;
xVals[1] = xVals[1] + "," + 40;
so,
Code:
xVals[1] = 20,40;
newstuff = explode(',', xVals[1]));
Any help would be greatly appeciated, thanks
~Matt
RandomSeed Equivalent In Actionscript?
Having worked in Director using Lingo, I am wondering if Flash has a RandomSeed equivalent in ActionScript?
For those of you not familiar with RandomSeed, it is the number that allows the computer to come up with 'random' numbers. By setting this number you can then get predictable results everytime. It can be very useful.
Thanks
chris
Cin And Cout's Equivalent In Actionscript 3?
Hey, I've coded for some time in C++, but I can't find an easy and fast way in ActionScript 3.0 to type in from the keyboard. The output panel with the Trace(); command works great, but typing in? Any suggestions?
Java Script Equivalent In Actionscript
my present java:
onclick="slideshow('1')"
http://192.117.122.36/view.asp?world
the "onclick" clicks on a start button in the above url to start a slide show.
what would be the actionscript code for such a link?
(clicking on a link in my movie would take you to this url and then the start button there would automatically be clicked on)
Java Script Equivalent In Actionscript
I am converting an html document to a flash based movie.
in the html a link takes one to a url and them "clicks" on the start button to start of ppt show.
i understand that I have to use the fs command with these.....
onclick="slideshow('1')"
http://192.117.122.36/view.asp?world
but I really dont know how after that....
On (within) Equivalent
I was wondering if anyone knows of a mouse event equivalent to the within event in director. I am trying some advanced layering to get to mouse position and need to check to see if the mouse pointer in with a given button or instance.
Thank you!
Equivalent To Set() In AS3
Im pulling data out of a xml config file. As such I need to dynamically set the varialbes and values in a global manor.
How should I go about re-writing the set method in AS3?
Thanks!
PHP Code:
set(data.key[row].@id, data.key[row].@value);
.jar Equivalent?
Hello,
I am fairly new to Flash and Actionscript, and I am having trouble finding the answer to a basic question. Is there the equivalent of a .jar file for actionscript code? Essentially, I am building a set of classes and interfaces that I want to package and distribute as a binary (no source code), so that another developer can import classes from my package for use in a swf. My code has nothing graphical, sprite, or timeline-related. It is purely for socket communication. Thanks for any help.
As2 Equivalent
Is there a similar function in actionscript to is_array or printr? I'm having trouble knowing what the return type for many functions is going to be. Is that just something that you have to learn or is there some way of being able to tell the return type programmatically?
- b
C# Equivalent Of This?
I've got some actnioscript that I need to emulate in C#. Unfortunately I
can't quite work out what type the variables are (as you don't seem to have
to declare them in actionscript).
This is the actionscript, which is to choose an rgb colour based on a input
'a'. Can anyone help?
getNewColor = function(a) {
var r = (45+a*90) & 0xFF;
var g = (180+a*135) & 0xFF;
var b = (230+a*71) & 0xFF;
var min = 60;
if (r<min && g<min)
{
r += min;
g += min;
}
else if (r<min && b<min)
{
r += min;
b += min;
}
else if (g<min && b<min)
{
g += min;
b += min;
}
return ((r << 16) | (g << 8) | b);
};
An Equivalent Of Php's Explode() ?
Does FlashMX Actionscript have a function that works like explode() in php. I need to explode a variable at 1 point and thus create two variables. Any ideas?
Thanks.
Keyboard Equivalent
Flash 5 Action Script. What script would allow a "button" to perform the same action as a keypress? In other words, I would like to create buttons that can be used to enter text. What string does Flash see when, for example, the "a" is pressed?
I understand getKeyCode...I'm trying to do the opposite I guess...send keyCode.
Thanks
On EnterFrame Equivalent
Hi all,
I'm trying to get a mc to load into a container on enterFrame (lingo)
Is there an actionscript equivalent and if so what may it be?
Cheers
Danny
Is There Are Flash Equivalent--
to the .html standard of "Save Target As.."? I ask this because .pdf's and .mpgs exist on my website, and the typical relative address of getURL:/mypage, "bigmovie", _blank gives less than stellar results. Using the absolute address in the actionscript window would be a headache because my files exist deep in my hosts' server. Is there some actionscript or command I'm missing that would allow the user to save a file to their desktop - just as they would be right-clicking within an .html document?
Thanks for your help,
[F8] Finding The Most Equivalent Value
I've an array of integer value for example
arrVal = Array(1002,1005,3000,600,50000,5500....thousands of numbers);
and the selectedVal receive as input is input = 900
when the selectedVal is pass to the function,the function must return the value = 1002 if we search it from the example array (above) to get the nearest value..
i already wrote a function using for loops and i think its not efficient when the array is large
does anyone has such function or idea to share?
CS3 Equivalent To LoadMovieNum()?
I want to be able to load an external SWF in the same window as the original files. Basically, I want to just call the next slide, think like a powerpoint presentation. In AS 2 I believe I used loadMovieNum() to perform this, it odes not appear to work in CS3. Does anybody know how to do this action is CS3? Thanks alot
AS3 Key.isDown Equivalent
Hey guys, this ones got me stumped
In as2 to get keypress information you could use actionlisteners OR check the function Key.isDown(asciivalue);.
But this has been depriciated in AS3, now Im making a game and you have a ship that turns left and right, and you can furl and unfurl the sails by hitting w and s, (left and right is a and d). Now if you hold a the ship starts turning left, but you hit w to unfurl the sails and the game stops detecting that you are pressing a and while the w works the ship stops turning left (can post example if needed).
Checking for Key.isDown every frame got around this, is there a way to check if a key is down in as3? or to make the listeners work for this?
Thanks,
Ian
FLV OnSoundComplete Equivalent?
I know there's a way to do this, but I'm feeling a bit under the weather and my fever could possibly be frying my brain, but I need to get this thing done by Monday, so I was hoping for a bit of help.
I know that with a dynamically loaded mp3 file you can tell Flash that when that mp3 is done, to move on and do something else. Is there a way to do that with an FLV as well? I've got about a 15-second long FLV that, when it reaches the end, should trigger several events to happen in other movieclips. I'm currently using the following scripts to load the movies into a Flash 6/7 instance of a MediaDisplay (a tad old school, but it works):
ActionScript Code:
vid.setMedia("test.flv", "FLV");
vid.play();
Is there a way to detect when I reach the end of the FLV and then trigger events elsewhere in my file? I'm pretty sure it has something to do with an event listener, but that's the extent of my knowledge on the subject.
Any help would be greatly appreciated!!
ActiveX Equivalent For Mac OSX
If you want to incorporate the Flash player into a windows C++ application, you can use the COM interface on the ActiveX control to set properties and call methods. Unfortunatley, ActiveX is only allowed on Windows, is there an equivalent on a Mac? I heard that ActiveX may have been slightly supported on Mac's version of IE, but is there some equivalent interface to the flash player in the mac that I can access within a C++ program?
AS Equivalent Of * For Strings?
Is there an AS equivalent of the * operator that other languages have to represent any string? Like for example, if I wanted to check if someone's input was a valid email, something like this:
if (email.text == *+"@"+*+"."+*)
Any help would be much appreciated! Thanks
PHP Sprintf Equivalent?
Hi guys,
I don't know how to output a preformatted string in actionscript, says, if I want the result of 2/3 displayed as 0.67 or 0.6 or 0.667 not 0.6666666667
How can I achieve that without having to write my own formula?(shortcut)
Is there a sprintf or printf function in actionScript?
Thanks
Kwong
FileReference Equivalent?
Is there a way to mimic the FileReference class from Flash 8 in MX 2004? I suspect I will need to upgrade to do the following, but I'd love some input from you guys first.
Basically, the concept is to build my friend a site that she can update herself - with a password protected area, I want her to be able to upload images to her server, and for the Flash movie to detect these new images in a gallery (with thumbnails preferably). Also some kind of blog and gig diary functionality would be nice.
I suppose the upload section could quite easily be done outside of Flash if anyone has thoughts on that?
Equivalent Of GetHighestDepth
Probably this is due to my failure of fully understanding how the display list works, but I can't seem to figure out how to put a sprite in the highest "depth".
I know AS3 works with indexes, but I'm a bit dumbfounded that there's not a displayObjectContainer.getHighestIndex or something like that.
What's the proper way to do this, if you want to create a custom cursor for instance?
Left, Mid, & Right Equivalent
Hi what is the Left Mid & Right Equivalent in action script.
I have a dynamic text box that has the value 12V in the box, I just want the value of 12 to use in a maths routine.
In VB I could find the length (3) and extract the left 2 char.
Re B
OnChanged Equivalent In AS3?
Greetings all,
I used this extensively in a few projects in F8 AS2:
_txt.onChanged = function(){
trace("i am changed")
// doSomething
}
When input text field has a single character typed in it either a function triggers or focus is changed to another input text field. Used quite a bit in word games.
I am attempting to update this to AS3 and am stuck.
Any help will be greatly appreciated.
SendToURL Equivalent In FMS 3
Hi,
Can anyone help me out, I would like to be able to send a request to a URL from FMS3 in a .asc file.
I can do it from the client in AS3 using…
flash.net.SendToURL(request);
Is there any equivalent functionality in FMS3?
Is it possible to supply credentials for that request as well, user / password?
Cheers,
Steve.
InitObject AS3 Equivalent
Hello.
In AS2 one could initiate class variables by adding an initObject parameter in attachMovie:
var instance:MovieClip = this.attachMovie("myClass", "i1", 0, {var1: value1, var2: value2, var3: value3, var4: value4});
How can I achieve the same in AS3:
import myClass;
var instance:myClass = new myClass();
instance.var1 = value1;
instance.var2 = value2;
instance.var3 = value3;
instance.var4 = value4;
Can I only use setter methods, or is there another way to group these variables and send them during the instance initialization?
Thanks in advance,
T.
Edited: 12/20/2007 at 04:16:02 PM by Plura
AS3 Equivalent Of SendAndLoad?
Hello, we are having difficulty in loading dynamic XML documents (those that are written dynamically). Reading in static XML files is fine but we alwasy get the "document malformed" error when reading on a server-generated file. The XML output of the script is fine, it's jsut that Flash does not recognize it as XML.
In AS2, we could load these dynamic XML files via XML sendAndLoad as follows:
// ignore XML white space
XML.prototype.ignoreWhite = true;
// Construct an XML object to hold the server's reply
var loginReplyXML:XML = new XML();
// this function triggers when an XML packet is received from the server.
loginReplyXML.onLoad = function(success:Boolean) {
if (success) {
trace("OK");
} else {
trace("an error occurred.");
}
};
var loginXML:XML = new XML();
// create XML formatted data to send to the server
// send the XML formatted data to the server
loginXML.sendAndLoad("getPoll.php", loginReplyXML);
However we thought this would be the AS3 equivalent, but it does not work:
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
var externalXML:XML;
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("LNS_getPoll.php");
loader.load(request);
loader.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
{
var loader:URLLoader = event.target as URLLoader;
if (loader != null)
{
externalXML = new XML(loader.data);
trace(externalXML.toXMLString());
}
else
{
trace(" not a URLLoader!");
}
}
Any help would be APPRECIATED! thanks
Breeze Equivalent
Could someone tell me if there is a component out there that can do what Breeze does, like using audio combined with a powerpoint presentation. I would like also the slider back and forth, timer, stop, play buttons.
Breeze seems to cost a lot to run!
thanks,
suzi
StartDrag Equivalent?
Just going through the tutorials, I can find the flash5 ones for using startDrag, but none for mx2004 (pro). Does anyone have a link pre-stashed for the n00bz because they're bored of being asked this already?
Is There A Flash Equivalent For This?
http://simile.mit.edu/timeline/
Ajax timeline script... But I think Flash will be able to handle this type of script better... Anyone knows if it has been done b4? I am not sure what to type to search actually... everytime I type timeline it gives me those basic tutorial..
AS3 Equivalent To AttachMovie...
Hi,
I think I'm close to figuring this out -- using addChild, but I just can't lock in. Basically, I'm trying to create a pop-up box using the Timer event, where when someone mouses over a button a box pops up similar to using attachMovie from AS2. And when they mouse away from the button the pop-up box fades away. I'm getting my AS2 way too mixed in w/AS3, and I'm confusing myself on how to make this work as a function. Any suggestions?
Thanks...Steve
AS3 _global Equivalent
Hey all,
I'm working on a AS3 Debug class, now although I've had some problems (helped in a previous kirupa post) my big concern is how to make the Debug class globally accessible?
In AS2 we had a Debug class which we call the static trace() method in and it declares itself as a _global variable but it seems the _global declaration is depriciated in AS3?
Does anyone know of a better way or alternative way to achieve this? so I can reference the Debug class from any other class or scope in an application.
Flex3 Equivalent?
I've been a huge kirupa fan for many years and I've always wondered if there is a Flex equivalent that you guys/gals might like just as much.
Breeze Equivalent
Could someone tell me if there is a component out there that can do what Breeze does, like using audio combined with a powerpoint presentation. I would like also the slider back and forth, timer, stop, play buttons.
Breeze seems to cost a lot to run!
thanks,
suzi
StartDrag Equivalent?
Just going through the tutorials, I can find the flash5 ones for using startDrag, but none for mx2004 (pro). Does anyone have a link pre-stashed for the n00bz because they're bored of being asked this already?
An Equivalent Of PHP's Explode()
Does FlashMX Actionscript have a function that works like explode() in php? I need to explode a variable at 1 point and thus create two variables. Any ideas?
Thanks.
Mouseword Equivalent?
hullo all developers,
a flash question for you:
we're trying to create a 'glossary bubble'. as the user reads through the text onscreen, certain words are highlighted. when the user rolls over one of these words, a text bubble appears with more information about it.
the trick is that we have a TON of content, so all of our text is dynamically drawn from xml files. what we need to do is:
a) figure out which word the user is rolling over
b) determine if that word is in the glossary
c) make the bubble with the appropriate information pop up.
i've created something similar in the past using director's mouseword command. (http://www.developerdispatch.com/art...nge/ll041.html to see what mouseword does).
does anyone know of any sort of similar command for flash? perhaps a component or some code or something?
thanks all.
What Is The Equivalent Code To TellTarget?
I've got the follwoing code:
tellTarget (_root.frontPage)
{
gotoAndStop ("lastFrame");
loadMovie ("test.swf", "dummyMovie");
}
Now... I've tried replacing this with:
_root.frontPage.gotoAndStop("lastFrame");
_root.frontPage.loadMovie("test.swf", "dummyMovie");
I thought this 'should' have the same effect as that of the first bit of code... but apparently not?
What I want to do is load a movie over a dummy movie (existing in a movie on the main timeline). Now, it just so happens that my dummy movie only exists on a specific frame - hence, I have to instruct it to go to the frame before I load it.
I've also tried:
_root.frontPage.gotoAndStop("lastFrame").loadMovie ("test.swf", "dummyMovie");
That doesn't work either.
[OK... so I was in Java mode!] : )
Does all that make sense?
If anyone can figure out what I'm saying... and can give the equivalent code... I'd really appreciate it.
Thanks.
Jam
Equivalent To <input Type=
I'm creating a form in flash... and i need a command of actionscript that makes the same work of the HTML command <input type="file">
....i need the user to select a local file and to upload it throught the form....
heeeeelp!!!
bye
Chobin
Is There A Flash Equivalent Of OnBlur?
here's the deal... I have two text fields. In one text field, you enter a social security number WITHOUT hyphens and when you click the other text field, the SSN needs to become hyphenated automatically.
The only way I can think of doing this is with a script involving some kind of onBlur but I don't think Flash has anything like that.
Anyone know?
Equivalent To Button Events
Hello everyone,
I need to put the equivalent to this code:
on (release) {
_root.resume.gotoAndPlay("startProfile");
}
on a text rather than a button. so how does it go?
|