Archive for November, 2006

scale9Grid workaround for nested movieclip

November 30, 2006

using setInterval:
http://www.devpro.it/code/122.html

possible solutions using bitmapData class:
http://luar.com.hk/blog/?p=594

Final solutions/Flex 2 (presumably bitmapData solution):
http://www.adobe.com/devnet/flex/quickstart/embedding_assets/#EmbeddingImagesScale9
http://chattyfig.figleaf.com/pipermail/flashcoders/2006-July/169871.html

time tested old goodies:
v2 UI component style  MC subclasses. The trick is to use boundingBox_mc to keep track of the desired dimension either set at runtime or compile time (Flash IDE) at the first frame it get instantiated, and then dynamically load(createChild()) and layout()/draw() all the other visual assets based on the preset layout algorithum accordingly. So it might take some energy just to get the layout right, considering the features such as alignment of a textfield to the bottom-right corner of the component. Using this approach, the MC that needs anti-distortion can be composed of 9-slice mcs, or maybe several slices bitmapData manipulated mcs.
This is the most time consuming while most generic solution. It’s worthwhile for building a site that implement this framework.

Don’t define onRollOver etc. in MovieClip suclasses

November 29, 2006

… unless absolutely necessary. Since MC is dynamic, onRollOver, etc. can always be attached at runtime. There is no need to define abstract type of onRollOver whose sole purpose is just to provide an interface for its subclasses to implement. Since once the methods is defined, even without implement, like this:

private function onRollOver(Void):Void{
//to be implemented in subclasses
}

the class and its subclass instances will automatically become “buttons”. This means if the instances are attached on the stage where they are stacked over other MCs, it will create problems such as flicking when user mouses over the overlapped area.

AS inheritance constructor 101

November 29, 2006

Subclass constructors need arguments

When extending a class whose constuctor got arguments other than “Void”, you need to explicitly call super(args) in its constructor in order to receive all the arguments from the subclasses instantiation.

E.g.,

function ThumbnailAni(url:String, x:Number, y:Number, maskID:String, maskFrmID:String, initAt:MovieClip)
{
super(url, x, y, maskID, maskFrmID, initAt);
}

Subclasses of Movieclips or UIComponents that got metadata from intialized objects don’t need to do this since Inspectable variables will be passed by init obj when attachMovie() is called.

mask/setMask() 101

November 29, 2006

1. setMask() will not affect the display of device fonts. They will be drawn regardless;

2. setMask() takes priority to timeline mask layers;

3. Movieclip nested inside a container mc can mask the container mc (which “includes” itself) by calling setMask() !

AS3 NOTE: setMask is deprecated in AS3 in favor of DisplayObject.mask property.

For a mask to be effective, it doesn’t need to be added to the display list. But you would _need_ to include it in “an active part of the display list” in the following cases:

  • To ensure that masking works when the Stage is scaled;
  • To be able to scale a mask object;
  • To be able to drag a mask Sprite object (by calling its startDrag() method)

A single mask object cannot be used to mask more than one calling display object. When the mask is assigned to a second display object, it is removed as the mask of the first object, and that object’s mask property becomes null.

A mask or maskee display object cannot take any mouse event, while its parent container object _can_. This means if both a mask object and its container are listening to a mouse click event, when you click on the maskee where there is no other content, the container handler will respond while the mask handler won’t.

this.stage.scaleMode = StageScaleMode.NO_SCALE;
this.stage.align = StageAlign.TOP_LEFT;
this.stage.showDefaultContextMenu = false;

//mask
var w:Number = 854;//stage.width;
var h:Number = 480;//stage.width;
var square:Shape = new Shape();
square.graphics.beginFill(0xFF0000, 1);
square.graphics.drawRect(0, 0, w, h);
square.graphics.endFill();
//this.addChild(square);

this.mask = square;

//frame
var frame:Shape = new Shape();
frame.graphics.lineStyle(1, 0x9E0000, 1);
frame.graphics.beginFill(0xFFFFFF, 0);
frame.graphics.drawRect(0, 0, w-1, h-1);
frame.graphics.endFill();
this.addChild(frame);

skin FLVPlayBack component (flash 8) quick start

November 25, 2006

here and here