1.一般应用(访问名称空间下方法)

use namespace mx_internal;

var textArea:TextArea = TextArea();

textArae.htmlText="<b>test</b>";

var itf:IUITextField=textArae.getTextField();

2.不同名称空间相同的函数签名

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.名称空间下的函数重写

package
{
 public class ns2 extends NamespaceExample
 {
  use namespace French;
  public function ns2()
  {
   French::hello();
  }
  French override function hello():String {
         return "bonjour";
     }
 }
}

4.接口不允许使用名称空间

package
{
 public interface I1
 {
  public namespace French;
  French function hello();
 }
}

Severity and Description Path Resource Location Creation Time Id
1166: 不允许在接口中使用 namespace 声明。 test I1.as line 5 1217302934515 13427

5.xml处理中使用名称空间

一个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 =
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<soap:Body>
<w:forecast xmlns:w="http://weather.example.org/forecast">
<w:city>Quito</w:city>
<w:country>Ecuador</w:country>
<date>2006-01-14</date>
</w:forecast>
</soap:Body>
</soap:Envelope>;
trace(myXML.soap::Body.w::forecast.w::city); // Quito

相关文章:

  • 2021-08-04
  • 2021-09-29
  • 2022-02-26
  • 2021-09-05
  • 2021-07-17
  • 2021-11-14
  • 2021-09-05
  • 2021-11-02
猜你喜欢
  • 2021-07-09
  • 2021-10-29
  • 2021-08-04
  • 2022-01-29
  • 2021-11-04
  • 2022-01-04
  • 2022-12-23
相关资源
相似解决方案