A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: gotoAndPlay AS3.0

  1. #1
    Member
    Join Date
    Nov 2008
    Posts
    52

    gotoAndPlay AS3.0

    Hey guys!
    I have a movie clip on a scene with a button inside. How can I make this button to go to play frames on the scene but not inside the movie clip in AS3.0?
    Thanks a lot!

  2. #2

  3. #3
    Member
    Join Date
    Nov 2008
    Posts
    52
    Quote Originally Posted by cresquin View Post
    add a listener to the button from the scene timeline
    What?

  4. #4
    http://pat.theorigin.net cresquin's Avatar
    Join Date
    Jun 2003
    Location
    Los Angeles, CA
    Posts
    685
    on the scene timeline add the following:

    PHP Code:
    import flash.event.MouseEvent;

    function 
    playTimeline(evt:MouseEvent){
        
    gotoAndPlay("myFrame")
    }

    movieClip.button.addEventListener(MouseEvent.ClickplayTimeline); 

  5. #5
    Member
    Join Date
    Nov 2008
    Posts
    52
    Quote Originally Posted by cresquin View Post
    on the scene timeline add the following:

    PHP Code:
    import flash.event.MouseEvent;

    function 
    playTimeline(evt:MouseEvent){
        
    gotoAndPlay("myFrame")
    }

    movieClip.button.addEventListener(MouseEvent.ClickplayTimeline); 
    Thank you, I appreciate your help! However, is there another way? Because it seems that the code you given me always looks at the last frame of the scene, and if the movie clip name or buttons do not exist in the last frame of the scene, I get an access of undefined property error...
    Last edited by ThunderSoul97; 05-27-2009 at 06:52 PM.

  6. #6
    Member
    Join Date
    Nov 2008
    Posts
    52
    I was hoping for something more along the lines of root.frameName, is there any code for that?
    Thanks!

  7. #7
    http://pat.theorigin.net cresquin's Avatar
    Join Date
    Jun 2003
    Location
    Los Angeles, CA
    Posts
    685
    the code always looks at the frame where it is placed.

    If you want to add the event listener on a different frame from the code, just put the addEventListener line into its own function and call that when the button exists:

    PHP Code:
    import flash.event.MouseEvent;
    import flash.display.DisplayObject;

    function 
    playTimeline(evt:MouseEvent){
        
    gotoAndPlay("myFrame")
    }

    function 
    listenTo(target:DisplayObject):void{
        
    target.addEventListener(MouseEvent.ClickplayTimelinefalse0true);
    }

    //place the listenTo call on the scene timeline when the button exists
    listenTo(movieClip.button); 

  8. #8
    Junior Member
    Join Date
    Aug 2009
    Posts
    1
    Hi, sorry for the bump.

    I want to know how am 9 able to go to the next scene smoothly from the moment my preloader stops playing, using code.

    Help?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center