Mryqu's Notes


  • 首页

  • 搜索
close

[Flex] 显式使用public namespace

时间: 2012-09-01   |   分类: FrontEnd     |   阅读: 147 字 ~1分钟

今天看代码时,发现public namespace的使用,搜了一下flex4 in action,貌似没有。 放狗搜了一下,学习学习。 

myspace.as

package
{
  public namespace myspace ="http://myspace";
}

TestClass.as

package
{
  import myspace;

  public class TestClass
  {

    public function foo():void
    {
      trace("Public foo is called");
    }

    myspace function foo():void
    {
      trace("MySpace foo is called");
    }

    private function fooPrivate():void
    {
      trace("Called private function");
    }

    protected function fooProtected():void
    {
      trace("Called protected function");
    }

    public function callFoo(t:TestClass):void
    {
      // call the private/protected members on the object.
      t.fooPrivate();
      t.fooProtected();
    }
  }
}

testApp.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 creationComplete="testFunc()">
<mx:Script>
 <![CDATA[

use namespace myspace;

private function testFunc():void
{
   var test:TestClass = new TestClass;
   //public can be also used as namespace name to call the correct function.
   test.public::foo();

   // call the myspace namespace function
   test.myspace::foo();

   var test2:TestClass = new TestClass;
   // call the function to demonstrate that private/protected functions
   // can be called on test2 object.
   test.callFoo(test2);

}
]]>
</mx:Script>
</mx:Application>

原文 Using public namespace explicitly

标题:[Flex] 显式使用public namespace
作者:mryqu
声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 CN 许可协议。转载请注明出处!

#flex# #namespace#
Eclipse中解决远程调试超时的设置
表驱动法
  • 文章目录
  • 站点概览

Programmer & Architect

662 日志
27 分类
1472 标签
GitHub Twitter FB Page
© 2009 - 2023 Mryqu's Notes
Powered by - Hugo v0.120.4
Theme by - NexT
0%