Skip to main content
msa96947redlands
Participating Frequently
December 28, 2017
Answered

my as3 code does not play on scene 2

  • December 28, 2017
  • 2 replies
  • 2148 views

I have created a simple animation in the fist scene that goes to a navigation screen and stops. When the user clicks on the first button "Try Surfing Animation" it should go and play scene 2 which I have called TrySuf. I do not know why this code does not play on scene 2. I am using Adobe flash. I am using AS3 code. I have shared the file on my google drive. Please let me know if you cannot access it from google drive as I find an alternative way of demonstrating my file. Any help will be much appreciated.

https://drive.google.com/open?id=1lz1aaXx3RUjOQep9o8fna2-3Shpp-Yc8

Thank you in advance

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Thanks!

The problem it's because you don't have a code to make your button do what you want.

In the last frame of your first scene, where there is a stop() function, replace the code there with this one:

import flash.events.MouseEvent;

function clickHandler(e:MouseEvent):void

{

    gotoAndPlay(1, "TrySurfing");

}

stop();

surfButton.addEventListener(MouseEvent.CLICK, clickHandler);

In the last frame of the second scene, the one with the surfing animation, put this code:

gotoAndPlay(11); // if you want to create a loop for the surfing animation

OR

This one:

stop(); // if you want to stop the animation on the last frame.

By the way, very cool animation! Well done!

I hope it helps.

Regards,

JC

2 replies

msa96947redlands
Participating Frequently
December 29, 2017

Strange, I thought I had put code on the work but the link on google drive had no code. Anyway there was a problem in the code which is now solved.

Thank you ever so much.

JoãoCésar17023019
Community Expert
Community Expert
December 29, 2017

You're welcome!

Participant
December 3, 2018

hi .

i have a problem in action script coding.

when i create a button in scene 2 or 3 in my projects adobe animate show this error :

1120:Access of undefined property button_back

while i set instance name !!

this  code is ok in scene 1 but in other scenes show erro!!

JoãoCésar17023019
Community Expert
Community Expert
December 29, 2017

Hi.

Please set your file sharing options to public so we can see what's going on.

Regards,

JC

msa96947redlands
Participating Frequently
December 29, 2017

Hi,

I have given anyone who has the link, full access, let me know if this is okay?

google drive does not always behave the way I want it to.

https://drive.google.com/file/d/1lz1aaXx3RUjOQep9o8fna2-3Shpp-Yc8/view?usp=sharing

Thank you

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
December 29, 2017

Thanks!

The problem it's because you don't have a code to make your button do what you want.

In the last frame of your first scene, where there is a stop() function, replace the code there with this one:

import flash.events.MouseEvent;

function clickHandler(e:MouseEvent):void

{

    gotoAndPlay(1, "TrySurfing");

}

stop();

surfButton.addEventListener(MouseEvent.CLICK, clickHandler);

In the last frame of the second scene, the one with the surfing animation, put this code:

gotoAndPlay(11); // if you want to create a loop for the surfing animation

OR

This one:

stop(); // if you want to stop the animation on the last frame.

By the way, very cool animation! Well done!

I hope it helps.

Regards,

JC