package { import away3d.containers.View3D; import away3d.lights.DirectionalLight3D; import away3d.materials.PhongColorMaterial; import away3d.primitives.Cone; import away3d.primitives.Cylinder; import flash.display.Sprite; import flash.events.Event; [SWF(width="500", height="220", frameRate="60", backgroundColor="#FFFFFF")] public class Basic08_cylinder extends Sprite { private var view:View3D; private var cone1:Cylinder; private var cone2:Cylinder; private var cone3:Cylinder; private var cover:Cover; private var light:DirectionalLight3D; public function Basic08_cylinder() { // create a viewport view = new View3D({x:250,y:110}); addChild(view); // create a cube and put it on stage cone1 = new Cylinder({material:"red#black",segmentsH:1,segmentsW:15,heigth:70,radius:30,x:-170}); view.scene.addChild(cone1); cone2 = new Cylinder({material:"orange#black",segmentsH:1,segmentsW:15,heigth:70,radius:30,x:0,openEnded:true,bothsides:true}); view.scene.addChild(cone2); var mat:PhongColorMaterial = new PhongColorMaterial(0x7777ff); cone3 = new Cylinder({material:mat,segmentsH:1,segmentsW:15,heigth:70,radius:30,x:170}); view.scene.addChild(cone3); // Add a light to make the Phong material visible light = new DirectionalLight3D({x:100,y:300,z:500}); light.color = 0xffffff; light.specular = 1; light.diffuse = .75; view.scene.addChild(light); // add the cover that prevents the problem with too many SWF files running at once view.render(); cover = new Cover(this,500,220); addChild(cover); // render on enterframe this.addEventListener(Event.ENTER_FRAME,render); } private function render(e:Event):void { if(!cover.visible) { // Rotate the cube cone1.rotationX += 1; cone1.rotationY += .5; cone2.rotationX += 1; cone2.rotationY += .5; cone3.rotationX += 1; cone3.rotationY += .5; // Render the view view.render(); } } } }