Skip to main content
Participant
August 19, 2014
Answered

Buttons does not work

  • August 19, 2014
  • 2 replies
  • 423 views

I have made a file with numbers as placeholders with buttons that navigate along the timeline. But when tested it does not work consistently. Can anyone help me? I have used actionscript 1 and 2 before, but now I have to switch to actionscript 3, and a lot is new to me. I have followed instructions and cannot see what is wrong with the file. Get the file from the link below.

https://dl.dropboxusercontent.com/u/5310648/2014del2svar04a.fla

This topic has been closed for replies.
Correct answer Ned Murphy

Thanks for the answer! But it did not solve the problem.

From ActionScript 1 and 2, I was used to having a code related to the button. Now the code is in a separate layer in the timeline. This is foreign to me and I do not really understand the logic.

Now I have moved the code for the forward buttons to frame 1. The code for the back buttons is still in frame 2. It works, but inconsistently. It works a couple of times and then it stops. Could it be bugs? Maybe I should download the application and Flash Player again?


I doubt it is a bug in the Flash software.  I did download your file and I see that if I change the code per what I suggested it does work okay except if you use the "end" button to start things off.  Then you get stuck at the end - this is because you skipped the frame where the code gets assigned to the backward moving buttons.

What you might consider doing instead of having the buttons not exist in frames where they won't be used is to instead just turn them invisible in those frames, then turn them visible when you change frames.  So in frame 1 you would make the two back buttons invisible and in frame 10 you would make the two forward buttons invisible.  Put all of the button event handler code in frame 1 so that everybody is coded up right away and they do not lose it anywhere along the timeline.

2 replies

Participant
August 19, 2014

I have four buttons. Two will navigate to each end of the timeline in question. The other two will bring you one step further on the timeline in either direction. The buttons are called start_btn, end_btn, fram_btn and tilbake_btn. The instances are called start, end, fram and tilbake. There are two labels on the timeline, in the Labels layer, one called start, the other called end, at each end of the timeline in question. In addition to the code below, placed at frame number 2, I have a stop-code in the Actions layer at frame number 1 because, when the file is opened I want the movie to stop at this frame.

Here is the code placed in the Actions layer at frame number 2:

start.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_9);

function fl_ClickToGoToAndStopAtFrame_9(event:MouseEvent):void

{

  gotoAndStop("start");

}

tilbake.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousFrame_4);

function fl_ClickToGoToPreviousFrame_4(event:MouseEvent):void

{

  prevFrame();

}

fram.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame_7);

function fl_ClickToGoToNextFrame_7(event:MouseEvent):void

{

  nextFrame();

}

end.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_10);

function fl_ClickToGoToAndStopAtFrame_10(event:MouseEvent):void

{

  gotoAndStop("end");

}

Ned Murphy
Legend
August 19, 2014

If the movie stops at frame 1 then how do you get out of frame 1 if the code for the buttons is in frame 2?  I am guessing you have at least the nextFrame and end buttons in frame 1 if they are what get you out of frame 1, so you will need to have their code in frame 1 as well.

Participant
August 19, 2014

Thanks for the answer! But it did not solve the problem.

From ActionScript 1 and 2, I was used to having a code related to the button. Now the code is in a separate layer in the timeline. This is foreign to me and I do not really understand the logic.

Now I have moved the code for the forward buttons to frame 1. The code for the back buttons is still in frame 2. It works, but inconsistently. It works a couple of times and then it stops. Could it be bugs? Maybe I should download the application and Flash Player again?

Ned Murphy
Legend
August 19, 2014

Many people will not download files thru the forum for a variety of good reasons.  If you show thw code that is not working and explain how your design fits into it you are more likely to get help.

Participant
August 19, 2014

Thanks, I will try to do that.

Inge