PDA

View Full Version : What's wrong with the following?


MeTV
03-09-2005, 03:09 PM
I'm using the following actionscript to load an external *.swf into an empty movieclip and resize the movieclip accordingly. All goes well except in Firefox where the empty movieclip doesn't resize and, on ocassion, the external *.swf doesn't load at all (I use a javascript alert to let me know whether it's loaded or not).

onClipEvent(load){
newfile=this.loadMovie("/swf/file.swf")
}
onClipEvent(enterFrame){
if(newfile.getBytesLoaded==newfile.getBytesTotal){
this.width=100
this.height=100
_parent.movieclipx._visible=false
delete enterFrame
}
}

<edit> Forgot to say I was on a PC and the only other browser I'd tested it in so far was IE. Since tested it in IE and Safari on a Mac with the same problems. </edit>

jballou
03-09-2005, 03:21 PM
hey- I've run across similar problems as well. Your issue lies with how flash looks for files. If you're using an html page with this swf in it, and the swf is trying to load and external swf, it will load as you have it only when all your swf files are in a subfolder names swf and if your html docs are in the root folder. Know what I mean? That's the first issue. Secondly, you should probably take your code off the empty movie clip and instead put the following code on a frame:


loadMovie("/swf/file.swf" , "my_mc");

my_mc.onEnterFrame = function () {

bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());

if(bytes_loaded == bytes_total){
this.width=100
this.height=100
this._parent.movieclipx._visible=false
delete enterFrame
}
}


you may have to troubleshoot that a little bit as I didn't test it, but you get my drift? Let me know if it works.

MeTV
03-09-2005, 03:30 PM
Thanks, jballou. All my *.swf files are in a the same subdirectory of my root directory where the HTML page is located but I'll give your method of placing the actionscript in a frame a shirl, see if it works.

<edit> Well, what do you know? It worked! :D Much thanks, mate, was going mad over that one! </edit>