A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: AS 3.0 Coding Issue, HELP PLEASE

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Location
    New York
    Posts
    8

    Unhappy AS 3.0 Coding Issue, HELP PLEASE

    Hey everybody, I have the following code which upon the pressing of the letter "s" opens up a new url in a uiloader window. If you press "s" repeatly it continues to open the window over and over without it finish fully playing, is there a way to add a timer to the "s" so it can only work once every few seconds or possibly a way to make the url completly open before you can press the "s" again??

    Thanks for any help available!!!

    Actionscript Code:
    stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);

    function keyHandler(e:KeyboardEvent):void{
      if (e.charCode == "s".charCodeAt(0)){
        var swfPathAndName:URLRequest = new URLRequest("intro.swf");
                swfbox.autoLoad = false;
        swfbox.maintainAspectRatio = true;
        swfbox.scaleContent = false;
        swfbox.source = swfPathAndName.url;
       
        swfbox.load();
      }
    }

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
    var okayToLoad:Boolean=true;
    function keyHandler(e:KeyboardEvent):void {
    	if (e.charCode=="s".charCodeAt(0)&&okayToLoad) {
    		okayToLoad=false;
    		var swfPathAndName:URLRequest=new URLRequest("intro.swf");
    		swfbox.addEventListener(Event.COMPLETE, completeHandler);
    		swfbox.autoLoad=false;
    		swfbox.maintainAspectRatio=true;
    		swfbox.scaleContent=false;
    		swfbox.source=swfPathAndName.url;
    		try {
    			swfbox.load();
    		} catch (error:Error) {
    			trace("Unable to load requested document.");
    			okayToLoad=true;
    		}
    	}
    }
    function completeHandler(e:Event) {
    	okayToLoad=true;
    }

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Location
    New York
    Posts
    8
    Thanks a lot for the code, but, the problem still persist, the new swf. (intro.swf) opening in the uiloader will continue to start over again if the letter "s" is pressed again before it actually finishes opening up. I have no idea which way to even go at it at this point. Any help you can provide will be greatly appreciated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center