Skip to main content
February 13, 2010
Question

Possible to load large files behind the scene?

  • February 13, 2010
  • 1 reply
  • 494 views

Is it possible for in a website to start loading a file after it's loaded the initial setup, so that when the user clicks to see the larger file, it's already loaded, or at least part of it's started loading, all without totally stopping other basic rollover functions and so on that appear with the initial setup?

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 13, 2010

yes, you can start loading any time.  that will have almost no impact on the performance of already loaded items in flash.

February 13, 2010

Ok then there's something I'm completely missing out with this code:

var BTS:Number = 0;

var board:Sprite=new Sprite();

this.addChild(board);

board.x=175;

board.y=stage.stageHeight/2.8-board.height/2;

board.buttonMode = true;

var loader:Loader;

var infoBox:TextField;

var image:Bitmap;

var imageData:BitmapData;

var glass:Sprite=new Sprite();

var glassWidth:int=500;

var glassHeight:int=500;

var doDrag:Boolean=false;

var picWidth:Number;

var picHeight:Number;

var dataWidth:Number;

var dataHeight:Number;

var shrinkFactor:Number=.3;

var magFactor:Number=1/shrinkFactor;

function descriptionFill(e:Event):void {

     if (description_mc.width < 588.15) {

          description_mc.width += 45;

     }

     if (description_mc.width >= 588.15 && description_mc.height < 200) {

          description_mc.height += 50;

          description_mc.y += 50;

     }

     if (description_mc.width >= 588.15 && description_mc.height >= 200) {

          stage.removeEventListener(Event.ENTER_FRAME,descriptionFill);

          timer.removeEventListener("timer",timerHandler);

          setChildIndex(descripTag_txt,numChildren-1);

          TweenLite.to(smallImg_mc,2,{alpha:1});

          fullTimer.start();

          mvm_design.alpha = 1;

          descripTag_txt.alpha = 1;

               if (navPanel.x == 0) {

               setChildIndex(smallImg_mc,1);

          }

          setUpLoadBox();

          startApp();

     }

}

smallImg_mc.addEventListener(MouseEvent.CLICK,goFull);

function goFull(e:MouseEvent):void {

     BTS = 1;

     smallImg_mc.removeEventListener(MouseEvent.CLICK,goFull);

     fullMode_txt.visible = false;

     smallImg_mc.visible = false;

}

function startApp():void {

     loader=new Loader();

     loader.load(new URLRequest("resized Images/Zombie Scan Half.jpg"));

     if (BTS == 1) {

          infoBox.text="Loading";

          preload_mc.visible = true;

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

          loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,updateInfo);

     }

}

function updateInfo(e:ProgressEvent):void {

     var loaded:Number = e.bytesLoaded;

     var total:Number = e.bytesTotal;

     var pct:Number = loaded/total;

     preload_mc.loader_mc.scaleX = pct;

     infoBox.text="Loading: " + (Math.round(pct*100)) + "%";

}

function initPic(e:Event):void {

     image=Bitmap(loader.content);

     imageData=image.bitmapData;

     dataWidth=image.width;

     dataHeight=image.height;

     image.scaleX=shrinkFactor;

     image.scaleY=shrinkFactor;

     picWidth=image.width;

     picHeight=image.height;

     removeChild(preload_mc);

     board.addChild(image);

     loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,initPic);

     loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,updateInfo);

     loader=null;

     infoBox.text="";

     infoBox.visible=false;

     board.addChild(glass);

     glass.filters=[ new DropShadowFilter() ];

     board.filters=[ new DropShadowFilter() ];

     setUpListeners();

}

Code's real long so I just posted what I thought would be necessary to show my problem

kglad
Community Expert
Community Expert
February 13, 2010

if you could highlight the line(s) of code you want checked that would be helpful.