Skip to main content
September 27, 2011
Answered

make button instance containing movieclip play specific frame

  • September 27, 2011
  • 1 reply
  • 2093 views

What I want to do is have one movieclip that has many frames and turn that into a button and then make different instances of the button and have those instances display a certain frame of the underlying movieclip.  I'm very new to AS3 and was very beginner with AS2 and have no idea what to even do here.  I have looked for tutorials and found nothing that helps me so if anyone knows of something or can help I would appreciate it.

This topic has been closed for replies.
Correct answer Kenneth Kawamoto

Here is what I have so far

Btn1.addEventListener(Event.ENTER_FRAME,gotoFrame);

function gotoFrame(event:Event):void {

Btn1.stop("Blue");

}

following labeled frames Gradient, Blue, Pink, Purple

The actual scene depth goes like this

Scene1:  instances of Btn_Art = Btn1, Btn2, Btn3, Btn4

Btn_art is a symbol made from the movieclip ButtonBase_Art (it still has the up, over, down, and hit states)

ButtonBase_Art has the following labeled frames Gradient, Blue, Pink, Purple

So I want Btn1 to display the Blue frame of animation but still maintain the up over down and hit states

I dont know if this makes anymore sense to you


Btn1.addEventListener(Event.ENTER_FRAME,gotoFrame);

function gotoFrame(event:Event):void {

Btn1.stop("Blue");

}

This does not make sense. It should simply be:

Btn1.gotoAndStop("Blue");

--

Kenneth Kawamoto

http://www.materiaprima.co.uk/

1 reply

September 27, 2011

Any movie clip can be a button simply by attaching mouse listeners to it. One example that relates to what you want to do is a check box. I often make these using a two frame movie clip. On frame one the box is blank. On frame two the box is checked... And there is a stop(); placed on frame one so the clip doesn't play.

If you would place that clip on stage, and give it an instance name of 'myCheck' then you could do:

myCheck.addEventListener(MouseEvent.CLICK, toggleCheck, false, 0, true);

function toggleCheck(e:MouseEvent):void

{

     if(myCheck.currentFrame == 1){

          myCheck.gotoAndStop(2);

     }else{

          myCheck.gotoAndStop(1);

     }

}

So, as you click it the check will toggle between the two frames / states. You can have as many instances as you like, they just need to have different instance names so you can access them separately from code.

September 27, 2011

But I dont want my button to change images when clicked just load in as the different images so even once clicked they stay the same image

September 27, 2011

you'll need to explain yourself better.