1

When I write the code:

var x:MovieClip = new MovieClip();
....
...
x._visible = false;

Then ActionScript hides the movieclip. When I navigate to MovieClip class then found _visible, is just a Boolean property along with other proporties:

dynamic intrinsic class MovieClip
{
        .......
    var _height:Number;
    var _alpha:Number;
    var _lockroot:Boolean;
    var _visible:Boolean;
        .......
}

But how does Flash Handle it??? When I am just changing the value of the property , how does that changing the the visibility? I can not see any events being dispatched or some thing!

Lars Blåsjö
  • 6,118
  • 2
  • 19
  • 23
Simsons
  • 12,295
  • 42
  • 153
  • 269
  • `var _visible` it's just like a parametre for the movieclip it' not the one that hide the movieclip – mgraph Feb 10 '12 at 12:06
  • Not sure what class you are looking at but I don't think that Flash's core source code is available. Most likely this is a skeleton class used for code completion only - it doesn't tell you what Flash does behind the scenes. _visible might be a getter/setter that does something more, or a simple property that works like @package described. – laurent Feb 10 '12 at 12:20
  • `_visible` is a private member. What does the public one (named `visible`) look like? – J. Holmes Feb 10 '12 at 12:29

2 Answers2

1

visible is MovieClip's property that is taken into account only when a frame is being rendered. First, the run-time checks if the movieClip is added to the display list and then it checks if the movieClip is visible. If both of these properties are true, then the movieClip is rendered. There are no events associated with movieclip being visible or not.

package
  • 4,741
  • 1
  • 25
  • 35
  • Then How does it gets unrendered when I say _visible = false; I am just changing the property here – Simsons Feb 10 '12 at 12:25
  • If in frame 1 movieclip is visible, it is rendered. If in frame 2 it is not visible, it is not rendered. There's no such thing as 'unrendered'. – package Feb 10 '12 at 12:52
  • How abt on the Frame 1 itself you are switching the visibility on Button Press?Now initially the MC is visible and when onPress happens it changes the visiblity to false on Frame1 itself. So if it is not "un-rendering" then What? – Simsons Feb 13 '12 at 04:18
  • 1
    Anything you do with visibility on frame 1 does not occur on the same frame 1. When frame 1 finishes, the screen is redrawn at frame 2 without the particular MC, because it is not visible anymore. BTW, if you're thinking about frames like `Button`'s frames where you have only few of them indicating different states, that is not the case. The term frames here means the framerate of the swf at run-time, which is usually 24-30 frames per second. – package Feb 13 '12 at 04:45
1

Nothing happens behind the scenes.

Flash renders each frame, so if an object was visible in the first, it is rendered. Then in the next frame, the changed regions of the screen are whitewashed, and re-rendered. If, now, the said object is not visible, it is simply not rendered.

Note: Changing the _visible invalidates the object so Flash knows something has changed here and it needs to be re-rendered.

Pranav Hosangadi
  • 23,755
  • 7
  • 44
  • 70
  • 2
    That not entirely true, flash keeps track of the areas that have changed (see [Redraw Regions](http://help.adobe.com/en_US/as3/mobile/WS948100b6829bd5a6-421a65ed127736eaa26-8000.html)) and only redraws the sections it needs to. – J. Holmes Feb 10 '12 at 14:15