0 Replies Latest reply on Jan 27, 2008 2:13 PM by Pete Mackie

    flash.display.loader Not Working For Me

    Pete Mackie Level 1
      Via "mx.rpc.remoting", my Flex client receive photos from a remote database server serialized as AMF3 ByteArray. The photo ByteArray is indeed sent and received by the client properly. I've verified the photo content to be correct by view using several debugging and wire sniffing procedures.

      I then use the following custom Loader class to load the photo, by first instantiating the class and then calling the method "loadPhotoFromByteArray()".

      public class PhotoLoader extends Sprite
      private var _loader:Loader;

      public function PhotoLoader()
      _loader = new Loader();
      _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
      _loader.contentLoaderInfo.addEventListener(Event.INIT, initListiner);
      _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
      _loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

      public function loadPhotoFromByteArray(photoBA:ByteArray):Loader
      return _loader;

      private function initListiner(e:Event):void

      private function completeHandler(e:Event):void
      trace("PhotoLoader.completeHandler:"+_i+", _done: "+_done);

      private function ioErrorHandler(event:IOErrorEvent):void
      trace("ioErrorHandler: " + event.toString);
      Alert.show(event.toString(), 'PhotoLoader IO Error');

      private function securityErrorHandler(event:SecurityErrorEvent):void
      trace("securityErrorHandler: " + event.toString);
      Alert.show(event.toString(), 'PhotoLoader Security Error');

      The the above "loadPhotoFromByteArray()" method is called the "initListiner()" and "completeHandler()" methods are sequentially called. There are no "ioError" or "securityErrorHandler" method call indication.

      When I look at the flash.display.loader results with the Flex debugger, I observe the following parameters below my signature line. By looking at the "contentLoaderInfo" below it appears that the photo did load, yet the content is displayed as "<exception thrown by getter>". Also observe there are also several other Loader parameters containing "<exception thrown by getter>"

      Perhaps these "exceptions" are because the Flex debugger is unable to display the parameters. Is this what one should expect to view here or are these "exceptions" indeed indication of problems?

      Furthermore, if I attempt display the photo, the following Flex debugger is displayed.
      warning: unable to bind to property 'content' on class 'flash.display::Loader'

      Perhaps the above error is caused by the photo being contained in Loader.content and I just do not have the right DisplayObject hierarchy set up. I find the Flex 2 documents on DisplayObject confusing and incomplete when describing DisplayObject deployment, leading to code trial and error on my part. This is my second question. Is there a possibility that I do not have my Loader DisplayObject hierarchy set up incorrectly?

      photoLoader = flash.display.Loader (@2c77c4c1)
      accessibilityImplementation = null
      accessibilityProperties = null
      alpha = 1
      blendMode = "normal"
      cacheAsBitmap = false
      content = <exception thrown by getter>

      contentLoaderInfo = flash.display.LoaderInfo (@2ca58161)
      actionScriptVersion = <exception thrown by getter>
      applicationDomain = <exception thrown by getter>
      bytes = flash.utils.ByteArray (@2cd951a1)
      bytesLoaded = 9485 [0x250d]
      bytesTotal = 9485 [0x250d]
      childAllowsParent = true
      content = <exception thrown by getter>
      contentType = "image/jpeg"
      frameRate = <exception thrown by getter>
      height = 63 [0x3f]
      loader = <exception thrown by getter>
      loaderURL = " http://localhost/~petem/WPhotoSearch/WPhotoSearch-debug.swf"
      parameters = Object (@2cd807e1)
      parentAllowsChild = true
      sameDomain = true
      sharedEvents = flash.events.EventDispatcher (@2c870701)
      swfVersion = <exception thrown by getter>
      url = " http://localhost/~petem/WPhotoSearch/WPhotoSearch-debug.swf/[[DYNAMIC
      width = 96 [0x60]

      contextMenu = null
      doubleClickEnabled = false
      filters = Array (@2cb3b319)
      focusRect = null
      height = 0
      loaderInfo = null
      mask = null
      mouseChildren = true
      mouseEnabled = true
      mouse_X = 125 [0x7d]
      mouseY = 122 [0x7a]
      name = "instance81"
      numChildren = 0
      opaqueBackground = null
      parent = <exception thrown by getter>
      root = null
      rotation = 0
      scale9Grid = null
      scaleX = 1
      scaleY = 1
      scrollRect = null
      stage = null
      tabChildren = true
      tabEnabled = false
      tabIndex = -1 [0xffffffff]
      textSnapshot = <exception thrown by getter>
      transform = flash.geom.Transform (@2cac8161)
      visible = true
      width = 0
      x = 0
      y = 0