Jump to content


cursor actionscript


  • You cannot reply to this topic
4 replies to this topic

#1 FlashGameboy

    Young Padawan

  • Members
  • Pip
  • 139 posts
  • Gender:Male
  • Location:Somewhere over the rainbow
  • Interests:Mostly flash but im trying to work on Maya and some<br />signiture design

Posted 10 August 2006 - 07:15 PM

Is there a way to program cursor actions into the actionscript without writing it on
a button?

#2 funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

Posted 10 August 2006 - 08:06 PM

Extract from the help file :P

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 FlashGameboy

    Young Padawan

  • Members
  • Pip
  • 139 posts
  • Gender:Male
  • Location:Somewhere over the rainbow
  • Interests:Mostly flash but im trying to work on Maya and some<br />signiture design

Posted 11 August 2006 - 12:28 PM

:P LOL I thought the cursor is the name for all the the arrow buttons.....Wow sorry :blush: :blush:

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 FlashGameboy

    Young Padawan

  • Members
  • Pip
  • 139 posts
  • Gender:Male
  • Location:Somewhere over the rainbow
  • Interests:Mostly flash but im trying to work on Maya and some<br />signiture design

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?

#5 funkysoul

    The Funky Stuff

  • Publishing Betazoids
  • PipPipPipPip
  • 2,307 posts
  • Gender:Male
  • Location:Zurich, Switzerland
  • Interests:Music: HIM, HIM, HIM, Cafe del Mar, Linkin Park, Fort Minor, Coldplay, Eric Jordan<br />Sports: Snowboarding, KiteSurfing, Extreme Sports<br />Computer: Flash, After Effects, Actionscript

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