Path to swf folder in AS3


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



Copy this code and paste it in your HTML
  1. You can use loaderInfo.loaderURL to get the full path and name of you swf
  2.  
  3. Example of a class:
  4.  
  5. public class Main extends Sprite {
  6. private function init():void {
  7. removeEventListener(Event.COMPLETE, init);
  8. var myUrl:String=loaderInfo.loaderURL;
  9. var tmp:Array=myUrl.split("/");
  10. var myName:String=tmp[tmp.length-1].split(".swf")[0];
  11. }
  12.  
  13. public function Main() {
  14. super();
  15. if (stage)
  16. init();
  17. else
  18. addEventListener(Event.COMPLETE, init, false, 0, true);
  19. }
  20. }

Report this snippet


Comments


You need to login to view comments.