loadMovie mc not showing?

  • BardicKnowledge
  • Novice
  • Novice
  • No Avatar
  • Joined: Apr 26, 2007
  • Posts: 21
  • Loc: Halifax
  • Status: Offline

Post May 31st, 2007, 10:00 am

Hey,
I am attempting to load a movieclip and position it just after it loads. Firstly the movieclip does not appear until a later function is ran, and secondly when it loads it is not in the proper place.

box is the empty movieclip that is acting as the container for the menu.swf (which is just a block at the moment).

Any help would be much appreciated.

Code: [ Select ]
box.loadMovie("menu.swf");
box._x = (Stage.width/2) - (box._width/2);
box._y = stageH - box._height;

Stage.scaleMode = "noScale";
Stage.align = "TL";

var stageListener:Object = new Object ();
stageListener.onResize = posMenu;
Stage.addListener(stageListener);

function posMenu():Void {
    oldH = stageH;
    oldW = stageW;
    oldCenter = OldH/2;
    
    stageW = Stage.width;
    stageH = Stage.height;
    center = (stageW/2) - (box._width/2);
    
    onEnterFrame = function(){                
        if((stageW - oldW) > 0){
            flip = 1;
        }else{
            flip = -1;
        }
    
        if(Math.round(box._x) == Math.round(center) || ((box._x-center)*flip) > 1 ){
            box._y = stageH - box._height;
            delete this.onEnterFrame;
        }else{        
            box._x += (center * .035)*flip;
            box._y = stageH - box._height;
        }        
    }
}

posMenu();
  1. box.loadMovie("menu.swf");
  2. box._x = (Stage.width/2) - (box._width/2);
  3. box._y = stageH - box._height;
  4. Stage.scaleMode = "noScale";
  5. Stage.align = "TL";
  6. var stageListener:Object = new Object ();
  7. stageListener.onResize = posMenu;
  8. Stage.addListener(stageListener);
  9. function posMenu():Void {
  10.     oldH = stageH;
  11.     oldW = stageW;
  12.     oldCenter = OldH/2;
  13.     
  14.     stageW = Stage.width;
  15.     stageH = Stage.height;
  16.     center = (stageW/2) - (box._width/2);
  17.     
  18.     onEnterFrame = function(){                
  19.         if((stageW - oldW) > 0){
  20.             flip = 1;
  21.         }else{
  22.             flip = -1;
  23.         }
  24.     
  25.         if(Math.round(box._x) == Math.round(center) || ((box._x-center)*flip) > 1 ){
  26.             box._y = stageH - box._height;
  27.             delete this.onEnterFrame;
  28.         }else{        
  29.             box._x += (center * .035)*flip;
  30.             box._y = stageH - box._height;
  31.         }        
  32.     }
  33. }
  34. posMenu();
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 31st, 2007, 10:00 am

  • krismeister
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Oct 21, 2006
  • Posts: 202
  • Status: Offline

Post May 31st, 2007, 10:09 am

Try setting _X and _y onload, maybe your problem is that the placement gets called too quickly.
  • BardicKnowledge
  • Novice
  • Novice
  • No Avatar
  • Joined: Apr 26, 2007
  • Posts: 21
  • Loc: Halifax
  • Status: Offline

Post June 1st, 2007, 5:14 am

Hey krismeister,
I just tried it and no luck:

Code: [ Select ]
box.loadMovie("menu.swf");

box.onLoad=function(){
    box._x = (Stage.width/2) - (box._width/2);
    box._y = stageH - box._height;
}
  1. box.loadMovie("menu.swf");
  2. box.onLoad=function(){
  3.     box._x = (Stage.width/2) - (box._width/2);
  4.     box._y = stageH - box._height;
  5. }


I tried putting the whole script in the onLoad and the box appears, but the rest of the script doesn't run. I'll keep playing around trying to figure it out, but if anyone has idea's I'm more than open to them ^_^

