0
我有一个小型flex应用程序。如何在Flex中加载动态事件
<mx:Script>
<![CDATA[
import flash.events.Event;
// Event handler function to print a message
// describing the selected Button control.
private function printMessage(event:Event):void {
message.text += event.target.label + " pressed" + "\n";
}
]]>
</mx:Script>
<mx:Panel title="Button Control Example"
height="75%" width="75%" layout="horizontal"
paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
<mx:VBox>
<mx:Label width="100%" color="blue"
text="Select a Button control."/>
<!-- The button can contain an image, as in the "Button with Icon" button -->
<mx:Button id="iconButton" icon="@Embed('assets/mm-icon.png')" label="Button with Icon"
labelPlacement="right" color="#993300" click="printMessage(event);"/>
<!-- The size of the button and the label attributes can be customized -->
<mx:Button label="Customized Button" color="#993300" toggle="true" selected="true"
textAlign="left" fontStyle="italic" fontSize="13" width="{iconButton.width}"
click="printMessage(event);"/>
<!-- By default, the look and feel of the customized button is
similar to the Default Button. -->
<mx:Button label="Default Button" click="printMessage(event);"/>
</mx:VBox>
<mx:TextArea id="message" text="" editable="false" height="100%" width="100%"
color="#0000FF"/>
</mx:Panel>
我想实现的是,我希望我的用户传递脚本作为参数。所以他可以灵活地使用按钮来做任何事情 - >像添加事件,隐藏其他按钮。
像这样(下图)
< PARAM NAME = “脚本” 值=“输入对象类型:flash.events.Event; \ n私有函数printMessage(事件:事件):无效{\ nmessage.text + = event.target.label +“pressed”+“\ n”; \ n}“>
谢谢。
它也可以实现IEventDispatcher接口。 – Robusto 2010-05-17 12:35:06
伙计们......我实际上希望程序员创建事件并将其作为参数发送到flex文件,这与在脚本标记中编写代码一样好 – user309010 2010-05-18 08:59:59