Solved

Urgent!!! Center the dynamic image in flash (500 points now)

Posted on 2006-06-18
5
146 Views
Last Modified: 2012-05-05
Hi everyone,

I'm trying to load images from a flash, but cant center the image, here's my actionscript:

loadMovie(image.jpg, _root.photo);
l = _root.photo.getBytesLoaded();
t = _root.photo.getBytesTotal();
while (l < t)
{
     //do nothing
}
_root.photo._x = (550-_root.photo._width)/2;
_root.photo._y = (400-_root.photo._height)/2;

the images show up, but still on the top left corner.

Anyone knows how to center the image?

Thanks
Harry
0
Comment
Question by:eezy2
  • 2
  • 2
5 Comments
 

Author Comment

by:eezy2
ID: 16932410
hello, anyone got ideas?

Thanks
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16933194
Hi,

this code will work fine for you
-----------
w = _root.photo._width;
loadMovie("image.jpg", _root.photo);
l = _root.photo.getBytesLoaded();
t = _root.photo.getBytesTotal();
_root.onEnterFrame = function()
{
      if (l == t && _root.photo._width>w)
      {
            _root.photo._x = (Stage.width-_root.photo._width)/2;
            _root.photo._y = (Stage.height-_root.photo._height)/2;
            delete _root.onEnterFrame;
      }
};
-----------

Rgds
Aneesh
0
 

Author Comment

by:eezy2
ID: 16933291
nah, didn't work, sorry aneesh.

or maybe i did it in the wrong way?
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 300 total points
ID: 16939956
Here I have uploaded working version..
http://www.4shared.com/file/2127922/43d5ae53/loadimageincenter.html

download and compare what you have done wrong


Rgds
Aneesh
0
 
LVL 12

Assisted Solution

by:SamuelRostol
SamuelRostol earned 200 total points
ID: 17478029
Try changing it to:

w = 0;
image = loadMovie("image.jpg", _root.photo);
l = image.getBytesLoaded();
t = image.getBytesTotal();
_root.onEnterFrame = function()
{
     if (l >= t && _root.photo._width>w)
     {
          image._x = (Stage.width - image._width)/2;
          image._y = (Stage.height - image._height)/2;
          delete _root.onEnterFrame;
     }
};
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

770 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