Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3348002
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:29:21+00:00 2026-05-18T01:29:21+00:00

Let’s state a few facts upfront: Livedocs tells us that dynamic classes enable us

  • 0

Let’s state a few facts upfront:

Livedocs tells us that dynamic classes enable us to add member variables and member functions. We are told that all classes ultimately derive from Object, which is dynamic, and that dynamic classes must be explicitly marked as such — inheritance doesn’t apply to dynamism.

Object is a dynamic class.
Date is a final dynamic class.
XML is a final dynamic class.
You can create your own final dynamic class and it ought to behave (in terms of dynamic capability) exactly as do XML and Date, above. In fact, final shouldn’t affect the issue at hand at all but I include it for exactness in my comparison against the “troubled” XML class.

My code:

public static function setup():void//Object
{
    //Uncomment each in turn to get results:
    //var o:Object = {};
    //var o:MyFinalDynamicClass = new MyFinalDynamicClass();
    //var o:Date = new Date();
    //var o:XML = new XML();

    o.foo = function():String
    {
        return "Works as expected.";
    }

    trace(o.foo());
}

The results for enabling each of the lines where o is defined:

Object: Works as expected.

MyFinalDynamicClass: Works as expected.

Date: Works as expected.

XML: TypeError: Error #1006: value is not a function.

I used Date as it is another core class that is final dynamic. Also note that member variables work just fine in all of the above classes. Only member functions have a problem, and only in class XML.

My conclusion is that not every class in AS3 is derived from Object, some are likely mocked up to look that way but are in fact derived in some other way in native C++, which I believe is what Adobe uses to write the AS languages.

QUESTION: Do you see any flaws in my logic? Or is this class actually bugged?

P.S. For those interested as to why I wanted to add functions to XML, I wanted a way to encapsulate complex access to my XML data model.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:29:22+00:00Added an answer on May 18, 2026 at 1:29 am

    It’s not a bug. The e4x object allows you to manipulate the child elements of the XML dom using normal object notation. This is further elaborated upon here. So, when you assign the function to an attribute of the XML object, the function gets converted to a string, and the string is then added to the XML document as the text value of the <foo> element.

    Another quirk of e4x is that, without a root-level element, it’ll more-or-less ignore any attempt to set child elements. So consider the following:

    var o:XML = new XML('<document/>');
    
    o.foo = function():String {
        return "Works as expected.";
    };
    
    trace(o.toXMLString());
    

    prints:

    <document>
        <foo>function Function() {}</foo>
    </document>
    

    Another Actionscript3 object that works like this is Proxy. Proxy is not final, which would allow you to build your own class that works just like the e4x XML class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.