PDA

View Full Version : Help with Movie Clip Button Action Script



Vish
June 1st, 2005, 02:09 PM
Hey,

I am having some trouble customizing the scripting on this button http://www.kirupa.com/developer/mx2004/button_effect.htm

If you look at the code there, you'll notice that it, when clicked it goes to www.kirupa.com (http://www.kirupa.com/), hence the code:
this.onRelease = function(){
getURL("http://www.kirupa.com","_blank");
}

Now I want this button, when clicked to go to for example a certain frame in my movie instead of a webpage... So I tried:

this.onRelease = function(){
gotoAndPlay(100);
}
But it does not work like that, nothing happens when I test the movie and click it. For your info, I do have something on frame 100, a motion tween.

What have I done wrong? How can I fix this?

I'm relatively new to Flash so please bear with my limited knowledge.

Thanks in advance,
Vish

rrluthi
June 1st, 2005, 02:30 PM
you need to do _parent.gotoAndPlay(100);

it's trying to play frame 100 of your button.

Vish
June 1st, 2005, 02:57 PM
doesn't seem to work still.

rrluthi
June 1st, 2005, 03:25 PM
where are you putting your action script? is it on the movie clip button, the button's timeline, or is it on the main timeline?

Vish
June 1st, 2005, 03:33 PM
I'm placing it in the movie clip button, on frame 1 of the timeline of the movie clip.

lunatic
June 1st, 2005, 03:37 PM
instead of using a frame number, try using a frame label. Click in frame 100 and in the Properties panel look for the box that says "frame label". Give it a name (it's like an instance name for a frame), for example "myframe" (no quotes).

Then change the code on the movieclip button to read:



this.onRelease = function(){
gotoAndPlay("myframe"); //must have quotes this time
}



Keep in mind that you may need to script the path to the movieclip the frame resides on. If the frame in question is on the main timeline use _root.gotoAndPlay. If the frame in question is inside a movieclip you would use myMC.gotoAndPlay (where myMC is the movieclip the frame is in).

Hope this helps

:hr:

Vish
June 1st, 2005, 03:56 PM
Thanks! It works now :D

lunatic
June 1st, 2005, 04:03 PM
:thumb:

theflash
June 1st, 2005, 05:24 PM
but why frame number would not work ?

theflash
June 1st, 2005, 05:25 PM
is there anything wrong in code ?

lunatic
June 1st, 2005, 05:53 PM
I'm guessing it was a path problem. Because Vish was using "this" flash was looking for frame 100 inside the movieclip that was being pressed. I'm gonna bet that the frame in question was on a different timeline. ;)