3 Replies Latest reply on Jun 20, 2006 11:10 PM by Craig Grummitt

    Question about OOP

      Hi guys,
      I'm very new to OOP concept in Flash and in general. Here's what Im been doing, and from this I experienced difficulty in implementing what I want.
      First, I created a class. This class contains properties and methods. Methods included are the setter and getter.
      Second, I setup the .fla
      I have one textbox and a command button in my first frame with this code:
      stop( );
      var product:myClass = new myClass( );

      Then for my command button I wrote this code:
      on(click) {

      And on the 5th frame: I created a second textbox (txt2) where what ever input on the first textbox should be reflected here. The textbox (txt1) and the command button (btn1) does not appear on this 5th frame. Only the txt2 is here.
      What I want is to pass what ever the value of product.setValue, what I did is to write a code in the 5th frame
      Here's the code:
      stop( );
      _root.txt2.text = product.getValue( );

      However, this does not work and it says on the txt2, undefined

      My question now is, how can I retain or get the value, I'd notice my object does not stay after going on the 5th frame.
      And I know using the _global is not a good idea, I know Im missing something here.
      Please advise.

      Thanks very much. Please help out.

      Best regards,

        • 1. Re: Question about OOP
          Craig Grummitt Level 3
          i suspect that the object does still exist on the fifth frame. have you confirmed this in the debugger?
          i think you should first check if your getValue and setValue functions are being called okay, by including a trace in their first lines.
          i suspect that your call to setValue is not being pathed correctly
          i.e. it should work if you had:
          • 2. Re: Question about OOP
            Amcasperforu Level 1
            Hi Craig,


            Thank you for your immediate reply. You are right, I should write _root. on it. Im just wondering why this is so? and when our object is lost?

            Lastly, any idea how can I remove the object, I mean totally removing it ? Thanks.

            Best regards,

            • 3. Re: Question about OOP
              Craig Grummitt Level 3
              if you are calling an object from a different path, you need to reference the object's path. if you were to replace your script inside the simpleButton handler(on (click)) with trace(this), you will discover that script inside the simpleButton event refers to the instance of the button. see livedocs

              you can remove objects with the delete statement.