ActionScript 2.0 :: Code Breakdown In For Loop - Array Syntax?
Aug 29, 2006
I've got this loop and can't get it to work. It won't read the trace so I know the array call in my function statement is wrong but I can't see it at the moment. What am I doing wrong here? The rollover works when I write it out repetitively for the four buttons.
var btnAction:Array = new Array (oneBut, twoBut, threeBut, fourBut);
for (var i=0; i<btnAction.length; i++) {
this.menuMC.btnAction[i].onRollOver = this.menuMC.btnAction[i].onDragOver = function() {
trace("anything");
}
};
var myData = new Array(); myData["name"] = "John"; myData["Age"] = 35;
What is the syntax to loop through and get the key and value? I have tried for each and for in but they just give me the value of "John" or "35", how can I get the key e.g. "Name" and "Age"?
I've got this loop and can't get it to work. It won't read the trace so I know the array call in my function statement is wrong but I can't see it at the moment. What am I doing wrong here? The rollover works when I write it out repetitively for the four buttons.
var btnAction:Array = new Array (oneBut, twoBut, threeBut, fourBut); for (var i=0; i<btnAction.length; i++) { this.menuMC.btnAction[i].onRollOver = this.menuMC.btnAction[i].onDragOver = function() {
Can anyone tell me why the following is taking 4 seconds for Flash to execute:
_moleHoles = new Array(); var countingMoleHoles:Boolean = true; var holeCount:int = 0;
[Code].....
There are 9 object on the stage (but this number could go up or down, that is why I'm dynamically grabbing these this way). So in my test case, this loop runs 10 times.
I have narrowed it down to something to do with the following line:
if (this['moleHole' + holeCount])
Is using dynamic (array syntax) object lookup that much of a performance hit?
I want to have an array that loops my movie clips.However, there also needs to be the ability for the loop to stop and play a specific movie clip when a specific thumbnail that corresponds to that clip is clicked on.Then, when that movie is done playing, the array is accessed again and the array continues once again, also looping.I don't even know if this is possible.I set up something that worked in Flash Catalyst, but the only problem is that FC doesn't have the ability to have a fullscreen button in it for the document.I need to be able to have the entire document go fullscreen when a button is pressed.I do not have Flash Builder.[code]
I've got a for loop and some fuctions working, but can't get one line of code to work. The red line below is what I'm having a hard time with. I'm calling a function called "moveit". If I insert moveit(x1, y1); then it works, and my movieclip is moved to the x and y positions that I specified for item #1. Though I want it to work for 10 items (I only have coordinates for two here, and will add the rest later).
I've searched my ActionScript book and just can't figure out what the syntax should be for calling that function.
I have put all button inside movieClip called "container" and I have added "container." inside for loop and now I am getting errors. for (i=8; i<15; i++){ container.this["button" + btns[i].name.replace("btn","")].mouseEnabled = false; }
how to breakdown a given functionality into resuable classes.The style of scripting is very messy and lots of repetitive codes, as most of the time I just jump straight into scripting without prior planning (bad habit).Now with this component as a base, I want to learn how to manage my codes in a cleaner, more efficient way, OOP style. (I only get to know about how good and time-efficient OOP style programming is after I 'discovered' the Tween class a month ago lolx)For a start I will need some planning.. that's the place where I'm now stuck in..I've come out with the core items which I think should be as classes
1) Controller
2) Drag clips
3) Hit boxes
How much further should I break them down? Read from tutorials that generally classes should only perform one task is that true? The controller deals with 2 tasks (handling events and 'calculation part'), should I break them into 2 separate classes?From tutorials I also get to know that we can assign a class to a symbol in the library. Is it possible for to attach classes at runtime to script generated or existing timeline instances? something like instanceName = new classFunction(parameters) ?
what I'm trying to do is access the data of several movies clips, that are inside of several other movie clips: MC1.insideMC._visible=false (which works, but isn't dynamic) but dynamically with a FOR loop. I've tried: For(bullet=1; bullet<5; bullet++){ "MC"+bullet.insideMC1._visible=false (this does not work) } Does anyone know the dot notation or another way to do this?
"you should create a fla, drag an flvplayback component to the stage, create an array of your flvs, initialize an index at zero, assign the flv to start playing your first flv and increment the index in a function that executes when an flv complete and play that array element until all are played. you'll publish your html and swf from that fla." And he gave me a code sample which is below... modified to show my "instance" name as FlvChainand my flv file names... vid1.flv, vid2.flv, and vid3.flv...
My code...
import fl.video.VideoEvent; var flvA:Array=["vid1.flv","vid2.flv","vid3.flv"]; var index:uint=0; FlvChain.source=flvA[index];
[code]....
When I attempt to Debug I get this message...
"1087: Syntax error: extra characters found after end of program."
Hi, whenever I click on my code snippets button in Flash Pro, the output panel gives me a message about a missing bracket at the end of an argument list. In addition, none of the code snippets work. How might I correct it?
_xml.group1..image[i] _xml.group2..image[i] _xml.group3..image[i] _xml.group4..image[i] _xml.group5..image[i] Im trying to reference each object thus: _xml.group[myVariable]..image[i]
I'm trying to populate a fl.controls.ComboBox dataProvider with this array. What I want to do is set the labelfield, as shown in the documentation:
[Code]...
In other words I want the name to be displayed, and the 'data' to be the code, which will be called when I click on the item. But the labelField is not the same as "French". How do I create the two fields in the array such that I can designate the first as labelField and the second as data?
I don't know what basic knowlege i missing here.I have two compiler error and don't know what to do about it.First says ") or , expected"Secondly "The class or interface 'BitmapData' could not be loaded."
ok, I got this doubt wich is kinda making me wonder for a while. scenario:_I've got a movieclip with a bunch of buttons inside that invoke a function and send parameters to it.no sweat so far._those buttons are named with a specific word followed by "_btn". that word is the same as the one that goes in the parameter. for example:ode:gobbledigook_btn.onRelease = function() {_root.myFunction(gobbledigook)}question:I'd like to be this work with a for loop, so I don't have to repeat the code for every button. so this is what I did:
I'm using addChild(new nmonster()) to populate an on stage MC from my Library.
Instead of specifying the Symbol, I want to add it using an Array reference, like addChild(new monsterArray[0]()). I've tried a number of variations, but AS3.0 is unforgiving.
I'm trying to load data from an external text file into an array. I created an array and am able to load the data into an array if I explicitly say something like
I can then do a trace statement on array[0] and it will output the correct name from the file. My problem is I'm trying to iterate through the variable names in the text file in the file by using an index variable. This is the code I'm using after doing all the URLloader, URLRequest, and so forth stuff:
All three of those also give me errors. For the first one the trace statement outputs "undefinded" instead of "Doug". For the second I get "syntax error. Expecting identifier before left bracket". And for the third I get "syntax error, expecting identifer before uid.":
syntax to iterate the number after uid(uid1_name, uid2_name, uid3_name, etc)?
I'm trying to load data from an external text file into an array. I created an array and am able to load the data into an array if I explicitly say something like: ActionScript Code: array[0] = event.target.data.uid1_name;
I can then do a trace statement on array[0] and it will output the correct name from the file. My problem is I'm trying to iterate through the variable names in the text file in the file by using an index variable. This is the code I'm using after doing all the URLloader, URLRequest, and so forth stuff: ActionScript Code: for(var i = 0; i<20;i++){ fArray[i] = event.target.data.uid[i]_name; }
This produces a syntax error. I've tried several other syntax variations but haven't been able to figure it out. Why syntax iterate the number after uid (uid1_name, uid2_name, uid3_name, etc)?
Having a hard time trying to resolve this issue, done a bit a of digging but can't find what i'm after. I'm pretty new to AS3 but know that Eval() has gone and been replaced with [] syntax. However, i'm trying to access a dynamic path to a clip and it seems that the array syntax will not allow more than one variable in a path.
ActionScript Code: var answerArray:Array = ["3", "2", "5", "3", "2"]; //these are the correct answers var answeredArray:Array = ["3", "1", "1", "3", "2"]; //this is an example of what the user
I'm creating a simple navigation from an MC (navBtn) in the library.The MC's are added using a loop with the text on the MC's coming from an array,(in the actual code it's from XML).When the loop has finished I wanted to create a final contact button using the same MC in the library.I'm using an if statement to determine the end of the loop
Code: if (i>=nameArr.length) { navCon = new Btn();
I found this code in an AS2 .fla and would like to use it in AS3. (The idea is to throw a random number of copies of the movieclip "star_mc" on the stage via AS).
for (var i =0;i<50;i++) { star_mc.duplicateMovieClip("star"+i,i,{_x:Math.random()*350,_y:Math.ra ndom()*150}); this["star"+i].gotoAndPlay(Math.random()); }
I get this error message: TypeError: Error #1006: duplicateMovieClip is not a function. at many_fla::MainTimeline/frame1()
I looking at a alternative coding which use two for loop, my code is require to overwrite the value in array b into a if b has a larger value than a, after break and loop a will continue point to the next index until it has the next 'mm' value while the loop b will resume from where it was "break"