Namespace in as3

Source: Internet
Author: User

1. General applications (access to namespaces)

Use namespace mx_internal;

VaR textarea: textarea = textarea ();

Textarae.html text = "<B> test </B> ";

VaR ITF: iuitextfield = textarae. gettextfield ();

2. Same Function signature for different namespaces

Package
{
Import flash. display. Sprite;
 
Public class namespaceexample extends Sprite
{
Public namespace French;
Public namespace Hawaiian;
Public Function namespaceexample (){
Trace (Hawaiian: Hello (); // Aloha
Trace (French: Hello (); // Bonjour
}
Hawaiian function Hello (): String {
Return "aloha ";
}
 
French function Hello (): String {
Return "bonjour ";
}
}
}

3. Function rewriting in The namespace

Package
{
Public class ns2-extends namespaceexample
{
Use namespace French;
Public Function NS2 ()
{
French: Hello ();
}
French override function Hello (): String {
Return "bonjour ";
}
}
}

4. namespace is not allowed for the interface

Package
{
Public interface I1
{
Public namespace French;
French function Hello ();
}
}

Severity and description path resource location creation time ID
1166: namespace declarations cannot be used in interfaces. Test i1.as line 5 1217302934515 13427
5. namespace used in XML Processing

An example provided by Adobe

 

 var soap: namespace = new namespace ("http://schemas.xmlsoap.org/wsdl/soap/"); var W: namespace = new namespace ("http://weather.example.org/forecast"); var myxml: xml = 
   
    
     
     
       Quito 
      
     
       Ecuador 
      
     
       2006-01-14 
      
     
    
  ; trace (myxml. soap: body. w: forecast. w: City); // Quito 

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.