为什么不绘制这个矩形?

时间:2010-08-17 17:34:43

标签: flex flash actionscript-3 mxml

我的动作:

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);
        }
    }
}

我还尝试使用注释行取消注释,但也不起作用。

我的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>

知道它为什么不画画?

1 个答案:

答案 0 :(得分:0)

你确定宽度&amp; SimpleFill中的高度不等于零?我先检查一下。