A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Center movieclip noScale

  1. #1
    Senior Member
    Join Date
    Sep 2005
    Location
    Gothenburg, Sweden
    Posts
    357

    Center movieclip noScale

    Hi and thanks for all the help here... Very appreciated!!!


    I while ago i posted a thread about align movieclips. I my movie i've got this movie clip called "copy" where all the copyright text is shown. The movieclip is always in the right bottom corner. I want my other movieclip, called "main", to always be centered and my third, called "logo" to be in the left upper corner. This must be possible, but how?

    I use this script to get my mc copy in the right corner:
    Code:
    Stage.scaleMode = 'noScale';
    Stage.align = 'TL';
    
    myListener = new Object();
    myListener.onResize = function(){
     sw = Stage.width;
     sh = Stage.height;
     copy._x = sw - 0;
     copy._y = sh - 0;
    }
    
    Stage.addListener(myListener);
    myListener.onResize();
    Thanks in advance
    /xzerox... Take a look at http://www.vmgcomputers.com/h75

  2. #2
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Top left is easy. In that case both _x and _y are 0.
    To find the center is also not very difficult. Just divide stage width and height by 2.
    Code:
    Stage.scaleMode = 'noScale';
    Stage.align = 'TL';
    
    myListener = new Object();
    myListener.onResize = function(){
     sw = Stage.width;
     sh = Stage.height;
     logo._x = 0;
     logo._y = 0;
     main._x = sw / 2;
     main._y = sh / 2;
     copy._x = sw;
     copy._y = sh;
    }
    
    Stage.addListener(myListener);
    myListener.onResize();
    Depending on where (0,0) is inside your movieclips you may have to add correction values. Another way to detect those correction values automatically is to use getBounds to detect the boundaries of each movieclip.

  3. #3
    Senior Member
    Join Date
    Sep 2005
    Location
    Gothenburg, Sweden
    Posts
    357
    thanks for the very very fast reply willbert!
    /xzerox... Take a look at http://www.vmgcomputers.com/h75

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center