3 Replies Latest reply on Jun 15, 2007 7:19 AM by complexity

    2000 lines of actionscript makes my movie playup

    complexity Level 1
      Hey all,

      When I approach 2000 lines of code in my current flash project my movie becomes unstable.

      Below is an example of 1 case statement (I have 15 in all). How can I better optimise this? I need to have both an alpha and enabled=true; value for my objects. At present I am writing out 2 lines to accomplish this. Is there a way I can just write 1 line?

      case "1": //project management
      _root.map.map_mc.vic.greatw._alpha = 100;
      _root.map.map_mc.vic.balm._alpha = 100;
      _root.map.map_mc.vic.wools._alpha = 100;
      _root.map.map_mc.vic.warrn._alpha = 100;
      _root.map.map_mc.vic.bendigo._alpha = 100;
      _root.map.map_mc.vic.maryb._alpha = 100;
      _root.map.map_mc.vic.ballarat._alpha = 100;
      _root.map.map_mc.vic.glenl._alpha = 100;
      _root.map.map_mc.vic.abbots._alpha = 100;
      _root.map.map_mc.vic.baccus._alpha = 100;
      _root.map.map_mc.vic.ballan._alpha = 100;
      _root.map.map_mc.vic.barwon._alpha = 100;
      _root.map.map_mc.vic.nagam._alpha = 100;
      _root.map.map_mc.vic.tollar._alpha = 100;
      _root.map.map_mc.vic.rubic._alpha = 100;
      _root.map.map_mc.vic.wando._alpha = 100;
      _root.map.map_mc.vic.clunes._alpha = 100;
      _root.map.map_mc.vic.tooborac._alpha = 100;
      _root.map.map_mc.vic.lorne._alpha = 100;
      _root.map.map_mc.vic.gelli._alpha = 100;
      _root.map.map_mc.vic.skipton._alpha = 100;
      _root.map.map_mc.vic.keilor._alpha = 100;
      _root.map.map_mc.vic.deerpark._alpha = 100;
      _root.map.map_mc.vic.garibaldi._alpha = 100;
      _root.map.map_mc.vic.newton._alpha = 100;
      _root.map.map_mc.vic.lallal._alpha = 100;
      _root.map.map_mc.vic.shepparton._alpha = 100;
      _root.map.map_mc.ball_map.bal_dsps._alpha = 100;
      _root.map.map_mc.ball_map.bal_apsd._alpha = 100;
      _root.map.map_mc.ball_map.bal_bosu._alpha = 100;
      _root.map.map_mc.ball_map.bal_lscb._alpha = 100;
      _root.map.map_mc.ball_map.bal_bgpp._alpha = 100;
      _root.map.map_mc.ball_map.bal_gs._alpha = 100;
      _root.map.map_mc.ball_map.bal_grnst._alpha = 100;
      _root.map.map_mc.ball_map.bal_bgtsf._alpha = 100;
      _root.map.map_mc.vic.greatw.enabled=true;
      _root.map.map_mc.vic.balm.enabled=true;
      _root.map.map_mc.vic.wools.enabled=true;
      _root.map.map_mc.vic.warrn.enabled=true;
      _root.map.map_mc.vic.bendigo.enabled=true;
      _root.map.map_mc.vic.maryb.enabled=true;
      _root.map.map_mc.vic.ballarat.enabled=true;
      _root.map.map_mc.vic.glenl.enabled=true;
      _root.map.map_mc.vic.abbots.enabled=true;
      _root.map.map_mc.vic.baccus.enabled=true;
      _root.map.map_mc.vic.ballan.enabled=true;
      _root.map.map_mc.vic.barwon.enabled=true;
      _root.map.map_mc.vic.nagam.enabled=true;
      _root.map.map_mc.vic.tollar.enabled=true;
      _root.map.map_mc.vic.rubic.enabled=true;
      _root.map.map_mc.vic.wando.enabled=true;
      _root.map.map_mc.vic.clunes.enabled=true;
      _root.map.map_mc.vic.tooborac.enabled=true;
      _root.map.map_mc.vic.lorne.enabled=true;
      _root.map.map_mc.vic.gelli.enabled=true;
      _root.map.map_mc.vic.skipton.enabled=true;
      _root.map.map_mc.vic.keilor.enabled=true;
      _root.map.map_mc.vic.deerpark.enabled=true;
      _root.map.map_mc.vic.garibaldi.enabled=true;
      _root.map.map_mc.vic.newton.enabled=true;
      _root.map.map_mc.vic.lallal.enabled=true;
      _root.map.map_mc.vic.shepparton.enabled=true;
      _root.map.map_mc.ball_map.bal_dsps.enabled=true;
      _root.map.map_mc.ball_map.bal_apsd.enabled=true;
      _root.map.map_mc.ball_map.bal_bosu.enabled=true;
      _root.map.map_mc.ball_map.bal_lscb.enabled=true;
      _root.map.map_mc.ball_map.bal_bgpp.enabled=true;
      _root.map.map_mc.ball_map.bal_gs.enabled=true;
      _root.map.map_mc.ball_map.bal_grnst.enabled=true;
      _root.map.map_mc.ball_map.bal_bgtsf.enabled=true;


      break;

      Any help would be much appreciated
        • 1. Re: 2000 lines of actionscript makes my movie playup
          anonymous thing
          create an array that contains all your MovieClip and create a loop to iterate thought the array.... sincerely I think is to much initialization of elements at the same time for the flash player(you will break it)


          • 2. Re: 2000 lines of actionscript makes my movie playup
            Level 7
            Its hard to tell from just this code but, if the list of items to be
            changed is always the same, then you could place the clip names in an
            array and then operate on the array items. That won't relieve the
            complexity or shorten the amount of time it takes the code to execute.

            If you use the _visible property instead of _alpha and enabled, you can
            cut out one operation. If a button or movieClip is not visible, then it
            is also not active. If you need to fade the button or clip then you'll
            need to use the _alpha property.

            An alternative to using the _visible property is to move the object off
            the visible area of the stage. Again, if you don't need to fade the
            object, you can just move it. If the object can't be reached, then it
            won't be active.
            • 3. Re: 2000 lines of actionscript makes my movie playup
              complexity Level 1
              thanks for the suggestions guys, yeah I will probably end up going with the visible object as it started playing up right near the finish of the coding. It will half it so it should be a winner.

              Let you know