Pretty useful code to draw Sprites from within a Flex application:
mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
mx:Script>![CDATA[
import flash.display.Sprite;
public function drawRectTest(nX:Number, nY:Number, nWidth:Number, nHeight:Number):void {
var testrect:Sprite = new Sprite();
testrect.graphics.beginFill(0xFF0000, 1);
testrect.graphics.drawRect(nX, nY, nWidth, nHeight);
testrect.graphics.endFill();
myPanel.rawChildren.addChild(testrect);
}
]]>/mx:Script>
mx:Panel id="myPanel"
paddingTop="10"
paddingBottom="10"
paddingLeft="10"
paddingRight="10"
height="200"
width="200"
>
mx:Button click="drawRectTest(75,75,50,100)" x="10" y="10" label="Draw" id="btnDrawRectangle"/>
/mx:Panel>
/mx:Application>
Its all about the rawchild. Now I just need to figure out how to do this "onload".
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment