topical media & game development

talk show tell print

sample-flex-draw-api.mx

sample-flex-draw-api.mx [swf] flex


  <?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
          <mx:Script>
                  <![CDATA[
  
tdotblog.info/?q=node/19

import mx.containers.GridRow; import mx.core.UIComponent; private function drawBox():void{ var aBox:Shape = new Shape(); var c:UIComponent = new UIComponent(); aBox.graphics.lineStyle(lineWidth_ns.value, line_cp.selectedColor); aBox.graphics.beginFill(fill_cp.selectedColor, 1); aBox.graphics.drawRect(x_ns.value, y_ns.value, width_ns.value, height_ns.value); aBox.graphics.endFill(); c.addChild(aBox); drawing_cvs.addChild(c); } ]]> </mx:Script> <mx:HBox width="100%" height="100%"> <mx:VBox paddingLeft="10"> <mx:Label text="Box Attributes:" fontWeight="bold"/> <mx:Label text="x:"/> <mx:NumericStepper id="x_ns" value="50" maximum="{drawing_cvs.width}"/> <mx:Label text="y:"/> <mx:NumericStepper id="y_ns" value="50" maximum="{drawing_cvs.height}"/> <mx:Label text="width:" /> <mx:NumericStepper id="width_ns" value="50" maximum="{drawing_cvs.width}"/> <mx:Label text="height:" /> <mx:NumericStepper id="height_ns" value="50" maximum="{drawing_cvs.height}"/> <mx:Label text="line width:" /> <mx:NumericStepper id="lineWidth_ns" value="1"/> <mx:Label text="line color:" /> <mx:ColorPicker id="line_cp" selectedColor="#000000"/> <mx:Label text="fill color:" /> <mx:ColorPicker id="fill_cp" selectedColor="#FFFFFF"/> <mx:Button label="Draw" click="drawBox()"/> </mx:VBox> <mx:VBox width="100%" height="100%"> <mx:Label text="Drawing Area:" fontWeight="bold"/> <mx:Canvas id="drawing_cvs" backgroundColor="#FFFFFF" width="500" height="500"/> </mx:VBox> </mx:HBox> </mx:Application>


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.