How add custom properties to built-in objects?

Ask a Question related to Macromedia Flash Actionscript, Design and Development.

  1. #1

    Default How add custom properties to built-in objects?

    Hi,

    I am just migrating a project to Actionscript 2.0 and ran into a problem: In
    1.0 I was adding a custom property to XML nodes like that:

    myXMLnode.customProp = "hi";

    If I do something like this in 2.0 I am getting en error because the property
    does not exist in the class. I know how to add custom functions (via
    prototype), but how can I add a custom property to the XMLNode class?

    I appreciate every help!
    Thanks!
    Ingo

    iweiss Guest

  2. Similar Questions and Discussions

    1. Need a custom exentsion built for me.
      I will soon be needing a custom extension built for a software program. Where to I post a job such as this? Is this the right forum? Or is there...
    2. Making Custom Control Properties Visible in Visual Studio's Properties Palette
      I am learning how to use the System.ComponentModel class in VB.NET so that I can add my ASP.NET controls to Visual Studio .NET 2003. I have managed...
    3. Custom TextBox with custom attributes and properties question
      I have an webform that has a datarepeater on it. In that repeater I'm binding some data and I have put a textbox control in there. On the...
    4. activex methods,events,properties and objects
      someby knows how to access objects inside activex? I know how to access properties, methods and events, but with objects director returns...
    5. #24732 [NEW]: Way to lock objects/properties/variables for include
      From: nightcat at poczta dot onet dot pl Operating system: * PHP version: 5.0.0b1 (beta1) PHP Bug Type: Feature/Change...
  3. #2

    Default Re: How add custom properties to built-in objects?

    You create a class that extends the original class

    with

    class Yournode extends XMLNode {
    var _prop:String;
    // constructor
    function Yournode(prop) {
    _prop = prop;
    trace(_prop)
    }
    public function getProp(){
    return _prop;
    }
    }

    In de flash file:
    var myNode:Yournode = new Yournode("your prop value");
    trace(myNode.getProp());

    That should be it basically.

    John



    --
    ----------------------------------------------------------------------------
    -----------
    RESOURCES
    [url]http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash[/url]
    ----------------------------------------------------------------------------
    -----------
    TUTORIALS at
    [url]www.laiverd.com[/url]
    Flash & PHP Emailform
    Using textfiles in Flash
    ----------------------------------------------------------------------------
    -----------


    Laiverd.COM Guest

  4. #3

    Default Re: How add custom properties to built-in objects?

    Thanks, John!

    The problem with this is that typically nodes aren't created with something
    like "new customNode()". I can create a custom XML class "customXML" but if I
    access nodes within that object, say "myCustomXMLInstance.firstChild", that
    would be always be an instance of the standard XMLNode class and thus don't
    have the custom property I need.

    It's just like you can't subclass MovieClip by something like "new
    customMovieClip()" but you need to attach a library symbol that's associated
    with that class instead.

    I can't really think of a way to get around that right now.
    Ingo

    iweiss Guest

  5. #4

    Default Re: How add custom properties to built-in objects?

    Maybe post the question at the flashcoders mailing list. Some pretty good
    people there. I'm only starting with the whole as2 thing and don't trust
    myself on this already ;-)

    John

    --
    ----------------------------------------------------------------------------
    -----------
    RESOURCES
    [url]http://groups.google.com/advanced_group_search?hl=en&as_ugroup=*flash[/url]
    ----------------------------------------------------------------------------
    -----------
    TUTORIALS at
    [url]www.laiverd.com[/url]
    Flash & PHP Emailform
    Using textfiles in Flash
    ----------------------------------------------------------------------------
    -----------


    Laiverd.COM Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139