Solved

How to place a external image in the center of stage area

Posted on 2006-11-03
4
195 Views
Last Modified: 2010-04-03
Hi, experts

I use a simple code to load a external image and I want to put it at center of stage, how do I do that ?

:: CODE ::

      this.contentClip = this.createEmptyMovieClip("myTarget", 500);
      this.picture = "netblue/size_sample.jpg";
      this.contentClip.loadMovie(picture);

Thanks,

Brian
0
Comment
Question by:mingchih
  • 2
  • 2
4 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17871508
Hi,

following code will do it for you. just replace your complete code with following:
-------------------------------------
this.contentClip = this.createEmptyMovieClip("myTarget", 500);
this.picture = "netblue/size_sample.jpg";
//
tlistener = new Object();
tlistener.onLoadInit = function(target_mc)
{
      target_mc._x = (Stage.width-target_mc._width)/2;
      target_mc._y = (Stage.height-target_mc._height)/2;
      //
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(this.picture, contentClip);
--------------------

-Aneesh
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 500 total points
ID: 17871517
and if you want to use only loadMovie and still want image in center, then use following code:

--------------
this.contentClip = this.createEmptyMovieClip("myTarget", 500);
this.picture = "netblue/size_sample.jpg";
this.contentClip.loadMovie(picture);
//
this.onEnterFrame = function()
{
      if (this.contentClip.getBytesLoaded() == this.contentClip.getBytesTotal() && this.contentClip._width>0)
      {
            delete this.onEnterFrame;
            this.contentClip._x = (Stage.width-this.contentClip._width)/2;
            this.contentClip._y = (Stage.height-this.contentClip._height)/2;
      }
};
-----------

-Aneesh
0
 

Author Comment

by:mingchih
ID: 17872099
Hi, Aneesh.... I post other question  on EE, can you also take alook at that one ? http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_22048391.html thanks
0
 

Author Comment

by:mingchih
ID: 17872101
Thanks for your answer again :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
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 live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

830 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