Hi everyone
I’ve created a grid of 3D cubes using modulus, and the 3d cubes are were created from the Math and Flash Tutorial, if you are interested it is here.
What I am trying to accomplish (and it works, just the performance is lousy). All the cubes in the grid are inactive until the mouse hovers over them, then they start to rotate, and once the mouse moves off them they continue to rotate…
So to create the grid of cubes:
public function FlowerMenu(){
var rowY:Number = 0;
for (var i:int = 0; i < 190; i++) {
var myCube = new CubeMenu(["anemon.jpg","parodia.jpg","anagallis.jpg","lila.jpg","cosm os.jpg","adonis.jpg"],100);
myCube.x = 0 + ((i % 10) * 200);
if (i % 10 == 0) {
rowY += 200;
}
myCube.y = rowY;
addChild(myCube);
}
No real issue there, all the cubes show up, tho if anybody has any improvements I would appreciate them.
Here is where the issue is, the mouse events & event listeners:
private var i:int = 0;
private function setUpListeners():void
{
spBoard.addEventListener(MouseEvent.MOUSE_OVER, boardOver);
spBoard.addEventListener(MouseEvent.MOUSE_OUT, boardOut);
}
private function boardOver(e:MouseEvent):void
{
addEventListener(Event.ENTER_FRAME, rotateSquare);
}
private function boardOut(e:MouseEvent):void
{
addEventListener(Event.ENTER_FRAME, rotateSquare);
}
private function rotateSquare(e:Event)
{
renderView(curTheta+i, curPhi+i);
i++;
}
So, this works, but after about 4 or 5 cubes have started rotating the
performance drops considerably. I can imagine creating that many
EventListeners isn’t a good idea, but I can’t see any other way of
doing it.
Does anybody have any suggestions or code improvements, I’m very new to AS3 and Flash so any help or suggestions would be greatly appreciated.
Thanks in advance.