Friday, January 30, 2009

ActionScript 3 - Namespaces

I recorded this video at a weird resolution (900x676), so youtube can't convert it to an HD video (which makes it really hard to watch).

So, instead, you can just download it here: Download Namespaces.mp4

13 comments:

  1. [...] namespaces in Flash & Flex. To learn more about namespaces awesomeness, John Lindquist has an excellent video post that covers the concepts really well and goes into some advanced [...]

    ReplyDelete
  2. very helpful, thanks for your uFlash presentation too!

    ReplyDelete
  3. 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.

    ReplyDelete
  4. 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

    ReplyDelete
  5. Cool. Thanks for making this! Was wondering how that use namespace worked. I have seen it used in some mvc frameworks.

    ReplyDelete
  6. [...] видео-туториал четко и понятно объясняющее как и для чего можно [...]

    ReplyDelete
  7. [...] mit ihnen befasst habe. Heute habe ich zum Glück ein sehr ausführliches und grundlegendes Videotutorial über Namespaces gefunden, das viele Fragen geklärt und mir Möglichkeiten und Einsatzgebiete aufgezeigt [...]

    ReplyDelete
  8. Pedro9:09 AM

    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.

    ReplyDelete
  9. Thanks John. This is really useful for me. Can u provide a downloadable url address for us of this video? Thanks!

    ReplyDelete
  10. Hello. I saw your last video about public, private, internal and protected and real like it, it's the best example about programm basic that i ever see.
    And that video is deleted or moved to another place??? I wish to see them to.
    Thanks you.

    ReplyDelete
  11. Ups two time posted, Sorry. Delete this please

    ReplyDelete
  12. Anonymous3:42 PM

    I updated the post with a download link for the video.

    ReplyDelete