Solved

how do you load an internal image from the library into an empty movie clip?

Posted on 2007-11-20
2
1,039 Views
Last Modified: 2008-02-01
I want to make an image viewer where the user clicks a button to create an empty movie clip which will automatically load a jpg from the library. It will also hav a button which will always remove the movie clip when pressed.

Is this possible? if so any help will be greatly apreciated!
0
Comment
Question by:sousflai
2 Comments
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 500 total points
ID: 20325809
First you have to assign a linkage identifier to the picture you want to be able to load dynamically; to do so, do this:

1. On the library, right click on the file you want to load dynamically.
2. Click on linkage.
3. On the checkboxes below, tick the Export for ActionScript checkbox, and it will automatically tick Export in first frame and it will also enable the Identifier textbox.
4. On the Identifier textbox enter whatever text you want to use to identify the picture. (For now just use "myPictureIdentifier" without the quotes).
5. Click ok.

Now, assuming you have a button named "myButton", add this code on the main timeline:

<code snippet>

Good luck.

-V
myButton.onRelease = function() {

      import flash.display.BitmapData;

      var bitmap:BitmapData = BitmapData.loadBitmap("myPictureIdentifier");

      this._parent.createEmptyMovieClip("myBitmap", this.getNextHighestDepth(),{_x:30,_y:30});

      this._parent.myBitmap.attachBitmap(bitmap, 2, "auto", true);      

}
 

myRemoveButton.onRelease = function() {

      removeMovieClip(this._parent.myBitmap);

}

Open in new window

0
 

Author Comment

by:sousflai
ID: 20325824
wow, Im suprised its that complicated, thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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 …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to how to record live broadcast.

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now