Basic ActionScripting - Part 2
Hi all, welcome to the second part of Basic ActionScripting!
In this lesson we will be talking about:
•Using AS on Buttons to configure Dynamic Text Boxes (more logical than “Input Text Boxes and a Login Form”).
•How to use the hitTest function to make an object disappear when it hits another onject.
Ok, lets start with the AS on a button to configure some Text Boxes! Create a Dynamic Text Box and a button (which you should
already know how to do). Click your button Once and press F9 to bring up the Actions panel. Type the following:
on (release){
_root.text1 ++;
}
Click your Text Box once and change it’s variable name to “text1″.
Click the first frame of the movie and press F9 for the AS. Type the following in the Frames AS:
stop();
text1 = 0;
Test your movie and press the button. you should find that your value increases by one every time!.
To:
•Decrease it:
change ++; (in the button’s AS) to –;
•Increase it by a certain number:
Change ++; to +=10; or something.
•Decrease it by a certain number
Change ++; to -=10; or something.
Good, that coveres the first part of the Tutorial, now lets hitTEST the hitTest:
Create two movie clips, one is the Movie Clip you want to make disappear with the Other one you will control!
So, you now have 2 movieclips. One you control and one you want to make disappear.
Click the movieclip you want to make disappear and add the following AS to it:
onClipEvent(enterFrame){
if ((this.hitTest(_root.mouse))){
this.play();
}
}
Good, now double click it so you can go into editing mode. Press F7 once and in the second, EMPTY frames AS type:
stop();
Go back to the main scene. click the object you want to make disappear once and change its instance name to “mouse”. now go
into “mouse”’s AS and type:
onClipEvent(enterFrame){
this._x = _root._xmouse;
this._y = _root._ymouse;
Mouse.hide(); //this is optional, remove Mouse.hide(); if you want to see the real mouse
}
Test the movie, roll over the object you want to make disappear and it WILL disappear. Keep looking forward to Basic
Actionscripting part 3, because after that we’ll go more advanced!
![]()