Jump to content
Search Community

Accessing rawContent in browser

Agent Oli test
Moderator Tag

Recommended Posts

Hi guys, thanks for all the support and documentation you have made available online. I’m quite surprised that I did not find a solution this problem on my travels. So I hope that you can make sense of it.

 

I am using loadermax in a preloader swf to load up an asset heavy swf (a game I'm working on). When I test it online the game loads incorrectly, throwing up assets that shouldn't be there.

 

However I tried to work around this problem (which was most likely my fault for coding on the timeline) By using loadermax to reference the raw content of the game during the load onComplete function, calling a function that exists in the loaded swf that sorts it all out.

This solution worked out well, when I tested the container in the flash IDE the raw reference worked, but for some reason the rawContent call is not getting made when run in a browser.

 

Below is my code for the swf container

 

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.display.*;
import flash.events.Event;
import com.greensock.easing.*;

var loader:SWFLoader = new SWFLoader("http://www.oliart.co.uk/schooloffish/school of fish.swf",{container:this,onProgress:progressHandler,noCache:true,onInit:completeHandler,onChildComplete:completeHandler,onComplete:completeHandler,onError:errorHandler,estimatedBytes:3796000});
var xload:int = 0;
var endofload:Boolean = true;
var rideaway:Boolean = false;
var fadeaway:Boolean = false;
loader.load();
playbutton.alpha = 0;

//mouse and frame events
addEventListener(Event.ENTER_FRAME, cycleload);
addEventListener(MouseEvent.MOUSE_DOWN, playgame);

//progress display
function progressHandler(event:LoaderEvent):void
{
trace("progress: " + xload);
xload = Math.round(event.target.progress * 100);
loadtext.text = "DISTANCE: " + (2.5- (int((event.target.progress * 2.5)*100)/100)) + "Mile(s)";
}

function completeHandler(event:LoaderEvent):void
{
var mc:MovieClip = loader.rawContent;
mc.preloadfix(); // ---------------------- This is not getting called

}
function errorHandler(event:LoaderEvent):void
{
trace("error occured with " + event.target + ": " + event.text);
}

function cycleload(e:Event):void
{
setChildIndex(playbutton,numChildren-1);
setChildIndex(loadtext,numChildren-2);
setChildIndex(ride,numChildren-3);
setChildIndex(fadeclip,numChildren-4);


//check for when the loading is near completion
if (xload >= 94 && endofload== true)
{
//endfunction triggers the play button tween
	endfunction();

}

if (ride.x > 0)
{
//loading bar position
	ride.x = 800 - (xload * 8);

}

}
//remove events at after loading
function removeall():void
{


removeChild(fadeclip);
removeChild(ride);
removeChild(playbutton);
removeChild(loadtext);
removeEventListener(Event.ENTER_FRAME, cycleload);
removeEventListener(MouseEvent.CLICK, playgame);

}
//moves button into position after load
function endfunction():void
{


TweenLite.to(playbutton, 5 , {alpha:1, y:400, ease:Back.easeOut});
TweenLite.to(loadtext, 2 , {alpha:0});
endofload = false;

}

//play button fades out movieclip to reveal game
function playgame(e:MouseEvent):void
{
if (e.target == playbutton && xload == 100)
{
	TweenLite.to(fadeclip, 4 , {alpha:0, delay:2, onComplete: removeall});
	TweenLite.to(ride, 2 , {x:-300});
	TweenLite.to(playbutton, 2 , {alpha:0});

}

}

 

You can take a look at the game with the described issues for reference http://oliart.co.uk/schooloffish/

 

Refreshing the page seems to get it to work, but its hardly an ideal solution.

 

Is this an issue with loadermax or am I doing something wrong here?

Link to comment
Share on other sites

i don't think this is related to your issue as your swf does load, but to save you any nightmares in the future, its a good idea to not have spaces in the file names of assets that are involved in any sort of browser experience.

 

var loader:SWFLoader = new SWFLoader("http://www.oliart.co.uk/schooloffish/school of fish.swf

 

--------

 

it very well could be a cross domain issue.

 

I noticed that the link you provided is:

http://oliart.co.uk

 

and the subloaded swf is at

 

http://www.oliart.co.uk

 

having www in the subloaded swf and not in the container url may make flash think the subloaded swf is loading from a different domain, in which case it may prevent communication between the 2.

 

read this:

 

http://kb2.adobe.com/cps/142/tn_14213.h ... Comparison

 

especially the part about "incompatible domains in flash player 7+"

 

does it work better if you visit this link?

 

http://www.oliart.co.uk/schooloffish/

Link to comment
Share on other sites

no problem. it's rare that I'm able to trouble shoot these screwball issues, I'm very glad it worked.

 

Flash has a way of teaching you many lessons like these by making your life miserable for a few hours /days. The good news is you probably won't have this problem again:)

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