Changing button's image

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. :slight_smile:

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!

Hi sbeener,

Thanks for the code. It works. I really have alot to learn about Flash Action scripting.

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}

great. i guess i’m just set in my ways… ; )

Phew… I thought you were going to prove me wrong and that your way was better…lol.

I was waiting for it :slight_smile:

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.

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. =)

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 :slight_smile:

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

You don’t put on (press) inside of the onClipEvent handler you put it as its own handler.