Be a Supporter!

[as2]array For Mcs ?

  • 301 Views
  • 4 Replies
New Topic Respond to this Topic
rishabh005
rishabh005
  • Member since: Feb. 8, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
[as2]array For Mcs ? 2009-02-10 06:24:40 Reply

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
Response to [as2]array For Mcs ? 2009-02-10 06:36:28 Reply

someone told me to use loops .........
is tht right ?

GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to [as2]array For Mcs ? 2009-02-10 06:51:57 Reply

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.


BBS Signature
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to [as2]array For Mcs ? 2009-02-10 06:52:39 Reply

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

- - Flash - Music - Images - -

BBS Signature
rishabh005
rishabh005
  • Member since: Feb. 8, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to [as2]array For Mcs ? 2009-02-10 07:35:39 Reply

Awesome Thanks Denvish !
And Thanks to Gustthe AS guy too..

I <3 It .!