AS3.: can stop net connection
Previous versions of the Flash player could not close connections to the internet once a download into the player has started. For example if you start loading 30mb and sudenely you need to stop and handle differnt request. previous version couldn’t do it.
In Flash Player 9, using ActionScript 3, you can now stop connections and abort loading requests made by the player. see the following code
var loader:Loader = new Loader(); var request:URLRequest = new URLRequest("image.jpg"); loader.load(request); addChild(loader); // abort loading if not done in 3 seconds var abortID:uint = setTimeout(abortLoader, 3000); // abort the abort when loaded loader.contentLoaderInfo.addEventListener(Event.COMPLETE, abortAbort); function abortLoader(){ try { loader.close(); }catch(error:Error) {} } function abortAbort(event:Event){ clearTimeout(abortID); }
leave a comment