detecting collision with a movie clip with transparent areas - actionscript-3

i have a project that involves a movie clip, which has transparent areas. Is there any way to get collisions on another object working so it only hits the opaque areas of this movie clip or is that asking too much? My current collision only counts the bounding box so the player cant really move as it get stuck in transparent areas

If you have a MovieClip with transparent area, create another MovieClip that has smaller width and height than first one. Then, use this new MC for collision detection, you can set visibility to false. Use "enterFrame" function to make new MC follows your MC with transparent areas.

Related

Binary Video Colour Collision Detection AS3

So I've got a field of yellow balls on the stage in rows all the way down the screen. About 200 of them. They're all movieClips linked from one ball MovieClip in the library.
I'm storing them in an Array called ballField.
I've also got a video feed on the stage (right now from webcam, but later will be whatever video I choose).
I want the video to be broken down into binary colour (black and white contrast).
Then I want to hit test all of the balls MovieClips against the color white from the video on enter frame.
Whenever a ball is 'hit' I want it to become visible. Whenever it's not hit, it will be invisible.
Essentially I want the end product to be a video created out of a field of balls (each ball would be like a binary pixel) appearing and disappearing against the white motion of the background video, (once it's working I'll hide the source) to give the illusion of a video created out of yellow balls.
This is a little over my head. I researched several options using the Bitmap data class for collision detection, but I'm not sure how to hitTest colours versus points. And I'm not sure how to hitTest bitmap data from a video to a MovieClip.
Any help is appreciated..
Hrm, one way I see to do this is for every ball, get the position of it and compare it to the pixel on the video it is supposed to match (may need to do some of your own mapping logic here). Then just look up that pixel colour to determine if the ball is visible or not. No hitTesting needed.

How to resize a movie clip as a whole, without hindering animation?

I have a movie clip with some animation in it. If I resize it inside the movie clip, the animation goes weird. How can I resize the whole movie clip without hindering the animation or changing the animation?
This movie clip gets brought on the stage by action script
This code scales a movieclip myMovieClip by 200%
myMovieClip.scaleX = 2;
myMovieClip.scaleY = 2;
Assuming the movieclip has been added to the stage w/ ActionScript (e.g., addChild(myMovieClip); and has an instance name, you should be able to plug that code in there to get it going.

Its possible do a hole in movieclip with mouse click?

I have a movieclip moving and when I click him I want that appears a hole.
Its possible do that with actionscript? how?
If your hole should appear there the mouse clicks, you could create new Sprite, draw two circles (one bigger than your MovieClip, another at size of you hole, both at position of your click) using his graphics property. Fill it with any color. It should look like donut.
After that assign created Sprite as a mask for your MovieClip.
youMovieClipId.mask=createdSpriteId;
After that, you could add mask as child of your MovieClip, using
youMovieClipId.addChild(createdSpriteId);
Now created mask will follow your MovieClip.

Flash CS6 AS3: Click listener on overlapping movieclips only fires top movieclip

I have several Movieclips which overlap one another, each one has a different graphic of a body part. I would like the user to be able to click on a body part and it highlights.
I've set up event listeners to detect a click on the movieclips and to then apply a colorTransform. The problem is that the top movieclip also gets selected, and not the one's below even though the movieclips have transparent BitMap (PNG) images in them.
Is there a way I can create the hotspots to support only opaque pixels?

erasing a movieclip

I have a fully working flash application, made in as3. Now i dynamicly added a movieclip and i would like to be able to erase that movieclip with a eraser of some sort, my goal is to be able pick up a sponge with the mouse and then start dragging over the movieclip and erasing the parts where i dragged over it.
Anyone who can help?
Looks like this might be what you're looking for:
http://www.piterwilson.com/personal/2008/05/07/bitmapdata-erasing-in-as3-with-custom-brush-shape/
Is the background behind the MovieClip always the same?
If so you can put an image of the background over the MovieClip you want to erase, and mask that image so it becomes invisible, then add a click listener that draws a circle in the mask when clicked. This way it'll look like the MovieClip is being erased.
With getPixel you can loop over the mask and detect the percentage of the MovieClip that has been erased, so you can remove the clip from stage when it's fully erased.