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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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?
Antonio EstradaTech 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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.