ActionScript 1/2 :: MovieClip Pixel Manipulation With BitmapData
Jan 30, 2010
I have a MovieClip in the library exported for actionscript. How do i convert or attachMovie it to a BitmapData class so that i can manipulate its pixel data? I will need that so that i can distort the MovieClip.
I am wondering if there is any way to set the pixel colors exclusively to black and white (instead of gray) in a bitmapData.noise animation. The previous related thread is: [URL]..For the function:
function makeNoise():void { _bitmapData.noise(getTimer(), 100, 255, 7, true);
Is there any way to set the noise color pattern to black and white? In the scripting reference, it seems the choices are R||G||B||Alpha channels, so I am not sure if there is any way to combine these to get black and white only.
Having trouble trying to scroll BitmapData on a half pixel here is my original code
var speed:Number = 1; _bitmapData.copyPixels(_backgroundParallax, _screenRect, _zeroPoint, null, null, true); _backgroundParallax.copyPixels(_backgroundParallax, new Rectangle(0, 0, speed, _backgroundParallax.height), new Point(_backgroundParallax.width-speed,0), null, null, false); _backgroundParallax.scroll( (speed*-1) , 0);
which works until i change the var speed to .5, which is because .scroll method is expecting int's so i replicated what scroll is doing to try and allow .5 pixels
How can I find a pixel position, based in its color, within a bitmapdata?Say, we have a path drawed (a movieclip), we make it a bitmapdata.The path´s color is red.How can I find a given pixel red, within that bitmapdata?
Using Actionscript 3 is there a way to search one bitmap for the coordinates matching pixels of another bitmap?
[URL]
Somehow you would have to loop through the bigger bitmap to find and the the pixel range that matches and return those coordinates. For example the Bitmap with the "E" is 250 pixels over and 14 pixels down in the bigger bitmap.
I've written a simple MovieClip replacement that converts an existing imported MovieClip to a sequence of BitmapData. This removes the requirement for Flash to render vector data in the MovieClip on each frame.
But BitmapData has a huge memory footprint. I've tried converting the BitmapData to a ByteArray and using the compress() method. This results in a significantly smaller memory footprint. But it has proven impractical. For each redraw, I tried uncompressing()'ing the ByteArray, then using SetPixels to blit the data to the screen, then re-compressing() the frame. This works but is terribly slow.
So I was wondering if anybody else has an approach I could try. In Flash, is it possible to compress bitmap data in memory and quickly blit it to the screen?
I wonder how native animated GIFs work in Flash. Does it uncompress them to BitmapData behind the scenes, or is frame decompression done on the fly?
I am looking for a fairly simple image comparison method in AS3. I have taken an image from a web cam (with no subject) passed it in to bitmap data, then a second image is taken (this time with a subject) to compare this data, from these two images I would like to create a mask from the pixels that match on both bitmaps. I have been scratching my head for a while, and I am not really making any progress. Could any one point me in the right direction for pixel comparison method, something like getPixel32()
I've googled out a lot of different stuff on this matter but nothing seems to work. I have a Sprite object which is used as a main container for other objects.The lowermost child of this sprite is a Bitmap which represents a background, the upper ones are MovieClips. These movie clips contain bitmaps. There are also DropShadow filters applied to these movie clipsThe problem is that when the main container moves, e.g. 1.3 pixels to to the right or to the left (doesn't matter) all those objects (movie clips contained inside of it) move like they snap to pixels. Well,it's obvious, they do. But is it possible to avoid pixel snapping for movie clips and sprites?I tried to set pixelSnapping of the bitmaps inside those MovieClips to "never", but it doesn't work. Removing all filters or drawing movie clip to bitmapdata doesn't help either.
i have a simple movieclip, based off text, with a few frames, and instead of creating an invisible area to do the hit test, is there any way to set the hit area to equal the movieclip's dimensions?, google seems to not be able to provide results, i don't need pixel perfect hit detection, but rectangle detection
I'm having this annoying proble with BitmapData. I try to turn a movieclip into a bitmap, but there is always white space to the right and bottom. At the top and left, it is obvious that part of the movieclip was cut off. However, the width and height of the bitmap are correct. In other words, white space takes up where the rest of my movieclip should go. About 30% of the bitmap is white.I have a method that creates a grid based on an array. The Wall class extends MovieClip. Each wall is a 70 x 70 movie clip that looks like a stone (its x and y are established within the class itself).[code]I have messed around with changing the registration using a class I found online, but it didn't fix anything. In fact, changing the registration made no difference. Also, I have called addChild(walls), and everything is displayed correctly. But for performance reasons, I need to make it a bitmap.
I am trying to snapshot a movieclip at X and Y by WIDTH and HEIGHT. All is fine, it snapshots fine and gets the width and height, but I can't adjust the x and y position for it to begin the snapshot at. I tried using a Matrix and its Matrix.translate() method, I tried moving the scroll beneath the draw method line. I don't understand how to get this thing to move.
I know half of the problem:the embedded movieclip is "content" of a Loader, and you can not draw Loaders directly with bitmapData.draw(aLoader);with a normal Loader, you could access the Loader.content and draw it but not in the embedded case.adobe forums could not give an answer to this and i searched for hours through the web ...
[Embed(source="aMovieClip.swf")] private static var AMovieClip:Class; //...
I've been looking for a solution for hours now. I have a movieclip which contains an image. Created by doing: put image on stage, convert to symbol, movieclip type, ok.I'd like to extract this bitmap because I want to use (somewhere else): graphics.begintBitmapFill(); but this method needs a BitmapData object and not a movieclip to create a repeating background (in my case).
So: how do I extract the Bitmap or the Bitmap data from a MovieClip?mind that attaching BitmapData as a base class to this symbol is NOT AN OPTION
I have a movieclip with an image that has transparency and filters applied to the movieclip.I know I can use "draw" to copy the movieclip to a bitmapdata object, but it doesn't seem to copy the filters and the transparency of the image. How can I copy these so the bitmapdata matches the original movieclip in appearance?
I'm trying to use BitmapData Class to capture an animated movieclip and adding it to the display list by using addChild, but it's causing my computer to bog down because it's adding a zillion children. what do I do to remove the old, or rather, update the current child with the new one?
I'm building an application where the user can upload a photo of their head, scale it and position it, and then pick a colour from the photo.The photo gets put into a movieclip called 'head'I'm stuck at the colour picker part and I just can't seem to work out the whole bitmapData thing. Here's my colour picker code -
ActionScript Code: private function beginColourPick():void { _bmd = new BitmapData(head.width, head.height);
[code]...
This code kind of works, but not correctly.
Problem #1: The colour picker only works in the bottom right quarter of the image because I moved the head mc so the registration point is bang in the middle. So the problem here is that I can't figure out how to move the bitmapData in line with the head mc.
Problem #2: If the user scales the head mc (even a tiny bit) the colour picker stops working altogether. Now I'm thinking I've got to use a transform matrix - but I read up on it and haven't got anywhere.
When you load an image into a MovieClip then use that as the data source to draw() into a BitmapData object, the documentation says "Optionally, you can specify whether the bitmap should be smoothed when scaled. This works only if the source object is a BitmapData object." To me that implies that a second BitmapData object is needed in order for the optional [smooth:Boolean] parameter to work when set to true.
We found we didn't need to "double buffer" in this way when using MovieClip.attachBitmap() with the [smoothing:Boolean] parameter set to true. We did run into another problem though. This problem only manifests itself when you run the SWF as part of an HTML file running from a local web server like http://127.0.0.1. Here's the problem: images are loaded dynamically (URL's pulled from assets.xml) and the ones that are loaded locally from a directory on the same machine load and are smooth and distortion free. Other URL's point to a remote host. The images loaded via a remote source (example) do not "smooth nicely" running the exact same code as the local images. The remote images are shimmery and exhibit update artifacts. If you run the exact same page not via an http:// web sever i.e. - just loading the html page into the IE, then the remote images do get nice smoothing when animated.
Is there some magic to get BitmapData loaded from a remote source to smooth correctly when run from a local web sever? For our internal demo we removed any remote URLs so we could demonstrate that Flash does provide the ability for nice smooth animations but it would be a good problem to solve.
As u must have noticed, the movieclip i wanna draw, namely _root.VESSEL, itself contains several other clips (eg _root.VESSEL.db). The problem is that the clip doesnt get drawn at all! All i get is a white rectangle of the size i've created the bitmapData. But nothing of that movie clip has been captured.
is it that the BitmapData cannot capture the details of a clip if it has child clips?? Coz here, VESSEL itself was created empty, and all the new shapes are actually being placed as movie clips inside other empty clips that were created in VESSEL.
When I publish the file, I'm getting the following error message in the Output panel:
**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 7: The class or interface 'BitmapData.loadBitmap' could not be loaded. var plaid:BitmapData.loadBitmap("plaid");
I am trying to use the reflect class from "http://pixelfumes.blogspot.com/2007/03/reflection-class-v3-with-source .html" but I keep getting this error:
ArgumentError: Error #2015: Invalid BitmapData. at flash.display::BitmapData() at Reflect() at Site_fla::GalleryPage_29/loadThumbs() at Site_fla::GalleryPage_29/sortXML()
[Code]...
btw, first I used assigned thumbContainer as the mc argument (outside the loadThumbs() function) and it worked but not exactly what I wanted... because I thought it is supposed to update when the movieclip is animated but it actually didn't... when I use a scroller, only the thumbs that are first loaded to the stage get the reflection..
I've been using BitmapData.copyPixels() to draw graphics onto a canvas (Bitmap).I need to rotate the resulting graphics without the use of draw() because it's vastly slower.How can I rotate the target graphic? I'm assuming that there might be a formula or library that I can use which will first reorganize the pixels that make up a graphic based on an origin (point) and radians.I'm pretty certain that I'm not capable of creating such logic, so if there are any known libraries that do this, that would be awesome.I'd like to achieve something similar to XNA's SpriteBatch.Draw() method, which accepts rotation as its 5th argument.
how to use the bitmapData collision method. Now I'm trying to figure out if there is a way to see at what angle or coordinate of the bitmapData the collision happens? I need it in order to figure the accurate bounce angle after the collision occurs.
I'm currently working on a flash game and I need to know how to addChild a BitmapData or draw a BitmapData to screen. If I can't than how can I give a DisplayObject my BitmapData?
I've made a mobile version of my software, with low-res images and such, and I can now fully buffer all my content (including a 360 frame animation which is buffered to memory). Problem is, that everytime I update the view, more memory is used.When I write image = new BitmapData();, does it store the previously created BitmapData's in memory? Do I have to flush the memory somehow before I draw my second picture in BitmapData?Example:
ActionScript Code: // In this example I draw using the same bitmapData several times, also //overwriting the first image. Do I have to somehow delete the data first, to
Using AS2 or 3, is there a way to create my own file format? I would like to create a game.And when users play the game, they can create a GAME-SAVE-FILE.So, let's say that player 1 is playing... He get's to level 22 and has to sign off.He clicks save my GAME-SAVE-FILE to my computer.He names the file MyGame and saves it to his desktop.So now on his desktop he has MyGame.gsf. Next time he visits, he can click on UpLoad My Saved Game.He selects his previously saved MyGame.gsf And bammo... all the information was stored in his file and now he can play on.
I need to know how I would put together the format for my own file-type / extension.I need to know how I would access, write, and edit my own file-type / extension.Since Flash can do this type of File Manipulation with PNG's and JPG's.So surely it can be done with any desired custom format.