Copy link to clipboard
Copied
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.
did that last answer resolve your "making play button to play different clips" issue?
if so, mark that answer as correct and start a new thread for new issues.
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
copy and paste the code you tried.
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
does this part of your code work:
play_btn.addEventListener(MouseEvent.CLICK, fl_Click_Play);
function fl_Click_Play(event:MouseEvent):void
{
MovieClip(this.parent).play();
}
Copy link to clipboard
Copied
nope this come up
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@391ec089 to flash.display.MovieClip.
at finalproject_fla::MainTimeline/fl_Click_Play()
Copy link to clipboard
Copied
if you're trying to get the main timeline to play with that code, use:
play_btn.addEventListener(MouseEvent.CLICK, fl_Click_Play);
function fl_Click_Play(event:MouseEvent):void
{
MovieClip(this.root).play();
}
Copy link to clipboard
Copied
i put that but it dnt play whats i selected on the timeline
Copy link to clipboard
Copied
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();
}
}
}
Copy link to clipboard
Copied
what about making a playhead so when it hits the movieclip thats on the timeline it plays the same movieclip in the preview box?
Copy link to clipboard
Copied
did that last answer resolve your "making play button to play different clips" issue?
if so, mark that answer as correct and start a new thread for new issues.