3 Replies Latest reply on Jul 14, 2008 7:15 PM by sandwicense

    AS3 Security Error

    sandwicense Level 1
      I downloaded this AS3 class for flex that extends the Image class. I am using the downloaded component as my image component. When I load an image into that component as a creationComplete event, I get a security error. I have the crossdomain.xml file in the root of the server I am trying to access. However I still get the error:

      SecurityError: Error #2122: Security sandbox violation: Loader.content: http://DOMAINNAME.com/flash/main.swf cannot access http://www.DOMAINNAME.com/$PROGRAMFILES/$INIT/initimage.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
      at flash.display::Loader/get content()
      at ActionScript::SmoothImage/ http://www.adobe.com/2006/flex/mx/internal::contentLoaderInfo_completeEventHandler()

      The files I wish to access and the .swf file are all on the same server. I am just using direct paths to the files.

      Here is the AS3 code that extends the Image component:

      package ActionScript
      import mx.controls.Image;
      import flash.display.Loader;
      import flash.display.Bitmap;
      import flash.events.Event;
      import mx.core.mx_internal;

      use namespace mx_internal;

      * SmoothImage
      * Automatically turns smoothing on after image has loaded
      * author Ben Longoria
      public class SmoothImage extends Image {

      public function SmoothImage():void {

      * @private
      override mx_internal function contentLoaderInfo_completeEventHandler(event:Event):void {
      var smoothLoader:Loader = event.target.loader as Loader;
      var smoothImage:Bitmap = smoothLoader.content as Bitmap;
      smoothImage.smoothing = true;