Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 12-28-2009, 08:28 PM   #1
flips30240
Registered User
 
Join Date: Dec 2009
Posts: 44
Exclamation [AS3] MOUSE_OVER help

Im trying to make a simple maze where when the mouse hits the wall the mouse resets back to the starting point. Im using the MOUSE_OVER function and that's where i get stuck. heres the code so far.

var wall:Shape = new Shape();
wall.addEventListener(MouseEvent.MOUSE_OVER, denied);

function denied(event:MouseEvent) :void {
if (


and thats where my brilliant ideas stop.... im not sure what to put in the if statement to make the program realize the mouse is touching the wall and it needs to reset. ( I just started as3 a few days ago so im pretty bad ) thanks in advance for any help!
flips30240 is offline   Reply With Quote
Old 12-28-2009, 08:50 PM   #2
tadster
tadster
 
tadster's Avatar
 
Join Date: Feb 2009
Location: Texas
Posts: 2,111
Default

hmmm.. make the actual users mouse move backwards? Even if you did that they would just move it again. Or do you mean somehting like make it invisible over the shape?
ActionScript Code:
import flash.ui.Mouse; wall.addEventListener(MouseEvent.MOUSE_OVER, denied); wall.addEventListener(MouseEvent.MOUSE_OUT, backAgain); function denied(event:MouseEvent):void { Mouse.hide(); } function backAgain(yeayeayea:MouseEvent):void { Mouse.show(); }
__________________
www.actiontad.com - ActionScript and JavaScript sitting in a tree...
tadster is offline   Reply With Quote
Old 12-28-2009, 09:02 PM   #3
flips30240
Registered User
 
Join Date: Dec 2009
Posts: 44
Default

you know like the scary maze game kinda thing where when you touch the wall the mouse is reset to the beginning, ill give what you posted a try =) thanks for fast response!
flips30240 is offline   Reply With Quote
Old 12-28-2009, 09:03 PM   #4
flips30240
Registered User
 
Join Date: Dec 2009
Posts: 44
Default

edit : still not working =(

Last edited by flips30240; 12-28-2009 at 09:33 PM.
flips30240 is offline   Reply With Quote
Old 12-28-2009, 09:43 PM   #5
flips30240
Registered User
 
Join Date: Dec 2009
Posts: 44
Default

Alright, seeing s im new and probably doing something wrong aside from the code im gonna go into more detail ( yay time to listen to me blabber ) i made 2 graphics ( one for each wall ) and saved them ass wall1 and wall2 i left space in between each one as the part the mouse will navigate through. so im assuming i want to call out those 2 walls as variables

var wall1:Shape = new Shape; should i calssify them as a shape or sprite?
var wall2:Shape = new Shape;

then i want to add an evet listenr to listen if the mouse is touching either of the walls

wall1.addEventListener(MouseEvent.MOUSE_OVER, resetmouse);
wall2.addEventListener(MouseEvent.MOUSE_OVER, resetmouse);

then make the function to reset the mouse

function resetmouse(event:MouseEvent) :void {

now what would i put here to reset the mouse back to the starting point
and what would i put to specify a starting point for the mouse to bet set at at the start of the app
}

hopefully at least part of that is semi right and makes sense
flips30240 is offline   Reply With Quote
Old 12-28-2009, 10:02 PM   #6
hoolagon
kigwana.com
 
Join Date: Aug 2006
Posts: 59
Default

You cant add MouseOver events to Shapes. You need to use a Sprite
hoolagon is offline   Reply With Quote
Old 12-28-2009, 10:15 PM   #7
flips30240
Registered User
 
Join Date: Dec 2009
Posts: 44
Default

so hopefuly
var wall1:sprite = new sprite;

should work? much thanks =)


so far i have


import flash.ui.Mouse;
var wall1:Sprite = new Sprite;
var wall2:Sprite = new Sprite;

wall1.addEventListener(MouseEvent.MOUSE_OVER, resetmouse);
wall2.addEventListener(MouseEvent.MOUSE_OVER, resetmouse);

function resetmouse(event:MouseEvent) :void {

Mouse.hide();
}

im nt getting any script errors but nothing is happening either -_-

Last edited by flips30240; 12-28-2009 at 10:19 PM.
flips30240 is offline   Reply With Quote
Old 12-28-2009, 10:56 PM   #8
hoolagon
kigwana.com
 
Join Date: Aug 2006
Posts: 59
Default

are you adding your Sprite to the stage?
Also instead of Mouse.hide() for now just try a trace such as trace("resetmouse");
hoolagon is offline   Reply With Quote
Old 12-28-2009, 11:06 PM   #9
flips30240
Registered User
 
Join Date: Dec 2009
Posts: 44
Default

ohh no i didnt add it to the stage, how do i go about doing that? stage.addSprite(wall1); ?
flips30240 is offline   Reply With Quote
Old 12-29-2009, 12:03 AM   #10
flashGeneral
Senior Member
 
Join Date: Dec 2009
Location: New York
Posts: 188
Default

Try

ActionScript Code:
addChild(wall1);
flashGeneral is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:26 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.