PDA

View Full Version : button within a movie


tott
12-04-2003, 01:26 PM
I have problems getting my button placed within a movie to change the scene. I have tried two approaches:

1: add the script to the movie

onClipEvent (enterFrame) {
this.forward.onPress = function() {
_parent.gotoAndPlay("Scene 2", 1);
};
}

where "forward" is the instance name of the button.

2: add the script to the button within the movie

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

Neither of the work. What am I doing wrong?

dzy2566
12-04-2003, 02:33 PM
Well you don't want an on enterFrame event, that's for sure. You might be looking for the following.//add this script to the timeline that your button sits on
forward.onRelease = function(){
_root.gotoAndPlay("Scene 2",1);
}

tott
12-04-2003, 03:04 PM
Thanks for the advice.

I pasted it to the timeline within the movie, where the button is (nothing highlighted) but there is still nothing happening.

If I instead attach it to the button (highlight it and paste it to the script), I get an error message:

Statement must appear within on/onClipEvent handler
forward.onRelease = function(){

..and I thought that was what I had done in the first place.

Does this give any further idea of what I am doing wrong?

divarch
12-04-2003, 06:55 PM
Hi there,
first, the warning you got is because if you attach the code to clip.
It should look like this
on(release){
_root.gotoAndPlay("Scene2",1)
}

If you attach it to the movie timeline, it should look like this:
button.onRelease=function(){
_root.gotoAndPlay("Scene2",2);
}
// as dzy2566 said earlier//

Hope this helps, cause I know it works
:)