本文介绍了为什么这个 Flex App 不绘制一个简单的矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码很简单,我的意图应该很明确.我仍然可以让它工作:
the code is straightforward and my Intention should be clear. Still i can get this to work:
<?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>
就这么简单的一个问题,给我带来了一些麻烦!你能帮忙吗?
For this simple a problem, it causes me some trouble! Can you help?
推荐答案
试试这个
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);
这篇关于为什么这个 Flex App 不绘制一个简单的矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!