0
votes

AS3 Newbie here... very confused, please be kind ;)

I have a MovieClip (rozette), which contains 7 instances of a MovieClip (circle). circle contains an animation and I would like to play each instance of it within rozette consecutively.

Questions - do I need to use an array? Is using eventListener the best way to do this? If so, how can I create an eventlistener for each item in the array? And what kind of event am I listening for?

Many thanks. Kat

2
is it animated via the timeline?Ronnie

2 Answers

0
votes

You can see some options given as answers here:

Flash AS3 - Wait for MovieClip to complete

Basically I would think you want to have an array and a counter for which one you're on, each time the "playNext" function gets called, you should increment the counter and pull the next movie clip from the array. What this means is the order of elements in the array will dictate the order they play in. Something like:

private var myArray:Array = [mc1,mc2,mc3]; //list all the movieclip instance names here
private var counter:Number = 0;  //start off on the first element, arrays in AS3 start at 0

//Play the next clip
private function playNext():void {
    //Check that we're not at the end of the list, if so just return/stop
    if(counter>myArray.length-1)
        return;

    //grab the next clip
    var curClip:MovieClip = myArray[counter] as MovieClip;

    //increment the counter for next time
    counter++;

    //when the last frame gets hit call this function again
    curClip.addFrameScript(curClip.totalFrames-1, playNext);

    //play the clip
    curClip.play();
}

From your constructor of your Main class you would want to call playNext() once to get things rolling.

0
votes

import com .greensock.*;
import com. greensock.easing.*;	
var s1:b1=new b1();
var s2:b2=new b2();
var s3:b3=new b3();
var r1:Array = new Array();
r1.push(s1);
r1.push(s2);
r1.push(s3);
function ff (){
var i = 0;
while (i < r1.length) {

	r1[i].visible=false
	r1[0].visible=true
	addChild(r1[i]);
    i++;
}
TweenMax.staggerTo(r1, 0.4, {visible:true},0.2);
}
bb.addEventListener(MouseEvent.CLICK,cliki4x);	
function cliki4x(e:Event):void{
	ff ();	
}