Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement AS3 event flow

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report