Skip to content


the New New BitmapData

In AS3, the MovieClip method attachBitmap is removed. what does that mean for setPixel, getPixel and copyPixel?
The documentation roughly states that addChild is the equivalent of attachBitmap… but only display objects can be “attached” using addChild.
Running addChild(myBitmapData) within a MovieClip or Sprite class throws an error, because it appears that BitmapData is not considered a DisplayObject.

With the previous experiments presentated on this blog, i used the BitmapData.copyPixel method to render states of a sprite. But that was only made possible by loading an image, using BitmapData.draw, (unloading the image), and then passing that BitmapData to a movieclip, attaching a new BitmapData object and copying pixels dependant on user interaction.

There has to be a way to represent this in AS3… but for my first day of trying, i’ve come up empty.

With all the flash 8 experiments out there, has anyone else come across this, and come up with a solution?

As a side note:
I am a huge fan of the new Loader class. Here’s a small sample:
[as]
import flash.net.URLRequest;
import flash.display.Loader;
import flash.util.trace;
import flash.events.*;

class LoaderTest extends Sprite
{
private var __loader:Loader;
private static var IMAGE_URL:String = “myimage.png”;

public function LoaderTest()
{
__loader = new Loader();
__loader.addEventListener(EventType.COMPLETE, onLoadComplete);
var request:URLRequest = new URLRequest(IMAGE_URL);

__loader.load(request);
}

private function onLoadComplete(evt:Event)
{
trace(”load that sucker ” + evt);
}
}
[/as]

…. no more loadMovie / onEnterFrame, or MovieClipLoader (which for some reason seems to crash Flash8 for me).

i guess i should get off the double-underscore train too… i don’t know … my head’s about to burst.

Posted in AS3, Flash.


5 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Anonymous says

    yes I like Loader class as well :) it’s nice. And I like it because now it’s possible situation like this:

    1) create loader, load image to it
    2) after loading you can add loader to any MC, sprite you want….

    so no like in previous versions of Flash, where MC must be created before and then loaded picture to it

    That’s just great :)

  2. franto says

    Just to let you know, previous post is mine :)

  3. sherif says

    I was looking for the replacement of attachBitmap too, and i found this..

    var efxStage:BitmapData = new BitmapData(50,50,true,0xFF3300FF);
    var efxStageBmp:Bitmap =new Bitmap(efxStage);
    addChild(efxStageBmp);

    I’m sure you’ve figured it out, but i thought i’ll still post it, just in case someoine else is looking for it. :)

  4. stufu says

    wtf is this??????

    eventtype????? does not exist
    AND WHERE THE FUCK IS MY LOADED IMAGE???

    “trace(”load that sucker ” + evt);”

    hahhaha how funny

    how do i display it.

    this article = crap

  5. todd anderson says

    @stufu

    I am very sorry i did not respond to your comment earlier. It seems my forwarding email is screwed up…
    I should preface that this post is nearly over 2 and half years old and was presented during the public beta when i was discovering the differences between the AS2 API introduced in Flash 8 and the AS3 API. As a consequence, the EventType class is not a part of the API any longer, and you can add the Loader instance to the display list using the addChild() method.
    Hope this clears it up. I do not intend to update the code here, as it was a discovery post from 2005. If you have any other questions, feel free to ask or look at the online API – http://livedocs.adobe.com/labs/flex3/langref/index.html



Some HTML is OK

or, reply to this post via trackback.