• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 154
  • Last Modified:

centering a loaded jpg

If you are loading a jpg into a MC is there away to control it so it centers.  I am loading many pics, some of different size and would like them centered....  Any idea.....

0
solsticeint
Asked:
solsticeint
1 Solution
 
Aneesh ChopraCommented:


suppose you are loading the movie on a movieClip "container" which is on "_root"

here is the sample code..
----------
_root.container.loadMovie("my.jpg");
//check for loading completion
_root.onEnterFrame = function()
{
      if (_root.container.getBytesTotal() == _root.container.getBytesLoaded() && _root.container._width>0)
      {
            //loading completed
            delete _root.onEnterFrame;
            //now you can set it to center
            _root.container._x = (Stage.width/2)-(_root.container._width/2);
            _root.container._y = (Stage.height/2)-(_root.container._height/2);
      }
};
----------

Rgds
Aneesh
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now