actionscript 3 - how to trigger a mouse_over event ONLY when mouse_down event is active? -


i'm building game relies on gaining points through having mouse_over repeatedly on hit area, want player able gain points provided mouse_down active. if i'm not getting syntax errors, nothing's happening. know code's wrong.

i need hit make pressing true, , trigger onpressing, then,
onpressing trigger noot mouse_over, , each mouse_over registers score point , traces it.

var score:int = 0 score = 0; var pressing:boolean = false;  hit.addeventlistener(mouseevent.mouse_down, maketrue); function maketrue(evt:event){ pressing = true; trace("honk"); onpressing(); } }  function onpressing(evt:event){ if (pressing==true){  noot(); } } function noot(event:mouseevent = null)// should mouse_over, gain points { score++; trace("moused over"); trace("score: " + score); } 

a few things:

  • there's "}" after onpressing()
  • onpressing() requires argument - suggest "evt"

once these fixed, tracing work, , score in increment each time click hit symbol.

however, achieve effect described user scores repeatedly having mouse on hit area when mouse button down, don't suggest using "mouse over". because mouse on trigger when mouse moving. when user has rolled on top of hit area , stopped, not fire mouse on event.

i suggest following adjustment:

var score:int = 0 score = 0; var pressing:boolean = false;  //stage listens mouse down stage.addeventlistener(mouseevent.mouse_down, maketrue); function maketrue(evt:event){     pressing = true;     trace("honk"); }  //stage listens mouse stage.addeventlistener(mouseevent.mouse_up, makefalse);  function makefalse(evt:event){     pressing = false;     trace("unhonk"); }  hit.addeventlistener(event.enter_frame, checkcollision);  function checkcollision(evt:event):void{     //pseudocode     /*     if(hitting cursor) && pressing){         score++;         trace("score: " + score);     }     */ } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -