Views

This page attempts to explain view programming for ActionScript developers.

MovieClip structure

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:

  1. mcFrame
  2. mcBounds
  3. mcFrameMask

mcBounds

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):Void
  • NSCell::drawWithFrameInView(rect:NSRect, view:NSView):Void
  • NSCell::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.

mcFrame

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.

mcFrameMask

Parent clip: mcFrame

This clip contains a (black) rectangle, and its only purpose is to mask mcFrame.

Hierarchy

A view's relation to other views are:

  • one and only one super view;
  • many different sub views.

This behaviour is rather similar to a MovieClip in Flash:

  • _parent –> super view

For 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.

Insertion

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.

Restrictions

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);

Discussion

Enter your comment
 
 
projects/actionstep/documentation/views.txt · Last modified: 2007/02/19 11:21 (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki