In as3, parameters and dynamic variables are transmitted through event listening.

Source: Internet
Author: User

In as3, adding a listener can pass parameters in a simple way.

For example, column1.addeventlistener (mouseevent. mouse_over,Function (E: mouseevent) {onmouseoverevent (E, subrisk. Days );}); // Tips on parameters passing through the listener Method

 
Private function onmouseoverevent (E: mouseevent, STR: string): void {lablecon. X = E. stagex; lablecon. y = E. stagey; lablecon. TEXT = "value:" + STR ;}

 

Problem: simple static constants can be passed in this way, but in the following case, there will be problems to be solved...

 

For each (VAR subrisk: XML in xmlrisk. area) {trace (subrisk .. @ display + "---" + subrisk. days); // generate the UI var UI: zhangui = new zhangui (); var column1: Label = UI. createlableback (164 + I * 13,124, subrisk. daylevel); var columnnum: Label = UI. createlablebacknum (150 + I * 13,200, subrisk. ID );//?????????????????? Is there a problem with the value passed in the listener ?? Subrisk. Days cannot use variables, but I still don't know how to solve them.Column1.addeventlistener (mouseevent. mouse_over, function (E: mouseevent) {onmouseoverevent (E, subrisk. days) ;}); // tips on parameters passing through the listener method column1.addeventlistener (mouseevent. mouse_out, onmouseoutevent); this. addelement (column1); If (subrisk .. @ display = "true") {This. addelement (columnnum);} I ++ ;}

 

 

The input parameter value of the listener is a constant.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.