AS3 Loading Variables from an External Text File


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var vars:URLLoader = new URLLoader();
  2. vars.dataFormat=URLLoaderDataFormat.VARIABLES;
  3. vars.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
  4. vars.load(new URLRequest("vars.txt"));
  5. function onComplete(evt:Event):void {
  6. var urlVars:URLVariables=evt.target.data;
  7. for (var prop in urlVars) {
  8. trace("urlVars." + prop + " = " + urlVars[prop]);
  9. }
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.