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 develop with Flex components

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to use Flex components for development, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Develop using Flex components

Probably the most important use of ActionScript in Flex applications is to use visual controls and containers for development. Flex provides several techniques to do this, including referencing Flex controls with ActionScript and manipulating properties of instances of controls and containers.

Reference Flex components

In order to use the Flex component in ActionScript, we usually define an id attribute for the Flex component in the MXML tag. For example, in the following code, we set the id property of the Button control to "myButton":

◆ if you don't want to manipulate the Flex component by using ActionScript, then this property is optional.

This code causes the MXML compiler to automatically generate a public variable with the name myButton that contains a reference to the Button instance. You can manipulate Flex components in ActionScript by using this automatically generated variable. You can explicitly reference an instance of the Button control through the id of the Flex component in any ActionScript class or block of code. By referencing an instance of the Flex component, you can modify the properties of the Flex component and call the methods of the Flex component.

For example, in the following block of ActionScript code, the program changes the value of the label property of the Button control when the user clicks the button:

The id properties of all MXMLFlex components, no matter how deeply they are nested, generate public variables of the defined Flex components. Therefore, all id attributes in the document must be *. This also means that if you specify the id property of the Flex component instance, you can manipulate the Flex component anywhere in the program: functions, external class files, imported ActionScript files, or embedded code.

◆ if the Flex component does not have an id attribute, you can reference the Flex component by using the Flex component's container. Such as the getChildAt () and getChildByName () methods.

You can refer to the current attached file or the current object to use such keywords.

You can also reference Flex components by using the same characters as the Flex component name. To use objects in your program, you can use square brackets, which contain the same string as the name of the Flex component. So you get a reference to the object.

In the following example, you get a reference to the object by using a string, and then change the style of each Button control:

This tip has a special use. When you create an object with a Repeater control or ActionScript, you don't have to know the object's name to reference it at run time. However, when you instantiate an object with ActionScript, if you want to add the object to the application's property array (as I understand it: the array is the application's array, containing instances of Flex components defined in the program), you must define the variable as public and define it in the scope of the entire class, not within the function.

Thank you for reading this article carefully. I hope the article "how to develop with Flex components" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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