all groups > flash actionscript > february 2005 >
You're in the

flash actionscript

group:

Button Linkage


Re: Button Linkage Byron Canfield
2/18/2005 4:34:18 PM
flash actionscript: In addition, when you preface gotoAndPlay with a path, you are then using
the gotoAndPlay() method of the MovieClip object, which only accepts one
parameter -- that parameter can be a frame number (integer 1 or greater up
to the total number of frames), a frame label name (a string, enlosed in
quotes), or a variable with a value corresponding to either of the previous
two.

Only by omitting the prepended path are you using the gotoAndPlay FUNCTION,
which accepts TWO parameters. If the first parameter is a string, it is
interpreted as a scene name (no variables allowed for scene name). If a
variable is supplied, its value is assumed to be either an integer 1 or
greater representing a frame number or a string representing a frame label
name. Otherwise, you may supply a frame label name as a string or an integer
1 or greater, as the only parameter. And because the prepended path must be
removed to use this function, the only way to reach the _root from a button
that is not ON the root is by reverting to the old Flash 4 syntax of
tellTarget():

on(press){
tellTarget(_root){
gotoAndPlay("scene1", 4);
}
}

--
--------
Reality will not be altered to comply with preconceived notions.

Byron "Barn" Canfield
Flash example files: http://www.canfieldstudios.com


Button Linkage ebeaz
2/18/2005 9:51:28 PM
I'm fairly new at Flash, but learning things as I go. One of the things I
haven't been able to figure out is how to link a button to a new scene. (if
this is even possible)

I've set up two scenes:

The first one has all of my buttons, making up a navigation menu. All of the
buttons have Up and Over scripts, or whatever you call them, and I have put
them on the stage. For Linkage, I selected "Export for Actionscript," thinking
that would make sense since I want to apply Actionscript. On my button
keyframe, in the first scene, I got some code online that I thought would work
in making Scene 1 go to Scene 2 when the button is clicked:

on(release){
_root.gotoAndPlay("Scene 2",1);
}

I thought this meant that on the release of a mouse click, it would go
straight to Scene 2.

But when I export, it tells me:

**Error** Scene=Scene 1, layer=Layer 1, frame=135:Line 1: Mouse events are
permitted only for button instances
on(release){

Total ActionScript Errors: 1 Reported Errors: 1

---------------------------
Is this telling me my button is not a button instance? Is this code all wrong
or am I missing something small? Or is this just totally the wrong way to do
navigation? Any help is greatly appreciated. Thanks.

-ebeaz

Re: Button Linkage kglad
2/18/2005 11:38:37 PM
first, scene information only exists in the authoring environment. so, you
shouldn't use scene info to navigate. to remedy label your frames and use
those labels to navigate.

second, that error message is telling you that your code is NOT attached to a
movieclip or a button. most likely it's attached to a frame. to remedy,
remove that code and click on an empty spot on your stage and then click on the
button or movieclip to which you want to attach that code. in the actions
panel type:

on(release){
_root.gotoAndPlay("scene2_frame1");
}
// assuming you labelled the first frame of scene 2 with that label
(scene2_frame1);
AddThis Social Bookmark Button