我想从我的Player.as派发一个自定义的YouTubeEvent,并希望我的Main.as会监听并创建视频播放器......显然,我的eventHandler无法捕捉事件来创建录像机。 ......我的Flex调试模式是如此搞砸,我甚至不能使用它...我的代码如下..我真的很感激任何回复或帮助.....Flex事件调度程序问题
我的自定义事件..
package com.youtube.events {
import flash.events.Event;
public class YouTubeEvent extends Event{
public static const PLAYER_READY:String="PLAYER_READY";
public function YouTubeEvent(type:String){
super(type);
}
}
}
我Main.as
public class SearchYoutube extends Sprite
{
private var videoPlayer:Player;
public function SearchYoutube()
{
/*********************Load Video Player****************************/
loadPlayer();
}
private function loadPlayer():void{
videoPlayer= new Player();
videoPlayer.addEventListener(YouTubeEvent.PLAYER_READY, playerReady);
//playReady would never be excuted....
}
private function playerReady(event:YouTubeEvent):void{
videoPlayer.createPlayer(); //This handler would never be executed...
addChild(videoPlayer); //This handler would never be executed...
}
}
Player.as
//only show part of codes here
public function Player(){
}
public function createPlayer():void{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
}
private function onLoaderInit(event:Event):void {
_loader.content.addEventListener("onReady", onPlayerReady);
}
private function onPlayerReady(event:Event):void {
dispatchEvent(new YouTubeEvent(YouTubeEvent.PLAYER_READY));
}
Cool.thanks的答案...... – FlyingCat 2010-08-07 16:48:49