[as2]array For Mcs ?
- rishabh005
-
rishabh005
- Member since: Feb. 8, 2008
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
I have a probelm .!
I never learnt Arrays !
nor AS3..
So please try to solve my problem using AS2 ..!
I want tp know that how can I apply a single onClipEvent(enterFrame){ function on two or more movieclips using Arrays , thank YOU !
- rishabh005
-
rishabh005
- Member since: Feb. 8, 2008
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
someone told me to use loops .........
is tht right ?
- GustTheASGuy
-
GustTheASGuy
- Member since: Nov. 2, 2005
- Offline.
-
- Send Private Message
- Browse All Posts (12,016)
- Block
-
- Forum Stats
- Member
- Level 08
- Blank Slate
An array is a sequence of slots where you can keep stuff.
var rotateClips : Array = [];
function onEnterFrame ()
{
for (var i=0; i<rotateClips.length; i++)
{
var mc = rotateClips [i];
mc._rotation += 3;
}
}
rotateClips.push (thingy1);
rotateClips.push (thingy2);
'rotateClips' is an array of clips that are rotated each frame. You can add movieclips to it as in the last two lines. Movieclips 'thingy1/2' are gonna be rotated.
Look at the language reference to see properties and methods arrays have.
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
Two MCs on stage, instance names: mc1, mc2
Code on main timeline:
mcArr=[_root.mc1,_root.mc2]; //THIS IS AN ARRAY
for(var i in mcArr){ //LOOP THROUGH ARRAY
mcArr[i].onEnterFrame=function(){ //FOR EACH ITEM
this._y+=2; //MAKE IT FALL ON ENTERFRAME
} //
} // - rishabh005
-
rishabh005
- Member since: Feb. 8, 2008
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
Awesome Thanks Denvish !
And Thanks to Gustthe AS guy too..
I <3 It .!


