|
-
Angkor-What?
positioning a mc with onLoadComplete
Hi,
I'm loading a swf into an mc on the stage. After it's loaded I want to center it on stage. I'm doing something like this:
Code:
maintimeline = this;
mainMC.onResize = function() {
this._x = (Stage.width+this._width)/4;
this._y = (Stage.height+this._height)/4;
};
Stage.addListener(mainMC);
maintimeline.mainMC.onResize();
//
var mainMCloader = new MovieClipLoader();
mainMClistener = new Object();
mainMClistener.onLoadComplete = function() {
updateAfterEvent;
maintimeline.mainMC.onResize();
};
mainMCloader.addListener(mainMClistener);
mainMCloader.loadClip("main.swf", maintimeline.mainMC);
The problem is that, even while I'm using onLoadComplete, Flash thinks that the mainMC._width = 0. It is only, when I make the timeline play a couple of frames that mainMC._width finally results in the real size (the one of the loaded swf).
What I'm I doing wrong???
Cheers
MX 2004 Pro - Oops I did it again!!!
SWF, it's a journey... not a destination
-
Angkor-What?
MX 2004 Pro - Oops I did it again!!!
SWF, it's a journey... not a destination
-
Monkey Moderator
try using onLoadInit instead of onLoadComplete.
onLoadComplete executes before the loaded movieClip is initialised and so you do not have access to its methods and properties etc. onLoadInit executes when the movie has finished loading and has initialised.
www.lexicon-design.co.uk
If we aren't supposed to eat animals, then why are they made of meat?
If Vegetarians like animals so much, why do they eat all their food?
-
Angkor-What?
That helped, thanx! Somehow I though that onLoadComplete was trggered when the load was completed and onLoadInit was triggered when the load initiated...
One more question though. I want to position the mc onLoadInit but I can't seem to call the function correctly...
Code:
maintimeline = this;
maintimeline.mainMC.onResize = function() {
trace(this._width);
};
//
var mainMCloader = new MovieClipLoader();
mainMClistener = new Object();
mainMClistener.onLoadInit = function() {
// going wrong here I think...
maintimeline.mainMC.onResize();
};
mainMCloader.addListener(mainMClistener);
mainMCloader.loadClip("ain.swf", maintimeline.mainMC);
Any clues on this?
Cheers
MX 2004 Pro - Oops I did it again!!!
SWF, it's a journey... not a destination
-
Angkor-What?
Found it thanx anyway 
Code:
var mainMCloader = new MovieClipLoader();
mainMClistener = new Object();
mainMClistener.onLoadInit = function() {
mainMC.onResize = function() {
this._x = (Stage.width-this._width)/2;
this._y = (Stage.height-this._height)/2;
};
Stage.addListener(mainMC);
maintimeline.mainMC.onResize();
};
mainMCloader.addListener(mainMClistener);
mainMCloader.loadClip("main.swf", maintimeline.mainMC);
MX 2004 Pro - Oops I did it again!!!
SWF, it's a journey... not a destination
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|