3 Replies Latest reply on Aug 9, 2010 4:58 AM by BhaskerChari

    Pass Custom Event Data

    jerry98225

      Hi guys..

         I am trying to pass custom event data from 1 class to another class...here is my codes..

       

      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 SearchResultContainer();

          newvideoida=searchContainer.selectedVideoID; //I want to get b.as newVideoID variable

          trace(newvideoida);  //display nothing.....

       

          addChild(searchContainer);

         

          }

       

      I appreciate any help..

        • 1. Re: Pass Custom Event Data
          BhaskerChari Level 4

          Hi Jerry,

           

          What is the code in the SearchResultContainer file...

           

          In what way do you think you can get new Video Id  by using the statement newvideoida= searchContainer.selectedVideoID

           

          What is the relation where you have set the videoId in b.as so that you are accessing in SearchResultContainer file..

           

          Thanks,

          Bhasker Chari

          1 person found this helpful
          • 2. Re: Pass Custom Event Data
            jerry98225 Level 1

            Sorry for the confusion...

             

            SearchResultContainer()  is actually b.as

            I forgot to change it when I posted here...

             

            so

             

            newvideoida= searchContainer.selectedVideoID

            =newvideoida= b.selectedVideoID

            • 3. Re: Pass Custom Event Data
              BhaskerChari Level 4

              Hi Jerry,

               

              Few questions come to my mind...by seeing your code posted...

               

              1) Do you have any public variable or property selectedVideoID in b.as (This was not seen in b.as file)

               

              2) When your YouTubeSearchEvent.CHANGE_VIDEO_READY event is dispatched in your a.as file which is called in onClick()


              3) Just by creating an instance to b.as file ...Do you get the video Id populated in b.as file.....

                  searchContainer=new SearchResultContainer();

                  newvideoida=searchContainer.selectedVideoID;


              Your code I think is not fully clear ...and you missed some part of the code being posted..


              Thanks,
              Bhasker