Solved

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

Posted on 2007-11-20
2
1,031 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

758 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

19 Experts available now in Live!

Get 1:1 Help Now