admin管理员组

文章数量:1287517

function pauseScene(evt:MouseEvent):void
{   
stop();
pause_btn.visible = false;
play_btn.visible = true;
}

I have written the above code in Actionscript to stop a mouse event. Now I want to convert that into Javascript so that the scene in flash cc will be converted to Html5. For that I have used the below code as

function pausescene()
{
 this.stop();
 }

But this is not satisfying my requirement. Please do help me.

function pauseScene(evt:MouseEvent):void
{   
stop();
pause_btn.visible = false;
play_btn.visible = true;
}

I have written the above code in Actionscript to stop a mouse event. Now I want to convert that into Javascript so that the scene in flash cc will be converted to Html5. For that I have used the below code as

function pausescene()
{
 this.stop();
 }

But this is not satisfying my requirement. Please do help me.

Share Improve this question asked Apr 13, 2015 at 10:12 priyankapriyanka 2073 silver badges14 bronze badges 3
  • You want to stop any default action or stop it's propagation ? – Vigneswaran Marimuthu Commented Apr 13, 2015 at 10:15
  • I want to stop an animation(action). – priyanka Commented Apr 13, 2015 at 10:21
  • What does stop do ? It will stop the animation ? Why you used this.stop() ? Because this is function context. Can you post how stop has been implemented ? Are you seeing any errors in console ? – Vigneswaran Marimuthu Commented Apr 13, 2015 at 10:31
Add a ment  | 

2 Answers 2

Reset to default 9

event.preventDefault() prevents the default behaviour, but will not stop its propagation to further event listeners.

event.stopPropagation() will not prevent the default behaviour, but it will stop its propagation.

You can use a bination of both.

Example code:

myElement.addEventListener('click', function (event) {
    event.stopPropagation();
    event.preventDefault();

    // do your logics here
});

Reference: https://developer.mozilla/en/docs/Web/API/Event/preventDefault https://developer.mozilla/en/docs/Web/API/Event/stopPropagation

If you can capture the event object, you can use the preventDefault() to stop it

function catchMouseEvent(e){
     e.preventDefault();
}

本文标签: actionscript 3How can i stop a mouseevent in javascriptStack Overflow