Skip to main content
Participant
April 15, 2008
Question

hide object and reveal later in timeline

  • April 15, 2008
  • 1 reply
  • 491 views
How do I make an object invisible at frame 1 and show up at frame 20?
This topic has been closed for replies.

1 reply

Ned Murphy
Legend
April 15, 2008
Frame 1 code: instanceName.visible = false;

Frame 20 code: instanceName.visible = true;

Where instanceName is whatever you name it in the properties panel... does not apply for graphic symbols.
mayamaraAuthor
Participant
April 16, 2008
Thanks. OK, how would I make it fade in at frame 20?
Ned Murphy
Legend
April 16, 2008
There are two approaches I know of:

1. The non-programatic approach: Take the existing object (movieclip and add it into another movieclip object on a layer by itself... plant it in frame 2 and set its alpha property to 0%, then place it in another keyframe somewhere down the timeline and set its alpha to 100% (you can move it around to set the speed of the fade in. Then add a motion tween from the first instance in frame 2 . Create another layer above the object layer and put the stop(); action in the first frame of that second layer and another in the frame above the second instance of the object. This eliminates the need to deal with the invisibility issue you first asked about because the object you want to have invisible isn't even there to be seen while the movieclip it sits in is stopped at frame 1. Add this new movieclip in place of the one that you probably have in the main timeline now. When your main timeline gets to frame 20, tell the new movieclip you added to gotoAndPlay(2)... it will gradually fade in as a result of the tween you added and stop.

2) The programatic approach: type in "AS3 fade in" in Google and check out the first item listed. There's a tutorial there that will explain things in detail, though it involves dynamically loaded objects. But it will still fly for planted objects as well once you understand what parts of their code you need. It'll be good to read thru and get an understanding. There may be other Google links that directly address your situation.

This approach uses an event listener (Event.ENTER_FRAME) that calls a function continuously, gradually changing the alpha value from zero (which you set ahead of time) to whatever you want the final alpha value to be (probably 100%). For the tutorial I mentioned, you can ignore the scaleX/Y parts, unless you'd like to include that effect as well.