View comments | RSS feed

loadBitmap (BitmapData.loadBitmap method)

public static loadBitmap(id:String) : BitmapData

Returns a new BitmapData object that contains a bitmap image representation of the symbol that is identified by a specified linkage ID in the library.

Availability: ActionScript 1.0; Flash Player 8

Parameters

id:String - A linkage ID of a symbol in the library.

Returns

flash.display.BitmapData - A bitmap image representation of the symbol.

Example

The following example loads a bitmap with the linkageId libraryBitmap from your library. You must attach it to a MovieClip object to give it a visual representation.

import flash.display.BitmapData;

var linkageId:String = "libraryBitmap";
var myBitmapData:BitmapData = BitmapData.loadBitmap(linkageId);
trace(myBitmapData instanceof BitmapData); // true

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());

Version 8

Comments


liquid_sound said on Jan 2, 2006 at 1:03 AM :
this example does not appear to work, it always traces false for me. ( yes I have created the proper library symbol and selected export for actionscript )
pganaye said on Jan 6, 2006 at 3:54 PM :
In the library, right click the bitmap and then linkage.
Check the boxes : 'Export for ActionScript' and 'Export in First Frame'

Worked for me
panorezo said on Jan 16, 2006 at 5:28 AM :
To use dynamic loaded image with bitmapdata, first load your image into a movieclip with loadmovie method, and when image is fully loaded, use the "draw" method of bitmapdata class to get content :

var mcPict:MovieClip = createEmptyMovieClip( 'mcPict', 1 );
mcPict.loadMovie( 'myPict.png' );
// test loading...

// after set image
var curImg:BitmapData = new BitmapData();
curImg.draw( mcPict );
Juise said on Feb 22, 2006 at 1:34 AM :
Seems that symbol has to be bitmap - loadBitmap cannot get movieclip´s bitmap data.
isite_peter said on Mar 21, 2006 at 4:58 PM :
liquid_sound said: "this example does not appear to work, it always
traces false for me."

It will fail if you use "new" like this:

var myBitmapData:BitmapData = new
BitmapData.loadBitmap(linkageID);

It works (for me, anyway) if you omit the "new":

var myBitmapData:BitmapData = BitmapData.loadBitmap(linkageID);
YanPak said on Apr 11, 2006 at 4:49 AM :
loadBitmap work only with bitmap data, but not with instances of symbol (MovieClip, Button, Graphic) in library.
Therefore, allways for this method use source(imported) bitmaps in library, and don't forget to check the boxes "Export for ActionScript" and "Expotr in first frame" in Linkage...
No screen name said on Sep 17, 2006 at 1:10 PM :
There seems to be some problem either with the example. No matter if I link bitmap image, gif, jpg or symbols the loadBitmap doesn't seem to work. am i doing something wrong?
dafreq said on Apr 9, 2007 at 2:06 AM :
instead of
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
there should be
mc.attachBitmap(myBitmapData, mc.getNextHighestDepth());
pisikopatikalistor said on Jun 18, 2007 at 9:57 AM :
panorezo, thanks a lot I was searching for this, exactly
mal.seq said on Jul 21, 2008 at 4:59 AM :
this didn't even work for me... it always traces false.
Could you please tell me what should be the type (MovieClip, graphic or button) of the symbol in the library as in..

var bmpdata:BitmapData = BitmapData.loadBitmap("bbmp");

where bbmp is the LinkageId of a MovieClip in the library.

is this correct ?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00001959.html