Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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.

839 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