Solved

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

Posted on 2006-11-03
4
197 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
[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
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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.
Suggested Courses

630 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