1

I am creating an app where when a button is pressed a very large picture is added to the stage (it is larger than the screen but can be dragged around by the user)

When the button is pressed the picture (well, movieClip) does come up and it able to be dragged fine, buttons inside it work.

The problem though is that there is a pause of about 6 seconds between the button press and the image appearing. I am using one .fla file for publishing and compiling (let's just call it Main.fla for now), and another one to hold all the graphics. The graphics are then added with this embed command:

[Embed (source = "assets/graphic.swf", symbol = "Content")]
private var Content:Class; 
private var _content:*;

I have these lines where all the variables are declared (in between the class definition and the constructor function) I was under the impression that embedding it like this was equivalent to loading it at compile time. Is this true? What could be causing this lag when the button is pressed?

If I can't cut out the lag, another idea I had was to make some spinning circle or something to tell the user, "hey, don't worry. It's loading!"

Jim
  • 3,821
  • 1
  • 28
  • 60

2 Answers2

1

If the slowness is at addChild you can add the asset to the stage much earlier and set it's visiblility to false, then when the button is clicked set it back to true. Obviously this is a small hack but might be sufficient for what you are doing.

var asset:MovieClip;

private function init():void
{
    asset = new Content();
    assset.visible = false;
    addChild(asset);

    button.addEventListener(MouseEvent.CLICK, onMouseClick);
}

private function onMouseClick(e:MouseEvent):void
{
   asset.visible = true;
}
Barış Uşaklı
  • 13,440
  • 7
  • 40
  • 66
  • 1
    hmm. I'm going to try this. I have a part in the beginning where I "build" all of the pages to make them scrollable. I could just add this image to the stage here and set visibility to true when the button is clicked. – Jim Mar 20 '13 at 23:37
0

Embedding your SWF is probably not what is causing the delay.. or rather it would not likely be better if you imported the SWF into your FLA. Is this on a device? Chances are you would either have to devise a different way of loading your asset, or be satisfied with a loading animation.

If the main K size is coming from a large image, you could consider loading it in segments, starting with the part that is initially visible.

Mike Bedar
  • 632
  • 5
  • 14