A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Help! *simple* button/stage issue

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    12

    Help! *simple* button/stage issue

    In creating a portfolio website I ran into some difficulties. I am using simple button commands such as gotoandPlay, and gotoandStop. The entire site has been working correctly until I recently was making revisions and included another branch from the portfolio section of enlarged images. To get to this section it looks like this:

    Code:
    stop();
    
    
    this.Nex_Btn.addEventListener(MouseEvent.CLICK, onButtonClickNextPub);
    
    function onButtonClickNextPub(event:MouseEvent):void
    {
    // check for the current frame
    switch (this.currentFrame)
    {
    // if the movie is on frame 478 then do something
    case 478: this.gotoAndStop(479); break;
    
    // if the movie is on frame 479 then do something
    case 479: this.gotoAndStop(480); break;
    
    // if the movie is on frame 480 then do something
    case 480: this.gotoAndStop(481); break;
    
    // if the movie is on frame 481 then do something
    case 481: this.gotoAndStop(482); break;
    
    // if the movie is on frame 482 then do something
    case 482: this.gotoAndStop(483); break;
    
    // if the movie is on frame 483 then do something
    case 483: this.gotoAndStop(484); break;
    
    // if the movie is on frame 484 then do something
    case 484: this.gotoAndStop(485); break;
    
    // if the movie is on frame 485 then do something
    case 485: this.gotoAndStop(486); break;
    
    // if the movie is on frame 486 then do something
    case 486: this.gotoAndStop(487); break;
    
    // if the movie is on frame 487 then do something
    case 487: this.gotoAndStop(488); break;
    
    // if the movie is on frame 488 then do something
    case 488: this.gotoAndStop(489); break;
    
    // if the movie is on frame 489 then do something
    case 489: this.gotoAndStop(490); break;
    
    // if the movie is on frame 490 then do something
    case 490: this.gotoAndStop(491); break;
    
    // if the movie is on frame 491 then do something
    case 491: this.gotoAndStop(492); break;
    
    // if the movie is on frame 492 then do something
    case 492: this.gotoAndStop(493); break;
    
    // if the movie is on frame 493 then do something
    case 493: this.gotoAndStop(478); break;
    } // end switch
    
    }
    
    
    this.Prev_Btn.addEventListener(MouseEvent.CLICK, onButtonClickPrevPub);
    
    function onButtonClickPrevPub(event:MouseEvent):void
    {
    // check for the current frame
    switch (this.currentFrame)
    {
    // if the movie is on frame 478 then do something
    case 478: this.gotoAndStop(493); break;
    
    // if the movie is on frame 479 then do something
    case 479: this.gotoAndStop(478); break;
    
    // if the movie is on frame 480 then do something
    case 480: this.gotoAndStop(479); break;
    
    // if the movie is on frame 481 then do something
    case 481: this.gotoAndStop(480); break;
    
    // if the movie is on frame 482 then do something
    case 482: this.gotoAndStop(481); break;
    
    // if the movie is on frame 483 then do something
    case 483: this.gotoAndStop(482); break;
    
    // if the movie is on frame 484 then do something
    case 484: this.gotoAndStop(483); break;
    
    // if the movie is on frame 485 then do something
    case 485: this.gotoAndStop(484); break;
    
    // if the movie is on frame 486 then do something
    case 486: this.gotoAndStop(485); break;
    
    // if the movie is on frame 487 then do something
    case 487: this.gotoAndStop(486); break;
    
    // if the movie is on frame 488 then do something
    case 488: this.gotoAndStop(487); break;
    
    // if the movie is on frame 489 then do something
    case 489: this.gotoAndStop(488); break;
    
    // if the movie is on frame 490 then do something
    case 490: this.gotoAndStop(489); break;
    
    // if the movie is on frame 491 then do something
    case 491: this.gotoAndStop(490); break;
    
    // if the movie is on frame 492 then do something
    case 492: this.gotoAndStop(491); break;
    
    // if the movie is on frame 493 then do something
    case 493: this.gotoAndStop(492); break;
    } // end switch
    
    }
    
    
    this.Enlarge_Btn.addEventListener(MouseEvent.CLICK , onButtonClickEnlargePub);
    
    function onButtonClickEnlargePub(event:MouseEvent):void
    {
    // check for the current frame
    switch (this.currentFrame)
    {
    // if the movie is on frame 478 then do something
    case 478: this.gotoAndPlay(1156); break;
    
    // if the movie is on frame 479 then do something
    case 479: this.gotoAndPlay(1181); break;
    
    // if the movie is on frame 480 then do something
    case 480: this.gotoAndPlay(1206); break;
    
    // if the movie is on frame 481 then do something
    case 481: this.gotoAndPlay(1231); break;
    
    // if the movie is on frame 482 then do something
    case 482: this.gotoAndPlay(1256); break;
    
    // if the movie is on frame 483 then do something
    case 483: this.gotoAndPlay(1281); break;
    
    // if the movie is on frame 484 then do something
    case 484: this.gotoAndPlay(1306); break;
    
    // if the movie is on frame 485 then do something
    case 485: this.gotoAndPlay(1331); break;
    
    // if the movie is on frame 486 then do something
    case 486: this.gotoAndPlay(1356); break;
    
    // if the movie is on frame 487 then do something
    case 487: this.gotoAndPlay(1381); break;
    
    // if the movie is on frame 488 then do something
    case 488: this.gotoAndPlay(1406); break;
    
    // if the movie is on frame 489 then do something
    case 489: this.gotoAndPlay(1431); break;
    
    // if the movie is on frame 490 then do something
    case 490: this.gotoAndPlay(1456); break;
    
    // if the movie is on frame 491 then do something
    case 491: this.gotoAndPlay(1481); break;
    
    // if the movie is on frame 492 then do something
    case 492: this.gotoAndPlay(1506); break;
    
    // if the movie is on frame 493 then do something
    case 493: this.gotoAndPlay(1531); break;
    
    } // end switch
    
    }
    Then once to the larger images portfolio section on the timeline, the script looks like this:

    Code:
    gotoAndStop(1180);
    This allows the site to continue to play through an intro transition to the next section of about 20 frames, then heads to the next frame and appears as this:

    Code:
    stop();
    
    
    this.Close_Btn.addEventListener(MouseEvent.CLICK, onButtonClickClosePub1);
    
    function onButtonClickClosePub1(event:MouseEvent):void
    { 
    // check for the current frame
    switch (this.currentFrame)
    {
    // if the movie is on frame 1180 then do something
    case 1180: this.gotoAndStop(478); break;
    }
    }
    
    Next_Btn.addEventListener(MouseEvent.CLICK, mouseDownHandlerEnlargeNextPub1);
    function mouseDownHandlerEnlargeNextPub1(event:MouseEvent): void {
    gotoAndStop(1205);
    }
    
    Prev_Btn.addEventListener(MouseEvent.CLICK, mouseDownHandlerEnlargePrevPub1);
    function mouseDownHandlerEnlargePrevPub1(event:MouseEvent): void {
    gotoAndStop(1555);
    }

    Simply put, all of this works. When the close button (Close_Btn)is clicked it takes the viewer back to where it should, but the buttons there do nothing. The stage is more or less frozen in place and the viewer is not able to navigate anywhere. I was not having this issue in any other section along the timeline and have no idea why it is happening now.

    Ideas?

  2. #2
    Member
    Join Date
    Jun 2008
    Location
    US
    Posts
    84
    None of your other event listener functions account for frame 1205. E.g. onButtonClickNextPub does not account for 1205 in its switch statement.

    So, the functions might be running, but the there is no case 1205 (for the switch), so they don't do anything.

    To check if the functions are running, use a trace as the first line of the function.

    On the other land, if the functions aren't running, then perhaps your button names changed on 1205, so that the listeners aren't registering anymore?

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Posts
    12
    I think you have misunderstood me. The functions all work on 1205; on this frame and to this frame. The problem is navigating back to previous frames when things cease to work.

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    It sounds like you are adding button events in one frame, passing into a frame where the buttons don't exist (or are moved inside another object, or something - the point being that the reference breaks) from then on, your buttons won't work unless you re-run that addEventListener code.

    On an efficiency note, this sounds like you are using a boatload of code to handle continuity in the timeline...you could do this much more easily with a library like TweenLite or Tweener, by tweening the frame (say TweenLite.to, this, 1, {frame:1205}); to get to 1205 in 1 second)...definitely worth checking out, and I suspect it could save you a lot of effort.

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