*EDIT*
I run a trace from within the onLoad function and it's not returning the value. But the clip does load since once you start resizing it appears.
  • BardicKnowledge
  • Novice
  • Novice
  • No Avatar
  • Joined: Apr 26, 2007
  • Posts: 21
  • Loc: Halifax
  • Status: Offline

Post June 1st, 2007, 9:02 am

I rewrote my code since I couldn't get that to work. I'll include my code here for anyone that may be interested in it.

Code: [ Select ]
box.loadMovie("menu.swf");
Stage.scaleMode = "noScale";
Stage.align = "TL";
count = 0;

onEnterFrame = function(){    
    if(count == 0){
        box._x = (Stage.width/2) - (box._width/2);
        box._y = Stage.height - box._height;
        getStageSize();
        if(box._width > 0 ){
            count = 1;
        }
    }else{    
        stageW = Stage.width;
        stageH = Stage.height;
        centerHor = (stageW/2) - (box._width/2);
        
        if((stageW - origW) < 0){
            flip = -1;
        }else{            
            flip = 1;
            getStageSize();            
        }
        
        if(Math.round(box._x) == Math.round(centerHor) || ((box._x - centerHor)*flip) > 1 ){
            box._y = stageH - box._height;
        }else{        
            box._x += (centerHor * .035)*flip;
            box._y = stageH - box._height;
        }        
    }
}

function getStageSize(){
    origW = Stage.width;
    origH = Stage.height;
}
  1. box.loadMovie("menu.swf");
  2. Stage.scaleMode = "noScale";
  3. Stage.align = "TL";
  4. count = 0;
  5. onEnterFrame = function(){    
  6.     if(count == 0){
  7.         box._x = (Stage.width/2) - (box._width/2);
  8.         box._y = Stage.height - box._height;
  9.         getStageSize();
  10.         if(box._width > 0 ){
  11.             count = 1;
  12.         }
  13.     }else{    
  14.         stageW = Stage.width;
  15.         stageH = Stage.height;
  16.         centerHor = (stageW/2) - (box._width/2);
  17.         
  18.         if((stageW - origW) < 0){
  19.             flip = -1;
  20.         }else{            
  21.             flip = 1;
  22.             getStageSize();            
  23.         }
  24.         
  25.         if(Math.round(box._x) == Math.round(centerHor) || ((box._x - centerHor)*flip) > 1 ){
  26.             box._y = stageH - box._height;
  27.         }else{        
  28.             box._x += (centerHor * .035)*flip;
  29.             box._y = stageH - box._height;
  30.         }        
  31.     }
  32. }
  33. function getStageSize(){
  34.     origW = Stage.width;
  35.     origH = Stage.height;
  36. }


As you can see, I just told it not to load the rest of the script until the movieclips size is larger than 0, which is the default width of an empty MC.
  • krismeister
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Oct 21, 2006
  • Posts: 202
  • Status: Offline

Post June 1st, 2007, 2:28 pm

No promises, but I still have a feeling you should use a real onload listener.

An example is:
Code: [ Select ]
this.createEmptyMovieClip("tester_mc", 1);
var mclListener:Object = new Object();
mclListener.onLoadComplete = function(target_mc:MovieClip) {
 trace("movie loaded");
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.yourserver.com/your_movie.swf", tester_mc);
  1. this.createEmptyMovieClip("tester_mc", 1);
  2. var mclListener:Object = new Object();
  3. mclListener.onLoadComplete = function(target_mc:MovieClip) {
  4.  trace("movie loaded");
  5. };
  6. var image_mcl:MovieClipLoader = new MovieClipLoader();
  7. image_mcl.addListener(mclListener);
  8. image_mcl.loadClip("http://www.yourserver.com/your_movie.swf", tester_mc);
  • BardicKnowledge
  • Novice
  • Novice
  • No Avatar
  • Joined: Apr 26, 2007
  • Posts: 21
  • Loc: Halifax
  • Status: Offline

Post June 5th, 2007, 9:47 am

Thanks for the replies krismeister. I have tried using the listener and it didn't trace anything. I don't know why it work work for me. But the way I posted above is still working xD

I will try to figure it out though.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 39 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.