I have got a movie clip that is dynamically created with actionscript
I then load an external swf into that movieclip. My problem is having it centered when I view it in my browser…
How do place I center that dynamic created movie clip?
I was trying this but it’s not seeming to work.
var container:MovieClip = this.createEmptyMovieClip("container_mc", 0);
container._x =Stage.width/2;
container._y =Stage.height/2;
The loader fits in the middle of the Stage but it loads from the relative x=0 y=0 from the loader (the upper-leftcorner of it :D). I guess you will have to adjust the loader component manually depending on the swf height and width.
You could also align the container with AS, but the way you had it, it would move the top left corner to the center, not center the clip. For that you’d want something more like this:
var container:MovieClip = this.createEmptyMovieClip("container_mc", 0);
container._x =(Stage.width/2)-(this._width/2);
container._y =(Stage.height/2)-(this._height/2);
I noticed the error I was making in my code when i viewed yours… the difference was in the width vs the _width property.
I am still having problems with regards to centering the “container” after I load an external swf into it. It just does not center.
when I do a trace of this._width it returns undefined. Is this._width suppose to reference the loaded swf?
when I trace container._width after the enternal swf has been loaded into the container it returns 0
One thing to keep in mind is that the width of the loaded external swf vary for each one…
use container._width, but it will not be the correct value until the external clip has loaded fully into the container. If your using loadMovie, try changing your code to use movieClipLoader instead, it has more control of the loaded clips and the ability to preload as well.
Hey defective, i am using the movie clip loader class… but was getting the same result as before until I placed the code in onLoadInit = function(){}; seem like I needed to make sure the first frame in the loaded swf was read…