为什么不这个Flex应用程序绘制一个简单的矩形? [英] Why doesnt this Flex App draw a simple rectangle?

查看:182
本文介绍了为什么不这个Flex应用程序绘制一个简单的矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码很简单,我的意图应该清楚。我仍然可以得到这个工作:

 <?xml version =1.0encoding =utf-8?> ; 
xmlns:s =library://ns.adobe.com/flex/spark
xmlns:mx =library://ns.adobe.com/flex/mxminWidth =955minHeight =600
creationComplete =application1_creationCompleteHandler(event)>
< fx:Script>
<![CDATA [
import mx.events.FlexEvent;
$ b保护函数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:声明>
<! - 在这里放置非可视元素(例如服务,值对象) - >
< / fx:声明>


< / s:应用程序>

对于这个简单的问题,这会带来一些麻烦!你可以帮忙吗?

解决方案

试试这个

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


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?

解决方案

Try this

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应用程序绘制一个简单的矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