Skip to main content
Participating Frequently
August 18, 2011
Question

Make object visible only in certain frames!

  • August 18, 2011
  • 2 replies
  • 606 views

For keeping the actionscript in the first frame; I'm creating buttons only in the first frame that doesn't change; but I want for some of them to be visible only in certain frames! Is there any code for doing that?

This topic has been closed for replies.

2 replies

Ned Murphy
Legend
August 18, 2011

If you want to have all code in the first frame. then in any function where you command things to move to a new frame you need to set the visibility of all of the objects that can be visible/invisible based on the frame you are moving to since some may have been turned invisible at some point and might need to be made visible again while a new set might need to be made invisible.

Another way could be to have some continuously operating function (ENTER_FRAME event) that tests which frame you are in and adjusts visibility accordingly, though that would be wasteful use of processing.

In any case, the objects whose visibility you want to control need to extend for the length of the timeline starting from the first frame to be able to command them from frame 1.

relaxatraja
Inspiring
August 18, 2011

If you'r not maintaining the objects in the first frame where code resides, then you have do this way

first frame:

function visibility(str:String):void{

    this[str].visible=false;

     //any number of lines

}

on your certain frame:

you should call the visibility function:

visibility(mc1);