Rollover and gotoAndPlay not working after stop action

  • Thread starter fredlexus
  • Start date
In summary, the conversation discusses issues with a website that has 7 rollover buttons that play movies. The first 3 buttons work as expected, but the remaining 4 buttons do not. The code for the buttons is similar, with different instance and frame names. Attempts to fix the issue by adding a stop action and changing the syntax did not produce any errors, but the movies do not play and the user is not sent to any frame when the buttons are selected.
  • #1
fredlexus
3
0
Subject: Flash (cs4, as3)
Background:
I have a website with 7 rollover buttons that play a movie. The first 3 buttons display from frames 17-29 (timeline animation plays on frames 1-16). Frame 29 has a stop action as well as blank keyframes. This gives the user the opportunity to select one of the 3 buttons. The same code is repeated on frame 30 for the additional 4 buttons (the instance and frame names are different.
- The objective is to have a movie play and the user sent to a different frame each time a button is selected.

Code:
import caurina.transitions.*;
import caurina.transitions.properties.*;
DisplayShortcuts.init();
conbut.addEventListener(MouseEvent.ROLL_OVER, conbut_ROLLOVER);
function conbut_ROLLOVER(e:MouseEvent):void
{
Tweener.addTween(contact_1, {_frame:10, time:0.2, transition:"linear"});
var over:Over = new Over();
over.play();
}
conbut.addEventListener(MouseEvent.ROLL_OUT, conbut_ROLLOUT);
function conbut_ROLLOUT(e:MouseEvent):void
{
Tweener.addTween(contact_1, {_frame:0, time:0.5, transition:"linear"});
} 

conbut.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_29);
function fl_ClickToGoToAndPlayFromFrame_29(event:MouseEvent ):void
{
gotoAndPlay("contact..");
}

- The code for the remaining 6 buttons is similar except for the instance and frame names. I've attached 2 action script files (pdf format).
The code above works as expected for the first 3 buttons. The issue is with the other 4 buttons. Although the first 3 buttons play their movies and the user is sent to the correct frames which play when the button is selected, this behavior is expected to repeat with the other 4 buttons, but is not. How can this be fixed? I am not getting any errors.
 

Attachments

  • Code for first 3 buttons.pdf
    38.9 KB · Views: 297
  • Code for last 4 buttons.pdf
    40.3 KB · Views: 301
Last edited by a moderator:
Technology news on Phys.org
  • #2
Adding additional info to post:

- There is a stop action on the first frame of each movie
- In the code for last 4 buttons I replaced 'gotoAndPlay("home..")' with 'this. gotoAndPlay("home..")'; replaced 'gotoAndPlay("news..")' with 'this. gotoAndPlay("news..")'; replaced 'gotoAndPlay("gallery..")' with ' this.gotoAndPlay("gallery..")'; replaced 'gotoAndPlay("gallery..")' with ' this.gotoAndPlay("gallery..")'; and replaced 'gotoAndPlay("contact..")' with ''this.gotoAndPlay("contact..")'.
Checking the syntax did not produce any errors but, when the buttons are selected the movies do not play and the user is not sent to any frame.
 

1. Why is my rollover event not triggering the gotoAndPlay action?

There could be a few reasons for this. One possibility is that there is a syntax error in your code, preventing the event from firing. Another possibility is that the rollover event is not actually being registered by the browser, in which case you may need to check your event listeners. It's also possible that the element you are trying to trigger the action on is not correctly set up for a rollover event, such as not having a hover state defined.

2. How can I troubleshoot why my rollover and gotoAndPlay actions are not working?

The best way to troubleshoot this issue is to use a browser's developer tools to inspect your code and see if there are any errors or warning messages. You can also try using console.log() statements to see if your code is reaching certain points and if any variables are being properly assigned. Additionally, you can try simplifying your code to see if the issue is with a specific line or block of code.

3. Can I use rollover and gotoAndPlay actions together?

Yes, it is possible to use these actions together. However, you need to make sure that they are properly nested in your code and that the event is being triggered correctly. It's also important to ensure that the gotoAndPlay action is not being overridden or interrupted by any other code.

4. Why does my stop action prevent my rollover and gotoAndPlay actions from working?

The stop action essentially pauses the timeline of your animation, preventing any further actions or events from occurring. This means that any rollover or gotoAndPlay actions that come after the stop action will not work. To fix this, you may need to move the stop action to a different point in your timeline or use a different method to pause your animation.

5. Can I use rollover and gotoAndPlay actions in multiple frames?

Yes, you can use these actions in multiple frames of your animation. Just make sure that they are properly nested and triggered in each frame where you want them to occur. It's also important to keep in mind that the gotoAndPlay action will reset the timeline to the specified frame, so any rollover events in subsequent frames may need to be adjusted accordingly.

Similar threads

  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
2
Views
10K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Replies
10
Views
2K
  • Programming and Computer Science
Replies
8
Views
6K
Replies
2
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
0
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Programming and Computer Science
Replies
3
Views
4K
Back
Top