This page attempts to explain view programming for ActionScript developers.
Unless you’re themeing, you almost never have to deal with MovieClips in ActionStep. Everything is handled for you.
An instance of NSView, or just referred to as a view, contains 2 important MovieClips:
Parent clip: mcFrame
This clip can be thought of as the “canvas” of the view, where all the drawing will be performed. Common methods that draw to it are:
NSView::drawRect(rect:NSRect):VoidNSCell::drawWithFrameInView(rect:NSRect, view:NSView):VoidNSCell::drawInteriorWithFrameInView(rect:NSRect, view:NSView):Void
Please note that when drawing to a view, you have to invoke NSView::mcBounds().clear.
You may have to do this when subclassing NSView and overwriting the drawRect method.
Parent clip: super view’s mcBounds
This clip “frames” the view, such that any drawings exceeding its dimensions will not be displayed.
The dimensions are specified by NSView::frame():NSRect.
Note that any changes in the size of the frame, ie through NSView::setFrame(rect:NSRect):Void will result in both mcFrame and mcFrameMask being redrawn. This may impact performance.
Parent clip: mcFrame
This clip contains a (black) rectangle, and its only purpose is to mask mcFrame.
A view’s relation to other views are:
This behaviour is rather similar to a MovieClip in Flash:
_parent –> super viewFor a view to be displayed, it must first be inserted into a heirarchy. In other words, it must be the sub view of another view. If this is not done, the aforementioned MovieClips will not exist, and attempts to access them will result in an exception being thrown.
The only views without a super view are instances of window.ASRootWindowView. They can be displayed without inserting them into a view heirarchy.
This is similar to the MovieClip _root.
A view is almost always inserted into a window’s heirarchy. For example:
myWindow.setContentView(myView); //alternatively, myWindow.contentView().addSubview(myView);
Please note that they do *not* do the same thing.
A view cannot be both the super view and sub view of another view at the same time. For example:
viewA.addSubview(viewB); //exception thrown here viewB.addSubview(viewA);