Я пытаюсь передать данные пользовательского события из одного класса в другой класс ... вот мои коды ..
a.as
private function onClick(event:MouseEvent):void{
dispatchEvent(new YouTubeSearchEvent(YouTubeSearchEvent.CHANGE_VIDEO_READY, videoId));
}
b.as
private var newVideoID:String;
public function get selectedVideoID():String{
return newVideoID;
}
private function buildSingleCont(videoResult:Array):void{
tn=new a();
addChild(tn);
tn.addEventListener(YouTubeSearchEvent.CHANGE_VIDEO_READY, getNewVideoID);
}
private function getNewVideoID(event:YouTubeSearchEvent):void{
newVideoID=event.videoResult;
}
c.as
// this is the main class.....
private var newvideoida:String;
public function c(){
createSearchContainer() //this method is called before b.as and c.as are called...
}
private function createSearchContainer():void{
searchContainer=new b();
newvideoida=searchContainer.selectedVideoID; //I want to get b.as newVideoID variable
trace(newvideoida); //display nothing.....
addChild(searchContainer);
}
пакет com.search.events
{
импорт flash.events.Event;
public class YouTubeSearchEvent extends Event
{
public static const FEED_VIDEO_READY:String="feed_video_ready";
public static const CHANGE_VIDEO_READY:String="change_video_ready";
public var videoResult:*;
public function YouTubeSearchEvent(type:String, videoResult:*)
{
super(type);
this.videoResult=videoResult;
}
public override function clone():Event {
return new YouTubeSearchEvent(this.type, this.videoResult);
}
}
}
Я ценю любую помощь ..