away3d, starling - problem with GPU Memory

Software: Away3D 4.x

3pstation, Newbie
Posted: 13 April 2014 06:34 AM   Total Posts: 11

Hi!
There are Main class where i have starling and PrefabProject. I use Stage3DProxy for this. This swf(it’s 3D level-map) i use in main flash . When i do dispose, how i can see, GPU memory do not release… So when this map-swf is loaded again flash player crash… Please Help smile

//Main Class
  
public function My3DClass()
  
{
   addEventListener
(flash.events.Event.ADDED_TO_STAGE, initProxies);
  
}
  
  
private function initProxies(event:flash.events.Event = null):void
  {
   removeEventListener
(flash.events.Event.ADDED_TO_STAGE, initProxies);
   
_stage3DManager = Stage3DManager.getInstance(stage);
   
   
_stage3DProxy = _stage3DManager.getFreeStage3DProxy();
   
_stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATED, initApp);
   
_stage3DProxy.antiAlias = 2;
   
_stage3DProxy.color = 0xFF0000;
  
}
  
  
private function initApp(event:flash.events.Event):void
  {
   _stage3DProxy
.removeEventListener(Stage3DEvent.CONTEXT3D_CREATED, initApp);
   
_prefab = new PrefabProject();
   
_prefab.initView(_stage3DProxy, this);
   
addChild(_prefab);
   
initStarling();
  
}
  
private function initStarling():void
  {
   _starling 
= new Starling(StarlingStarsSprite, stage, _stage3DProxy.viewPort, _stage3DProxy.stage3D);
   
_starling.addEventListener(starling.events.Event.ROOT_CREATED, starlingActivated)
  
}

  
private function starlingActivated(event:starling.events.Event = null):void
  {
   _starling
.removeEventListener(starling.events.Event.ROOT_CREATED, starlingActivated)
   
_stage3DProxy.addEventListener(flash.events.Event.ENTER_FRAME, onEnterFrame);
  
}

  
private function onEnterFrame(event:flash.events.Event):void
  {
   Guys
.update();
   
_hoverController.update();
   
_prefab.renderFrame(null);
   
_starling.nextFrame();
  
}

  
public function destroy():void
  {
   _awayStates
.unregisterView(_prefab.view);
   
this.removeChild(_awayStates);
   
_stage3DProxy.removeEventListener(flash.events.Event.ENTER_FRAME, onEnterFrame);
   
   
_prefab.destroy();
   
_starling.stop();
   
_starling.dispose();
   
_stage3DProxy.dispose();
   
   
AssetLibraryBundle.getInstance().removeAllAssets(true);
   
   
_stage3DManager = null;
   
   
this.removeChild(_prefab);
   
   try 
{
    
new LocalConnection().connect('foo');
    new 
LocalConnection().connect('foo');
   
} catch (e:*) {};
}

//Prefab Class
  
public function initView(stage3DProxy:Stage3DProxy, parent:DisplayObjectContainer):void
  {
   _view 
= new View3D();
   
_view.antiAlias = 2;
   
_view.stage3DProxy = stage3DProxy;
   
_view.shareContext = true;
   
_view.backgroundColor = 0xCCCCCC;

   
_camera = _view.camera;
   
_camera.lens = new PerspectiveLens(48);
   
_camera.lens.near = 10;
   
_camera.lens.far = 550000;

   
_camera.x = -2636.898193359375;
   
_camera.y = 1824.3687744140625;
   
_camera.z = 2308.4296875;

   
//addChild(_view);
   
parent.addChild(_view);
  
}

  
public function destroy():void
  {
   parent
.removeChild(_view);
   
_view.dispose();
  
} 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X