I just want my crosshairs to move!

Probably a simple error but...

Page 1 of 1

8 Replies - 3328 Views - Last Post: 12 October 2009 - 02:38 PM

#1 Chainsaw_Matt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 03-November 08

I just want my crosshairs to move!

Post icon  Posted 23 September 2009 - 01:12 PM

Hi! I'm super beginner actionscript/flash user. I began writing a program, and all that I'd like for it to do is make the crosshairs follow my mouse! Sounds simple right? For some reason I can't seem to get it working. I have a main fla file, with a very simple crosshair drawing in the library, I have a main class, and an empty curser class (curser is what I'm using to refer to the crosshairs)
Both classes look like this:
Main class

package
{
	import flash.display.MovieClip;
	import flash.ui.Mouse;
	
	public class whatever extends MovieClip
	{
		public var Curser:curser;
		
		public function awesome()
		{
			Curser = new curser();
			addChild(Cursr);
			
			Curser.x = mouseX;
			Curser.y = mouseY;
		}
	}
}



and the empty Curser class
package
{
	import flash.display.MovieClip;
	
	public class curser extends MovieClip
	{
		public function curser()
		{
			
			
		}
	}
}



It seems like I've imported everything neccessary, and all my names are the same, so I couldn't have named something incorrectly. Any ideas?

Is This A Good Question/Topic? 0
  • +

Replies To: I just want my crosshairs to move!

#2 KiKaL  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 09-October 02

Re: I just want my crosshairs to move!

Posted 23 September 2009 - 01:50 PM

Curser = new curser();
addChild(Cursr);


should that be

addChild(Curser);
Was This Post Helpful? 0
  • +
  • -

#3 Chainsaw_Matt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 03-November 08

Re: I just want my crosshairs to move!

Posted 23 September 2009 - 02:13 PM

Thank you for responding, but sadly it didn't work! I had checked for errors like that, that's what I thought it was but that is not the case. Any other ideas?
Was This Post Helpful? 0
  • +
  • -

#4 Chainsaw_Matt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 03-November 08

Re: I just want my crosshairs to move!

Posted 05 October 2009 - 12:22 PM

So I'm still having this same problem, does anyone think they can help me?
Was This Post Helpful? 0
  • +
  • -

#5 jeeppsycho223  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-September 09

Re: I just want my crosshairs to move!

Posted 05 October 2009 - 04:35 PM

http://www.dummies.c...d-DOWNLOAD.html



download the source code for chapter 6.
open the custom cursor file.

the rest should be self explanitory.
Was This Post Helpful? 0
  • +
  • -

#6 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: I just want my crosshairs to move!

Posted 06 October 2009 - 05:53 AM

What you have there is only positioning your crosshair to the mouse positions once. Presumably you want the cursor to always follow the mouse?

I would create a listener for the event of mouse moving, and when the mouse moves you can update the position of the cursor movieclip:
package
{
	import flash.display.MovieClip;
	import flash.ui.Mouse;
	import flash.events.MouseEvent;
   
	public class whatever extends MovieClip
	{
		public var Curser:curser;
	   
		public function whatever()
		{
			Curser = new curser();
			addChild(Cursr);
		   
			//Curser.x = mouseX;
			//Curser.y = mouseY;

			stage.addEventListener(MouseEvent.MOUSE_MOVE, updateCursor);
		}

		private function updateCursor(evt:MouseEvent):void
		{
			Curser.x = mouseX;
			Curser.y = mouseY;
		}
	}
}



Was This Post Helpful? 0
  • +
  • -

#7 Chainsaw_Matt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 03-November 08

Re: I just want my crosshairs to move!

Posted 07 October 2009 - 04:09 PM

That website didn't work, and was slightly hard to understand. But thehat had a good idea, and I thought it was going to work, but to no avail. I still can't even get the curser to show up on screen. My edited code is as follows:
package
{
	import flash.display.MovieClip;
	import flash.ui.Mouse;
	
	public class whatever extends MovieClip
	{
		public var Curser:curser;
		
		public function awesome()
		{
			Curser = new curser();
			addChild(Curser);
			
			stage.addEventLisener(MouseEvent.MOUSE_MOVE, updateCurser);
		}
		private function updateCurser(evt:MouseEvent):void
		{
			Curser.x = mouseX;
			Curser.y = mouseY;
		}
	
	}
}


Any more suggestions?
Was This Post Helpful? 0
  • +
  • -

#8 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: I just want my crosshairs to move!

Posted 08 October 2009 - 01:23 AM

Is this your actual code? If so, you haven't defined a constructor. Your constructor must be named the same as your class. Maybe you could zip up your fla and classes so we can better see what's going on?
Was This Post Helpful? 0
  • +
  • -

#9 Chainsaw_Matt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 03-November 08

Re: I just want my crosshairs to move!

Posted 12 October 2009 - 02:38 PM

Sure, no problem. I appreciate your help quite a lot. Here's the code and the fla.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1