My question in regards to my file is, can you import the .swf file, which
inDesign makes, into a Flash document so that a preloader for the file can be
used? My .swf (packet.swf) is about a 1mb large and so should have a preloader.
But, when I import it, or have an attached .swf within the file that points to
my packet.swf, this is what happens. WARNING: IF YOU ARE PREDISPOSED TO HAVING
SEIZERS, YOU SHOULD PROBABLY NOT CLICK ON THIS LINK. (c8
http://www.directrixsolutions.com/cw/FlashVersion.html
As you can see, the document goes crazy. Any ideas?
Preloader Code:
stop();
loaderInt = setInterval(Lbar,10);
function Lbar(){
dynamicTxt.text = Math.round(getBytesLoaded()/getBytesTotal()*100) + "%";
if (getBytesLoaded() >=getBytesTotal()){
play();
loadingTxt._visible = false;
preloader._visible = false;
dynamicTxt._visible = false;
clearInterval(loaderInt);
}
preloader._xscale = (getBytesLoaded()/getBytesTotal()*100);
}
SWF embed Code:
stop();
_root.createEmptyMovieClip("container",1);
container.loadMovie("packet.swf");
container._x = container._y = 0 ;
While I've heard different versions of the story here in the forums, I can
only rely on what I have read in the Flash help docs:
- A single SWF file cannot combine ActionScript 1.0 or 2.0 code with
ActionScript 3.0 code.
- ActionScript 3.0 code can load a SWF file written in ActionScript 1.0 or
2.0, but it cannot access the SWF file's variables and functions.
- SWF files written in ActionScript 1.0 or 2.0 cannot load SWF files written
in ActionScript 3.0. This means that SWF files authored in Flash 8 or Flex
Builder 1.5 or earlier versions cannot load ActionScript 3.0 SWF files.
Preloader Code: (received off another forum):
stop();
import flash.display.*;
this.stop();
this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING);
function PL_LOADING(event:ProgressEvent):void {
var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
lbar.scaleX=pcent/100;
lTxt.text=int(pcent)+"%";
if(pcent==100){
this.gotoAndPlay(2);
}
}
SWF embed Code:
stop();
var ld:Loader = new Loader()
ld.load(new URLRequest("packet.swf"))
addChild(ld)
var ld:Loader = new Loader();
ld.contentLoaderInfo.addEventListener(Event.COMPLETE, addSWF);
ld.load(new URLRequest("packet.swf"));
function addSWF(e:Event):void {
addChild(ld);
}
This is what the code ended up looking like at the end, for anyone else that
has this problem. I just put it all into the first frame of the SWF
import flash.display.*;
this.stop();
var ld:Loader = new Loader();
ld.contentLoaderInfo.addEventListener(Event.COMPLETE, addSWF);
ld.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
preloaderHandler);
ld.load(new URLRequest("packet.swf"));
function preloaderHandler(event:ProgressEvent):void{
var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
preloadBar.scaleX=pcent/100;
preloadTxt.text=int(pcent)+"%";
if(pcent==100){
this.gotoAndPlay(2);