初学者第一个flex程序的问题?xml version1.0 encodingutf-8?s:Application xmlns:fxhttp://ns.
初学者第一个flex程序的问题
<?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[
import mx.controls.Alert;
private function initApp():void
{
btn.addEventListener(MouseEvent.CLICK,btn_click);
btn.addEventListener(MouseEvent.MOUSE_OVER,btn_over);
}
private function btn_click():void
{
Alert.show("鼠标单击事件");
}
private function btn_over():void
{
Alert.show("鼠标经过事件");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button id="btn" x="226" y="174" label="按钮"/>
</s:Application>
首先上面fx,mx,x是什么意思,书上的例子里面就只有mx,然后运行后单击按钮没有任何反应,为什么?
[解决办法]<s:Button id="btn" x="226" y="174" label="按钮" click="btn_click()" mouseOver="btn_over()"/>
[解决办法]<?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" creationComplete="initApp()"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
private function initApp():void
{
this.addEventListener(MouseEvent.CLICK,btn_click);
this.addEventListener(MouseEvent.MOUSE_OVER,btn_over);
}
private function btn_click(e:MouseEvent):void
{
Alert.show("鼠标单击事件");
}
private function btn_over(e:MouseEvent):void
{
Alert.show("鼠标经过事件");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button id="btn" x="226" y="174" label="按钮"/>
</s:Application>
[解决办法]<?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" creationComplete="initApp()"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
private function initApp():void
{
this.addEventListener(MouseEvent.CLICK,btn_click);
this.addEventListener(MouseEvent.MOUSE_OVER,btn_over);
}
private function btn_click(e:MouseEvent):void
{
Alert.show("鼠标单击事件");
}
private function btn_over(e:MouseEvent):void
{
Alert.show("鼠标经过事件");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:Button id="btn" x="226" y="174" label="按钮"/>
</s:Application>