Note that there are some explanatory texts on larger screens.

plurals
  1. POCode performance, event listeners, multiple rotating boxes
    text
    copied!<p>I've created a grid of 3D cubes using modulus, and the 3d cubes are were created from the Math and <a href="http://www.flashandmath.com/advanced/menu3d/" rel="nofollow" title="3D Menu on a Cube with Perspective, Distorting Images in ActionScript 3">Flash tutorial</a> </p> <p>I have set up listeners so when the mouse hovers over a cube it starts to rotate:</p> <pre><code>private function setUpListeners():void { spBoard.addEventListener(MouseEvent.ROLL_OUT,boardOut); } </code></pre> <p>That works fine. </p> <p>To begin the rotation of the cube when the mouse passes over it I have used:</p> <pre><code> private function boardOut(e:MouseEvent):void { addEventListener(Event.ENTER_FRAME,rotateSquare); var i:int = 1; function rotateSquare(e:Event) { renderView(curTheta+i,curPhi+i); i++; } } </code></pre> <p>I can see why this would be inefficient, as it is running the loop every every frame, and for so many multiple cubes it just lags (very badly).</p> <p>Does anybody have a better method of doing this? I'd be happy to post more code if people need/require it. </p> <p>Thanks in advance.</p> <p>EDIT: I should clarify, i'm hoping for the rotation to continue indefinitely once the mouse moves off the cube. </p> <p>2nd EDIT:</p> <p>Here is how I am creating the cubes onto the "grid":</p> <pre><code>public function FlowerMenu(){ var rowY:Number = 0; for (var i:int = 0; i &lt; 190; i++) { var myCube = new CubeMenu(["anemon.jpg","parodia.jpg","anagallis.jpg","lila.jpg","cosmos.jpg","adonis.jpg"],100); myCube.x = 0 + ((i % 10) * 200); if (i % 10 == 0) { rowY += 200; } myCube.y = rowY; addChild(myCube); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload