Solved

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

Posted on 2006-06-18
5
142 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Action Script commands 3 212
Flash Slides/Presnetation 4 71
How to convert image files to a movie file 6 108
File conversion question 5 84
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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 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.

910 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

17 Experts available now in Live!

Get 1:1 Help Now