代码很简单,我的意图应该清楚。我仍然可以让这个工作:
<?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="955" minHeight="600"
creationComplete="application1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var mySprite:Sprite = new Sprite();
mySprite.graphics.lineStyle(1,0x0000FF,1.0);
mySprite.graphics.drawRect(0,0,200,50);
this.addChild(mySprite);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:Application>
对于这个简单的问题,它给我带来了一些麻烦!你能帮忙吗?
答案 0 :(得分:3)
试试这个
var x:SpriteVisualElement = new SpriteVisualElement();
var mySprite:Sprite = new Sprite();
mySprite.graphics.lineStyle(1,0x0000FF,1.0);
mySprite.graphics.drawRect(0,0,200,50);
x.addChild(mySprite);
this.addElement(x);