※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

 notice: Flash editor updated! Join the development! Thanks to MiniBuilder


forked from : butr0s's Star Field [diff(2)]

FORKED
  1. // forked from prjohnny's forked from: Star Field
  2. // forked from butr0s's Star Field
  3. // Just a star field!
  4. package {
  5.     import flash.display.Sprite;
  6.     [SWF(width="465", height="100", backgroundColor="0x000033", frameRate="20")]
  7.     public class StarField extends Sprite {
  8.         public function StarField():void { main = this; initialize(); }
  9.     }
  10. }
  11. import flash.display.*;
  12. //import flash.geom.*;
  13. import flash.events.Event;
  14. var SCREEN_WIDTH:int = 465, SCREEN_HEIGHT:int = 200;
  15. var main:Sprite, g:Graphics;
  16. //var stars:Vector.<Star> = new Vector.<Star>;
  17. var stars:Array = new Array(1000);
  18. function initialize():void {
  19.     g = main.graphics;
  20.     main.addEventListener(Event.ENTER_FRAME, update);
  21.     for(var i:int = 0; i < 200; i++) stars[i] = new Star();
  22. }
  23. function update(e:Event):void {
  24.     g.clear();
  25.     for each(var s:Star in stars) s.update();
  26. }
  27. class Star extends Sprite {
  28.     public var position:Object = new Object();
  29.     public var velocity:Object = new Object();
  30.     
  31.     public function Star():void {
  32.         position.x = Math.random() * SCREEN_WIDTH;
  33.         position.y = Math.random() * SCREEN_HEIGHT;
  34.         position.z = Math.random() * 8;
  35.         
  36.         velocity.x = position.z * -1/4;    // 5 being an arbitrary "speed up" number
  37.         velocity.y = velocity.z = 0;
  38.     }
  39.     
  40.     public function update():void {
  41.         //position.incrementBy(velocity);
  42.         position.x += velocity.x;
  43.         if(position.x < 0) position.x = SCREEN_WIDTH;
  44.         alpha = position.x;
  45.         g.lineStyle(position.z, 0xffffff, 0.8);
  46.         g.moveTo(position.x, position.y);
  47.         g.lineTo(position.x + 1, position.y);
  48.     }
  49. }
noswf
Get Adobe Flash Player