Jump to content
Search Community

What dont I understand here

Cadfael test
Moderator Tag

Recommended Posts

HOla,

 

Total noob to Greensock stuff, but looks cool so far.

 

Below is is code for a loader I am using to read XML and then play the videos one after another. FYI: I do flash in AS3 only.

 

I can access the videos using LoaderMax.getContent("floyd") or play them with LoaderMax.getLoader("floyd"), but what I need to be able call them with LoaderMax.getChildAt() so i can cycle thru them.

But LoaderMax. code hinting doesnt indicate getChildAt as an option and compiling says it is undefined. IF I create and XML I can point traces at the list of myXML.LoaderMax.Videoloader and see all the XML lines for the Videos.

 

What am I missing?

 

 

 

var loader:XMLLoader = new XMLLoader("ex_queue.xml",
								 {name:"Ex_queue.xml",
								 onProgress:progressHandler,
								 onComplete:completeHandler});
loader.load();

 

XML file

 

<?xml version="1.0" encoding="iso-8859-1"?> 













Link to comment
Share on other sites

Oh, you literally meant "LoaderMax.getChildAt()" rather than myLoaderMaxInstance.getChildAt()? Yeah, it's not a static method. It couldn't be static because you can have lots of LoaderMax instances, each with their own queue. See what I mean? Don't think of LoaderMax as one massive sequential queue of loaders. It's much more flexible and modular than that. You could have several LoaderMax instances running simultaneously, or even nest them inside of each other. Think of a LoaderMax instance like a group of loaders - you can have lots of groups and even groups within groups.

 

//to use the LoaderMax from your XML...
var myLoaderMax:LoaderMax = LoaderMax.getLoader("Ex_queue"); 
var secondVideo:VideoLoader = myLoaderMax.getChildAt(1);
...

 

And of course you can create new LoaderMax instances like:

var myLoaderMax:LoaderMax = new LoaderMax();
myLoaderMax.append( ... );
...

 

Does that make more sense now?

 

The getLoader() and getContent() methods are static for convenience and they search pretty much ALL loaders and LoaderMax instances. The getChildAt() method couldn't be static, though. See what I mean?

Link to comment
Share on other sites

Got another question.

 

I used the method you describe. I play video's for two different queues. I access the Videoloader with getchildat and then pull the contents using the name. So far all is good. But once I have played the video once, and cycle back around to it, It either doesnt play or hangs.

 

I am using myvideoloader.gotoVideoTime(0,true, true); in an efort to restart the video from the contents reference

 

So my question is is there some other potential problem with repeatedly accessing a videoloader and the contents?

Link to comment
Share on other sites

Below is test code I ran last night. It played thru the first 4 videos in my XML file six times and crashed. Hung in one of the videos. This is the issue I have been seeing in my production code, the video hangs or the flash debugger just closes. Below the code I will attach the output from the debugger ( not hugely useful, but...)

 

 

 

LoaderMax.activate([imageLoader,VideoLoader, DataLoader, XMLLoader]);

var loader:XMLLoader = new XMLLoader("ex_queue.xml",
								 {name:"Ex_queue.xml",
								 onProgress:progressHandler,
								 onComplete:completeHandler});
loader.load();



var VidContent:ContentDisplay;
var VidLdr:VideoLoader;

function ShowVideo(VideoNum:int):void
{ 	

VidLdr = EXLoader.getChildAt(VideoNum);
VidContent = EXLoader.getContent(VidLdr.name);


trace(" - ShowVideo [" +VidLdr.name+ "] " + VideoNum);
//get the content 

//add it to the display list 
addChild(VidContent);

//fade it in
TweenMax.fromTo(VidContent, 4,{alpha:0}, {alpha:1});
TweenMax.fromTo(VidContent, 3,{z:10000}, {z:0});


VidContent.width = 400;
VidContent.height =280;
VidContent.x = 0;
VidContent.y = 0;

VidLdr.gotoVideoTime(0,true, true);// .playVideo();
VidLdr.addEventListener(VideoLoader.VIDEO_COMPLETE, VideoFinished, false,0, true);

}
//=================================================================================
function VideoFinished(evt:LoaderEvent)
{
trace(" - VideoFinished:  [" + VidLdr.name + "] "  );
VidLdr.removeEventListener(VideoLoader.VIDEO_COMPLETE, VideoFinished);
TweenLite.to(VidContent, 3, {alpha:0});
demoIndex++;
startVideos();
}

