View Full Version : AS3 Load an image into a MovieClip

02-22-2012, 11:32 PM
I have a movieclip 'MainImage', what i need to load an image into, also the image needs to be centered in it too.

Can anyone give me a hand sorting this out?

02-23-2012, 12:56 AM
loadMovie() into a MovieClip and loadMovieNum() were used in AS2 [I have to check my syntax here]

Let me also check my notes on AS3 Loader class methodology.

So the basic question is: Are you using AS2 or AS3?

02-23-2012, 01:06 AM
Im using actionscript 3.

I've just found this

//URL of the external image content
var myRequest:URLRequest=new URLRequest("images/3.jpg");

//Create a new Loader to load the image
var loader:Loader = new Loader()

//Load the external image into the Loader

// Listen when the loading of image is completed

function loadTheImage(evt:Event):void {
//Display the Loader on the MainTimeline
//The holder_mc (new symbol) was created before by:
Insert -> New Symbol -> Select MovieClip
Give this new symbol any name you like (e.g. MyImage)
Return to the scene.
Drag the MovieClip (e.g. MyImage) into your scene from the Library window
Give the instance name of this MovieClip "holder_mc"

You can add fun to the picture showing up, e.g. TransitionManager
Remember to add Classes to use the Transition Effect at the beginning
import fl.transitions.*;
import fl.transitions.easing.*;

Please see "Transition Effect + Tween Animation (2)"

TransitionManager.start(holder_mc, {
type: PixelDissolve,
direction: Transition.IN,
duration: 3,
easing: None.easeNone,
xSections: 20,
ySections: 20


That loads the image into my movieclip however its not centered,but im not sure why, will i have to mess with the margins to get it centered?

02-23-2012, 02:02 AM
For AS2 see http://www.verticalmoon.com/tutorials/swfnslide/loadmovie/loadmovie.htm

... add the loadMovie command to the maintimeline.The first parameter is the name of the .swf file you want to load and display. The second parameter is the instance name where you want the movie to be loaded in to.
loadMovie("slideshow.swf", holderMC);

For AS3, see http://www.iheartactionscript.com/loading-an-external-swf-in-as3/
http://kb2.adobe.com/cps/141/tn_14190.html ]covers both AS3 LOADER class and AS2 loadMovie() method]