2013-03-13 47 views
0

我真不明白我在做什麼錯: 很簡單的例子,但是當我按一下按鈕沒有任何反應..添加簡單的非繪製線在ActionScript

<?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"> 

<fx:Script> 
    <![CDATA[ 

     private function drawLine():void 
     { 
      var myShape:Shape = new Shape(); 
      myShape = new Shape() ; 
      myShape.graphics.lineStyle(2, 0x990000, .75); 
      myShape.graphics.moveTo(100, 100); 

      myShape.graphics.lineTo(25, 45); 
      this.addChild(myShape); 
     } 
    ]]> 
</fx:Script> 
<!--<mx:Label text="Hello World"/>--> 
<mx:Button label="Click" click="drawLine()" /> 

</s:Application> 
+0

嘗試給一個MyShape的高度和寬度 – JeffryHouser 2013-03-13 13:01:16

+0

使用[行](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/primitives/Line.html);更容易。 – RIAstar 2013-03-13 14:38:28

回答

1

使用SpriteVisualElement - 反射物體。

<s:SpriteVisualElement width="500" height="500" id="spr"/> 

spr.addChild(myShape) 
+0

Yeeeah!其作品!謝謝! – 2013-03-13 15:06:41

+0

@速度令人愉快 – 2013-03-13 16:16:37