//=================================================================================
function progressHandler(event:LoaderEvent):void 
{
trace("progress: " + event.target.progress);
}
//=================================================================================

var DemoLoader:LoaderMax;
var EXLoader:LoaderMax;
var CLOUDLoader:LoaderMax;
var Loaded:Boolean = false;
var cloudLoader:VideoLoader;
var ExVideo1:VideoLoader;
var ExVideo2:VideoLoader;
var ExVideo3:VideoLoader;
var demoIndex:int =0;

//=================================================================================
function completeHandler(event:LoaderEvent):void 
{
trace ("load complete");
var myXML:XML = event.target.content;
DemoLoader = LoaderMax.getLoader("Demo_queue");
EXLoader = LoaderMax.getLoader("Ex_queue");
CLOUDLoader = LoaderMax.getLoader("BG_queue");
trace ("DemoLoader: " + DemoLoader.numChildren);
trace ("EXLoader:   " + EXLoader.numChildren);
Loaded = true;

startVideos();

}
//=================================================================================
function startVideos()
{
if (demoIndex >= 4)//(DemoLoader.numChildren ))
{
	trace ("reset demoIndex from ["+ demoIndex+"]");
	demoIndex = 0;//Main loop
}


ShowVideo(demoIndex);


}
//=================================================================================

 

 

[sWF] repeatvideo.swf - 264504 bytes after decompression
progress: 0.989685124864278
progress: 0.04128226457141489
progress: 0.3784852887238477
progress: 0.3786410678323146
progress: 0.37992323713584436
progress: 0.4127734143993666
progress: 0.4517110670679977
progress: 0.45186001246739643
progress: 0.45203681332235923
progress: 0.5800560285741022
progress: 0.593794028687755
progress: 0.5945585285325702
progress: 0.6355881624812747
progress: 0.6356760785638164
progress: 0.6359385996664544
progress: 0.5052849302726923
progress: 0.5155561049861275
progress: 0.5157149923383375
progress: 0.5157682536055859
progress: 0.5411734751595607
progress: 0.5729794992582892
progress: 0.5731258113992502
progress: 0.5733091976276193
progress: 0.6023350695789295
progress: 0.6977384745850522
progress: 0.6979420314955361
progress: 0.6986127664120068
progress: 0.7292097236930476
progress: 0.9793820838435878
progress: 0.9796831862417499
progress: 0.9821590868490137
progress: 0.9996497916705075
progress: 1
load complete
DemoLoader: 8
EXLoader:   7
- ShowVideo [peter] 0
- VideoFinished:  [peter] 
- ShowVideo [hpc] 1
- VideoFinished:  [hpc] 
- ShowVideo [levee] 2
- VideoFinished:  [levee] 
- ShowVideo [corrs] 3
- VideoFinished:  [corrs] 
reset demoIndex from [4]
- ShowVideo [peter] 0
- VideoFinished:  [peter] 
- ShowVideo [hpc] 1
- VideoFinished:  [hpc] 
- ShowVideo [levee] 2
- VideoFinished:  [levee] 
- ShowVideo [corrs] 3
- VideoFinished:  [corrs] 
reset demoIndex from [4]
- ShowVideo [peter] 0
- VideoFinished:  [peter] 
- ShowVideo [hpc] 1
- VideoFinished:  [hpc] 
- ShowVideo [levee] 2
- VideoFinished:  [levee] 
- ShowVideo [corrs] 3
- VideoFinished:  [corrs] 
reset demoIndex from [4]
- ShowVideo [peter] 0
- VideoFinished:  [peter] 
- ShowVideo [hpc] 1
- VideoFinished:  [hpc] 
- ShowVideo [levee] 2
- VideoFinished:  [levee] 
- ShowVideo [corrs] 3
- VideoFinished:  [corrs] 
reset demoIndex from [4]
- ShowVideo [peter] 0
- VideoFinished:  [peter] 
- ShowVideo [hpc] 1
- VideoFinished:  [hpc] 
- ShowVideo [levee] 2
- VideoFinished:  [levee] 
- ShowVideo [corrs] 3
- VideoFinished:  [corrs] 
reset demoIndex from [4]
- ShowVideo [peter] 0
- VideoFinished:  [peter] 
- ShowVideo [hpc] 1
- VideoFinished:  [hpc] 
- ShowVideo [levee] 2
- VideoFinished:  [levee] 
- ShowVideo [corrs] 3
Test Movie terminated.

