Skip navigation
1richard1
Currently Being Moderated

making play button to play different clips

Apr 21, 2012 9:04 AM

Tags: #problem #cs5 #flash #script #button #code_snippets #action_script_3 #movieclip #ac3 #actionscript3 #function #actionscript_3.0

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.

 

Screen shot 2012-04-21 at 16.50.26.png

 
Replies
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 21, 2012 9:04 AM   in reply to 1richard1

    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();

    }

     
    |
    Mark as:
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 21, 2012 12:23 PM   in reply to 1richard1

    copy and paste the code you tried.

     
    |
    Mark as:
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 21, 2012 3:08 PM   in reply to 1richard1

    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();

    }

     
    |
    Mark as:
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 22, 2012 6:43 AM   in reply to 1richard1

    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();

    }

     
    |
    Mark as:
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 22, 2012 7:11 PM   in reply to 1richard1

    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();

    }

    }

    }

     
    |
    Mark as:
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 23, 2012 3:10 AM   in reply to 1richard1

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points