From martin at hatchlane.com Sun May 9 15:37:18 2010 From: martin at hatchlane.com (Martin Collins) Date: Sun, 9 May 2010 15:37:18 +0000 Subject: Flash Plugin - HTTP Status/Error handling Message-ID: <20100509153718.GB25717@anyanka.hatchlane.com> Hi, I've noticed some strange behaviour in how flash player doesn't seem to receive status events when run under nspluginwrapper. Using the attached AS3 file compiled with flex-4.1.0.15674 on linux with the following: mxmlc -static-link-runtime-shared-libraries=true \ -target-player 10.0.0 \ -compiler.omit-trace-statements=false \ -compiler.keep-generated-actionscript=false \ -compiler.accessible=true \ -compiler.debug=true \ -compiler.incremental=false \ src/IOErrorBug.as -o out/IOErrorBug.swf Synopsis: Module loads, and tries to load an image that does not exist (swf path + missing_image.jpg), on various handlers traces out statements to the debug log. On any of the major error handlers being reached (IOErrorEvent and SecurityErrorEvent), it will draw a red box to the stage. Setup: I have placed a version of this here should you wish to use a pre-compiled version: http://www.hatchlane.com/flash/nspluginwrapper/IOErrorBug.swf In order to view the trace() statements you would need the debug player installed, however the red box is drawn for this very reason (test 1). Output: The following conditions are encountered: Expected Result: red box drawn to stage 1) Firefox: firefox-3.0.18-1.el5.centos.x86_64 Shockwave Flash 10.0 r45 (x86_64) (http://labs.adobe.com/downloads/flashplayer10_64bit.html) Actual Result: red box shows Debug Trace: No x86_64 debug player available 2) Firefox: firefox-3.0.18-1.el5.centos.i686 Shockwave Flash 10.0 r45 (i686) Actual Result: red box shows Debug Trace: TRYING TO LOAD: http://www.hatchlane.com/flash/nspluginwrapper/missing_image.jpg STATUS: 0 IO ERROR EVENT 3) Firefox: firefox-3.0.18-1.el5.centos.x86_64 nspluginwrapper: nspluginwrapper-0.9.91.5-22.el5 Shockwave Flash 10.0 r45 (i686) Actual Result: nothing shows Debug Trace: TRYING TO LOAD: http://www.hatchlane.com/flash/nspluginwrapper/missing_image.jpg Is this a bug? or a limitation of nspluginwrapper? I suppose this would most likely disappear when adobe officially releases the 64bit one and people stop using the nspluginwrapper for flash, however the problem may exist for other plugins that people use the wrapper for. Kind Regards, Martin -------------- next part -------------- package { import flash.display.Shape; import flash.display.Sprite; import flash.display.Stage; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.display.StageDisplayState; import flash.display.Loader; import flash.display.LoaderInfo; import flash.net.URLRequest; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.HTTPStatusEvent; import flash.events.SecurityErrorEvent; import flash.events.ProgressEvent; [SWF(frameRate="30", backgroundColor="#222625")] public class IOErrorBug extends Sprite { private var img:Loader; private var box:Shape; private var swfDir:String; public function IOErrorBug() { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; this.addEventListener(Event.ADDED_TO_STAGE,stageSetup); } private function addListeners():void { img.contentLoaderInfo.addEventListener(Event.OPEN,openHandler); img.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); img.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,errorHandler); img.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS,statusHandler); img.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler); img.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler); } private function removeListeners():void { img.contentLoaderInfo.removeEventListener(Event.OPEN,openHandler); img.contentLoaderInfo.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); img.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,errorHandler); img.contentLoaderInfo.removeEventListener(HTTPStatusEvent.HTTP_STATUS,statusHandler); img.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler); img.contentLoaderInfo.removeEventListener(Event.COMPLETE,completeHandler); } private function stageSetup(e:Event = null):void { this.removeEventListener(Event.ADDED_TO_STAGE,stageSetup); swfDir = this.loaderInfo.url.substr(0,this.loaderInfo.url.lastIndexOf('/')); var image:String = swfDir + "/missing_image.jpg"; trace("TRYING TO LOAD: " + image); img = new Loader(); addListeners(); img.load(new URLRequest(image)); } private function setupBox():void { box = new Shape(); box.graphics.beginFill(0xFF0000,1); box.graphics.drawRect(0,0,100,100); box.graphics.endFill(); this.addChild(box); } private function openHandler(e:Event):void { trace("OPEN HANDLER"); } private function securityErrorHandler(e:SecurityErrorEvent):void { trace("SECURITY ERROR"); removeListeners(); setupBox(); } private function errorHandler(e:IOErrorEvent):void { trace("IO ERROR EVENT"); removeListeners(); setupBox(); } private function statusHandler(e:HTTPStatusEvent):void { trace("STATUS: " + e.status); } private function progressHandler(e:ProgressEvent):void { trace("PROGRESS: " + (e.bytesLoaded/e.bytesTotal)*100 + "%"); } private function completeHandler(e:Event):void { trace("COMPLETE"); removeListeners(); this.addChild(img); } } }