#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    GotoAndStop() not working like it should AS3/CS4


    Hi everyone, I've recently started using AS3 in flash and it's giving me some troubles. Here's the situation:

    On my first frame on the main timeline I use a gotoAndStop("home") command to go to my homepage which is on frame 45 and labeled "home".

    From frame 2 up to frame 44 there are multiple movieclips with animations and sound in them, which stop at frame 45.

    When I use the gotoAndStop() command in my first frame it seems to work but the sounds of my movieclips in the previous frames keep looping.

    I don't understand why this is happening, since my movieclips aren't even on frame 45.

    Anyway, here's some of my code.

    first frame on main timeline code:
    Code:
    import flash.events.MouseEvent;     
    this.gotoAndStop("home");
    below that code are my buttons.

    here's the code from one of the buttons I use.

    Code:
    function mouse_over(e:MouseEvent){   
    e.currentTarget.gotoAndStop("_over");   
    }   
    function mouse_out(e:MouseEvent) {   
    e.currentTarget.gotoAndStop("_up");   
    }   
    function mouse_down_center(event:MouseEvent) {   
    btn_center.gotoAndStop("_down");   
    gotoAndStop("home");   
    }   
    btn_center.buttonMode = true;    
    btn_center.addEventListener(MouseEvent.MOUSE_DOWN, mouse_down_center);   
    btn_center.addEventListener(MouseEvent.ROLL_OVER,mouse_over);   
    btn_center.addEventListener(MouseEvent.ROLL_OUT,mouse_out);
    I've also tried putting "this." in the button code and making a variable out of "this" to then use that variable in the code. It didn't change anything.

    Any help with this would be greatly appreciated.
    Last edited by Legchewer; June 29th, 2011 at 09:48 AM. Reason: gotoAndStop seems to work, it's just the audio problem now
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    660
    Rep Power
    32
    I had that happen to me on a site once. I couldn't figure it out and so did process of elimination.

    I would suggest first remove sounds one by one in the previous frames until the sound stopped playing when it goes to frame 45. Then once you have found the offending sound, then either use script or timeline to trigger it onto the particular frame.

    Flash acts funny sometimes, especially when a site becomes more complex from my experience.

    Theres probably a better solution but give this a try if all else fails.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    problem fixed


    Thanks for the reply but I have already gotten a solution from another site's forum.

    There were actually 2 things I did wrong.

    First off: I put my sounds in movieclips together with the animations. Apparently I had to export the audio for actionscript and then put them into variables.

    After I did that I still heard a lone sound somewhere and deleted the content of the layers one at a time to see when the sound disappeared. When I found the right spot I only had to check 3 movieclips and in one of them there was a sound that wasn't supposed to be there.

    Now everything seems to be working fine .
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    38
    Rep Power
    4
    the other thing i would look at is the fact that it seems you're putting code on the button rather than on the frame in an actions layer... if its all working fine I wouldn't touch it (if aint broke dont fix it) but keep this in mind as this is the way Flash with AS3 apparently wants to work (according to my tutors in the past)
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0
    Originally Posted by bowers_1991
    the other thing i would look at is the fact that it seems you're putting code on the button rather than on the frame in an actions layer... if its all working fine I wouldn't touch it (if aint broke dont fix it) but keep this in mind as this is the way Flash with AS3 apparently wants to work (according to my tutors in the past)
    Don't know where you got the idea but I never put any code in my buttons, it was all on a separate layer in the main timeline.

    And I'm gonna close this thread since the problem has been long fixed.

IMN logo majestic logo threadwatch logo seochat tools logo