all groups > flash actionscript > january 2005 >
You're in the

flash actionscript

group:

Loaded MC reference Problem


Loaded MC reference Problem bknowlden01
1/25/2005 10:42:46 PM
flash actionscript:
I have a button that when pressed creates an empty movieclip and loads
something into it when pressed. I want to center this content on the stage
dynamically (because all things to be loaded are different in size) upon load.
I am not having a problem referencing the stage (Stage.width) but am having a
problem referencing the object once loaded. I was under the impression that
once an MC is loaded, it takes on the call of the parent SWF. Attached is the
code that is currently functioning(with some substitution). :: blk ::

adTwo.onRelease = function() {
_global.loadMe = 1;
if (_global.loadMe == 1) {
createEmptyMovieClip("loadInto", this.getNextHighestDepth);
var mclLoader:MovieClipLoader = new MovieClipLoader();
mclLoader.loadClip("avenir.swf", loadInto);
loadInto._x = ((content_sqr._width/2) - (270/2) + 155);
loadInto._y = ((content_sqr._height/2) - (350/2) + 70);
trace(loadInto._width);
trace(loadInto.avenir._width);
trace(avenir._width);
/* Notice the trace statements, the file "Avenir.swf" that is being loaded
has a movieclip instanceon the main timeline "Avenir", hence the attempted
dot syntax reference. The trace statements are returning the following
pixel values: 0, undefined, undefined. Any Ideas? */
}
}
Re: Loaded MC reference Problem tbore
1/26/2005 12:30:44 AM
_width and _height will return 0 on the same frame where it is loaded.

To zero out uncertainty always use references like 'this or '_parent' when
creating a movieclip. You can get a reference like this:




var myclip = this.createEmptyMovieClip("loadInto", this.getNextHighestDepth);
AddThis Social Bookmark Button