Skip to main content
Known Participant
April 29, 2010
Answered

Checking for Movie Clip Instance

  • April 29, 2010
  • 2 replies
  • 625 views

Is it possible to check if a button instances is available on a certain frame?

i.e.

Frame 1 has the following movie clips

a_btn

b_btn

c_btn

Frame 2 has the following movie clips

a_btn

c_btn

I want to check if buttons a, b, c is available on Frame 2 and run a corresponding function if condition 1 or condition 2 is met

This topic has been closed for replies.
Correct answer Ned Murphy

You can use a simple conditional to check if an object is present....

if(a_btn){

     trace("yes");

} else {

     trace("no");

}

2 replies

Known Participant
April 29, 2010

Hello,

I took what Ned did and added an event to check specifically for frame 2:

stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);


    function enterFrameHandler(event:Event):void {
        if ( currentFrame ==2 ){
                  if(a_btn){
                   trace("yes");
                   } else {
                    trace("no");
                   }
         }
    }

I am assuming you have more than 2 frames on your timeline.

The code is to be pasted in on Frame 1

Jim

c0jAuthor
Known Participant
April 30, 2010

Much appreciated. I really don't have any project working at this moment that I will be using this but more of

a passing thought. Thanks!


Ned Murphy
Ned MurphyCorrect answer
Legend
April 29, 2010

You can use a simple conditional to check if an object is present....

if(a_btn){

     trace("yes");

} else {

     trace("no");

}