15.10.2012 Views

Actionscript 3 Entwicklerhandbuch

Actionscript 3 Entwicklerhandbuch

Actionscript 3 Entwicklerhandbuch

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ACTIONSCRIPT 3.0 ENTWICKLERHANDBUCH<br />

Arbeiten mit drei Dimensionen (3D)<br />

for (var i:int = 0; i < numLayers; i++)<br />

{<br />

this.addChild(createBox(150, 50, (numLayers - i) * depthPerLayer, boxWidth,<br />

boxHeight, 0xCCCCFF));<br />

this.addChild(createBox(50, 150, (numLayers - i) * depthPerLayer, boxWidth,<br />

boxHeight, 0xFFCCCC));<br />

this.addChild(createBox(250, 150, (numLayers - i) * depthPerLayer, boxWidth,<br />

boxHeight, 0xCCFFCC));<br />

this.addChild(createBox(150, 250, (numLayers - i) * depthPerLayer, boxWidth,<br />

boxHeight, 0xDDDDDD));<br />

}<br />

}<br />

public function createBox(xPos:int = 0, yPos:int = 0, zPos:int = 100, w:int = 50, h:int<br />

= 50, color:int = 0xDDDDDD):Shape<br />

{<br />

var box:Shape = new Shape();<br />

box.graphics.lineStyle(2, 0x666666);<br />

box.graphics.beginFill(color, 1.0);<br />

box.graphics.drawRect(0, 0, w, h);<br />

box.graphics.endFill();<br />

box.x = xPos;<br />

box.y = yPos;<br />

box.z = zPos;<br />

return box;<br />

}<br />

public function startDragProjectionCenter(e:Event)<br />

{<br />

center.startDrag();<br />

inDrag = true;<br />

}<br />

public function doDragProjectionCenter(e:Event)<br />

{<br />

if (inDrag)<br />

{<br />

root.transform.perspectiveProjection.projectionCenter = new Point(center.x,<br />

center.y);<br />

}<br />

}<br />

public function stopDragProjectionCenter(e:Event)<br />

{<br />

center.stopDrag();<br />

root.transform.perspectiveProjection.projectionCenter = new Point(center.x,<br />

center.y);<br />

inDrag = false;<br />

}<br />

}<br />

}<br />

Für komplexere perspektivischen Projektionen verwenden Sie die Matrix3D-Klasse.<br />

Letzte Aktualisierung 27.6.2012<br />

382

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!