我正在尝试在一个新的 Flex 项目(使用 Flash Builder 4.6)中画一条线的最小程序:
但是,当它在网络浏览器(Chrome 或 Firefox)中运行时,myButton
单击按钮时,不会画线——有谁知道如何使它工作,以及如何使它无需绘制就可以绘制点击按钮?
<?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:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
public function drawLine():void
{
var canvas:Shape = new Shape();
canvas.graphics.lineStyle(3, 0xff);
canvas.graphics.moveTo (0,0);
canvas.graphics.lineTo(300,300);
this.addChild(canvas);
}
]]>
</fx:Script>
<s:Button label="myButton" click="drawLine()" />
</s:Application>