Jump to content
Search Community

Loading an URL with a query string

a-ok test
Moderator Tag

Recommended Posts

if you want to strip the query string (the ? and all the comes after), you can run your swf's url through a cleaner function prior to putting it into your swfLoader

 

 

var swfUrl:String = "someSwf.swf?cat=3";



function stripQuery(url:String):String{
var question:int = url.indexOf("?");
if(question!=-1){
	var cleanUrl:String = url.slice(0, question);
	return cleanUrl;
	}else{
		return url;
		}
}

//test
trace(stripQuery(swfUrl));	

trace(stripQuery("http://www.somedomain.com/someSwf?size=8&color=red"));

//or real world usage:
var swf:SWFLoader = new SWFLoader(stripQuery("someSwf.swf?cat=3"), {name:"mainSWF", container:this, x:50, y:100, onInit:initHandler, estimatedBytes:9500}) 

Link to comment
Share on other sites

if you want to strip the query string (the ? and all the comes after), you can run your swf's url through a cleaner function prior to putting it into your swfLoader

 

Thanks but I need the query string to be sent to the file that's being loaded. It looks like I'll have to make a function that parses the query string and creates an URLrequest out of it. :(

Link to comment
Share on other sites

I'm a little confused - why can't you use it in the straightfoward way like:

 

var swf:SWFLoader = new SWFLoader("someSwf.swf?cat=3", {name:"mainSWF", container:this, x:50, y:100, onInit:initHandler, estimatedBytes:9500})
swf.load(); 

 

?

 

Is there something breaking for you? Carl was just trying to help you get rid of the query string because it sounded like that's what you were asking for initially but I guess that's not what you're after.

Link to comment
Share on other sites

I'm a little confused - why can't you use it in the straightfoward way like:

 

var swf:SWFLoader = new SWFLoader("someSwf.swf?cat=3", {name:"mainSWF", container:this, x:50, y:100, onInit:initHandler, estimatedBytes:9500})
swf.load(); 

 

?

 

Is there something breaking for you? Carl was just trying to help you get rid of the query string because it sounded like that's what you were asking for initially but I guess that's not what you're after.

 

Sorry I've been extra stupid (and I forgot all about this thread). I was getting the error when testing the site through Flash and not through a browser so it was able to load someSwf.swf but produced an error when loading someSwf.swf?cat=3

:oops:

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