View Full Version : Changing button's image
ewyong
November 20th, 2002, 03:29 AM
Hi,
I need help from the experts here. Well, I am not that familiar with Flash Scripting and I need to do some scripting here I think.
I want to create a button with 2 images where when we click on it, the image of the button changes. Something like control buttons to control a movie. When we click on the Pause button, it changes to a Play button, and when click on the Play button, it goes back to the Pause button. Anyone can help me here. Thanks in advance. :)
sbeener
November 20th, 2002, 04:02 AM
here's a way:
make a movie with two frames, one for on, one for off.
select the movie and put this in the actions panel:
onClipEvent(load){
stop();
this.onPress = function(){
this.gotoAndStop(!(this._currentframe-1)+1);
}
}
that'll do it!
ewyong
November 20th, 2002, 04:19 AM
Hi sbeener,
Thanks for the code. It works. I really have alot to learn about Flash Action scripting.
lostinbeta
November 20th, 2002, 04:29 AM
Hey sbeener, you can use button handlers on movie clips as well, so you don't need the this.onPress you can just do
on (press){//stuff}
sbeener
November 20th, 2002, 05:03 AM
great. i guess i'm just set in my ways... ; )
lostinbeta
November 20th, 2002, 05:05 AM
Phew.... I thought you were going to prove me wrong and that your way was better....lol.
I was waiting for it :)
I know I used the method you used, until I accidently put buttons handlers on a movie clip and realized it worked just the same....lol.
ewyong
November 20th, 2002, 05:13 AM
Hi guys,
Well, I tried the code and it works great. But I got one small problem. I tried to put in the control to control a keyframe but I can't stop or play a movie clip.
At the moment, I have a movie clip with some animaitons, and the button that I have created is another movie clip in this movie clip. So, how can I overcome this problem? Thanks again in advance. =)
lostinbeta
November 20th, 2002, 05:21 AM
So your button is actually a movie clip inside a movie clip?
And what you want this button to do is???
Sorry it is 4:15am here, I really need to get to bed (very long day). Maybe sbeener will reply back :)
Neo_Clone01
November 22nd, 2002, 12:48 AM
hey lost, i was messin around witht he code as well,
i replaced this.onPress
with
on (Press)
and it said that u cant bundle the on operator
meaning that the onClipEvent (load) and on (press) handlers were conflicting
whats up witht that? hehe
lostinbeta
November 22nd, 2002, 12:49 AM
You don't put on (press) inside of the onClipEvent handler you put it as its own handler.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.