ActionScript 2.0 :: How Does Bitmapdata Hittest Work

Sep 23, 2009

import flash.display.BitmapData;
import flash.geom.Point;
//
var BitmapA:BitmapData = new BitmapData(550, 400, true, 0x00);

[code]....

This is using the bitmapdata.hittest way to check whether the one bitmap is overlapping the other. Throug pixel-to-pixel detection.But I'm having trouble understanding this line:

Code:

if (BitmapA.hitTest(destPoint, 255, BitmapB, currPoint, 255))

I know that destPoint is the topleft point from which it is determining all opaque pixels. No value is given to destPoint so basically it is checking from 0,0. Having determined all opaque pixels from that bitmap it should compare them with the opaque pixels of the other bitmap. But why does currPoint use the topleft coordinate of its movieclip? Couldn't it just as well use 0,0 too? I mean when determining the opaque pixels of bitmap two it might as well start checking for those from 0,0 as the topleft position as well?

View 2 Replies


Similar Posts:


ActionScript 3.0 :: BitmapData.hitTest - What Angle Or Coordinate Of The BitmapData The Collision Happens?

Sep 1, 2011

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.

View 2 Replies

ActionScript 3.0 :: How To Use BitmapData.hitTest

Jul 11, 2009

Im making a simple game with destructable terrain. Therefore i use a bitmap for the ground and a movieClip for the player. When the ground is a bitmap i cant use regular hitTestPoint because of the bitmaps transparent pixels. So i looking i the livedocs for the bitmapData.hitTest but i rly dont understand all the parameters.So my question is. How can i reproduce this with bitmapData.hitTest?

