Skip to main content
Participating Frequently
May 30, 2012
Question

I have a button that keeps blowing up my code

  • May 30, 2012
  • 2 replies
  • 1715 views

can someone take a look and tell me why? I have imported the classes

package {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
    import com.yahoo.astra.fl.controls.Tree; 
import com.yahoo.astra.fl.controls.treeClasses.*;
import flash.events.MouseEvent;
import fl.controls.Button;


public class VideoPlaylistNoThumb extends MovieClip {
  private var xmlLoader:URLLoader;
  public var btnNext:Button;
  //btnNext.label = "Next";
 
 
  public function VideoPlaylistNoThumb():void {
   // Load the playlist file, then initialize the media player.
   xmlLoader = new URLLoader();
   xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
   xmlLoader.load(new URLRequest("playlist2.xml"));
  }
 
  public function initMediaPlayer(event:Event):void {
   var myXML:XML = new XML(xmlLoader.data);
   var item:XML;
   for each(item in myXML.vid) { // populate playlist.
    // Send data to List.
    videoList.addItem({label:item.attribute("desc").toXMLString(),
    data:item.attribute("src").toXMLString(),
    data:item.attribute("id").toXMLString(),
    data:item.attribute("wNnext").toXMLString(),
    data:item.attribute("aNext").toXMLString(),
    data:item.attribute("allNext").toXMLString(),
    ttURL:item.attribute("ttURL").toXMLString()});
}  
   // Select the first video.
   videoList.selectedIndex = 0;
   myVid.autoRewind = true;
   // Listen for item selection.
   videoList.addEventListener(Event.CHANGE, listListener);
   // And automatically load it into myVid.
   myVid.source = videoList.selectedItem.data;
   myVidCaptioning.source = videoList.selectedItem.ttURL;
   myVidCaptioning.flvPlayback = myVid;
   // Pause video until selected or played.
   //myVid.pause();
}  

  // Detect when new video is selected, and play it
  function listListener(event:Event):void {
   myVid.stop();
   myVidCaptioning.source = event.target.selectedItem.ttURL;
   myVidCaptioning.showCaptions = false;
   myVidCaptioning.showCaptions = true;
   myVid.autoPlay = true;
   myVid.play(event.target.selectedItem.data);

  }
 
   function clickHandler(event:MouseEvent):void {
      trace("I have been clicked");
  }

  btnNext.addEventListener(MouseEvent.CLICK, clickHandler); 

}

}

It is not recognizing btnNext

This topic has been closed for replies.

2 replies

esdebon
Inspiring
May 30, 2012

What kind of button you're using whatever turn it into the library symbol and a name asiganela "As Linkage", something like myButton

and in your code

  public var btnNext: myButton = new myButton ();

   addChild (btnNext);

Participating Frequently
May 30, 2012

how do I turn it into a libraby symbol? the properties tab shows it as a button named btnNext I am pretty new to flash so sorry if this is a silly question

esdebon
Inspiring
May 30, 2012
ok, in the library click the right button on your btnNext symbol, then select the option "Properties", then select "advanced" (bottom left), then check "Export for ActionScript", and in the field Class type:

myButton

Now use the code before you send

Participating Frequently
May 30, 2012

when I use that code on the timeline it works but not in the as file

this is the error

1120: Access of undefined property btnNext.