2 Replies Latest reply on Jul 28, 2008 1:37 PM by jumpseven

    problem creating sprite

    jumpseven

      hi,

      I am just trying to draw a circle in a flex application
      with a sprite. Can someone please tell me why this code
      doesn't work? It doesn't draw the circle. In fact, it
      doesn't update myStr to "bye".

      If I comment out the addChild statement, the string gets updated.

      thanks


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute" applicationComplete="myStartFunction()">

      <mx:Label text = "{myStr}" />

      <mx:Script>
      <![CDATA[

      import flash.display.DisplayObject;
      import flash.display.Graphics;
      import flash.display.Shape;
      import flash.display.Sprite;
      import flash.text.TextField;

      [Bindable]
      var myStr:String = "hello";

      function myStartFunction()
      {
      var mySprite:Sprite = new Sprite();
      var g:Graphics = mySprite.graphics;
      mySprite.graphics.beginFill(0xFF00FF);
      mySprite.graphics.drawCircle(50,50,100);
      mySprite.graphics.endFill();
      addChild(mySprite);

      myStr = "bye";

      }


      ]]>
      </mx:Script>

      </mx:Application>