Jump to content
Search Community

VideoLoader target specific video for control

stonestudioprod test
Moderator Tag

Recommended Posts

I have ten videos that I want to play, pause,scale up, change volume and unload.
 
I created ten vars representing each video. EXAMPLE:

var sterling1:VideoLoader = new VideoLoader(“assets/sterling1.mp4”,{name:”sterling1”, container:this, onProgress:progressHandler, onComplete:completeHandler, autoplay:false});

 
I have ten MCs representing each video, each one with an ID. EXAMPLE:

sterlingButs.sterling1.ID = “sterling1”;

 
I created a function called playVid that I want to use to play the videos.
 

function playVid(event:MouseEvent):void {
        targetMovie=event.target.ID;
        trace("targetMovie "+targetMovie);
       
        VARIABLE_HERE.load();
        choreoButs.gotoAndStop("none");
        sterlingButs.gotoAndStop("one");
        break;
ETC…

I also have functions representing Rewind, Forward, scaleUp, and ScaleBack.
 
EXAMPLE:

controls.RewBut.addEventListener(MouseEvent.CLICK,RewVidHandler);
function RewVidHandler(event:MouseEvent):void {
        trace("Fwd");
        trace(VARIABLE_HERE.videoTime);
        VARIABLE_HERE.gotoVideoTime(VARIABLE_HERE.videoTime-5);

 
I can’t seem to figure out how to cast the variable I get when clicking the button into the VideoLoader instance name.
 
Sorry if this seems too basic, but I just have a hard time with data types.

Link to comment
Share on other sites

There are a lot of ways you could do it, but perhaps this would fit the best with the way you seem to like to structure things...

 

When you're assigning your "ID" property to each MovieClip, you could assign a "video" property (or whatever you want to name it), like:

sterlingButs.sterling1.ID = “sterling1”;
sterlingButs.sterling1.video = new VideoLoader(“assets/sterling1.mp4”,{name:”sterling1”, container:this, onProgress:progressHandler, onComplete:completeHandler, autoplay:false});

so that then you could reference it in your handlers like:

function RewVidHandler(event:MouseEvent):void {
        var video:VideoLoader = (event.target as MovieClip).video;
        trace("Fwd");
        trace(video.videoTime);
        video.gotoVideoTime(video.videoTime-5);
        ...
}

Another option is to use the LoaderMax.getLoader() method and feed in the name, like:

function RewVidHandler(event:MouseEvent):void {
        var video:VideoLoader = LoaderMax.getLoader(event.target.ID);
        trace("Fwd");
        trace(video.videoTime);
        video.gotoVideoTime(video.videoTime-5);
        ...
}

I hope that helps. 

  • Like 1
Link to comment
Share on other sites

Ok, this seems to work.

function playVid(event:MouseEvent):void {
	resetForMovie();
	var targVideo:VideoLoader = LoaderMax.getLoader(event.target.ID);
	trace("targVideo =" +targVideo);
	resetForMovie();
	choreoButs.gotoAndStop("one");
	targVideo.load();
}

Now I want to unload the video that is currently playing before loading the targVideo.
How do I determine the video that is currentlyplaying? So I will have curVideo and targVideo vars

 

thanks!

Link to comment
Share on other sites

We really try to keep the questions here focused on GreenSock-specific issues (we just don't have the resources to provide free consulting for general ActionScript stuff), but you'd need to have a variable somewhere that you'd update with the current video all the time. I'm just not familiar with how you've set everything up exactly, but I'd probably create a class or something where you can store state information like this. YourClass.currentVideo = yourLoader. 

 

Good luck with the project. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...