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
still getting errors
1180: Call to a possibly undefined method addChild.
1120: Access of undefined property btnNext.
1120: Access of undefined property btnNext.
public var btnNext: myButton = new myButton ();
addChild (btnNext);
does it matter that it is in a external as file?
thanks for the replies!!
if your button is already part of the display list, you can probably remove public var btnNext:Button; ... and just go back to your original code, forget all the other responses, and add the button listener here instead:
public function VideoPlaylistNoThumb():void {
btnNext.addEventListener(MouseEvent.CLICK, clickHandler);
// Load the playlist file, then initialize the media player.
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
xmlLoader.load(new URLRequest("playlist2.xml"));
}
//---
however, if your button is NOT already part of the display list, you DO need public var btnNext:Button; and then you'd have to ADD it to the display list like this:
public var btnNext:Button;
public function VideoPlaylistNoThumb():void {
btnNext = new btnNext();
addChild(btnNext);
btnNext.addEventListener(MouseEvent.CLICK, clickHandler);
// Load the playlist file, then initialize the media player.
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
xmlLoader.load(new URLRequest("playlist2.xml"));
}
keep in mind that the btnNext will need the actionscript linkage identifier "btnNext" and check the box for "export for actionscript" and "export in frame 1" ... you can set these in the properties of the library symbol.
North America
Europe, Middle East and Africa
Asia Pacific