views:

31

answers:

1

My actionscript:

package
{
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.events.Event;

    import spark.core.SpriteVisualElement;

    public class SimpleFill extends SpriteVisualElement
    {
        public function SimpleFill()
        {
            //var sprite:Sprite = new Sprite();
            //var graphics:Graphics = sprite.graphics;
            graphics.beginFill(0x0000FF, 1);
            graphics.drawRect(10, 10, width, height);
            graphics.endFill();
            //addChild(sprite);
        }
    }
}

I also tried with the commented lines uncommented, but does not work either.

My MXML:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="640" minHeight="480"
               creationComplete="initApp()">

    <fx:Script>
        <![CDATA[
            public function initApp():void
            {
                addElement(new SimpleFill());
            }
        ]]>
    </fx:Script>

</s:Application>

any idea why it isn't drawing?

A: 

Hi Tom,

Are you sure width & height in SimpleFill are not equal to zero? I'd check that first.

Tyler Egeto
right.. solved by using added_to_stage event and drawing to stage.width and stage.height. Thanks!
Tom Brito