ComboBox的触发JS事件

本文介绍了一个使用 Flash 实现的简单用户界面案例,其中包括一个下拉菜单及其对应的事件处理逻辑。当用户选择不同的书籍选项时,界面会显示所选项目的标签和数据,并通过 ExternalInterface 调用 HTML 中定义的 JavaScript 函数。
摘要由CSDN通过智能技术生成
ExpandedBlockStart.gif 代码
<? xml version = " 1.0 "  encoding = " utf-8 " ?>
< mx:Application xmlns:mx = " http://www.adobe.com/2006/mxml "  layout = " absolute "  creationComplete = " initUI() " >

< mx:Script >
 
<! [CDATA[
  import mx.events.DropdownEvent;
  import mx.controls.Alert;
  internal 
function  initUI(): void {
  
var  info:Array = new  Array();
  info.push({label:
" Book 1 " ,data: " 1 " });
  info.push({label:
" Book 2 " ,data: " 2 " });
  info.push({label:
" Book 3 " ,data: " 3 " });
  bookList.dataProvider
= info;
  bookList.addEventListener(DropdownEvent.CLOSE,change);
  }
  
  internal 
function  chooseHandler(evt:DropdownEvent): void {
  
var  item:Object  = bookList.selectedItem;
  tip_txt.text
= " Selevt:Label: " + item.label + " :data: " + item.data;
  }
  
  private 
function  change(evt:DropdownEvent): void {
   
// Alert.show("关闭窗口");
  ExternalInterface.call( " change() " );
  }
  
   private 
function  closeHandler(evt:DropdownEvent): void {  
                Alert.show(
" 关闭窗口 " );  
            }
 ]]
>
< / mx:Script>
    < mx:ComboBox id = " bookList "  x = " 30 "  y = " 86 "  width = " 160 " >
   
< / mx:ComboBox>
    < mx:TextArea id = " tip_txt "   x = " 30 "  y = " 129 "  height = " 182 "  width = " 178 "/ >
< / mx:Application>

 

页面当中应用:

 

ExpandedBlockStart.gif 代码
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head >
    
< title ></ title >
    
< script  type ="text/javascript" >
        
function  change() {
            alert(
" 哈哈,我被调用了!!! " );
        }
    
</ script >
</ head >
< body >

      
< object  classid ="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
            id
="main"  width ="600"  height ="400"
            codebase
="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" >
            
< param  name ="movie"  value ="include/flash/main.swf"   />
            
< param  name ="quality"  value ="high"   />
            
< param  name ="bgcolor"  value ="#869ca7"   />
            
< param  name ="allowScriptAccess"  value ="sameDomain"   />
            
< embed  src ="include/flash/main.swf"  quality ="high"  bgcolor ="#869ca7"
                width
="600"  height ="400"  name ="main"  align ="middle"
                play
="true"
                loop
="false"
                quality
="high"
                allowScriptAccess
="sameDomain"
                type
="application/x-shockwave-flash"
                pluginspage
="http://www.adobe.com/go/getflashplayer" >
            
</ embed >
    
</ object >
</ body >
</ html >

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值