This Blog contains About Action script 3.0 Variables, Data types, Access specifies, Keywords, Operators, Conditional statements, Control statements, Arrays (Indexed, Associative, Multidimensional, Cloning), Functions, Symbols, Movie clips (Transformation point, Registration point, Loading images), Buttons, Events (Key board, Mouse, Timer, XML)Pre- defined function :- Random, Hit test object, Drag and drop, Sort, Loader, Tween,URL Loader, Video components, Audio Components, Sound Channel.
Wednesday, 19 December 2012
collision detection using hittestobject in as3
1. create movieclip with instance name of 'star'.
2. create movieclip with instance name of 'circle'.
3. create one dynamic text box with the instance name of 'messageText'.
code : -
// move star with mouse
addEventListener(Event.ENTER_FRAME, test_fun1);
function test_fun1(event:Event):void {
star.x=mouseX;
star.y=mouseY;
// test star versus circle
if (star.hitTestObject(circle)) {
messageText.text="collide";
} else {
messageText.text="Not collide";
}
}
output looks like :-
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment