I am trying to use the bitmapData.setPixels method to set certain pixels in the bitmap transparent.But no matter what I do, it always seems to set the pixel(s) black (non-transparent).Here is my code:
[AS] bmpd = new ImageFromLibrary(0, 0); bmpd.setPixel(0, 0, 0x00000000); [/AS]
I'm trying to get my head round bitmapData and everything you can do with it. I'm using pure AS3 at the moment.I've been playing with some Perlin noise examples - worked ok - and tried writing another image (png) onto the bitmapdata.The new image is EMBEDed in the as3 code:
Code: [Embed(source='icon.png')] private var ImageClass:Class; private var img:Bitmap = new ImageClass();
I write the perlin noise to the BitmapData thus:
Code: var bmd:BitmapData = new BitmapData(200, 200, true, 0x00000000); bmd.perlinNoise(baseX, baseY, octaves, seed, stitch, fractal, channels, grayscale, offsets); var bm:Bitmap = new Bitmap(bmd);
In the 4th line in the code above i am getting "Error: Error #2030: End of file was encountered." I checked the length of the pixels object which is 4 times the width*height of the rect object. Given that setPixels() functions reads unsigned int from bytearray and sets that value to pixels, I think it should work.
But I have no clue why this wont work. The pixels object is filled after RLE decoding of the data which i get from a server.
Is there any work around or any other method which I could try to use. The loader class wont work as the data that I get from the server is not in any of the recognized format.
I am trying to retrieve the ByteArray from a file selected using the FileReference class so that I can pass this to a Web Service call that I am making to Sharepoint.Is there any way I can do this using Flash Player 9 without having to upload to a remote server first and then downloading the file to extract the ByteArray?
This is assuming you can't use Adobe Flash Player 10 and the data property from the FileReference class.
I'm trying to write the RECT structure described on page 20 of the SWF specification to a ByteArray. I started with some Java code from Adobe that does the same thing (but in Java, not AS3).
This is my adaptation so far: PHP Code: public static function writeRect(bytes:ByteArray, rect:Rectangle):void { bitPos = 8; currentByte = 0; var left:int = rect.left * 20; var right:int = rect.right * 20; var top:int = rect.top * 20; [Code] .....
It seems like the right calls are being made to writeBits, because the values make sense as multiplied forms of the Rectangle dimensions: Code: writeBits 14 5 writeBits 0 14 writeBits 8000 14 writeBits 0 14 writeBits 5000 14 So, something seems to be wrong with how it's writing the last field (or how it does its bit/byte position bookkeeping overall), but I've been trying to debug this code for quite a while without any luck.
The documentation says that clipRect parameter of the BitmapData.draw method sets clipping for the source.Reading this I wrote an AnimatedObject class for my potential flash game. This class draws a frame from a .png animation strip, and doesn't work with Flash scene hierarchy.
I am trying to serialize a Bitmap to store in an XML file. My plan is to turn the BitmapData into a byteArray, but I haven't been able to fine an example of this.
i want to do some cryptographic routines in my flash. I've encrypted .jpg files on my server, so I can't use simple Loader class, to download that data as Bitmap. I'm thinking to:
1) download it with URLLoader as BINARY data in ByteArray class.
2) decrypt the data
3) convert to BitmapData. (..., is this possible ?
I need a function to change an ByteArray to BitmapData in 1 function:
makeBitmapData(bytes:ByteArray):BitmapData
Is this possible? Cause all I can find about this is first put the bytes in a loader. add listener to the complete event and then call a function that make the bitmap/bitmapdata. can this also be done in 1 function?
is there anything that will take a very large png (even larger then the total pixel limit of BitmapData) and load in the png as raw bytes into a bytearray and then take that array and grab only portions of the image to be able to generate a grid of usable bitmaps to render the very large png..I got to the point where I was able to get the png as a bytearray but from there I don't know how to grab a portion of the bytearray and attempt to load the partial bytes in a loader via loadBytes()..basically I think I need a decoder to decode the partial bytes to a bitmapdata.
I'm trying to grab the BitMapData from an Image, convert it to JPG, and send it to a server where it will be written to a file. It "looks" like it works, the resulting .jpg is the right size and displays in an image viewer, but there is no picture... just an off-white background. Here's a code snippet:
imgTemp.addEventListener(FlexEvent.UPDATE_COMPLETE , imageLoadedHandler); ... private function imageLoadedHandler(event:Event):void { if (imgTemp.width == 0) return;
[Code].....
Then send "ba" to the server where it's written as a .jpg.
The data "looks" right when I receive it on the server, correct length, bits look the same.
overriding clone() while creating custom events?I read in the Flex cookbook that we need just in case we want to redispatch this event. Does this exactly means that when we want event to be bubbled up the display hierarchy , at that time our custom cloned event should be dispatched and not the Event object.
second - whats the need of metadata tag - [Event(name="modelEvent", type="com.abc.data.model.ModelEvent")] public class LoginModel extends EventDispatcher I understand we need to extend EventDispatcher in case we want to dispatch evnet from class.. but In what cases i would need to specify the MetaData TAg
Third is.. If i write -- "dynamic customEventClass extends Event".. Is there any use of Dynamic i can make?
I'm trying to take a 'snapshot' of a movieclip that i've got on the stage with "BitmapData" and then starting a "draw()" command on it. I'm able to get it drawing.. however.. it only takes the things from (0,0).( the upper left corner of the movieclip. Doing a trace on "BitmapData.rectangle" gives me it's X and Y coordinates .. and it's width and height..
How do I change the X and Y locations of the BitmapData for it to start the drawing from? As I have some stuff on the negative side of x.
i am rendering a BitmapData from my webcam and sending the rendered ByteArray(i cant compress using ZLIB because its not running on AIR) file as binary to a server side. problem is each JPEG picture is around 40kb and it needs to be compressed a bit.now i am not talking about resizing the image, just making the file size smaller. anyone know how to do this?
I was working on some blitting code today and after profiling it found that I was creating 1000s of new rectangles. I was shocked because I only had 1 or 2 different new Rectangle() calls or I was using the .rect property of BitmapData.
I started commenting out huge swathes of code until I was left with this code in my sprite class:
After seeing the I've been told that movieclips aren't suited for games, what do you use? thread, I thought I would try to incorporate the approach into a game I'm currently programming to make it a little less processor intensive.
I have a giant movieclip of a football field, of which only 5-10% is shown at any given time. I'm guessing that flash still has to make calculations for the other 90-95% of the field every frame, even though it's of no use. From what I understand (not much), copyPixels seems like the perfect candidate for such a situation.
It seems simple, but I'm having trouble actually implementing it, and I'm not sure which actions are needed and what might be introducing unnecessary work. I have a movieclip (mc_field, exported for as), but if it would save the processor some effort,I could easily save this as a bitmap and export that for actionscript. The width and height of the final product (bitmap/BitmapData) will be Stage.width, Stage. height,respectively,and I can handle making the calculations of the x,y coordinates of the rectangle cropping (which part of the source bitmap I want to crop).I'm sure it's only 3 lines of code, and I know that there are a few examples online, but for some reason.
Say, for frame one, I want to take the field (either mc_field or bm_field) and copy 500px x 300px, starting at 140,230 from the source bitmap to mc_container.Then, for frame two, I want to copy 500px x 300px starting at 240,540 from the source bitmap to mc_container.
I would like to learn Adobe Flex mobile development.I have created a new project called SampleProject, then I got SampleProject.mxml in default package and SampleProjectHomeView.mxml.[code]How can I call the add and sub methods from the class above in SampleProjectHomeView.mxml?
I have a BitmapData with 2 red circles. I want to find the rectangle area or each circle. If i use [B]getColorBoundsRect[/B] I get the smallest area enclosed by the 2 circles. How can i go about this and get individual area of the circles?
I can read an image from hard drive and get a ByteArray from its source. Is there any way to store those bytes in local SQL database? What datatype for this field I need to choose?Or maybe there is a more clever way to save an Image file itself into AIR SQL?..
I would like to generate a sound in Adobe Air using ByteArray. The sound should be a silence of x seconds. I found this code that I am using to generate the bytes:
private function encode(data : ByteArray) : ByteArray { var channels : uint = 2; var bits : uint = 16;
[Code].....
But when I save the file using Filereference and import it into a flash file I get an error message saying that there were problem reading the file.
I want to drag one movie clip within specific region. For that I have created one rectangle with following var rectangle:Rectangle = new Rectangle(52.75, 5, 100.25, 0); Though I have given x position 52.75 ; i can drag movieclip to x position - 52.
I found out how to make for example a rectangle via the LineTo method. But how can I change the size of this rectangle and SEE it changing (ie a tween), not jumping from one format to the other? I guess it has to do with using "elapsing time" in the actionscript? I find it hard to get info on this subject. Though it seems important because otherwise it is impossible to create animations.
Does the uncompress method of ByteArray only supports level 3 compressed streams? Because I have a valid zlib compressed file but compressed in level 2, and Flash always throws me the 2058 error message.
I've also tried using the DefaultCompressionAlgorithm class for AIR with its two compression methods, but with no success.
Doing some quick tests with python using the same file gets uncompressed with no problems.
My idea was to create a method for drawing rectangle with rounded corners, but while being able to specify which of the four corners (any, all, none,etc.) you wanted to round. The method below does the trick, but for some reason my corners don't match the same curves that I get using the same radius with drawRoundRect(). In other words, if I call my method (and set all four corners to be rounded) and compare that with the same call to drawRoundRect() the actual curves of the corners are slightly different.
HTML Code: public function drawComplexRoundedRect(startX:int,startY:int,rectWidth:int,rectHeight:int,radius:int,canvas:Sprite,roundTopLeft:Boolean=false,roundTopRight:Boolean=false,roundBottomLeft:Boolean=false,roundBottomRight:Boolean=false):void{ if(roundTopLeft){ canvas.graphics.moveTo(startX,(startY+radius)); [Code] .....
Then compare HTML Code: var canvas:Sprite = new Sprite; drawComplexRoundedRect(0,0,200,200,25,canvas,true,true,true,true); with HTML Code: var canvas:Sprite = new Sprite; canvas.drawRoundRect(0,0,200,200,25); and you will see the two rectangles are not identical.
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?