Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-11-03
4
Medium Priority
?
198 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 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: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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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 this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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…

688 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