Skip to main content
February 29, 2012
Question

Download and display images.Works in FlashPro,but doesnt after Publish as SWF.

  • February 29, 2012
  • 2 replies
  • 669 views

Hi,

I spent quite a while to code the preloader scene to download few images from photobucket, so that i can update photos, instead of compiling the FLA everytime.

The problem is, everything works accordingly in FlashPro by using "Test Movie", however after I publish it as SWF,the SWF will play in IE8/Chrome, but it won't connect to photobucket to download the images, thus, the preloader scene never get pass.

Any suggestions?

http://www.autohotkey.net/~evanlim86/EL2_29f.fla

http://www.autohotkey.net/~evanlim86/EL2_29f.swf

stop();

var imagesArray:Array = new Array(

'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_1.jpg',

'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_2.jpg',

'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_3.jpg',

'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_4.jpg',

'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_5.jpg',

'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_6.jpg',

'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_7.jpg',

'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_8.jpg');

loadingLogo.alpha = 0.0;

var loadedArray:Array = new Array();

var counter:int = 0;

loadingLogo.addEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);

function loadImage():void

{

          var loader:Loader = new Loader();

          loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);

          loader.load(new URLRequest(imagesArray[counter]));

}

function loaded(e:Event):void

{

          loadedArray.push(e.target.content);

          if (counter == imagesArray.length-1)

          {

                    for (var i:uint = 0; i < loadedArray.length; i++)

                    {

                              loadedArray.width = 90;

                              loadedArray.height = 90;

                              loadedArray.x = 1;

                              loadedArray.y = 1;

                              if (i == 7)

                              {

                                        CompleteDownloadImage();

                              }

                    }

          }

          else

          {

                    counter++;

                    loadImage();

          }

}

function CompleteDownloadImage():void

{

          this.loadingClip.visible = false;

          loadingLogo.removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);

          loadingLogo.addEventListener(Event.ENTER_FRAME, fl_FadeSymbolOut_3);

}

function fl_FadeSymbolOut_3(event:Event)

{

          if (loadingLogo.alpha <= 0)

          {

                    loadingLogo.removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolOut_3);

                    this.loadingLogo.visible = false;

                    DisplayDownloadImage();

          }

          else

          {

                    loadingLogo.alpha -=  0.04;

          }

}

function fl_FadeSymbolIn(event:Event)

{

          if (loadingLogo.alpha >= 1)

          {

                    this.loadinglogoELSE.visible = false;

                    loadImage();

                    loadingLogo.removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);

          }

          else

          {

                    loadingLogo.alpha +=  0.03;

          }

}

function DisplayDownloadImage():void

{

          gotoAndStop(2,"PreloaderScene");

}

This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
March 1, 2012

use:

stop();


var imagesArray:Array = new Array(
'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_1.jpg',
'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_2.jpg',
'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_3.jpg',
'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_4.jpg',
'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_5.jpg',
'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_6.jpg',
'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_7.jpg',
'http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_8.jpg');


loadingLogo.alpha = 0.0;
var loadedArray:Array = new Array();
var counter:int = 0;
loadingLogo.addEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);


function loadImage():void
{
          var loader:Loader = new Loader();
          loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
          loader.load(new URLRequest(imagesArray[counter]));
}


function loaded(e:Event):void
{
          loadedArray.push(e.target.loader);
          if (counter == imagesArray.length-1)
          {
                    for (var i:uint = 0; i < loadedArray.length; i++)
                    {
                              loadedArray.width = 90;
                              loadedArray.height = 90;
                              loadedArray.x = 1;
                              loadedArray.y = 1;


                              if (i == 7)
                              {
                                        CompleteDownloadImage();

                               }                     }           }           else           {                     counter++;                     loadImage();           } } function CompleteDownloadImage():void {           this.loadingClip.visible = false;           loadingLogo.removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);           loadingLogo.addEventListener(Event.ENTER_FRAME, fl_FadeSymbolOut_3); } function fl_FadeSymbolOut_3(event:Event) {           if (loadingLogo.alpha <= 0)           {                     loadingLogo.removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolOut_3);                     this.loadingLogo.visible = false;                     DisplayDownloadImage();           }           else           {                     loadingLogo.alpha -=  0.04;           } } function fl_FadeSymbolIn(event:Event) {           if (loadingLogo.alpha >= 1)           {                     this.loadinglogoELSE.visible = false;                     loadImage();                     loadingLogo.removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);           }           else           {                     loadingLogo.alpha +=  0.03;           } } function DisplayDownloadImage():void {           gotoAndStop(2,"PreloaderScene"); }
kglad
Community Expert
Community Expert
February 29, 2012

SecurityError: Error #2122: Security sandbox violation: LoaderInfo.content: http://www.autohotkey.net/~evanlim86/EL2_29f.swf cannot access http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/th_1.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.

    at flash.display::LoaderInfo/get content()

    at EL2_29f_fla::MainTimeline/loaded()

a policy file is not needed to download cross-domain images.  however, because you're trying to access your loader's content, you're triggering a need for a cross-domain policy file.

to remedy, either upload a cross-domain policy file or push your loaders into that array and not that content property.

March 1, 2012

Thank you kglad, I was not aware with the cross-domain policy. My earlier version was using actionscript 2 and everything is compiled within the SWF. I am reading through the documentation, and it seems I need to change the XML file on the uploaded website?

<?xml version="1.0"?>

<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">

<cross-domain-policy>

<allow-access-from domain="http://img.photobucket.com/albums/v439/evanxxxm/elsesite_flash/" />

</cross-domain-policy>

I uploaded the above lines within crossdomain.xml and put in my autohotkey.net server (same folder as the EL2_29f.swf,AC_RunActiveContent.js)

http://www.autohotkey.net/~evanlim86/crossdomain.xml

Still the same, is there something I am missing here?

kglad
Community Expert
Community Expert
March 1, 2012

yes, you're missing something.

but, why bother with a policy file when you're not using anything that requires a policy file.  just push your loader into that array instead of a content property.