Hi. I wanted to get a couple of points of view (if someone is willing to look at this) on how others would do this because I don’t know where to even start.
I have a buttons class that puts 9 pictures on the stage and each one represents a different movie and leads to that movie when clicked (or will lead there once I figure out how to reference it to the specific movie).
I have 9 movies referenced through XML. And I am using flvPlayer. Currenly I can only have one movie loading. I am not sure how to get each one to play upon click of the respective btn.
Here is some of the code I think is pertinent if figuring how to go about this:
ProjectOneButtons class
//I have each picture loaded through an array and each button is waiting for the right code through a Switch statement:
public function onButtonClick(e:MouseEvent):void {
var releventImageAray:Array = this["rowOfImages" + MovieClip(e.currentTarget).row];
var imageWanted:String = relaventImageArray[MovieClip(e.currentTarget).column];
switch (imageWanted) {
case "Video1" :
//Have not figured out the specific video code in class below
//This switch statement continues for the rest of the buttons.
//this code works but it just loads one movie and so I don't think this is what I need.
projectOneVideos = new projectOneVideos();
addChild(projectOneVideos);
projectOneVideos.x = 0;
projectOneVideos.y = 0;
here is the ProjectOneVideos class where the videos are loaded and played:
package asFiles.projectOne{
//import statments taken out for post
public class ProjectOneVideos extends Sprite {
public var videoX:Number;
public var videoY:Number;
public var projectOneVideos:XMLList;
public var projectOneTotal:Number;
public var projectOneXML:XML;
public var xmlLoader:URLLoader;
public var player:FLVPlayback;
public var playBtn:VideoPlayBtn;
public var pauseBtn:VideoPauseBtn;
public var videoContainer:MovieClip = new MovieClip;
public function ProjectOneVideos() {
xmlLoader = new URLLoader();
xmlLoader.load(new URLRequest("projectOneVideos.xml"));
xmlLoader.addEventListener(Event.COMPLETE, processXML);
}
public function processXML(e:Event):void {
projectOneXML = new XML(e.target.data);
projectOneVideos = projectOneXML.VIDEO;
projectOneTotal = projectOneXML.length();
makePlayer();
addButtons();
}
public function makePlayer():void {
player = new FLVPlayback();
player.skinBackgroundColor = 0x47ABCB;
player.skinBackgroundAlpha = .85;
player.x = 40.3;
player.y = 220;
player.width = 1200;
player.height = 594.2;
videoContainer.addChild(player);
player.addEventListener("complete", backToVideoMenu);
}
public function addButtons():void {
trace("addButtons initiated");
playBtn = new VideoPlayBtn();
videoContainer.addChild(playBtn);
playBtn.x = 625.6;
playBtn.y = 930;
pauseBtn = new VideoPauseBtn();
videoContainer.addChild(pauseBtn);
pauseBtn.x = 625.6;
pauseBtn.y = 930;
pauseBtn.visible = false;
addChild(videoContainer);
videoContainer.x = 0;
videoContainer.y = 0;
playBtn.addEventListener(MouseEvent.CLICK, playVideo);
pauseBtn.addEventListener(MouseEvent.CLICK, playVideo);
}
public function playVideo(event:MouseEvent):void {
// this is where I have the video referenced to play.
trace("play/pause button clicked");
if (player.playing || player.paused) {
if (player.paused) {
player.play();
} else {
player.pause();
}
playBtn.visible = player.paused;
pauseBtn.visible = ! player.paused;
} else if (player.stopped) {
player.play();
playBtn.visible = false;
pauseBtn.visible = true;
} else {
//this will obviously not work because then its just this one movie referenced
player.play("videos/projectOneVideos/videoOne.f4v", 0, false);
pauseBtn.visible = true;
playBtn.visible = false;
}
}
}
}
The reason I included a bunch of code is to show that there is a play/pause button that is supposed to play the movie. But the thing is I only have the one movie referenced and I am not sure how to have it variable as to which movie is played and make it depend on the button that is clicked from the button class above.
thanks for any input you can give!!!
Note: All of this code works as it is and I am getting no errors.