Link to comment
Share on other sites

Please post the source files that can be published, not just an excerpt of the code. I need your XML, the swf files, FLAs, etc. It is very difficult to troubleshoot without seeing things in context and being able to add trace() statements, etc. It would be best if you could reproduce the issue in a SEPARATE set of files with only the absolutely essential code (not your production files). Strip out everything that's unnecessary for demonstrating the specific issue.

Link to comment
Share on other sites

When you say "crashes" and "hangs", do you literally mean that the Flash Player completely locks up and ignores even operating system requests (like you need to force-quit)? Or do you just mean that you don't see the video(s) playing anymore?

 

The sample you provided contained a bug in your code where you unload() the loaders after they play once, and then it looks like you're trying to show them again but you never load() them. So you put the "content" on the screen again but there is no rawContent inside the ContentDisplay object because you unloaded it (after the first time through). See what I mean? All I had to do was delete your unload() line and the video showed fine the 2nd (and 3rd, etc.) time through.

 

Does that solve things for you? If not, please post very specific directions about what the issue is and how it is consistently reproduced in your sample FLA. Maybe I'm missing something obvious. I let it run for at least 30 minutes and watched the memory usage too - I saw nothing that concerned me. Seemed to work fine.

Link to comment
Share on other sites

Sorry, the unload was something I was in the middle of testing when I zipped up the files. I was not using the unload statement.

 

What I was seeing was the flash would hang. I could still close the window in Windows. The hang I was seeing was typically at about an hour and a half. But that seems to be coincidence. I just ran the sample I gave you over night. I can see that is didnt hang, but the videos still dont play every time. The tween works, the video hits the right size, but you cant see the video playing. At 30 seconds, the approximate length of the video, it fades and the next one starts.

 

Memory usage is not at issue as far as I can tell.

Link to comment
Share on other sites

Hmmm...this doesn't sound like a "crash" or "hang". I wonder if it has more to do with a bug in Adobe's NetStream or Video class that is aggrivated in very rare circumstances by the autoDetachNetStream feature (which is aimed at reducing memory usage on videos that aren't visible on the stage). Maybe it's not getting re-attached properly once in a blue moon. Please try passing autoDetachNetStream:false in the vars object of your VideoLoaders and let me know if that resolves the issue for you. Or if you don't want to set it in the vars object initially, you can set the property directly on the VideoLoader like:

 

myVideoLoader.autoDetachNetStream = false;

Link to comment
Share on other sites

I passed it in thru the XML file by changing each of the videoLoaders to look like ...

 

 

Didnt seem to work.

 

I also tried to edit the VideoLoader in the code, but the video was not visible at all.

 

IN the sample I sent you, I can set the number of loaders that it cycles thru in the startvideo function. when I set it to 3, it play the 0,1,2 indexed videos over and over. Oddly enough it seems to only play the first from of the video at index 1, where index 0 and index 2 play everytime. I tried replacing the video, but still the same behavior.

Link to comment
Share on other sites

Ah, sorry about that - XMLLoader needed to be updated in order to recognize the autoDetachNetStream="true" attribute in your nodes. Would you mind downloading the latest version of LoaderMax and giving it another shot? I actually changed the default value of autoDetachNetStream to false now anyway.

 

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...