Jump to content


LoaderMax.getContent() Not Working! but getLoader() is?

Recommended Posts



I have a very straight forward application of LoaderMax setup where I'm loading only 1 swf. (I will be adding more swf's to the queue and that's why I'm using LoaderMax and not just the individual SWFLoader).


Problem: After a successful, complete load, LoaderMax.getContent("name"); returns null? (very frustrating)


Weirdness: HOWEVER!, in the same instance, LoaderMax.getLoader("name").rawContent; returns exactly the swf root as expected (so this is how I got it to work).


Question: What's going on? Any insight would be greatly appreciated!


THANKS (and code below),



var illusionsPrint:MovieClip;

function moduleLoader():void
var que:LoaderMax = new LoaderMax({name:"illusionsQue",onError:queError});
que.append(new SWFLoader("swf/illusions-print.swf",{name:"swfIllusionsPrint",estimatedBytes:725722,onProgress:printProgress,onComplete:printComplete}));

function printProgress(e:LoaderEvent):void
	trace("progress: " + e.target.progress);

function printComplete(e:LoaderEvent):void
	illusionsPrint = LoaderMax.getLoader("swfIllusionsPrint").rawContent;  // This works fine!
//            illusionsPrint = LoaderMax.getContent("swfIllusionsPrint") as MovieClip;  // This doesn't work -> returns null ?
	illusionsPrint.x = 490;
	illusionsPrint.y = 100;
	illusionsPrintReady = true;
	dispatchEvent(new Event("illusions_print_ready"));
	trace(e.target + " is complete!");

function queError(e:LoaderEvent):void
	trace("error occured with " + e.target + ": " + e.text);

Link to comment
Share on other sites

Nope, that's not a bug - the problem is that you're trying to cast a ContentDisplay Sprite to a MovieClip. You can't do that. Remember, a SWFLoader's, ImageLoader's, and VideoLoader's "content" is always a ContentDisplay Sprite which isn't a MovieClip. Whenever you cast illegally like that, Flash returns null.


BAD: LoaderMax.getContent("swfIllusionsPrint") as MovieClip;

GOOD: LoaderMax.getContent("swfIllusionsPrint") as ContentDisplay;


Or you can cast it as a Sprite. Or don't cast it at all. Of course you need to change the type of your illusionsPrint variable too. I wonder if maybe you meant to do LoaderMax.getLoader("swfIllusionsPrint").rawContent as MovieClip;

Link to comment
Share on other sites

Hi Greensock,


Thank you so kindly for replying. I understand what you are saying and have a follow-up question to make sure that I'm getting the paradigm:


So would this be correct, if what I am after is the "MovieClip(root)" of the loaded SWF: (?)


myMovieClip = LoaderMax.getContent("swfIllusionsPrint").rawContent as MovieClip; (?)


Thanks kindly!


Link to comment
Share on other sites

Yep, that should work (assuming the root is a MovieClip). Technically the root is a DisplayObject according to Adobe's docs, but in most cases it's also a MovieClip (depending on how you build your file).

Link to comment
Share on other sites

  • 1 month later...

Hi i have the same problem but your solution is not working.


if i use

thisMC = LoaderMax.getContent(clips[index].name).rawContent as MovieClip; 

everytime the variable take the value null but if i use

var content:ContentDisplay = LoaderMax.getContent(clips[index].name);


the movie clip apear on the screen. The problem is that i need to access this like a movieClip.


if you have a solution on this please let me know. Thanks!


Somehow i resolved this. if i use for loading my movieclips from an xml file with XMLLoader is not working, but if i load with SWFLoader separately every movieclip from that xml file is working. in my opinion in XMLLoader is some bug. Because i tryied all the posibile way to take rawContent from the loader i tryied with LoaderMax.getLoader(clips[index].name).rawContent and the same rawContent was null.

Link to comment
Share on other sites

pls post simplified files that illustrates the issue you are having.


make one fla that uses one XMLLoader to load a small external swf.

pls include the xml and swf to be loaded. nothing fancy.





Link to comment
Share on other sites

if you replace the following functions in your file it will work:

private function appPlay() {
		xmlLoader = new XMLLoader("data/list.xml", {name:"playListLoader", onComplete:xmlHandler});

	private function xmlHandler(event:LoaderEvent):void {

		trace("XML playlist file loaded...")
		//get the LoaderMax named "playListLoaded" which was inside our XML
		mainQueue = LoaderMax.getLoader("playListLoader");
		//store the nested VideoLoaders in an array

		clips = mainQueue.getChildren();


	private function loadAndPlay() {
		clips[0].addEventListener(LoaderEvent.COMPLETE, completeHandler);


	public function completeHandler(e:LoaderEvent){

		videoContent = LoaderMax.getContent("a").rawContent
		videoContent.alpha = 0;


		TweenLite.to(videoContent, 1, {alpha:1});
		videoContent.addEventListener(Event.ENTER_FRAME, enterFrame);

	// When currentFrame equals totalFrames in loaded clip (playing), increment index & play the next clip. 		
	private function enterFrame(e:Event):void {
		//check when the animation is finish and move to the next file
		if (videoContent.currentFrame == videoContent.totalFrames) { 
			trace("Next clip...")
			videoContent.removeEventListener(Event.ENTER_FRAME, enterFrame);
			//index = (index + 1)%(clips.length);



this should at least illustrate that videoContent references the loaded swf and you can:

-use addEventListener on videoContent.

-call methods on videoContent like videoContent.gotoAndPlay(1)

-tween video content


I think the big problem was that you were trying to access rawContent before the swf was loaded.

notice how I added


clips[0].addEventListener(LoaderEvent.COMPLETE, completeHandler)






this makes sure the swf is loaded before you try to do anything with it.

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.