1 Reply Latest reply on Jan 28, 2008 7:05 AM by kglad

    Overloading constructors and parsing instance of class to itself

    lilalfyalien Level 1

      I have a class called Screen. This class I ideally want to have two constructors, but from what I understand this isn't possible in ActionScript 2. The reason I need this is because I want to be able to, in some cases, parse an instance of a Screen object (the same as the class) to a new Screen object. Can I do this? I've tried using default parameters (= null) but I get compiler errors!

      I attach my code so far.

      What I'm trying to achieve basically, is to seperate the GUI, i.e. the Scene from the data and logic below. So each screen will look the same but will just have different info/images. I have buttons you see which allow navigation through said screens and so I need to tell each screen object the next and previous screens.

        • 1. Re: Overloading constructors and parsing instance of class to itself
          kglad Adobe Community Professional & MVP
          Screen instances should be self-contained and not use info about other Screen instances. include all the functionality the Screen instance needs in that class.

          use another class, maybe a ScreenController class to create your Screen instances and store references to them in an array. this ScreenController class can code the way the Screen instances interact with each other. it has access to all the Screen instances, their relationship to each other (ie, which is next and which is previous) and has access to all the Screen methods and properties.