Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-34913

Types passed by reference should not be stored on the prototype because they are shared by all instances

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Apache FalconJX 0.5.0
    • Apache FalconJX 0.5.0
    • FalconJX
    • None

    Description

      Try the following ActionScript:

      class Example
      {
      public var prop:Object = {};
      }

      var obj:Example = new Example();
      obj.prop.value = 5;

      var obj2:Example = new Example();
      trace(obj2.prop.value); //5

      The emitter puts the prop member on the prototype, so it is shared by all instances of Example:

      Example.prototype.prop = {};

      Instead, the emitter should set the property in Example's constructor so that each instance has a separate object. Maybe something like this:

      public function Example()
      {
      this.prop = {};
      super();
      }

      There is a workaround. A developer can manually set the property in the constructor, basically using the same code as above:

      class Example
      {
      public function Example()
      {
      this.prop = {};
      }

      public var prop:Object;
      }

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            aharui Alex Harui
            joshtynjala Josh Tynjala
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment