Flex中如何利用JavaScript ExternalInterface API监测Label控件链接事件的例子
By Minidxer | March 8, 2009
接下来的例子演示了Flex中如何利用JavaScript ExternalInterface API,监测Label控件链接事件。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Script>
- <![CDATA[
- import mx.controls.Alert;
- private function lbl_initialize():void {
- lbl.htmlText = "For more information on Flex, see <u><a href='event:flex.org'>http://www.flex.org/</a></u>."; }
- private function lbl_link(evt:TextEvent):void {
- Alert.show(evt.toString(), evt.text);
- switch (evt.text) {
- case "flex.org":
- // You clicked the flex.org link.
- break;
- }
- }
- ]]>
- </mx:Script>
- <mx:Label id="lbl"
- selectable="true"
- initialize="lbl_initialize();"
- link="lbl_link(event);" />
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
Label |
No Comments » |
418 views
Tags: event, Label, link, selectable