I wrote 2 swfs, first is based on Away3D, the secon on Lite version.
First application use CPU only ven I hover my camera, when camera
doesn't hover CPU doesn't using, the second use CPU really less then
first application, but, when I don't hover the camera it continue use
CPU? what am i do wrong?
this is the source of lite version:
public function Map_Ukraine_Vector()
{
init();
listeners();
}
private function init():void
{
scene=new Scene3D();
cam=new HoverCamera3D();
view=new View3D();
view.x=stage.stageWidth/2;
view.y=stage.stageHeight/2;
view.camera=cam;
view.scene=scene;
cam.distance=CAM_DISTANCE;
cam.focus=100;
addChild(view);
setChildIndex(view, 0);
txt.selectable=false;
addChild(txt);
}
private function listeners():void
{
xml.addEventListener(Event.COMPLETE, onXMLLoaded);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onXMLLoaded(e:Event):void
{
var loader:Loader=new Loader();
loader.load(new URLRequest(xml.picUkraine));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
createMap);
}
private function createMap(e:Event):void
{
e.target.removeEventListener(Event.COMPLETE, createMap);
cityPropArray=xml.cityPA;
mapUkraine=new Sphere();
mapUkraine.segmentsH=25;
mapUkraine.segmentsW=25;
mapUkraine.radius=RADIUS;
mapUkraine.bothsides=false;
var m:BitmapMaterial=new
BitmapMaterial(Cast.bitmap(e.target.content));
m.smooth=true;
m.repeat=false;
m.debug=false;
mapUkraine.sortFaces=false;
mapUkraine.material=m;
mapUkraine.useHandCursor=false;
world.addChild(mapUkraine);
var ar2:Array=new Array();
var color:ColorMaterial=new ColorMaterial();
color.color=0x000000;
for (; counter<25; counter++)
{
oblGroup[counter]=new ObjectContainer3D();
world.addChild(oblGroup[counter]);
var ar:Array=new Array();
for (var i:int=0;
i<cityPropArray[counter].length; i++)
{
ar[i]=new Cone();
ar[i].height=CITY_HEIGHT;
ar[i].radius=CITY_RADIUS;
ar[i].segmentsH=1;
ar[i].segmentsW=3;
ar[i].visible=true;
ar[i].useHandCursor=true;
ar[i].material=color;
ar[i].openEnded=false;
ar[i].rotationY=parseFloat(cityPropArray[counter][i][0][0]
[0].cityY);
ar[i].rotationX=-parseFloat(cityPropArray[counter][i][0][0]
[0].cityX)+90;
arPosition=rotPoint.returnPosition(RADIUS+ar[i].height/2,
ar[i].rotationX-90, ar[i].rotationY,
mapUkraine.x, mapUkraine.y, mapUkraine.z);
ar[i].x=arPosition[0].x;
ar[i].y=arPosition[0].y;
ar[i].z=arPosition[0].z;
oblGroup[counter].addChild(ar[i]);
oblGroup[counter].addEventListener(MouseEvent3D.MOUSE_OVER,
mouseOverObl);
oblGroup[counter].addEventListener(MouseEvent3D.MOUSE_OUT,
mouseOutObl);
oblGroup[counter].addEventListener(MouseEvent3D.MOUSE_DOWN,
mouseDownObl);
var
s:String=cityPropArray[counter][0][0][0][0].oblName+" -
"+cityPropArray[counter][i][0][0][0].cityName;
ar2.push(({lbl:s, oblNum:counter,
cityNum:i}));
}
}
ar2.sortOn("lbl");
for (var h:int=0; h<ar2.length; h++)
{
cityPropArray[ar2[h].oblNum][ar2[h].cityNum][0][0][0].cityID=h;
}
view.scene.addChild(world);
}
.................
private function onEnterFrame(e:Event):void
{
cam.panAngle=-((mouseX-(stage.stageWidth/2))*0.07)+1;
cam.tiltAngle=-((mouseY-(stage.stageHeight/2))*0.01);
cam.hover();
view.render();
}