ActionScript 3 – Namespaces

Friday, January 30th, 2009 | ActionScript 3, videos

Click to view the video in a pop-up. Right-click and “save as” to download the video to your hard drive.

Watch Video Tutorial on Namespaces in ActionScript 3

Tags:

  • Pedro
    Thanks for the tutorial. I was able to implement namespaces to create access restricted methods successfully except in one instance. Can methods declared with a custom namespace be overwritten? I have been unsuccessful in doing so. Here is a short sample:

    // secret.as
    package {
    public namespace secret = "http://www.example.com/secret";
    }

    // Base.as
    package {
    import secret;
    public class Base {
    public function Base() {
    }

    secret function test():void {
    trace("Base test");
    }
    }
    }

    // Extended.as
    package {
    import secret;
    public class Extended extends Base {
    public function Extended() {
    }

    override secret function test():void {
    trace("Extended test2");
    }
    }
    }

    If I mark test() with override I get "1004: Namespace was not found or is not a compile-time constant."
    If I remove override I get "VerifyError: Error #1053: Illegal override of test in Extended."
    Is this not possible? Is there a workaround? Thanks.
  • evan
    Cool. Thanks for making this! Was wondering how that use namespace worked. I have seen it used in some mvc frameworks.
  • Great post. I love the idea of assisting developers so they only seeing the methods via intellisense (of Flex Builder) for methods they need to see. I created a new demo to show that off. http://www.blog.rivello.org/?p=422
  • What about defining variables in the namespace file? For example, in flash authoring there is the compiler option:

    CONFIG::FLASH_AUTHORING

    'CONFIG' is the namepace and 'FLASH_AUTHORING' is a variable. Which seems to be a boolean. cause I can turn it on and off with:

    -define=CONFIG:: FLASH_AUTHORING,false

    Do you mind saying what that class looks like? is it:

    package
    {
    public namespace CONFIG;
    public var FLASH_AUTHORING:Boolean;
    }

    I am trying to turn off and on classes. When I do this

    package
    {
    CONFIG::FLASH_AUTHORING
    public class Main extends Sprite
    {

    }
    }

    The class can be skipped with that compiler option. I would like to create my own namespace files with similar functionality, but my own naming conventions.
  • very helpful, thanks for your uFlash presentation too!
  • Great tutorial!
blog comments powered by Disqus

Search

Recommended Books

Speaking at FITC Toronto

 

January 2009
M T W T F S S
« Dec   Feb »
 1234
567891011
12131415161718
19202122232425
262728293031  

Preferred Video Tutorial Resolution

  • 1024x768 (53%, 85 Votes)
  • 1280x1024 (15%, 24 Votes)
  • 1920x1080 (15%, 24 Votes)
  • 800x600 (13%, 20 Votes)
  • 480x320 (4%, 6 Votes)
  • 640x480 (0%, 2 Votes)

Total Voters: 160

Loading ... Loading ...