Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement AS3 event flow

Shulou Source: shulou.com Published: 2022-06-02 04:43:13 09月20日 Update

This article mainly explains "how to achieve AS3 event flow". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to realize AS3 event flow".

First, set up a test environment:

The code is as follows:

Var $a: MovieClip = ResLibrary.instance.getMovieClip ("A"); $a.x = (stage.width-$a.width) > > 1; $a.y = (stage.height-$a.height) > > 1; stage.addChild ($a); var $b: MovieClip = ResLibrary.instance.getMovieClip ("B") $b.x = ($a.width-$b.width) > > 1; $b.y = ($a.height-$b.height) > > 1; $a.addChild ($b); var $c: MovieClip = ResLibrary.instance.getMovieClip ("C"); $c.x = ($b.width-$c.width) > > 1 $c.y = ($b.height-$c.height) > > 1; $b.addChild ($c); $a.addEventListener (MouseEvent.CLICK,this.ClcikHandler,true,0,false)

Click callback method:

Private function ClcikHandler (event: MouseEvent): void {trace (event.target, event.currentTarget);}

Click the result of C, B, A: click An and there is no response at all.

If you change the click registration event of $a to:

$a.addEventListener (MouseEvent.CLICK,this.ClcikHandler,false,0,false)

If you change the third parameter to false, the result is: click A to react.

If the third parameter of addEventListener is false (default is flase), the callback event will be executed in the bubbling state; otherwise, it will be executed in the target state. When the parameter is true, register on A, there is no bubbling state, and the fallback function will not be executed.

Three stages of event mechanism

Event has one property: eventPhase, which can be the following three values:

Capture phase (EventPhase.CAPTURING_PHASE).

Target phase (EventPhase.AT_TARGET).

Bubbling stage (EventPhase.BUBBLING_PHASE).

Thank you for your reading, the above is the content of "how to achieve AS3 event flow", after the study of this article, I believe you have a deeper understanding of how to achieve AS3 event flow, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Event stage parameter state learning three content that is goal result response code function property idea situation article method time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MariaDB Redmi macOS Shulou Tech Info