centering a loaded jpg

Posted on 2006-04-06
Last Modified: 2010-04-03
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.....

Question by:solsticeint
    1 Comment
    LVL 34

    Accepted Solution


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

    here is the sample code..
    //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);


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Action Script coding 1 168
    Adobe Flash Player not supported on my Tablet 7 692
    Flash Converter 8 98
    Play RTMP without Flash 3 155
    There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
    Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
    The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now