how do i make a play button play different movie clips that are placed on to a timeline in actionscript 3?
here is an example of what im doing. so you drag and drop the moive clips on to the timeline, at the bottom which then snaps in to place.
once the timeline has been filed up you press the play button, then it plays all the moive clips in sequence.
you assign instance names to each movieclip and button (in the properties panel) and in the actions panel you assign listeners to your buttons that call a listener function that "plays" your movieclip. for example, if you have a button (btn1) and movieclip (mc1), you could use:
btn1.addEventListener(MouseEvent.CLICK,btn1F);
function btn1F(e:MouseEvent):void{
mc1.play();
}
I just done that but it dont work. is there a way for it to play all the movie clips that you have dragged on to the time line.
so for example say i have dragged Vid2 vid6,vid5, vid10, vid3 and vid11 on to the timeline then press play. playing only them selective movieclips in my preview box?
if (event.target.hitTestObject(box))
{
var myMovie:MovieClip = MovieClip(event.target);
stopClipDrag(myMovie);
myMovie.snapBack();
switch (myMovie.name)
{
case "vid1" :
this.gotoAndPlay("two");
break;
case "vid2" :
this.gotoAndPlay("three");
break;
case "vid3" :
this.gotoAndPlay("four");
break;
case "vid4" :
this.gotoAndPlay("five");
break;
case "vid5" :
this.gotoAndPlay("six");
break;
case "vid6" :
this.gotoAndPlay("seven");
break;
case "vid7" :
this.gotoAndPlay("eight");
break;
case "vid8" :
this.gotoAndPlay("nine");
break;
case "vid9" :
this.gotoAndPlay("ten");
break;
case "vid10" :
this.gotoAndPlay("eleven");
break;
case "vid11" :
this.gotoAndPlay("twelve");
break;
case "vid12" :
this.gotoAndPlay("thirteen");
break;
case "vid13" :
this.gotoAndPlay("fourteen");
break;
case "vid14" :
this.gotoAndPlay("onefive");
break;
case "vid15" :
this.gotoAndPlay("onesix");
break;
case "vid16" :
this.gotoAndPlay("oneseven");
break;
case "vid17" :
this.gotoAndPlay("oneeigth");
break;
case "vid18" :
this.gotoAndPlay("onenine");
break;
}
}
else
{
// do some tests for the time slots
for (i=1; i<7; i++)
{
if (event.target.hitTestObject(this["dropzone" + i]))
{
myMovie = MovieClip(event.target);
if (this["dropzone" + i].getVid() != myMovie)
{
stopClipDrag(myMovie);
myMovie.x = this["dropzone" + i].x;
myMovie.y = this["dropzone" + i].y;
this["dropzone" + i].setVid(myMovie);
}
}
}
}
}
play_btn.addEventListener(MouseEvent.CLICK, fl_Click_Play);
function fl_Click_Play(event:MouseEvent):void
{
MovieClip(this.parent).play();
}
if you have a number of movieclips on the main timeline that you want to play, you can assign them to an array and loop through the array to play them. if you want all the movieclips on the main timeline to play, you can use:
playAll(MovieClip(root));
function playAll(mc.MovieClip):void{
for(var i:int=0;i<mc.numChildren;i++){
if(mc.getChildAt(i) is MovieClip){
MovieClip(mc.getChildAt(i)).play();
}
}
}
North America
Europe, Middle East and Africa
Asia Pacific