I've created three *.as files. Two of them are classes? the third is
main logic of program. In Away3D.as I've create a scene and view. In
meshesModule.as I've create plane primitive, in xmlLoaderModule.as I'm
loading *.swf and when it's loaded I set it as Movimaterial texture on
plane. After every click I'm loosing more and more RAM memory. Here's
code:
Away3D.as:
package {
import away3d.cameras.HoverCamera3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.events.MouseEvent3D;
import code.meshesModule;
import code.xmlLoaderModule;
import flash.display.Sprite;
import flash.events.Event;
[SWF(backgroundColor="0xFFFFFF", quality="high")]
public class Away3D extends Sprite
{
private var scene:Scene3D;
private var view:View3D;
private var cam:HoverCamera3D;
private var meshesCode:meshesModule=new meshesModule();
private var xmlLoaderCode:xmlLoaderModule=new xmlLoaderModule();
public function Away3D()
{
scene=new Scene3D();
cam=new HoverCamera3D();
cam.distance=1500;
cam.mintiltangle=-90;
view=new View3D({x:stage.stageWidth/2,
y:stage.stageHeight/2,
camera:cam});
addChild(view);
xmlLoaderCode.llooaaddiinngg();
view.scene.addChild(meshesCode._plane);
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void
{
if (xmlLoaderCode.xmlFileLoaded)
{
xmlLoaderCode.loadingTexture();
xmlLoaderCode.xmlFileLoaded=false;
}
if (xmlLoaderCode.swfLoaded)
{
meshesCode._plane.material=xmlLoaderCode.swfMaterialArray[0];
xmlLoaderCode.swfLoaded=false;
}
meshesCode._plane.addOnMouseDown(msdwn);
cam.targetpanangle=-(mouseX-(stage.stageWidth/2))*0.1;
cam.targettiltangle=-(mouseY-(stage.stageHeight/2))*0.1;
cam.hover();
view.render();
}
private function msdwn(e:MouseEvent3D):void
{
xmlLoaderCode.llooaaddiinngg();
}
}
}
meshesModule.as:
package code
{
import away3d.primitives.Plane;
public class meshesModule
{
public var _plane:Plane;
public function meshesModule()
{
_plane=new Plane({rotationX:-90, rotationZ:180,
width:600, height:
490});
}
}
}
xmlLoaderModule.as:
package code
{
import away3d.materials.MovieMaterial;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class xmlLoaderModule
{
//--arrays--
//--flashes--
public var swfMaterialArray:Array=new Array();
public var timeSwfMaterialArray:Array=new Array();
//--variables--
private var groupIndex:int=0;
public var swfLoaded:Boolean=false;
//--XML--
public var xml:XMLList;
private var xmlLoader:URLLoader=new URLLoader();
//--booleans--
public var xmlFileLoaded:Boolean=false;
public function xmlLoaderModule()
{
}
public function llooaaddiinngg():void
{
xmlLoader.addEventListener(Event.COMPLETE,
xmlFileLoadedFunc);
xmlLoader.load(new URLRequest("Sirius-Group.xml"));
}
public function xmlFileLoadedFunc(e:Event):void
{
var xmlDataPic:XML=new XML(e.target.data);
xml=xmlDataPic.children();
xmlFileLoaded=true;
}
public function loadingTexture():void
{
for (var i:int=0; i < xml[0].children()
[1].elements("swf").length(); i++)
{
var swfLoader:Loader=new Loader();
swfLoader.load(new URLRequest(xml[0].children()
[1].elements("swf")[i].attributes()[0]));
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
swfLoadedFunc);
timeSwfMaterialArray.push(swfLoader.contentLoaderInfo);
}
}
public function swfLoadedFunc(e:Event):void
{
var flashMaterial:MovieMaterial=new
MovieMaterial(e.target.content, {interactive:true, smooth:2});
swfMaterialArray[timeSwfMaterialArray.indexOf(e.target)]=flashMaterial;
LoaderInfo(e.target).removeEventListener(Event.COMPLETE,
swfLoadedFunc);
swfLoaded=true;
}
}
}
--
To unsubscribe, reply using "remove me" as the subject.