Question

Example:

var circle1 :Canvas = new Canvas();
var circle2 :Canvas = new Canvas();

circle1.addChild( circle2 )
circle1.scaleX = 2;

After the example before when Flash will render circle2 because it is child to circle1 it will be scaled to. Is there a way I can scale circle1 without affect circle2 or what can I do to circle2 so it can have the same scale ?

Was it helpful?

Solution

OTHER TIPS

It's quite simple, just compensate for the fact you double the size of the parent.

var circle1 :Canvas = new Canvas();
var circle2 :Canvas = new Canvas();

circle1.addChild( circle2 )
circle1.scaleX = 2;
circle2.scaleX = .5; // Added

A maybe handy function, which takes care of scaling issues, could be:

function setParentOnlyScaleX(parent:Canvas, scale:Number):void {
    parent.scaleX = scale;
    for (var i = 0; i < parent.numChildren - 1; ++i) {
        var child:Canvas = circle1.getChildAt(i);
        child.scaleX  = 1 / scale;
    }
}

The first snippet then would be:

var circle1 :Canvas = new Canvas();
var circle2 :Canvas = new Canvas();

circle1.addChild( circle2 )
setParentOnlyScale(circle1, 2);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top