Posts tagged as ' AS2 ' ...

Posted By Tommy

hitTest fails to work with a line!!!

So I’ve been trying to get my space alien game working, and ran into a huge block. No matter what I did, I couldn’t get Flash to recognize my lines with the hitTest function!

I couldn’t figure it out. I had two movieclips, and I was trying to use the hitTest function. What’s so hard about that???

You can test for yourself. First make a line on the stage, then make it into a movieclip with F8. Call it something original like “lineOnStage”. Now try as you can, you will never be able to get the hitTest to fire!!! Oh boy. Guess they forgot to mention that the hitTest function works with the fill, not the border.

createEmptyMovieClip("triangle_mc", getNextHighestDepth());
triangle_mc.beginFill(0x006090);
triangle_mc.moveTo(50, 50);
triangle_mc.lineTo(100, 150);
triangle_mc.lineTo(0, 150);
triangle_mc.lineTo(50, 50);

var hit_X = 100;
var hit_Y = 75;
var shapeFlag = true;

triangle_mc.onPress = function() {
this.startDrag();
};

triangle_mc.onRelease = function() {
this.stopDrag();
if (this.hitTest(lineOnStage)) {
trace("Hit.");
}
};

Ok, one more secret:

If you reduce the width of a rectangle to 1, you can never increase it again. It is now a line. Haha. So you have to delete it and start from scratch.

Posted By Tommy

10,000 foot view of Remoting – AMFPHP

10,000 foot view of Remoting

For a clean overview of how AMFPHP uses AMF (Actionscript Message Format), check out the documents at AMFPHP.org. Although more information than is provided on the site was still necessary for me to connect with my database, the help docs here are really great. Compared to the documentation for some other open-source projects, this one is really helpful. And since there’s a big community for AMFPHP, there are many helpful code snippets and tutorials on the Internet for it these days.