咖啡伴侣

呆在上海
posts - 163, comments - 156, trackbacks - 0, articles - 2

Flex 画2D

Posted on 2008-03-28 10:00 oathleo 阅读(424) 评论(0)  编辑  收藏 所属分类: Flex
<?xml version="1.0"?>
<!-- usingas/AddingChildrenAsUIComponents.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script><![CDATA[
        import flash.display.Sprite;
        import mx.core.UIComponent;

        private var xLoc:int = 20;
        private var yLoc:int = 20;
        private var circleColor:Number = 0xFFCC00;

        private function addChildToPanel():void {

            var circle:Sprite = new Sprite();
            circle.graphics.beginFill(circleColor);
            circle.graphics.drawCircle(xLoc, yLoc, 15);

            var c:UIComponent = new UIComponent();
            c.addChild(circle);
            panel1.addChild(c);
           
            xLoc = xLoc + 5;
            yLoc = yLoc + 1;
            circleColor = circleColor + 20;
        }
    ]]></mx:Script>

    <mx:Panel id="panel1" height="250" width="300" verticalScrollPolicy="off"/>

    <mx:Button id="myButton" label="Click Me" click="addChildToPanel();"/>
   
</mx:Application>

只有注册用户登录后才能发表评论。


网站导航: