# PixelMover class - explode & contract pixels and stuff

**URL:** <https://forum.kirupa.com/t/pixelmover-class-explode-contract-pixels-and-stuff/241935>\
**Category:** open source\
**Created:** [October 19, 2007, 4:47pm UTC](https://forum.kirupa.com/t/pixelmover-class-explode-contract-pixels-and-stuff/241935 "2007-10-19T16:47:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tylerdudley1986](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tylerdudley1986](https://forum.kirupa.com/u/tylerdudley1986)\
**Post date:** [October 19, 2007, 4:47pm UTC](https://forum.kirupa.com/t/pixelmover-class-explode-contract-pixels-and-stuff/241935/1 "2007-10-19T16:47:55Z")

</div>

Hello, not sure if anyone has done stuff like this before, so thought I would post it and see what people think.

**Try it:**  
[http://flash.sitdap.com/pixelmover](http://flash.sitdap.com/pixelmover)

**Download source:**

…you create an instance of pixelmover, and give it a sprite with any graphics in.

\*\*[U]methods:

[/U]\*\***spreadPixels(maxRadius:int)** - **maxRadius default value is 200**

- will randomly splay the pixels of your given sprite about the place, staying within the maximum radius  
**movePixels(speed:int)** - **speed default is 6, lower is faster.**
- at the moment, all this does is move back the pixels to their original position, then when they arrive it fades back to the original bitmap and removes itself from its parent. When it is all done, it dispatches an event called " **PIXELS\_MOVED"**.

so this is how I would use it:

```auto

var myPixelMover:PixelMover = new PixelMover(mySprite);
myPixelMover.spreadPixels(100);
addChild();
myPixelMover.addEventListener("PIXELS_MOVED", moveHandler);
myPixelMover.movePixels(4);

function moveHandler(evt:Event) {[INDENT]trace("the pixels are back where they were")
[/INDENT]}

```

…It should adapt to any size you make your sprite, but I fear about performance issues with so many pixels and all.  
Comments are welcomed - bad or good as I don’t know whether everything is fully efficient as it could be. Feel free to add to it if you think it needs something!

cheers,  
TD
