Solved

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

Posted on 2006-06-18
5
137 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
Comment Utility
hello, anyone got ideas?

Thanks
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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,…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to how to record live broadcast.
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.

763 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

7 Experts available now in Live!

Get 1:1 Help Now