ActionScript Code:
if(ground.hitTestPoint(player.x, player.y, true)) {
//actions

[code]....

View 3 Replies

Flash :: Use HitTest Between BitmapData And An Object?

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

ActionScript 3.0 :: Using HitTest With BitmapData And The Mouse: Hover Gfx?

Jul 31, 2011

Having used copyPixels to display an image, I'm trying to copy another in it's place when the mouse is hovering.The only way I can copy the new image over the old is by setting the If statement to == false. I know there's something wrong with testing the bitmapData of the loaded .png because the hitTest would apply to anything copied from that tile sheet... but how to designate just the copied area?

ActionScript Code:
package 
{

[code]......

View 4 Replies

ActionScript 3.0 :: Flex Bitmapdata Hittest Bug (Error #2005)?

Oct 11, 2010

sometimes I get this extremely nasty bug:

Code:
ArgumentError: Error #2005: Parameter 0 is of the incorrect type. Should be type BitmapData.

[code]....

View 3 Replies

ActionScript 3.0 :: Flex Bitmapdata Hittest Bug (Error #2005)

Feb 22, 2012

sometimes I get this extremely nasty bug:

Code:
ArgumentError: Error #2005: Parameter 0 is of the incorrect type. Should be type BitmapData.
at flash.display::BitmapData/hitTest()

This is the line where I get this error:

Code: if (player.bitmapData.hitTest(player.point, 255, tempUpgrade.bitmapData, tempUpgrade.point, 255))

I have absolutely no idea what went wrong. My object (tempUpgrade) is generated inside of a manager-class. There I can define the look of it and it gets cached. The image I use is a spritesheet (png) that's embed inside of my library-class. The spritesheet is splitted into appropriate pics via a CacheTileSheet-class.After that process they get thrown inside of an array because I need the bitmapData for pixel-perfect collision detection. Of course this is not the complete code so if someone needs more please let me know.

[Code]...

View 6 Replies

Actionscript 3 :: Bitmapdata.hittest Collisions With Opaque/transparent Png Files Imported With Loaders

Aug 27, 2010

I have two png files. I import them using loaders. The images in the png files each have opaque (solid) and transparent parts. I want to use the bitmapdata.hittest method to detect when their opaque parts have collided.

[Code]...

I've been working on this for a couple of days now and nobody seems to know how to do this. Please don't post the examples on google, I've looked through at least the first five pages of results on google and haven't gotten any of them to work. The problem is that none of them provide an example of using this method with loaders, so I'm guessing the reason I can't get it to work is some gimmick associated with them.

View 1 Replies

ActionScript 3.0 :: Bitmapdata.hitTest - Bitmap 'emptyBitmap' With Bitmap Data Created

Feb 3, 2009

I'm cutting my teeth in actionscript 3 on a game that has a character running through a world. So, I have set up my Hit Testing by using the bitmap data hit test method, since I figured my world is going to be destructible - it'd be nice to update the level and then redraw it and have the character interact with the new change. (That works beautifully) I am however; a bit confused as to how I have my hit Testing set up. I've been messing around with it, and it works for now - but I'm not sure why.. currently, I have a character set up by using a class I built and using a series of animations I created. So, this character has a walking and falling animation, etc. This is a movie clip.

Then there's a bitmap 'emptyBitmap' with bitmap data created - however; I never really added this as a child to the character. This is sized to the dimensions of my character. My level is created as a movielip, then it's drawn to a bitmap - when the level movieclip is changed, the bitmap redraws, and that's how this updates.

[Code]....

View 1 Replies

ActionScript 3.0 :: HitTest : Can't Get It To Work

Mar 17, 2011

I am trying to create a game. My game is birds eye view game and I am trying to get it so my character (instance name hero_mc )can't pass through the buildings(instance name block_mc). I have been looking at tutorials on the web and most of them cover it so that a text appears if you hit the object whereas I want it so my character can't pass through or well is "push back", the one tutorial I found doesn't want to work for me, but it's not giving me any errors so I really don't know what is wrong with it.

Actionscript Code:
hero_mc.addEventListener(Event.ENTER_FRAME, enter_frame); function enter_frame(event:Event):void{if (hero_mc.hitTestObject(block_mc)) { trace("hero _mc is next to block_mc") } else { hero_mc.y += 10  hero_mc.x += 10  } }

My character still passes through the block objects.

View 1 Replies

ActionScript 2.0 :: Only Want HitTest To Work Once

Mar 30, 2010

I have this very simple .fla file and you use the keys to move the bus around. As it detects the hittests with the other movie clips on the stage it goes to and plays a frame on that mc's movieclip. It all works fine but i dont want the hittest to repeat after it has done it once(on each movie clip) so that as you drive the bus around you reveal the photo. [URL]

View 1 Replies

ActionScript 2.0 :: Can't Get The HitTest To Work

Sep 3, 2005

so my game's code is as follows:

Code:
//The Austin Weisgrau (El Nacho)
//Blob Game, to go with the video so it will get like the .3 mor it needs not to be blammed

[Code]....

the character instance is Blob and the background instance is Background. i can't get the hitTest to work with either of those two things in the /* */ and i need to no how i can

View 1 Replies

ActionScript 2.0 :: Cannot Get HitTest To Work On A Mc

Oct 14, 2008

For some reason I cannot get my hitTest to work on an mc within an mc within an mc...which is assigned to a variable...

Code:
var miniWin:MovieClip = CAD_mc_mini.zoomControl.miniWin;
trace(miniWin); //returns _level0.CAD_mc_mini.zoomControl.miniWin
var mouseListener: Object = new Object();

[Code].....

View 3 Replies

ActionScript 2 :: HitTest Wont Work?

Sep 22, 2009

I was trying to make it so you had to hold up this ball, and if it touched the block near the bottom of the screen, it would go to the first keyframe. (The menu.) So, I labeled the ball, "ball", and the block, "block". Then, I added this code to the block:

onClipEvent (enterFrame) {
if (ball.hitTest(block)){
gotoAndPlay(1)[code]....

And tested it out. To my dismay, it didn't work at all. I've spent about 30 minutes testing other ways, and I cant seem to make it work.

View 6 Replies

ActionScript 2.0 :: Flash8 Why Can't Ever Get Hittest To Work

Mar 28, 2011

i am making a game where a ninja runs through a course, every thing is running smoothly. EXCEPT hittest will not work, hittest never works on ANY of my projects. I know im doing it right, because ive even tried copying and pasting working ones. Look at the attached fla file to see what im talking about.is it my computer that wont let it work, because the exact codes worked for all of the people on youtube that used it.

View 2 Replies

ActionScript 3.0 :: Hittest Will Not Work In Array?

Feb 18, 2009

I am trying to use the following code to simplify multiple Hittests using an Array, but the code won't work. Can anyone tell me why?

var blockArray:Array = new Array("block1", "block2", "block3");
player.addEventListener(Event.ENTER_FRAME, blockTest);
function blockTest(evt:Event):void {

[Code].....

View 4 Replies

ActionScript 2.0 :: How To Get Simple HitTest To Work With Two MCs (Lines)

Nov 30, 2009

I am having trouble getting a hitTest to work. My two MCs are lines, one horizontal, one slanted. When the horizontal line gets within the "bounding box" of the slanted line the hitTest is true, but it's not touching the slanted line yet. I saw that the shapeFlag property comes into play here, but only when using coordinates... I'm not sure how to apply it to these two lines. I want the hitTest to be true only when the lines actually touch. I have attached a simple FLA of the problem.

View 1 Replies

ActionScript 3.0 :: HitTestPoint - Hittest Doesn't Work?

Dec 30, 2008

I have this code so that when a spaceship goes through a blackhole it plays the spaceships moveiclip. This works fine on the first part of the code when the user just clicks the start button.However, i have put in a difficulty setting and when you change the difficulty setting the hittest doesn't work anymoreand there are no error messages. I have tried putting the blackHoles array in the difficulty function but nothing changes and i didn't really think this would make a difference as the easy function is already using the blackHoles array outside the difficulty function.

View 7 Replies

ActionScript 2.0 :: Hittest Doesn't Work Off The Stage?

Sep 13, 2009

I have about 100 movieclips that scroll across the stage from out of bounds. They are supposed to hit another movieclip both in bounds and out of bounds, but it seems like Flash only detects the hittest when it happens within the frame.

if(_root.sceneclip.reef1.hitTest(this._x+300, this._y+350, true) ){

View 2 Replies

ActionScript 2.0 :: Hittest Nor Other Method Doesn't Work

Aug 20, 2010

So I'm doing this project for school and all, and I'm trying to do a htitest on an object. For some reason, it doesn't work. So I tried writing out my own method... Which halff worked, but wasn't as exact as it should've been.

Heres my code (Though I'm pretty sure somethings wrong with my MC, so i'll upload the main .fla file)

Code:
right = true;
left = false;
itemX;
itemY;

[Code].....

View 1 Replies

ActionScript 2.0 :: Make E To HitTest F To Get Something Else Function But They Won't Work?

Sep 6, 2011

Lets say that I got movieclips A,B,C,D in my scene and E,F which only come into scene when A hitTest B and C hitTest D.I was able to make the A+B and C+D hitTest functioning properly. But when E,F came into the scene, I tried to make E to hitTest F to get something else function but they won't work.# note that there is some short animation before E & F come into scene.I am pretty sure all the instance names are named properly.

View 5 Replies

ActionScript 2.0 :: HitTest On Mc Doesn't Work With ScrollRect?

Oct 29, 2006

I have two pieces of code, that won't work together.First: this makes a hitTest on an mc to make it run on rollover:

Code:
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (this._currentframe<this._totalframes) {
nextFrame();

[Code]...

Each work seperately, but they won't together. How do I get around this?

View 7 Replies

ActionScript 2.0 :: Simple HitTest To Work For Rounded Walls

Mar 19, 2009

I've been trying to write a hittest that will work for rounded walls on my RPG. But I've been epic phailing.

Heres my code:
onClipEvent(load){speed=10;
}onClipEvent(enterFrame){if(Key.isDown(Key.UP)){this._y-=speed;this.gotoAndStop(5);
}if(Key.isDown(Key.DOWN)){this._y+=speed;
this.gotoAndStop(6);}
if(Key.isDo wn(Key.RIGHT)){this._x+=speed;this.gotoAndStop(7);
}if(Key.isDown(Key.LEFT)){this._x-=speed;this.gotoAndStop(8);}

View 2 Replies

ActionScript 3.0 :: BitmapData Method Lock Not Work?

Mar 30, 2012

import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Rectangle;

[code].....

View 4 Replies

Actionscript 3.0 :: Can't Make Scale BitmapData Work

Mar 19, 2010

I'm trying to resize each image without success. After pulling my hair a few time, I can't figure out to make the smoothing works on Stage. Basically I want to be able to resize any pics: 600x900 -> 400x600

Code: Select all // Call LoadBitmap class, bitmapWidth & bitmapHeight are the desired 400x600
loadBitmap = new LoadBitmap(bitmapWidth, bitmapHeight);
loadBitmap.loadBitmapData(theImage);

[code]....

View 2 Replies

ActionScript 2.0 :: HitTest - Setup In The Attached File Seems To Work In Relation With The Blue Box's

Nov 10, 2003

for some reason the hitTest I have setup in the attached file seems to work in relation with the blue box's that surround objects and not with the actually objects. Anyways I'm pretty sure that it has to do with the border.

View 4 Replies

ActionScript 2.0 :: BitmapData Stuff Doesn't Work When Uploaded?

Jul 3, 2007

For some of the menus and stuff, I have it grayscale the screen with BitmapData.draw and ColorTransform. It works perfectly when played through Flash and Flash Player, and even when played locally through a browser.

However when I upload it to a server and try and play it online, the BitmapData stuff apparently clunks out. It displays a white screen, suggesting that BitmapData.draw isn't working for some reason.

As it only doesn't work when on a server, you'd think it was some form of security violation. But I cannot think of anything that would cause this to breach Flash's security. I'm only drawing the _root of the movie clip, nothing located on another domain.

Even weirder, the exact same code worked a while ago when uploaded. It only stopped working a short time ago after I was adding some menus and such - and as much as I've been trying to pinpoint it to an exact moment in time when it stopped working, I can't.

View 1 Replies

ActionScript 3.0 :: Bitmapdata.draw() Doesn't Work With Blend Modes?

Feb 2, 2012

I am trying to save an image from flash, just load a image into flash place some decorative clip art and then save the image to the disk. I was able to do this via BitmapData + PNGEncoder + FileReference.

Now as an experiment I have introduced new clip sprites for decoration, where in each of these have multiple sprite children with different blend modes say "ERASE", "OVERLAY", etc. As far as the flash runtime is considered I am getting the expected effect for blend modes.

But as soon as I try to save the image, the output is weird, it doesn't resembels what I see in the flash player. I also tried to print the page as pdf using PrintJob class, but the pdf would not show the filter effects or the blend modes ones.
 
As far as I am using the plain clip arts with no effects, no blur, no blend modes the image is generated. But when i try to use the BitmapData.draw() method with the image that has clip arts with blend mode or blur it fails.

BitmapData.draw() with blend modes, as I feel if the we could possibly see the blending effects in the player then we could possibly print it as well.

View 3 Replies

ActionScript 2.0 :: Flash 8 BitmapData - Getting Error : The Class Or Interface 'BitmapData.loadBitmap' Could Not Be Loaded?

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

ActionScript 3.0 :: Error #2015: Invalid BitmapData At Flash.display::BitmapData()

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







Copyrights 2005-15 www.BigResource.com, All rights reserved