Is there a way to program cursor actions into the actionscript without writing it on
a button?
cursor actionscript
Started by FlashGameboy, Aug 10 2006 07:15 PM
4 replies to this topic
#1
Posted 10 August 2006 - 07:15 PM
#2
Posted 10 August 2006 - 08:06 PM
Extract from the help file 
1) Create a movie clip to use as a custom pointer, and place an instance of the clip on the Stage.
2) Select the movie clip instance on the Stage.
3) In the Property inspector, type cursor_mc in the Instance Name text box.
4) Select Frame 1 of the Timeline, and type the following code in the Actions panel:
The Mouse.hide() method hides the pointer when the movie clip first appears on the Stage; the onMouseMove function positions the custom pointer at the same place as the pointer and calls updateAfterEvent() whenever the user moves the mouse.
The updateAfterEvent() function immediately refreshes the screen after the specified event occurs, rather than when the next frame is drawn, which is the default behavior. (See updateAfterEvent function in the ActionScript 2.0 Language Reference.)
5) Select Control > Test Movie to test your custom pointer.
1) Create a movie clip to use as a custom pointer, and place an instance of the clip on the Stage.
2) Select the movie clip instance on the Stage.
3) In the Property inspector, type cursor_mc in the Instance Name text box.
4) Select Frame 1 of the Timeline, and type the following code in the Actions panel:
Mouse.hide();
cursor_mc.onMouseMove = function() {
this._x = _xmouse;
this._y = _ymouse;
updateAfterEvent();
};
The Mouse.hide() method hides the pointer when the movie clip first appears on the Stage; the onMouseMove function positions the custom pointer at the same place as the pointer and calls updateAfterEvent() whenever the user moves the mouse.
The updateAfterEvent() function immediately refreshes the screen after the specified event occurs, rather than when the next frame is drawn, which is the default behavior. (See updateAfterEvent function in the ActionScript 2.0 Language Reference.)
5) Select Control > Test Movie to test your custom pointer.
#3
Posted 11 August 2006 - 12:28 PM
Thanks anyway since i was going to use a custom cursor in my tetris game
Edited by FlashGameboy, 11 August 2006 - 12:55 PM.
#4
Posted 11 August 2006 - 06:44 PM
What I meant to say was do you know how to program arrow key actions without putting it on
a button?
a button?
#5
Posted 11 August 2006 - 07:30 PM
and again a sample from the help file 
onEnterFrame = function() {
trace("onKeyDown: "+this._name+" (Key: "+getKeyPressed()+")");
};
function getKeyPressed():String {
var theKey:String;
switch (Key.getAscii()) {
case Key.BACKSPACE :
theKey = "BACKSPACE";
break;
case Key.SPACE :
theKey = "SPACE";
break;
default :
theKey = chr(Key.getAscii());
}
return theKey;
}
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
