Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Embedding a SWF inside another SWF

216 views
Skip to first unread message

TCC-Adobe

unread,
Mar 11, 2009, 4:56:35 AM3/11/09
to
I used inDesign CS4 to develop a catalog of services for the company I work
for. Then exported it to a Flash document with interactive buttons and page
turns. This is the current look: http://www.directrixsolutions.com/cw

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?

NedWebs

unread,
Mar 11, 2009, 7:47:56 AM3/11/09
to
If you didn't add that message yourself, I'd recommend you destroy the file. I am not about to click that link to find out I just got a virus

TCC-Adobe

unread,
Mar 11, 2009, 2:39:25 PM3/11/09
to
NedWebs. Yes, I did add that message myself, and it isn't a virus. I can
explain what it is doing if that would be better. When the FlashVersion of the
packet is loaded, it goes through the preloader, then goes to the packet.swf.
But instead of remaining on the first page of the packet and waiting for
instructions from the viewer on going to the next page. It jumps to the next
page, then to the next and so on. Very quickly. I would have to say that it
goes through the entire 11page packet 3 or 4 times each second. It is as if
when the packet.swf is opened, it goes through each frame and is on a loop.
Maybe the stop(); script for each page is not being recognized? I have attached
the ActiveScript code that I used within this project.

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 ;

NedWebs

unread,
Mar 11, 2009, 3:03:49 PM3/11/09
to
Do you know what your inDesign uses in creating Flash files? My first instinct
is to say that the uncontrollable movie is suffering AS3 incompatibility
symptoms, possibly due to being an AS3 file being placed in an AS2 environment.

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.

TCC-Adobe

unread,
Mar 12, 2009, 5:31:44 PM3/12/09
to
NedWebs, thank you. That solved the problem of the swf freaking out. But, after
updating the FLA file with new code to be compliant with AS3, the rendered SWF
is only 1.5K which means that the preloader loads shows as 100% instantly, then
it pauses while it loads the embeded SWF. What am I doing wrong here? Below I
have included the updated code.

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)

NedWebs

unread,
Mar 12, 2009, 6:01:02 PM3/12/09
to
You probably need an event listener so that you wait until the swf has loaded
before you add it to the stage.

var ld:Loader = new Loader();
ld.contentLoaderInfo.addEventListener(Event.COMPLETE, addSWF);
ld.load(new URLRequest("packet.swf"));

function addSWF(e:Event):void {
addChild(ld);
}

TCC-Adobe

unread,
Mar 12, 2009, 6:56:13 PM3/12/09
to
Thank you so much NedWebs! That worked. Now, I have a preloader and the SWF
made from inDesign working together. Thank you so much for your help!

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);

NedWebs

unread,
Mar 12, 2009, 7:02:07 PM3/12/09
to
You're welcome. I'm glad it's all working for you now.
0 new messages