Hiya,

I've been having memory leak problems with a project that I'm working
on.. It's a massive project so thought I would set up a little test to
see if I can completely kill away3D from memory...

Below is the code I'm using, but even this has got a memory leak...

package
{
        import away3d.containers.View3D;
        import away3d.materials.WireColorMaterial;
        import away3d.primitives.Plane;

        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import nl.demonsters.debugger.MonsterDebugger;
        [SWF(backgroundColor="#000000", width="800", height="600")]
        public class MyTest01_viewCameraScene extends Sprite
        {
                private var _view:View3D;
                private var _plane:Plane;
                private var _clickFlag:Boolean = false
                public function MyTest01_viewCameraScene()
                {
                        this.stage.addEventListener(MouseEvent.CLICK, 
_onMouseClick)
                }
                private function _onMouseClick(e:MouseEvent):void
                {

                        if (_clickFlag) {
                                cleanUp()
                        } else {
                                ini()
                        }
                }
                private function cleanUp():void
                {
                        trace("cleanUp")
                        _clickFlag      = false;
                        removeEventListener(Event.ENTER_FRAME, _onEnterFrame);
                        _view.scene.removeChild(_plane)
                        _plane = null
                        removeChild(_view)
                        _view = null
                }
                private function ini():void
                {
                        trace("ini")
                        _clickFlag = true
                        _view = new View3D();
                        addChild(_view);
                        _view.x = 400;
                        _view.y = 300;
                        _plane = new Plane();
                        _plane.width = 500;
                        _plane.height = 500;
                        _plane.yUp = false;
                        _plane.bothsides = true;
                        _plane.material = new WireColorMaterial(0xFF0000)
                        _view.scene.addChild(_plane);
                        addEventListener(Event.ENTER_FRAME, _onEnterFrame);
                }
                private function _onEnterFrame(e:Event):void
                {
                        _plane.rotationY += 2;
                        _view.render();
                }
        }
}

Reply via email to