?
Solved

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

Posted on 2007-11-20
2
Medium Priority
?
1,072 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

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