Actionscript set image

Is it possible to set an image at run time to an image already in the libary?

Im currently using a loader, but need to have the images on the hard drive, and would like to use the libary.

Im currently using javascript as
loader.contentpath = "22.jpg";

but would like to specify and image in the libary like:-
loader.content = "22.jpg"

Any ideas?

Who is Participating?
Antonio EstradaConnect With a Mentor Tech Leader / Senior Web DeveloperCommented:
It does, it's called attachBitmap... here's an example:

You have to right click on your images of the library and give them a linkage identifier in order for this to work. (It's the string you'll need to use on the BitmapData.loadBitmap("linkage") method).

myButton.onRelease = function() {
	import flash.display.BitmapData;
	var bitmap:BitmapData = BitmapData.loadBitmap("kamlogo");
	this._parent.createEmptyMovieClip("myBitmap", this.getNextHighestDepth(),{_x:30,_y:30});
	this._parent.myBitmap.attachBitmap(bitmap, 2, "auto", true);	

Open in new window

I don't think it's possible to do that with the is for loading external objects.

You will need to put the images in movieClips and pull them out of the library with attachMovie

actually thinking about it..if the images are in the library and exported for actionscript in the first frame..then they are in cache..and even though the loader call is external they should be pulled from cache..which is the same ..only pulling them from the library. yeah?

tonelm54Author Commented:
Is it possible to use something like attachImage?
All Courses

From novice to tech pro — start learning today.