Solved

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

Posted on 2006-06-18
5
150 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
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.

738 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