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

Example Analysis of Flex Namespace

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

Share

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

This article mainly introduces the example analysis of Flex namespace, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.

Detailed explanation of Flex namespace

Namespaces let you control the visibility of the properties and methods you create. Think of public, private, protected, and internal access control specifiers as built-in Flex namespaces. If these predefined access control specifiers do not meet your requirements, you can create your own namespace.

If you are familiar with the XML namespace, you will be familiar with most of what is discussed here, but the syntax and details of the ActionScript implementation are slightly different from those of XML. It doesn't matter if you've never used a namespace before, because the concept of a namespace itself is simple, but its implementation involves specific terms that you need to know. To understand how Flex namespaces work, it is necessary to first understand that the name of a property or method always consists of two parts: an identifier and a namespace. Identifiers are usually treated as names. For example, the identifiers in the following class definition are sampleGreeting and sampleFunction ():

ClassSampleCode {varsampleGreeting:String; functionsampleFunction () {trace (sampleGreeting+ "fromsampleFunction ()");}}

As long as the definition does not start with a namespace attribute, its name is qualified with the default internal namespace, which means that they are visible only to callers in the same package. If the compiler is set to strict mode, the compiler issues a warning that the internal namespace will be applied to any identifier that does not have a namespace attribute. To ensure that the identifier can be used anywhere, you must explicitly precede the identifier name with the public attribute. In the sample code above, both sampleGreeting and sampleFunction () have a namespace value of internal. When using namespaces, you should follow these three basic steps.

*, you must use the namespace keyword to define the Flex namespace. For example, the following code defines the version1 namespace:

Namespaceversion1

Second, in the property or method declaration, use the namespace (rather than the access control specifier) to apply the namespace. The following example places a function named myFunction () in the version1 namespace:

Version1functionmyFunction () {}

Third, after the namespace is applied, you can use the use directive to reference it, or you can use the namespace to qualify the name of the identifier. The following example references the myFunction () function through the use directive:

Usenamespaceversion1; myFunction ()

You can also reference the myFunction () function with a qualified name, as shown in the following example:

Version1::myFunction (): thank you for reading this article carefully. I hope the article "sample Analysis of Flex Namespace" shared by the editor will be helpful to you. At the same time, I also hope that you will support and follow 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