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");
}
};

View 1 Replies


Similar Posts:


ActionScript 2.0 :: Loop Through Array Syntax?

Sep 15, 2009

I have an array like this:

Code:

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"?

View 2 Replies

ActionScript 2.0 :: How To Loop & Array Syntax

Sep 7, 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() {

[code].....

View 2 Replies

ActionScript 3.0 :: Array Syntax Object Reference In Loop Takes 4 Seconds To Run?

Nov 9, 2010

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?

View 2 Replies

ActionScript 1/2 :: Code For Movie Clip Array W/ Loop

Apr 11, 2012

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]

View 3 Replies

ActionScript 2.0 :: Syntax With For Loop?

Dec 15, 2005

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.

[Code]...

View 14 Replies

ActionScript 3.0 :: Dot Syntax Inside For Loop

Aug 11, 2011

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;
}

View 7 Replies

ActionScript 2.0 :: Breakdown A Functionality Into Reusable Classes?

May 28, 2008

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) ?

View 6 Replies

ActionScript 1/2 :: Dynamic Layered MC Syntax For FOR Loop?

Sep 18, 2009

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? 

View 13 Replies

AS3 :: Find Syntax Error In Code To Chain FLV Videos?

Mar 15, 2010

"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."

View 4 Replies

ActionScript 3.0 :: Code Snippets Buttons - Syntax Error

Sep 19, 2011

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?

View 1 Replies

ActionScript 2.0 :: Correct Syntax For Declaring A Variable Within A Loop?

Mar 25, 2007

Whats the correct syntax for declaring a variable within a loop? Something like this:[code]

View 1 Replies

ActionScript 2.0 :: Replacing Multiple Statements With A Loop - Syntax Incorrect?

Jun 30, 2009

I have a series of images loaded in via XML and assigned to "loady" movieclips. This code works fine:

Code:

_root.myMCL.loadClip(_root.myImages[0].attributes.url,_root.loady0);
_root.myMCL.loadClip(_root.myImages[1].attributes.url,_root.loady1);
_root.myMCL.loadClip(_root.myImages[2].attributes.url,_root.loady2);
_root.myMCL.loadClip(_root.myImages[3].attributes.url,_root.loady3);

[code]...

I want to replace this with a loop since I know the total amount of items (myImagesNo), but this isn't working:

Code:

for (i=0; i<_root.myImagesNo; i++) {
_root.myMCL.loadClip(_root.myImages[i].attributes.url,this["_root.loady" + i]);
}

View 2 Replies

ActionScript 2.0 :: Replacing Multiple Statements With A Loop / Syntax Incorrect?

Mar 12, 2010

I have a series of images loaded in via XML and assigned to "loady" movieclips. This code works fine:[code]

View 1 Replies

ActionScript 3.0 :: Correct Syntax For Referencing Array?

Sep 6, 2011

I have a number of XMLList objects:
 
_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]
 
But it doesnt work. What's the correct syntax?

View 3 Replies

Actionscript 3 :: Array Syntax To Populate Flash Combobox

Jul 31, 2011

I've got an array that looks like this, iterating through:

(languageArray[i].languageName); //e.g. "French"
(languageArray[i].languageCode); //e.g. "fre"

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?

View 2 Replies

Arrays :: Flex Differences Between Array Collection Syntax

Dec 15, 2011

I was wondering what's the difference between doing [code]However type 2 seems to work, but more people seem to reference type 1

View 1 Replies

ActionScript 2.0 :: Refer From Array In A Function Gets Syntax Error?

Mar 12, 2012

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."

Code:
listener.onLoadInit = function(mcTemp[i]:MovieClip) { // ") or ," expected
mcTemp[i]._visible = false;

[code].....

View 3 Replies

ActionScript 2.0 :: Array Syntax Error Or Sheer Impossibility?

May 31, 2008

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:

Code:
_root.wordsList = ["bafflegab", "esculent", "kakistocracy", "palimpsest", "quincux"]
for(i=0;i<_root.wordsList.length;i++){

[code].....

View 2 Replies

ActionScript 3.0 :: Correct Syntax To AddChild() Using Array Index

Jul 27, 2009

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.

View 4 Replies

ActionScript 3.0 :: Loading External Data To An Array Syntax Error?

Jan 25, 2009

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
= event.target.data.uid_name;
}

This produces a syntax error. I've tried several other syntax variations but haven't been able to figure it out. I've also tried the following:

fArray
= event.target.data["uid"+i+"_name"];
fArray = event.target.data.["uid"+i+"_name"];
fArray
= event.target.data."uid"+i+"_name";

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)?

View 3 Replies

ActionScript 3.0 :: Loading External Data To Array (Syntax Error)

Jan 24, 2009

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)?

View 3 Replies

ActionScript 3.0 :: Flash Dynamic Eval Of Path Using Array Syntax

Jul 29, 2010

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.

[Code]...

View 2 Replies

ActionScript 3.0 :: Movie Looping After Starting Syntax With Stop Command, No Compiler And Syntax Errors?

Jul 14, 2011

using action script...
 
stop();btn001_btn.addEventListener(MouseEvent.CLICK,showimage1);function showimage1(event:MouseEvent):void { gotoAndPlay(10);}btn002_btn.addEventListener(MouseEvent.CLICK,showimage2);function showimage2(event:MouseEvent):void { gotoAndPlay(20);}
 
however movie is playing without stopping to "Listen" for a Mouse CLICK. Images placed at frame 10 and 20 should appear only when CLICK'd.
 
This code is straight out of Classroom in a Book CS4.

View 5 Replies

Loop Through An Array And Use The Array Value To Reference A Variable?

Sep 25, 2009

I want to loop through an array and use the array value to reference a variable.

The Setup:
(For illustration only. Not actual script)
My MCs:
triangle_mc
square_mc

[Code]....

View 1 Replies

ActionScript 2.0 :: For Loop To Check One Array Against Another Array?

Aug 25, 2011

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

[code]....

View 3 Replies

ActionScript 3.0 :: Run Code At End Of Loop?

Mar 14, 2011

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();

[code].....

View 1 Replies

For Loop Code Migration?

Jul 21, 2009

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()

View 1 Replies

Flash :: Better Code For 2 For Loop?

Jul 9, 2011

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"

[Code]...

View 2 Replies

ActionScript 3.0 :: Put The Code Into A For Loop?

Feb 26, 2011

Is is possible to put the following code into a for loop?

ActionScript Code:
box2.b1_txt.text=String(text1);
box2.b2_txt.text=String(text2);[code]......

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved