flex与flash交互之dispatchEvent

(先记录一下,回头整理)

flash分发事件,在flex加载完成该flash后监听事件,并利用回调函数完成flex与flash的通信,也可直接调用flash里的函数进行交互

flash(主场景创建,不能为影片剪辑导出)

bt为按钮

i1为动态文本框

stop();
bt.addEventListener(MouseEvent.CLICK,handleClick);
function handleClick(event:MouseEvent):void
{
	var e:Event = new Event("test");
	Event.prototype.aa = "hi";
	this.dispatchEvent(e);
}
function showText(s:String):void
{
	i1.text = s;
}

 

flex(image)

 

var ccM;
function dh(event:Event):void
{
    ccM = cc.content as MovieClip;
    Alert.show(ccM);
    ccM.addEventListener("test",gogo);
    ddd.text="hi,flexflash";
}
function onStatus(event:StatusEvent):void
{
    ddd.text = event.level;
}
public function gogo(evet:Event):void
{
    ddd.text="哈哈test";
     Alert.show(Object(evet).aa);
 }
function goto(event:MouseEvent):void
 {
     ccM.showText("哈哈哈,刚刚开始");
 }

 

 

你可能感兴趣的:(Flex,prototype,Flash)