ActionScript 3.0 :: Convert Loader Object To BitmapData?
Jun 30, 2011
I am writing a script in which i want to do collision detection with Bitmap. Actually i took the script from book. I am using Loader class instead of Embed tag because i am using Flash IDE CS 5. If you see the code then everything is fine except one thing. That in hitTest() method i am using Loader instead of Bitmap. So it gives me error that parameter type should be Bitmap. Now my question is how can i convert Loader object to Bitmap so i can use it in my hitTest() method. Here is my code
[Code]...
View 3 Replies
Similar Posts:
Dec 23, 2011
I use the loader class to load some png files to the stage. The function that is called after the file is loaded is something similar to this:
private function IconLoaded(e:Event):void
{
percentLoaded_txt.visible = false;
iconLoader = Loader(e.target.loader);
[Code]....
imgBox is a class that auto resize the bitmap and allow also to add border for example...
My code works fine, to load PNG files. But I want also to be able to load swf files.
View 2 Replies
Nov 14, 2009
Can a flash.display bitmapData object be converted to flash.displayObject?i bump with an error when i tried to convert a bitmapData to DisplayObject
=> setChildIndex(DisplayObject(bitmapData),0);
"TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::BitmapData@35f4779 to flash.display.DisplayObject."
[code]....
View 3 Replies
Mar 27, 2012
The code below is a simple add and save program. You press the addButton to add content to the canvas and than press the exportButton to save an image of the canvas in its current state to your desktop. This code works fine when I add circle objects to the canvas that are drawn to the canvas. The problem lies when I try to load a .png into the canvas. Once the loaded content is added to the canvas the exportButton stops working all together and no longer responds. What is causing the loaded content to break the code?
[Code]...
View 1 Replies
Oct 10, 2011
I need to do this conversion so that I can determin the drag drop colour a puck lands on.
possibly involving:
ImageSnapshot
BitmapData
This would be in Flex 4
View 1 Replies
Aug 23, 2011
I have converted a jpg image to Base64 string and saved somewhere. Now How can i convert this Base64 encoded string to bitmapData in flash as2?
View 1 Replies
Dec 29, 2009
The title might be a little misleading. Look at my code and I will explain
public static function loadTile(tileDir:String = "empty"):void
{
if(tileDir != "empty")
{
tPoint = new Point(0,0);
tRect = new Rectangle(0,0,30,30);
[Code]...
I am trying to do tiling with sprites. I want my tiles to be interactive, so that is why I am using the sprite object instead of using regular bitMaps to represent my tiles. You might be wondering why I wouldnt just use graphics.beginBitmapFill(tImage); and graphics.drawRect(0, 0,tWidth ,tHeight ); to pick out the tiles I want to use. Well reason being is because it turns out that drawRect() first and second parameters actually alter the location of where the actual sprite sits at.
So if I set the x and y properties of the sprite to x = 20, and y = 20. then I set my drawRect(20,20). it actually adds an extra 20 pixels to my x and y coords of my sprite. And I know the reason why, I just need to know a better way.
View 2 Replies
Feb 16, 2011
I'm trying to trace the path of an object by using setPixel on the object's position every frame in a BitmapData/Bitmap pairing. These pixels aren't showing up normally and I suspect I have a fundamental misunderstanding of the BitmapData class. Here's what I'm doing:
public var contrailBase:BitmapData;
public var contrail:Bitmap;
private var contrailColor:uint;[code].....
Using this code, the red pixels don't show up. If I initialize contrailBase to 0xFF000000 instead then I get a black screen on which the red pixels DO draw, but I need the bitmap to be transparent except for the contrail. What am I doing wrong?
View 2 Replies
Mar 25, 2010
So I have this Photo class than handles loading a pic, and dispatches an event when the loading is done with:[code]which is simple and works, but now I'd like to make something more advanced. I'd like to dispatch the load ratio.So far I have extended the Event class, with my own EventRatio class, and I can put properties on that class. Which is cool, but I need something more dynamic than just sending a fixed value.So, what is the best way to connect the Loader object of the Photo object, with the EventRatio object?
View 5 Replies
Jan 3, 2010
I am loading a series of images from an XML file into Loader() objects, but I am having some issues with what I want to do with those images afterwards.
I need to set the size of the images to thumbnails for a sliding chooser and since the images are various widths, I cannot use a constant. I have to get the Bitmap from the contentLoaderInfo:
//This is found within an array loop and loads for each picture in the XML file (actually, every other pic)
picLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadChooserImages);
function loadChooserImages(evt:Event):void{
[Code].....
View 7 Replies
Jun 29, 2011
Do you know why this AS3 code works:
var loader = new Loader();
loader.load(new URLRequest("http://127.0.0.1/items/boing.png")));
var o:DisplayObject = addChild(loader);
o.x = 100;
o.y = 100;
But if I cast to sprite it doesn't work? Ie the sprite appears on (0, 0) instead of (100, 100):
var loader = new Loader();
loader.load(new URLRequest("http://127.0.0.1/items/boing.png"))
var o:Sprite = Sprite(addChild(loader));
o.x = 100;
o.y = 100;
How would I properly have a sprite instead of a DisplayObject? I need some sprite's features (drag'n drop, useHandCursor...), yet I wish I could still use the very quick writing with the loader.
View 2 Replies
Oct 12, 2009
I've seen mention of there being some security risk with loading images and leaving them in loaders. A few articles I've run across said that you should always draw them as a bitmap when the loading is done.
Is there any truth to this? I have a few loaders I have left in my project, do I need to hand their content off to a bitmap? What is the advantage of always having a bitmap represent the loaded image?
View 9 Replies
May 17, 2005
Allright, i receive a string and want to convert it to object. here a test that i have made:
[code]....
this work pretty fine... but i am receiving the object property as follow: "{a:'test',b:'testAgain'}" How can i easily convert it to object properties?
View 4 Replies
Jul 1, 2011
How to dynamically add attributes to an object and convert that object into xml in Flex/Actionscript?
View 1 Replies
Oct 11, 2009
Flex 3, ActionScript 3, Flash player 9.
I have a picture in a BitmapData object. And an array of points. I nead to erase the part of the picture inside a polygon specified by the points. In other words, draw a polygon specified by the points and fill it with transparency.
View 2 Replies
Dec 28, 2009
I have 3 objects. One BitMap that acts as my canvas. And 2 bitmapDatas. One is my buffer and another is my tiles. I am creating a tiling effect for a game. I would like to take my tile:BitMapData, and turn it into a custom object. reason being is I want each tile to be interactive. So I can click on each one. Is it possible to turn my bitMapData that represents a tile, into a custom object that has properties and methods. Sort of like a movie clip. and draw it into my buffer ?? Could I create a new class that extends bitMapData ?? Or would I have to get rid of the buffer and draw the tile objects directly into the BitMap ??
In other words, what is the best way to put Sprite or a tile into a BitMapData object or even a Bitmap.
View 2 Replies
Aug 23, 2011
I have converted a PNG into a bitmap, then converted that into bitmapData.
I have a object called _player, and I wish to add collision detection, however I can seem to get it to work.
my code is:
if(bmd1.hitTest(new Point(_player.x, _player.y))){
trace("hit");
}
bmd1 is my bitmapData,_player is the object is wish to test against.
I am getting the following error:
1136: Incorrect number of arguments, Expected 3
I have looked around but cannott find what argument I am missing
I have tried
if(bmd1.hitTest(new Point(_player.x, _player.y), 50, _player)){
trace("hit");
}
I should mention that the reason for me taking this approach is that I have a PNG, with transparent areas, I need to test for collisions in the non-transparent areas, which is why I was using this approach
I have a PNG, i import that and convert to bitmap, then convert to bitmapData
View 3 Replies
Sep 30, 2009
I'm really struggling to work out how to split a BitmapData object into two separate bjects, and eventually add them to a mc and animate them.I can successfully create a new Bitmap out of the left half, but when I try changing the Rectangle props for the second Bitmap draw method to make a Bitmap out of the right half, it doesn't work?Here's my code:
ActionScript Code:
// 'image' being a MovieClip on the stage
var bit1:BitmapData = new BitmapData(image.width*0.5, image.height, true, 0xff000000);
[code]....
View 4 Replies
Sep 4, 2007
I am trying to create a BitmapData object of a jpg that is loaded into a movieClip, so that I can then remove the jpg and have just the BitmapData of the image to manipulate. I have the original image loading into my temporary MC without any problems..and am using a listener to check to make sure that the image has been fully loaded before it moves onto creating an empty movie clip for the BitmapData... but for some reason the BitmapData isn't working as nothing shows up in my holderMC.. and it says the width of the holderMC is 0 when it should be something liek 367 for the 'surf.jpg' test image I am using. My code is below..
Code:
import flash.display.BitmapData;
stop();
_root.createEmptyMovieClip("tempMC", 1, {_alpha:0});
[Code].....
View 1 Replies
Dec 30, 2009
I have a BitmapData object with an alpha channel. I'd like to know the fastet way to offset that alpha channel in ActionScript3 (FlashPlayer10). By offsetting I mean shifting all pixels of that channel in one direction (wrapping around the image borders) while leaving the color channels as they were.Is there a good way to apply a such a transform to one channel only?
View 2 Replies
Nov 17, 2010
I want to store the bitmap data from _sampleTile in array, but I was wondering how to increase the performance. If I do it like this:
var _sampleTile:BitmapData;
var _arrayLenght:int = _tileClipArray.length;
for(var i:int = 0; i < _arrayLenght; ++i){
[code].....
View 1 Replies
Mar 31, 2009
In Flash, the BitmapData object can be used to store bitmaps in RAM, you can later draw them to a MovieClip using the beginBitmapFill() method.
How do you load an external bitmap file (.jpg) into a BitmapData object?
View 5 Replies
Feb 6, 2011
I have the following display hierarchy:- - container- - - objectI need to draw 'object' to a BitmapData instance which matches object.getBounds(stage) rectangle area. So the first part is easy:
ActionScript Code:
var rect:Rectangle = object.getBounds(stage);
var bmp:BitmapData = new BitmapData(rect.width, rect.height, true, 0x00000000);
[code]......
View 2 Replies
Apr 8, 2007
I've been looking at one of senocular's rather brilliant source files, specifically the 'rising grid transition', which performs a transition effect by using the bitmapData class. Currently,it loads a variable called 'tempbmp' by using the bitmapData.loadBitmap function:
var tempbmp = flash.display.BitmapData.loadBitmap('hill');
where hill is a jpg in the library with a linkage ID of 'hill'. what i'd like to know is if this process could use an image that is not in the Flash library. Is there a way to load an external image as a bitmapData object?
View 1 Replies
Aug 1, 2007
reason is i'm copying this grayscale Perlinnoise smoke image and makig it such that the darker the color, the more transparent it is. (I'musingcopyChannel.RED/GREEN/BLUE->CopyChannel.ALPHA). But right now, it's the other way round at the moment (ie. the brighter the pixel, the more opaque it is.). I want it to be more transparent instead (inversely proportional), so if i could find simple & fast way invert the alpha channel, it would do me so much more good. (I need a fast method...performance is critical!)
View 6 Replies
Jun 16, 2010
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.
View 2 Replies
Jun 22, 2010
I'm looking for an efficient way to filter a specific color from a bitmapData object in ActionScript 3. Currently I use a loop with readByte32(). This takes about a second to process which is unacceptable. I have been trying to get paletteMap() to work but so far haven't been able to grasp its API (any truly useful links? Google has failed me...). Here's my current logic, which I want to improve:
[Code]...
View 2 Replies
Jul 14, 2009
How to resize a BitmapData ?I've got this right after loading an image:var bitmapdata1:BitmapData = Bitmap(_bitmaploader.contentLoaderInfo.content).bi tmapData;I want to create a new BitmapData called "temp": var temp:BitmapData = new BitmapData(_custom_resize_width, _custom_resize_height);which should become a resized version of the " bitmapdata1 "how do I do that ?my attempt worked but produced white background:
var mat:Matrix = new Matrix();
mat.scale(_custom_resize_width / bitmapdata1.width, _custom_resize_height / bitmapdata1.height);
[code].....
View 4 Replies
Jan 31, 2007
I'm using Flash 8, with this code in the first frame:
import flash.display.BitmapData;
rissa._x=Stage.width/2;
rissa._y=Stage.height/2;[code].....
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");
Total ActionScript Errors: 1 Reported Errors: 1
View 8 Replies
Oct 14, 2009
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..
View 10 Replies