hello everyone,
my problem is that i have created a custom shape class which inherit UIComponent. now if i transform the shape object i am unable to get the new width and height value.
e.g:
var shape:Shape = new Shape();
shape.type = Shape.TRIANGLE.
shape.width = 100;
shape.height = 100;
var mat:Matrix = new Matrix();
mat.scale(1.5, 1.5);
shape.transform.matrix = mat;
trace(“scaleX: “+shape.scaleX+”, width: “+shape.width+”
scaleY:”+shape.scaleY+", height: "+shape.height);
///// scale value tracing 1 instead of 1.5, and 100 instead of 150 for height and width.
the problem also persists if i use canvas instead of shape. it will be realy helpfull if someone will point me out what i am doing wrong
on basis of above problem i have written a basic app in flex in which i have used a Sprite and a UIComponent, Sprite is working well but UIComponent is having a problem.
code:
[SIZE=1]<?xml version=“1.0” encoding=“utf-8”?>
<mx:Application xmlns:mx="[/SIZE][SIZE=1]http://www.adobe.com/2006/mxml[/SIZE][SIZE=1]" layout=“absolute” minWidth=“955” minHeight=“600”
creationComplete=“init()”>
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private var spt:UIComponent;
private var spt2:Sprite;
private function init():void{
spt = new UIComponent();
with(spt.graphics){
beginFill(0xffffff);
drawRect(0, 0, 100, 100);
}
addChild(spt);
spt2 = new Sprite();
with(spt2.graphics){
beginFill(0xffffff);
drawRect(0, 0, 100, 100);
}
rawChildren.addChild(spt2);
spt2.x = 500;
}
private function onChange():void{
var mat:Matrix = new Matrix();
mat.scale(scale.value, scale.value);
spt.transform.matrix = mat;
debug.text = "scaleX: "+spt.scaleX+", width: "+spt.width+"
scaleY: “+spt.scaleY+”, height: "+spt.height; ///// not able to trace the update width, height and scale value
var mat2:Matrix = new Matrix();
mat2.tx = 500;
mat2.scale(scale.value, scale.value);
spt2.transform.matrix = mat2;
debug.text = debug.text+"
scaleX: “+spt2.scaleX+”, width: “+spt2.width+”
scaleY: “+spt2.scaleY+”, height: "+spt2.height; ///// tracing correct value
}
]]>
</mx:Script>
<!–<mx:Canvas width=“100” height=“100” x=“10” y=“10” backgroundColor="#FFFFFF"
id=“can”/>–>
<mx:Text x=“10” y=“502” id=“debug”/>
<mx:HSlider x=“411” y=“508” minimum=“0.2” maximum=“4” snapInterval=“0.1” liveDragging=“true”
change=“onChange()” id=“scale”/>
</mx:Application>
[/SIZE]
[SIZE=1][/SIZE]
[SIZE=1][/SIZE]
[SIZE=1][SIZE=2]pls help me :puzzle:[/SIZE][/SIZE]