Posted By

ddegner on 02/25/09


Tagged

url variables as3 query-string


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

LeeRJohnson
dx0ne
zimmen


Pull query-string variables from the loading files URL


 / Published in: ActionScript 3
 

URL: www.DegnerWeddings.com

It's not the prettiest piece of code but it works for now

  1. import flash.external.ExternalInterface;
  2. var fullurl:String = ExternalInterface.call("window.location.href.toString");
  3.  
  4.  
  5. if(fullurl){
  6. var params:Array = fullurl.split('?');
  7. fullurl = params[1];
  8. params = fullurl.split('&');
  9. var length:uint = params.length;
  10. var g:uint;
  11. for (g=0; g< length; g++){
  12. var index:int=0;
  13. var kvPair:String = params[g];
  14. if((index = kvPair.indexOf("=")) > 0){
  15. var key:String = kvPair.substring(0,index);
  16. var value:String = kvPair.substring(index+1);
  17. params[key] = value;
  18. }
  19. }
  20. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: ddegner on February 25, 2009

Here's a corrected version //Get URL query import flash.external.ExternalInterface;

function querystrings(){ var fullurl:String = ExternalInterface.call("window.location.href.toString"); if(fullurl){ var params:Array = fullurl.split('?'); if(!params[0]){return undefined;} fullurl = params[1]; params = fullurl.split('&'); var length:uint = params.length; var g:uint; for (g=0; g< length; g++){ var index:int=0; var kvPair:String = params[g]; if((index = kvPair.indexOf("=")) > 0){ var key:String = kvPair.substring(0,index); var value:String = kvPair.substring(index+1); params[key] = value; } } } }

Posted By: ddegner on February 25, 2009

fuck, why can't I just edit the origional code?

Posted By: dx0ne on February 26, 2009

u don't have Edit Snippet link on right? try http://snipplr.com/edit/12569

You need to login to post a comment.