Skip to main content
Participant
April 12, 2013
Answered

Why does the button only work in test scene, not test movie?

  • April 12, 2013
  • 1 reply
  • 1831 views

Hi everyone, I have a very frustrating problem with my flash project.

I have two scenes in my flash movie, each of them has lots of links and navigation within itself. And there is one button that takes you from one scene to another.

When I test Scene 2, everything works fine. However, when I test the whole movie, the navigation within Scene 2 won't work and there is no error!

Does anyone has any thought about what is going wrong?

I'm using Flash CS6.

Thank you!

This topic has been closed for replies.
Correct answer Chipleh

Thank you! The simple code works...

I used all that code because I want to jump to the target frame upon pressing the button instead of finishing the click. There is a minor difference between the effects. Since the button still exists in the target frame in a clicked state, the CLICK MouseEvent will create a little flash during the transition.

I used this code within Scene 1 and it worked exactly what I wanted it. But when I used this code to transit to Scene 2, it messed up the navigation in Scene 2.

Do you have a better idea to achieve the effect I want?

Thank you!


Swap up the type of mouse event to MOUSE_DOWN, i.e.:

StoreHomeBtn.addEventListener(MouseEvent.MOUSE_DOWN, StoreHomeonClicked);

1 reply

Ned Murphy
Legend
April 12, 2013

Show the code involved and explain how things are set up on the timeline of the scene for the button involved.

Participant
April 12, 2013

Thank you for replying me!

My Scene 1 has some key frames and some gotoAndStop functions navigate between the frames. My Scene 2 has basically the same set up, but different content.

Then I use a button to jump from Scene 1 to Scene 2.

Here is the code:

var StoreHomepressing:Boolean = false;

function StoreHomeonPressing(evt:Event){

          if (StoreHomepressing==true){

                    gotoAndStop(1,"Scene 2");

                              }

}

function StoreHomehandlePress(evt:MouseEvent){

          StoreHomepressing = true;

}

function StoreHomehandleRelease(evt:MouseEvent){

          StoreHomepressing = false;

}

StoreHomeBtn.addEventListener(MouseEvent.MOUSE_DOWN, StoreHomehandlePress);

StoreHomeBtn.addEventListener(MouseEvent.MOUSE_UP, StoreHomehandleRelease);

addEventListener(Event.ENTER_FRAME, StoreHomeonPressing);

"StoreHomeBtn" is the instant name of a the button. Through this code, I want it to go to and stop at frame 1 of Scene 2 on pressing this button. It does jump to frame 1 of Scene 2, but once it goes to Scene 2, all the gotoAndStop functions in Scene 2 don't work and no errors show up.

Ned Murphy
Legend
April 12, 2013

Why don't you just use the following instead of all that code....

StoreHomeBtn.addEventListener(MouseEvent.CLICK, StoreHomeonClicked);

function StoreHomeonClicked(evt:Event){

          gotoAndStop(1,"Scene 2");

}

You might consider not using scenes at all.  They have a checkered past and are better to avoid when your design involves navigation.  Just keep things in one scene/timeline and either use frames for different sections or use movieclips for them and control visibility... or a mixture of the two.