Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Button link to another Scene, need code. I apologize

New Here ,
Sep 16, 2008 Sep 16, 2008
I am just stumped over doing something really simple and I need the code and the understanding to do this in Actionscript 2.0 . I hope someone can help !! I am authoring with Flash CS3, but need to do the following for one file in Actionscript 2.0. I have searched this forum and tried many solutions offered by experts, but they do not seem to help. Perhaps I am missing something.

I need to enable a button on the main timeline that when clicked, brings the user to Scene 2, frame 1. By the way this particular frame is named M1

I have created a button properly. The instance name on the timeline in Scene 1 is skipintro_btn


>>>Scenario 1 that I tried unsuccessfully
In the main timeline, I created an Actionscript layer and in it, on the same frame as the skipintro_btn, I add this AS 2.0 code:

skipintro_btn.onPress = function():Void {
gotoAndPlay("Scene 2",1)
}

and I tried this:

skipintro_btn.onPress = function():Void {
gotoAndPlay("Scene 2",1)
}

But the above does not work. The cursor turns into a hand when rolled over the button, but upon clicking there is no action.


>>>Scenario 2 that I tried unsuccessfully
On the main timeline, I added this code to the object itself, instead of relying on the actionscript in a separate layer:

on(release){
gotoAndPlay("M1")
}
TOPICS
ActionScript
712
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2008 Sep 16, 2008
don't use scenes for navigation in as2 and don't use the goto functions. use frame labels or numbers and the goto methods:

_root.gotoAndPlay("scene2_frame1"); // <- label this frame
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 16, 2008 Sep 16, 2008
Kglad,

You must be so tired of these questions, thank you for helping me.

first, I have a two scene scenario already built.

Secondly, do I place the below code on the instance as AS or instead it gets placed in a keyframe in another layer, which is on the same frame as the instance of the skipintro_btn ?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2008 Sep 16, 2008
place the code wherever you want. if you like having the code attached to a button/movie, you can still do that. (it's not good practice, but it causes no problem until later when you or someone else returns to your project.)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 16, 2008 Sep 16, 2008
Thanks kglad!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 16, 2008 Sep 16, 2008
kglad,

I was testing scene 1, I should have been testing the movie.

this code worked in AS in an layer dedicated to AS.
skipintro_btn.onPress = function():Void {
gotoAndPlay("Scene 2",1)
}

the code you gave I placed in a layer dedicated to AS. it made the timeline auto skip to scene 1, frame 1 when the timeline reached that actionscript.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2008 Sep 16, 2008
you're welcome.

but your coding is still problematic: if you change the order of your scenes, and especially if you move a new scene before your first scene, you'll expose a nasty flash bug.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 16, 2008 Sep 16, 2008
kglad,

Thx for this information, then what should the entire AS be then? The code you sent needs the instance name, the onPress or onRelease information, maybe something else...? We gotta tell it if something happens (the person clicks on that instance of button), then do what you give below...

_root.gotoAndPlay("scene2_frame1"); // <- label this frame



thx!

DAve Varga

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2008 Sep 16, 2008
LATEST
just replace your goto functions with goto methods:

skipintro_btn.onPress = function():Void {
_root.gotoAndPlay("scene2_frame1"); // <- label this frame
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines