2 Replies Latest reply on Mar 29, 2011 8:52 PM by Drew747

    action script objects not displayed

    Gaurang Mathur Adobe Employee

      Hi,

       

      I am creating an air application using Flex 4.5 compiler. The problem i am facing currently is that i have extended shape class to my custom class movingObject. in this class i have defined a function "drawcircleObj" in this class and calling this class function to display my customized circle on the stage.


      But it is not behaving as desired. i.e. no object is being displayed

        • 1. Re: action script objects not displayed
          Gaurang Mathur Adobe Employee

          Adding my code snippets

           

          The as file code

          ************

          package secondPackage
          {
              import flash.display.*;
             
              public class movingObject extends Shape
              {
                  private var xPos:Number;
                  private var yPos:Number;
                  private var radius:Number;
                  private var color:uint;
                 
                  public function movingObject()
                  {// currently a stub will use it later
                                 
                  }
                 
                  public function drawcircleObj(xInput:Number,
                                                yInput:Number,
                                                radInput:Number,
                                                colorInput:uint): void
                  {
                      xPos = xInput;
                      yPos = yInput;
                      radius = radInput;
                      color = colorInput ;
                      this.graphics.beginFill(color);
                      this.graphics.drawCircle(xPos,yPos,radius);
                  }
          }

           

          *************************

           

          The mxml file code

          **********************************

          <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                 xmlns:s="library://ns.adobe.com/flex/spark"
                                 xmlns:mx="library://ns.adobe.com/flex/mx"
                                 creationComplete="initApp()">
           
              <fx:Script>
                  <![CDATA[
                      import secondPackage.movingObject;
                      import flash.display.*;
                                 
                      private var myMoving:movingObject = new movingObject();
                     
                      public function initApp():void
                      {
                          //show the string
                         
                         
                          myMoving.drawcircleObj(500,500,30,0xFF0000);
                         
                          mainText.text = myMoving.letsStart();
                      }
                  ]]>
              </fx:Script>
              <s:TextArea id="mainText" x="390" width="50" y="133"/>
             
              <s:Button  id="button1" x="804" y="227" label="Button" width="45"/>
             
             
          </s:WindowedApplication>

           

          ************

           

          The problem which i suspect is that there should be a stage object holding the same object or circle created and then display it.

           

          A faster reply will be highly appreciated. Thank you.

          • 2. Re: action script objects not displayed
            Level 2

            not exactly AIR but here it is in action:

             

            http://www.trumpboston.com/graphics001/draw_circle.html

             

            ok, so it is not a circle but you get the idea.

             

            poached most of it from o'reilley (sp?)

             

            app:

            http://pastie.org/1733797

             

            2ndPackage:

            http://pastie.org/1733802