5 Replies Latest reply on May 16, 2006 9:33 AM by juro_el_muerto

    AS1: instanceof Movieclip subclass

    juro_el_muerto
      Hi,
      I have a problem with an ActionScript 1 movie (I would like to upgrade, but unfortunately there isn't a newer standalone Flash player for Linux).

      I have created a class XYZ which is a subclass of MovieClip with a custom method createXYZ(). Now I attach a few XYZ instances to the _root movie, so the object structure lookes like this:
      _root.xyz1
      _root.xyz2
      _root.xyz3
      _root.xyz4
      Now when I call the custom method createXYZ() with this
      _root.xyz1.createXYZ()
      nothing happens. And displaying the instance of _root.xyz1
      typeof(_root.xyz1)
      returns moviclip, which is not totally correct. So here are my questions:
      1. Can I call my custom method in the way I am trying?
      2. If not, how can I achieve this?

      Thank you in advance
      juro
        • 1. Re: instanceof Movieclip subclass
          Level 7
          > Hi,
          > I have a problem with an ActionScript 1 movie (I would like to upgrade,
          > but
          > unfortunately there isn't a newer standalone Flash player for Linux).

          That doesn't matter . you can still use AS2 and export to SWF6 or SWF7

          > And displaying the instance of _root.xyz1
          > typeof(_root.xyz1)
          > returns moviclip, which is not totally correct.

          Read the help on typeof .. that is exactly what it is supposed to return.
          try trace("Is XYZ = " + _root.xyz1 instanceof XYZ)

          How did you make your movieclips be instance of the XYZ class?
          --
          Jeckyl


          • 2. Re: instanceof Movieclip subclass
            juro_el_muerto Level 1
            > That doesn't matter . you can still use AS2 and export to SWF6 or SWF7
            Unfortunately we had MAJOR problems using this approach, so we have to code everything in AS1.
            >try trace("Is XYZ = " + _root.xyz1 instanceof XYZ)
            This does not work (compilation error). I did however construct an IF claus looking like this:
            if (_root.xyz1 instanceof XYZ) { do something }
            but the condition always returned false.
            if (_root.xyz1 instanceof MovieClip) { do something }
            returns true.
            > How did you make your movieclips be instance of the XYZ class?
            I have a dummy symbol (xyzSymbol) in the library and have this code in the main movie (as described in o'reilly's ActionScript for Flash MX):
            // create namespace in which to store livequoten classes
            if (_global.org == undefined) {
            _global.org = new Object();
            }
            if (_global.org.dummy == undefined) {
            _global.org.dummy = new Object();
            }

            org.dummy.XYZ = function() {
            delete this.params;
            }
            org.livequoten.XYZ.prototype = new MovieClip();
            Object.registerClass("dummySymbol", org.livequoten.XYZ);

            And then I attach instances of this class to the main movie:

            xxx = new Object();
            for (i=0; i < 4; i++) {
            _parentMC.attachMovie("dummySymbol", "xyz_" + i, i+1, xxx);
            }

            Now this is a part of a VERY more complex project, so I tried to sumarise my problem as much as possible ...

            And thank you for your time.
            • 3. Re: instanceof Movieclip subclass
              Level 7
              > if (_root.xyz1 instanceof XYZ) { do something }
              > but the condition always returned false.
              > if (_root.xyz1 instanceof MovieClip) { do something }
              > returns true.

              Then that is the cause of your problem .. the xyz1 is NOT of class XYZ at
              all.


              • 4. Re: instanceof Movieclip subclass
                juro_el_muerto Level 1
                > Then that is the cause of your problem .. the xyz1 is NOT of class XYZ at all.
                And why not? XYZ is a subclass of MovieClip and the dummySymbol is the flash aquivalent of XYZ, therefore any instance of dummySymbol must be an instance of XYZ and of MovieClip.
                • 5. Re: instanceof Movieclip subclass
                  juro_el_muerto Level 1
                  And, if "the xyz1 is NOT of class XYZ at all" how do I make it a class of XYZ (which is a subclass of MovieClip)?