3 Replies Latest reply on Nov 29, 2006 3:51 AM by Peter Lorent

    bothering class

    Level 7
      hi,
      although i have over 5 years of flash experience, only recently i've
      actually learnt how to use OOP, and began implementing code via classes in
      my projects.
      for examle, i have several different projects on my computer, all of them
      have in them more-or-less the same type of menu. up untill now, that menu
      was created (dynamically) inside a MC called 'menu', with the code for
      creating that menu found inside the 'menu' MC (to be honest - this sort of
      structure is inheritence i got from the previous flash programmer in my
      office...). so what i did, is create a class called 'menu', which recieves
      (together with other parameters) the MC into which the menu is created, and
      create that menu on the fly. i've placed that class file in a folder which
      i defined as a 'class path' (in the AS 2.0 settings in the IDE prefrences)
      so i won't have a different copy of it for every project.

      i wrote all this down only so you'd understand the problem i've encountered:
      older projects which don't use the 'menu' class yet, but the old structure,
      and has no link what-so-ever to that class, when i publish them i get
      errors, for flash looks for methods and properties found in the 'menu' MC in
      the 'menu' class.
      let me try make things more clear: in the old projects, i have a MC called
      'menu', which has a function called 'menuBuild', and when i publish that
      project i get the following error: "There is no method with the name
      'menuBuild'." - which is a menthod of the 'menu' MC but not a method of the
      'menu' class! but as i said, that old project doesn't use that class at
      all!

      if anyone understood my problem, i'd appreciate some explainations. in the
      meanwhile, my work-around for this, is before i publish old projects i
      rename my menu class file to something like '_menu.as', so it can't b found.

      thanks in advance,
      eRez


        • 1. Re: bothering class
          Peter Lorent Level 2
          Scenario:
          -the menu class is called 'menu.as' and placed in a class path
          -movieclip has an instance name 'menu'

          That's error prone. Every time Flash encounters the word 'menu' in the code (old code included) it will assume you are trying to call a function in the class menu.as
          The class should have been called Menu.as (first letter capital - 'best practices').
          • 2. Re: bothering class
            Level 7
            thanks for the advise, i'll keep that in mind.
            any idea why this happens in the first place? why a file which isn't
            'linked' to a class, is still affected by its existance?

            "LuigiL" <webforumsuser@macromedia.com> wrote in message
            news:ekjipg$smn$1@forums.macromedia.com...
            > Scenario:
            > -the menu class is called 'menu.as' and placed in a class path
            > -movieclip has an instance name 'menu'
            >
            > That's error prone. Every time Flash encounters the word 'menu' in the
            > code
            > (old code included) it will assume you are trying to call a function in
            > the
            > class menu.as
            > The class should have been called Menu.as (first letter capital - 'best
            > practices').
            >



            • 3. Re: bothering class
              Peter Lorent Level 2
              It happens because the class is in the class path. Where you think you are targeting the movieclip with the instance name 'menu', Flash 'sees' the class in the class path and assumes you mean the class. Personally I never use the class path but always use packages.