Solved

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

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't get text from a text entry 13 282
Can't see Flash on IE Windows Apps - Windows 8.1 4 395
Flash player plugin 13 7 332
Embedded Webpage Videos don't auto play on Windows 7 1 112
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

777 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