Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-11-03
4
Medium Priority
?
199 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:Brian Lin
  • 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 2000 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:Brian Lin
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:Brian Lin
ID: 17872101
Thanks for your answer again :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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 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 what frame rate is, how to control it and what effect it has on the video.

926 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