madcat
madcat

Reputation: 49

best way to embed swf that loads other swf files

In main.swf I loaded file.swf as:

var loader:Loader = new Loader();
var request:URLRequest = new URLRequest(“file.swf”);

When main swf loaded in HTML with an absolute link like:

"http://domain.com/main.swf"

It reports 404 error loading failed of file.swf

Because it looks for file.swf at current web host.

What's the best way to do this without hard code absolute url in main.swf? Is this something swfobject can help?

Upvotes: 0

Views: 413

Answers (1)

PatrickS
PatrickS

Reputation: 9572

"What's the best way to do this without hard code absolute url in main.swf?"
You could provide the main url thru flashvars or by making a PHP request

Is this something swfobject can help?
Yes if you use flashvars

var params = {/* whatever you need here*/}

swfobject.embedSWF("main.swf", "flash", 
"100%", "100%", "9.0.0" , 
"expressInstall.swf" , 
{mainUrl:"http://example.com/"}, params );

In AS3

//In your main class

var mainURL:String  = this.loaderInfo.parameters.mainUrl;

var loader:Loader = new Loader();
var url:String = mainURL + “file.swf”;
var request:URLRequest = new URLRequest(url);

Upvotes: 1

Related Questions