topical media & game development

talk show tell print

actionscript-book-GeometricShapes-GeometricShapes.mx

actionscript-book-GeometricShapes-GeometricShapes.mx [swf] [flash] flex


  <?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="vertical">
  
      <mx:Script>
          <![CDATA[
              //import com.example.programmingas3.geometricshapes.IGeometricShape;
              //import com.example.programmingas3.geometricshapes.GeometricShapeFactory;
              //import com.example.programmingas3.geometricshapes.RegularPolygon;
              
              public var currentShape:actionscript_book_GeometricShapes_com_example_programmingas3_geometricshapes_IGeometricShape;
              
              public function describeShape():void
              {
                  var shapeName:String = shapeNameCbo.selectedLabel;
                  
                  this.currentShape = actionscript_book_GeometricShapes_com_example_programmingas3_geometricshapes_GeometricShapeFactory.createShape(shapeName, shapeWidthNs.value);
                  
                  this.outputTxt.text = this.currentShape.describe();
              } 
          ]]>
      </mx:Script>
      
           <mx:Label id="title" text="Geometric Shapes Example" fontSize="24" fontStyle="bold" />
          <mx:Text id="subtitle" text="From Programming ActionScript 3.0, Chapter 4: Object-oriented programming in ActionScript" width="100%" textAlign="center" fontSize="12" />
      
      <mx:Form width="500">
         <mx:FormItem label="What kind of shape would you like to describe?">
            <mx:ComboBox id="shapeNameCbo" change="describeShape()">
               <mx:dataProvider>
                  <mx:Array>
                     <mx:String>Circle</mx:String> 
                     <mx:String>Triangle</mx:String> 
                     <mx:String>Square</mx:String> 
                  </mx:Array> 
               </mx:dataProvider> 
            </mx:ComboBox>
         </mx:FormItem>
         
         <mx:FormItem label="How wide should the shape be in pixels?">
            <mx:NumericStepper id="shapeWidthNs" minimum="10" maximum="400" stepSize="10" change="describeShape()" />
         </mx:FormItem>
      </mx:Form>
         
      <mx:Label text="Results:" width="500" />
      <mx:TextArea id="outputTxt" width="500" height="150" editable="false" />
  
  </mx:Application>
  


(C) Æliens 04/09/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.