actionscript 3 - How does Flash calculate a DisplayObject's dimensions based on the children? -
i have class called container extends sprite , adds ability set width , height manually, scalex , scaley remaining 1.
i have put such class sprite , noticed sprite measures internal calculations, not getting width / height getters.
what math , how can extend force sprite consider extended width , height getters while doing internal measures?
the math lies within getboundary()
function that's called of children , own graphics determine coordinates edges of entire sprite's display list. that's why setting width without scaling might not useful. if still wish this, first make fields contain info on set width , height, update on container.width
, container.height
assignment, override getters on width , height, returning maximum of stored width/height , calls of super.width
, super.height
.
var storedwidth:number=0; // not have nans public override function width():number { var w:number=super.width; // width math if (storedwidth>w) w=storedwidth; // or other logic, operate these values return w; }
the same approach height.
Comments
Post a Comment