5 Replies Latest reply on Oct 6, 2007 11:58 AM by kglad

    HELP.as2 code forces swf to be unresponsive

    WChristian
      Hi Anyone
      i have been playing with some great open source from blitz agency and have been tweaking it. All the code is in an as file and contains no errors but when exported the swf does not play and i get an error saying the code is forcing it to run slowly.

      Here is the file if any one wants to have a look, Im really struggling.

      Thanks all
      http://www.isbg.co.uk/patrickm/main.zip
      as2 file here

      its a problem somewhere in the attached code

        • 1. Re: HELP.as2 code forces swf to be unresponsive
          kglad Adobe Community Professional & MVP
          linkageIds.length is probably undefined.
          • 2. Re: HELP.as2 code forces swf to be unresponsive
            WChristian Level 1
            this is more, where would you define it. thanks for help.

            var linkageIds:Array = ["mc1","mc2","mc3"]
            for(var i=0;i<linkageIds.length;i++){
            var mc:MovieClip = this.attachMovie(linkageIds ,"clip"+i,this.getNextHighestDepth(),{index:i});
            mc.myButton.addEventListener("onRelease",Delegate.create(this,onButtonRelease));
            }

            var spaceMovieClip:SpaceMovieClip = new SpaceMovieClip(mc,spaceObject);
            spaceView.push(spaceMovieClip);
            }
            Key.addListener(this);
            }
            • 3. Re: HELP.as2 code forces swf to be unresponsive
              kglad Adobe Community Professional & MVP
              that for-loop is not causing the problem. comment it out and then retest. keep commenting out for-loops until you narrow the problem. occasionally, this problem is not a for-loop/while-loop problem.
              • 4. Re: HELP.as2 code forces swf to be unresponsive
                WChristian Level 1
                This is all of it except the imports, if i comment out i get errors where as the cod ebelow gives me no errors but script kills teh swf?

                ps i am an as 2 newbie

                Appreciate your help


                class demos.blur.Main extends MovieClip{

                public var totalItems:Number = 5;
                private var space:Space;
                private var spaceView:SpaceView;
                private var camera:SpaceCamera;

                private var xTween:Tween;
                private var yTween:Tween;
                private var zTween:Tween;
                private var index:Number = 0;

                private var tracer:MovieClip;

                public function Main(){}

                private function onLoad():Void{
                space = new Space();
                camera = new SpaceCamera(0,0,-5000,0,0,0,400);
                space.push(camera);
                spaceView = new SpaceView();
                spaceView.camera = camera;
                for (var i:Number=0; i<totalItems; i++){
                var spaceObject:SpaceObject = Space.createRandomObject(800,600,5000);
                space.push(spaceObject);

                var linkageIds:Array = ["mc1","mc2","mc3"]
                for(var i=0;i<linkageIds.length;i++){
                var mc:MovieClip = this.attachMovie(linkageIds ,"clip"+i,this.getNextHighestDepth(),{index:i});
                mc.myButton.addEventListener("onRelease",Delegate.create(this,onButtonRelease));
                }

                var spaceMovieClip:SpaceMovieClip = new SpaceMovieClip(mc,spaceObject);
                spaceView.push(spaceMovieClip);
                }
                Key.addListener(this);
                }

                private function onEnterFrame():Void{
                space.update();
                spaceView.render(camera);
                tracer.debug(camera)
                }

                private function onButtonRelease(eventObj:Object):Void{
                index = eventObj.target._parent.index;
                var spaceMovieClip:SpaceMovieClip = SpaceMovieClip(spaceView[index]);
                moveCamera(spaceMovieClip.spaceObject);
                }

                private function moveCamera(spaceObject:SpaceObject):Void{
                xTween = new Tween(camera,"x",Strong.easeOut,camera.x,spaceObject.x,18,false);
                yTween = new Tween(camera,"y",Strong.easeOut,camera.y,spaceObject.y,18,false);
                zTween = new Tween(camera,"z",Strong.easeOut,camera.z,spaceObject.z-25,18,false);
                }

                private function onKeyDown():Void{
                if(Key.isDown(38) || Key.isDown(87)){
                index++;
                index = (index > totalItems-1)?0:index;
                var spaceObject:SpaceObject = SpaceObject(space[index]);
                moveCamera(spaceObject);
                }
                if(Key.isDown(40) || Key.isDown(83)){
                index--;
                index = (index < 0)?totalItems-1:index;
                var spaceObject:SpaceObject = SpaceObject(space[index]);
                moveCamera(spaceObject);
                }
                }

                }
                • 5. Re: HELP.as2 code forces swf to be unresponsive
                  kglad Adobe Community Professional & MVP
                  i don't see a problem there but there are a few other classes that are called that could contain the problematic code. use some trace() functions to narrow the problem's location.