Monday, 19 January 2015

HIT TEST IN AS2 AND SCORE

Flash College


--------------------------------------------------------------------------------------------------------------------
1- SET VARIABLE CODE FOR TEXT BOX :  _root.score
2- PASTE BELOW CODE IN SCORE TIME LINE LAYER
//SCORE TIME LINE LAYER CODE

var score=0;
3- CREATE MOVIE CLIPS, TEXTBOX AND GIVE INSTANCE NAME
green , ball , red , square
hittext

DOWNLOAD SOURCE FILE
http://bit.ly/1BuVMVy
---------------------------------------------------------------------------------------------------------------------
INSIDE MOVIE CLIPS CODE
--------------------------------------------------------------------------------------------------------------------

//green MOVIE CLIP INSIDE CODE
on (release) {
stopDrag()}
on (press) {
startDrag(this)}

//ball  MOVIE CLIP INSIDE CODE

on (release) {
stopDrag();
}
on (press) {
startDrag(this);
}

//red MOVIE CLIP INSIDE CODE

on (release) {
stopDrag()}
on (press) {
startDrag(this)}
onClipEvent (enterFrame){
if (this.hitTest(this._parent.green)){
_root.hittext.text = "HIT TEST SUCCESFUL"
//FOR INVISIBLE GRREN AND RED MOVIE CLIPS NEXT FRAME = BLANK KEY FRAME
_root.green.nextFrame()
_root.red.nextFrame()
_root.red.stopDrag();
_root.score+=10;
} else {
_root.hittext.text = ""
}}

//square MOVIE CLIP INSIDE CODE

on (release) {
stopDrag();
}
on (press) {
startDrag(this);
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.ball)){
_root.hittext.text = "HIT TEST SUCCESFUL"
//FOR INVISIBLE BALL AND SQUARE MOVIE CLIPS NEXT FRAME = BLANK KEY FRAME
_root.ball.nextFrame()
_root.square.nextFrame()
_root.square.stopDrag();
_root.score+=10;
} else {
_root.hittext.text = ""
}}







EmoticonEmoticon