Button navigation to diff scenes

  • Aanish
  • Newbie
  • Newbie
  • Aanish
  • Posts: 8

Post 3+ Months Ago

Hi,

I am a novice Flash user and i have 6 scenes in my project.
I have a menu scene with 5 buttons to select each scene. i want to click on a button and on releasing it , should play a particular scene.

i cant get it to do that, i have this

on (release) {
_root.gotoAndPlay("FrameLabel_I_used_to the scene i wanttogo to");
}

where do i put this piece of code? and is this right?

Thank you
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

I'm a little confused as to weather you want to navigate to a scene, or a frame with a frame label.

Otherwise, you should select the button on the stage (don't edit the button) and go to your actions panel. That's where your code goes.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

dM: Flash has an issue where if you try and navigate to a scene from a button that is contained with another movieclip and not on the main timeline you can't. So the typical workaround to switching between scenes is to give the first frame in that scene a frame label then use _root.gotoAndPlay("frameLabel") to go there.

@Aanish: That code is correct, and it goes directly on your button (right click on your button, open the actions panel, add those actions). However there are 2 things you must make sure you have done...

1) Give the first frame in your scene a frame label (right click on the frame, open the properties panel)

2) Change "FrameLabel_I_used_to the scene i wanttogo to" to the correct frame label.

Sure these are obvious, but as far as I can see, these could be the only things going wrong.

Unless of course you are loading this movie into another movie via loadMovie(), if that is the case then it is the _root that is messing it up.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

cool. never run across that. thanks LIB!! :)
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

No problem dM, glad to help :)
  • Aanish
  • Newbie
  • Newbie
  • Aanish
  • Posts: 8

Post 3+ Months Ago

Thanks,

but thats what i have done and with no success.
when you say " That code is correct, and it goes directly on your button (right click on your button , open the actions panel, add those actions)"

Should i place this code on the button in the main timeline or the buttons timeline? i think it should be on the main timeline.

PS: iam working with Flash MX ver 6.0
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

You can't put any actions in a button timeline they won't work ;) Also since this code is in an on handler, you wouldn't be able to put it on a frame anyway since an on handler is for a button symbol and as of Flash MX a movieclip symbol as well.

You will have to put it directly on the button... you do this by right clicking on the button, choosing "Actions" from the context menu, and placing the actions you want within the actions panel.
  • Aanish
  • Newbie
  • Newbie
  • Aanish
  • Posts: 8

Post 3+ Months Ago

Thankyou very much, that works well.
  • Aanish
  • Newbie
  • Newbie
  • Aanish
  • Posts: 8

Post 3+ Months Ago

As i explained before i have one menu scene and 5 buttons on that scene which i use to access 5 other diff scenes.

i did name the first frame of a scene as "framelable" and with the appropriate actions on the button was able to access that scene.

on (release) {
_root.gotoandPlay("framelable");
}

but when i name another scene as"framelable2"
and place these actions on another button:

on (release) {
_root.gotoandPlay("framelable2");
}

it fails to work, any IDEAS??? why???

Thank you so much in advance.
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

well the problem is that you are using scenes. :shock:
Scenes are messy and tough to deal with at times...like now.
I would suggest looking into using Movie Clips instead. You'll
find it's MUCH EASIER to understand and control.

However, to get this to work, you have to realize that your AS
on your buttons are only applying to the scene they are on. So,
that's why 1 works, and the other don't. Your code is telling the
buttons to go to framelabel2 on THAT scene, which obviously
doesn't exist.

What you need to is simply add to your buttons which scene
they are being directed to play that frame. something like this:
Code: [ Select ]
on(release){
    gotoAndPlay("SCENE", "framelabel");
}
  1. on(release){
  2.     gotoAndPlay("SCENE", "framelabel");
  3. }
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

UNFLUX wrote:
However, to get this to work, you have to realize that your AS
on your buttons are only applying to the scene they are on. So,
that's why 1 works, and the other don't. Your code is telling the
buttons to go to framelabel2 on THAT scene, which obviously
doesn't exist.

What you need to is simply add to your buttons which scene
they are being directed to play that frame. something like this:
Code: [ Select ]
on(release){
    gotoAndPlay("SCENE", "framelabel");
}
  1. on(release){
  2.     gotoAndPlay("SCENE", "framelabel");
  3. }
You are 100% right about scenes being difficult to manage and use... I personally hate scenes.

However, the rest isn't exactly correct. When you target a frame label it doesn't matter which scene it is in, it will still go there. That is why the method worked the first time. And it is the gotoAndPlay("SCENE", frame) method that is buggy in Flash and won't work when inside a movieclip symbol, the button must be contained in the main timeline for something like this to work.

@Aanish: I'm not entirely sure if this is right or not, but I don't believe frame labels can contain numbers. Try changing it to framelabelTwo and see what happens.
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

hmm...ok well i tested it to see, but i only used 2 scenes and
2 buttons. Good to know, but not sure why it worked. :?
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

It works because when you publish your movie flash doesn't have "scenes" it combines everything into 1 long timeline (which is why if you don't add a stop() action at the end of your scene it just plays right into the next scene).
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

ohhhhh...never realized that. doh! :P
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Yeah scenes are apparently supposed to be for organizational purposes, but really they just make it messy for you (something you learn when you get more into loading in external movies and whatnot).
  • Aanish
  • Newbie
  • Newbie
  • Aanish
  • Posts: 8

Post 3+ Months Ago

well framelable2 was only an example i have not used it in practise.. i have used only words and no numbers....
also the fact that file when published becomes one timeline - is good cauz then this should work.

on (release) {
_root.gotoandPlay("framelabelTWO");
}

I will never use frames again ofcourse. but i need a way out of this right now, and this is still not working out. the first button works.. not the second, if u'all have any more ideas ill appreciate it- else ill just change the whole thing.

Thankyou so muck.
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

sounds to me like you should probably just start over...going to
save you a lot of time and headache, i'm sure.

Post Information

  • Total Posts in this topic: 17 posts
  • Users browsing this forum: No registered users and 23 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.