Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

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…
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 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.

758 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

22 Experts available now in Live!

Get 1:1 Help Now