トンネルをくぐる感じ yoshuki forked:3favorite:2lines:59license : MIT License modified : 2009-06-01 15:53:37 Embed Tweet package { import flash.display.Sprite import flash.events.Event import flash.events.TimerEvent import flash.utils.Timer import org.papervision3d.materials.WireframeMaterial import org.papervision3d.view.BasicView [SWF(width=640, height=480, frameRate=30, backgroundColor=0x000000)] public class Roll extends Sprite { public static const TICK:String = 'tick' private var timer:Timer = new Timer(33) private var ticks:uint = 0 private var world:BasicView public function Roll() { var material:WireframeMaterial = new WireframeMaterial(0xffff00) var roll:Roll = this; timer.addEventListener(TimerEvent.TIMER, function (event:Event):void { ticks++; dispatchEvent(new Event(TICK)) if (ticks % 3 === 0) { new Ball(roll, world, material) } world.camera.z += 5 if (world.camera.z >= 0) { world.camera.z = -1 timer.stop() } }) timer.start() world = new BasicView(640, 480, true, true) addChild(world) world.startRendering() } } } import flash.events.Event import flash.events.EventDispatcher import org.papervision3d.core.proto.MaterialObject3D import org.papervision3d.objects.primitives.Sphere import org.papervision3d.view.BasicView class Ball extends Sphere { private static const RADIUS:int = 100 private var degree:int function Ball(dispatcher:EventDispatcher, world:BasicView, material:MaterialObject3D) { super(material, 10, 10, 10) dispatcher.addEventListener(Roll.TICK, function (event:Event):void { degree += 20 if (degree === 360) { degree = 0 } x = (RADIUS * Math.cos(degree * Math.PI / 180)) y = (RADIUS * Math.sin(degree * Math.PI / 180)) z -= 10 try { if (world.camera.z > z) { world.scene.removeChild(this) } } catch (e:Error) { // I don't know what I should do yet. } }) x = (RADIUS * Math.cos(degree * Math.PI / 180)) y = (RADIUS * Math.sin(degree * Math.PI / 180)) world.scene.addChild(this) } } Code Fullscreen Preview Fullscreen run soundkitchen.. world material EventDispatcher stop dispatchEvent Math.PI Error removeChild start Math.cos addEventListener Math.sin addChild Timer String uint Sprite int sort new page view favorite forked pv0 forked from: トンネルをくぐる感じ run forked:0 favorite:0lines:59 (diff:1) pv0 forked from: トンネルをくぐる感じ run forked:0 favorite:0lines:59 (diff:1) pv0 forked from: トンネルをくぐる感じ run forked:0 favorite:0lines:59 (diff:1)