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

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

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


FAVORITE BY
:
#
:
:
ball throwing
:
grey ball dropping
FORKED
  1. // forked from clockmaker's Ball
  2. // forked from clockmaker's code on 2008-12-17
  3. package 
  4. {
  5.     import flash.display.Sprite;
  6.     import flash.events.Event;
  7.     import flash.events.MouseEvent;
  8.     
  9.     /**
  10.      * ボールを投げ遊ぶサンプル
  11.      */
  12.     public class Main extends Sprite
  13.     {
  14.         private var ball:Sprite;
  15.         private var vx:Number = 0;
  16.         private var vy:Number = 0;
  17.         private var oldX:Number;
  18.         private var oldY:Number;
  19.         private var flag:Boolean = false;
  20.         
  21.         /**
  22.          * コンストラクター(実行時にはじめに実行される関数)
  23.          */
  24.         public function Main()
  25.         {
  26.             // フレームレートを設定
  27.             stage.frameRate = 60;
  28.             
  29.             // ボールを作成
  30.             ball = new Sprite();
  31.             ball.graphics.beginFill(0x999999, 1);
  32.             ball.graphics.drawCircle(0050);
  33.             this.addChild(ball);
  34.             
  35.             // インタラクティブの設定
  36.             ball.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
  37.             ball.addEventListener(MouseEvent.MOUSE_UP, upHandler);
  38.             this.addEventListener(Event.ENTER_FRAME, enterHandler);
  39.         }
  40.         
  41.         /**
  42.          * ボールを押したときの処理です
  43.          */
  44.         private function downHandler(e:MouseEvent):void 
  45.         {
  46.             // マウスの位置を保存
  47.             oldX = this.mouseX;
  48.             oldY = this.mouseY;
  49.             
  50.             // ドラッグを開始
  51.             ball.startDrag(true);
  52.             
  53.             // ボールの速度を無効にする
  54.             flag = true;
  55.         }
  56.         
  57.         /**
  58.          * ボールからマウスを離したときの処理です
  59.          */
  60.         private function upHandler(e:MouseEvent):void 
  61.         {
  62.             // ボールの速度を有効にする(ドラッグした距離に応じて、速度を設定)
  63.             vx = this.mouseX - oldX;
  64.             vy = this.mouseY - oldY;
  65.             
  66.             // ドラッグを解除
  67.             ball.stopDrag();
  68.             
  69.             // ボールの速度を無効にする
  70.             flag = false;
  71.         }
  72.         
  73.         /**
  74.          * フレーム毎に実行される処理です(アニメーション用途で設定しています)
  75.          */
  76.         private function enterHandler(e:Event):void 
  77.         {
  78.             // ボールをドラッグ中はアニメーションを無効化
  79.             if (flag) return;
  80.             
  81.             //重力
  82.             vy += .5
  83.             
  84.             // 摩擦
  85.             vx *= 0.97
  86.             vy *= 0.97;
  87.             
  88.             // ボールに物理演算を適用
  89.             ball.x += vx; 
  90.             ball.y += vy;
  91.             
  92.             // 画面の端からはみ出さないようにする処理
  93.             if(ball.x + ball.width/2 > stage.stageWidth)
  94.             {
  95.                 ball.x  = stage.stageWidth - ball.width / 2;
  96.                 vx *= -0.7;
  97.             }
  98.             else if(ball.x - ball.width/2 < 0)
  99.             {
  100.                 ball.x  = 0 + ball.width / 2;
  101.                 vx *= -0.7;
  102.             }
  103.             if(ball.y + ball.height / 2 > stage.stageHeight)
  104.             {
  105.                 ball.y  = stage.stageHeight - ball.height / 2;
  106.                 vy *= -0.7;
  107.             }
  108.             else if(ball.y - ball.height / 2 < 0)
  109.             {
  110.                 ball.y  = + ball.height / 2;
  111.                 vy *= -0.7;
  112.             }
  113.         }
  114.     }
  115. }
noswf
  1. // forked from clockmaker's Ball
  2. // forked from clockmaker's code on 2008-12-17
  3. package 
  4. {
  5.     import flash.display.Sprite;
  6.     import flash.events.Event;
  7.     import flash.events.MouseEvent;
  8.     
  9.     /**
  10.      * ボールを投げ遊ぶサンプル
  11.      */
  12.     public class Main extends Sprite
  13.     {
  14.         private var ball:Sprite;
  15.         private var vx:Number = 0;
  16.         private var vy:Number = 0;
  17.         private var oldX:Number;
  18.         private var oldY:Number;
  19.         private var flag:Boolean = false;
  20.         
  21.         /**
  22.          * コンストラクター(実行時にはじめに実行される関数)
  23.          */
  24.         public function Main()
  25.         {
  26.             // フレームレートを設定
  27.             stage.frameRate = 60;
  28.             
  29.             // ボールを作成
  30.             ball = new Sprite();
  31.             ball.graphics.beginFill(0x999999, 1);
  32.             ball.graphics.drawCircle(0050);
  33.             this.addChild(ball);
  34.             
  35.             // インタラクティブの設定
  36.             ball.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
  37.             ball.addEventListener(MouseEvent.MOUSE_UP, upHandler);
  38.             this.addEventListener(Event.ENTER_FRAME, enterHandler);
  39.         }
  40.         
  41.         /**
  42.          * ボールを押したときの処理です
  43.          */
  44.         private function downHandler(e:MouseEvent):void 
  45.         {
  46.             // マウスの位置を保存
  47.             oldX = this.mouseX;
  48.             oldY = this.mouseY;
  49.             
  50.             // ドラッグを開始
  51.             ball.startDrag(true);
  52.             
  53.             // ボールの速度を無効にする
  54.             flag = true;
  55.         }
  56.         
  57.         /**
  58.          * ボールからマウスを離したときの処理です
  59.          */
  60.         private function upHandler(e:MouseEvent):void 
  61.         {
  62.             // ボールの速度を有効にする(ドラッグした距離に応じて、速度を設定)
  63.             vx = this.mouseX - oldX;
  64.             vy = this.mouseY - oldY;
  65.             
  66.             // ドラッグを解除
  67.             ball.stopDrag();
  68.             
  69.             // ボールの速度を無効にする
  70.             flag = false;
  71.         }
  72.         
  73.         /**
  74.          * フレーム毎に実行される処理です(アニメーション用途で設定しています)
  75.          */
  76.         private function enterHandler(e:Event):void 
  77.         {
  78.             // ボールをドラッグ中はアニメーションを無効化
  79.             if (flag) return;
  80.             
  81.             //重力
  82.             vy += .5
  83.             
  84.             // 摩擦
  85.             vx *= 0.97
  86.             vy *= 0.97;
  87.             
  88.             // ボールに物理演算を適用
  89.             ball.x += vx; 
  90.             ball.y += vy;
  91.             
  92.             // 画面の端からはみ出さないようにする処理
  93.             if(ball.x + ball.width/2 > stage.stageWidth)
  94.             {
  95.                 ball.x  = stage.stageWidth - ball.width / 2;
  96.                 vx *= -0.7;
  97.             }
  98.             else if(ball.x - ball.width/2 < 0)
  99.             {
  100.                 ball.x  = 0 + ball.width / 2;
  101.                 vx *= -0.7;
  102.             }
  103.             if(ball.y + ball.height / 2 > stage.stageHeight)
  104.             {
  105.                 ball.y  = stage.stageHeight - ball.height / 2;
  106.                 vy *= -0.7;
  107.             }
  108.             else if(ball.y - ball.height / 2 < 0)
  109.             {
  110.                 ball.y  = + ball.height / 2;
  111.                 vy *= -0.7;
  112.             }
  113.         }
  114.     }
  115. }
noswf
  1. // forked from clockmaker's Ball
  2. // forked from clockmaker's code on 2008-12-17
  3. package 
  4. {
  5.     import flash.display.Sprite;
  6.     import flash.events.Event;
  7.     import flash.events.MouseEvent;
  8.     
  9.     /**
  10.      * ボールを投げ遊ぶサンプル
  11.      */
  12.     public class Main extends Sprite
  13.     {
  14.         private var ball:Sprite;
  15.         private var vx:Number = 0;
  16.         private var vy:Number = 0;
  17.         private var oldX:Number;
  18.         private var oldY:Number;
  19.         private var flag:Boolean = false;
  20.         
  21.         /**
  22.          * コンストラクター(実行時にはじめに実行される関数)
  23.          */
  24.         public function Main()
  25.         {
  26.             // フレームレートを設定
  27.             stage.frameRate = 60;
  28.             
  29.             // ボールを作成
  30.             ball = new Sprite();
  31.             ball.graphics.beginFill(0x999999, 1);
  32.             ball.graphics.drawCircle(0050);
  33.             this.addChild(ball);
  34.             
  35.             // インタラクティブの設定
  36.             ball.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
  37.             ball.addEventListener(MouseEvent.MOUSE_UP, upHandler);
  38.             this.addEventListener(Event.ENTER_FRAME, enterHandler);
  39.         }
  40.         
  41.         /**
  42.          * ボールを押したときの処理です
  43.          */
  44.         private function downHandler(e:MouseEvent):void 
  45.         {
  46.             // マウスの位置を保存
  47.             oldX = this.mouseX;
  48.             oldY = this.mouseY;
  49.             
  50.             // ドラッグを開始
  51.             ball.startDrag(true);
  52.             
  53.             // ボールの速度を無効にする
  54.             flag = true;
  55.         }
  56.         
  57.         /**
  58.          * ボールからマウスを離したときの処理です
  59.          */
  60.         private function upHandler(e:MouseEvent):void 
  61.         {
  62.             // ボールの速度を有効にする(ドラッグした距離に応じて、速度を設定)
  63.             vx = this.mouseX - oldX;
  64.             vy = this.mouseY - oldY;
  65.             
  66.             // ドラッグを解除
  67.             ball.stopDrag();
  68.             
  69.             // ボールの速度を無効にする
  70.             flag = false;
  71.         }
  72.         
  73.         /**
  74.          * フレーム毎に実行される処理です(アニメーション用途で設定しています)
  75.          */
  76.         private function enterHandler(e:Event):void 
  77.         {
  78.             // ボールをドラッグ中はアニメーションを無効化
  79.             //if (flag) return;
  80.             
  81.             //重力
  82.             vy += .5
  83.             
  84.             // 摩擦
  85.             vx *= 0.97
  86.             vy *= 0.97;
  87.             
  88.             // ボールに物理演算を適用
  89.             ball.x += vx; 
  90.             ball.y += vy;
  91.             
  92.             // 画面の端からはみ出さないようにする処理
  93.             if(ball.x + ball.width/2 > stage.stageWidth)
  94.             {
  95.                 ball.x  = stage.stageWidth - ball.width / 2;
  96.                 vx *= -0.7;
  97.             }
  98.             else if(ball.x - ball.width/2 < 0)
  99.             {
  100.                 ball.x  = 0 + ball.width / 2;
  101.                 vx *= -0.7;
  102.             }
  103.             if(ball.y + ball.height / 2 > stage.stageHeight)
  104.             {
  105.                 ball.y  = stage.stageHeight - ball.height / 2;
  106.                 vy *= -0.7;
  107.             }
  108.             else if(ball.y - ball.height / 2 < 0)
  109.             {
  110.                 ball.y  = + ball.height / 2;
  111.                 vy *= -0.7;
  112.             }
  113.         }
  114.     }
  115. }
noswf
  1. // forked from clockmaker's Ball
  2. // forked from clockmaker's code on 2008-12-17
  3. package 
  4. {
  5.     import flash.display.Sprite;
  6.     import flash.events.Event;
  7.     import flash.events.MouseEvent;
  8.     
  9.     /**
  10.      * ボールを投げ遊ぶサンプル
  11.      */
  12.     public class Main extends Sprite
  13.     {
  14.         private var ball:Sprite;
  15.         private var vx:Number = 0;
  16.         private var vy:Number = 0;
  17.         private var oldX:Number;
  18.         private var oldY:Number;
  19.         private var flag:Boolean = false;
  20.         
  21.         /**
  22.          * コンストラクター(実行時にはじめに実行される関数)
  23.          */
  24.         public function Main()
  25.         {
  26.             // フレームレートを設定
  27.             stage.frameRate = 60;
  28.             graphics.beginFill(0x999999, 1);
  29. graphics.drawCircle(stage.stageWidth, stage.stageHeight, 10);
  30. graphics.drawCircle(stage.stageWidth, 010);
  31. graphics.drawCircle(0, stage.stageHeight, 10);
  32. graphics.drawCircle(0010);
  33.             // ボールを作成
  34.             ball = new Sprite();
  35.             ball.graphics.beginFill(0x999999, 1);
  36.             ball.graphics.drawCircle(0050);
  37.             this.addChild(ball);
  38.             
  39.             // インタラクティブの設定
  40.             ball.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
  41.             ball.addEventListener(MouseEvent.MOUSE_UP, upHandler);
  42.             this.addEventListener(Event.ENTER_FRAME, enterHandler);
  43.         }
  44.         
  45.         /**
  46.          * ボールを押したときの処理です
  47.          */
  48.         private function downHandler(e:MouseEvent):void 
  49.         {
  50.             // マウスの位置を保存
  51.             oldX = this.mouseX;
  52.             oldY = this.mouseY;
  53.             
  54.             // ドラッグを開始
  55.             ball.startDrag(true);
  56.             
  57.             // ボールの速度を無効にする
  58.             flag = true;
  59.         }
  60.         
  61.         /**
  62.          * ボールからマウスを離したときの処理です
  63.          */
  64.         private function upHandler(e:MouseEvent):void 
  65.         {
  66.             // ボールの速度を有効にする(ドラッグした距離に応じて、速度を設定)
  67.             vx = this.mouseX - oldX;
  68.             vy = this.mouseY - oldY;
  69.             
  70.             // ドラッグを解除
  71.             ball.stopDrag();
  72.             
  73.             // ボールの速度を無効にする
  74.             flag = false;
  75.         }
  76.         
  77.         /**
  78.          * フレーム毎に実行される処理です(アニメーション用途で設定しています)
  79.          */
  80.         private function enterHandler(e:Event):void 
  81.         {
  82.             // ボールをドラッグ中はアニメーションを無効化
  83.             if (flag) return;
  84.             
  85.             //重力
  86.             vy += .5
  87.             
  88.             // 摩擦
  89.             vx *= 0.97
  90.             vy *= 0.97;
  91.             
  92.             // ボールに物理演算を適用
  93.             ball.x += vx; 
  94.             ball.y += vy;
  95.             
  96.             // 画面の端からはみ出さないようにする処理
  97.             if(ball.x + ball.width/2 > stage.stageWidth)
  98.             {
  99.                 ball.x  = stage.stageWidth - ball.width / 2;
  100.                 vx *= -0.7;
  101.             }
  102.             else if(ball.x - ball.width/2 < 0)
  103.             {
  104.                 ball.x  = 0 + ball.width / 2;
  105.                 vx *= -0.7;
  106.             }
  107.             if(ball.y + ball.height / 2 > stage.stageHeight)
  108.             {
  109.                 ball.y  = stage.stageHeight - ball.height / 2;
  110.                 vy *= -0.7;
  111.             }
  112.             else if(ball.y - ball.height / 2 < 0)
  113.             {
  114.                 ball.y  = + ball.height / 2;
  115.                 vy *= -0.7;
  116.             }
  117.         }
  118.     }
  119. }
noswf
  1. // forked from clockmaker's Ball
  2. // forked from clockmaker's code on 2008-12-17
  3. package 
  4. {
  5.     import flash.display.Sprite;
  6.     import flash.events.Event;
  7.     import flash.events.MouseEvent;
  8.     
  9.     /**
  10.      * ボールを投げ遊ぶサンプル
  11.      */
  12.     public class Main extends Sprite
  13.     {
  14.         private var ball:Sprite;
  15.         private var vx:Number = 0;
  16.         private var vy:Number = 0;
  17.         private var oldX:Number;
  18.         private var oldY:Number;
  19.         private var flag:Boolean = false;
  20.         
  21.         /**
  22.          * コンストラクター(実行時にはじめに実行される関数)
  23.          */
  24.         public function Main()
  25.         {
  26.             // フレームレートを設定
  27.             stage.frameRate = 60;
  28.             
  29.             // ボールを作成
  30.             ball = new Sprite();
  31.             ball.graphics.beginFill(0x999999, 1);
  32.             ball.graphics.drawCircle(0050);
  33.             this.addChild(ball);
  34.             
  35.             // インタラクティブの設定
  36.             ball.addEventListener(MouseEvent.MOUSE_DOWN, downHandler);
  37.             ball.addEventListener(MouseEvent.MOUSE_UP, upHandler);
  38.             this.addEventListener(Event.ENTER_FRAME, enterHandler);
  39.         }
  40.         
  41.         /**
  42.          * ボールを押したときの処理です
  43.          */
  44.         private function downHandler(e:MouseEvent):void 
  45.         {
  46.             // マウスの位置を保存
  47.             oldX = this.mouseX;
  48.             oldY = this.mouseY;
  49.             
  50.             // ドラッグを開始
  51.             ball.startDrag(true);
  52.             
  53.             // ボールの速度を無効にする
  54.             flag = true;
  55.         }
  56.         
  57.         /**
  58.          * ボールからマウスを離したときの処理です
  59.          */
  60.         private function upHandler(e:MouseEvent):void 
  61.         {
  62.             // ボールの速度を有効にする(ドラッグした距離に応じて、速度を設定)
  63.             vx = this.mouseX - oldX;
  64.             vy = this.mouseY - oldY;
  65.             
  66.             // ドラッグを解除
  67.             ball.stopDrag();
  68.             
  69.             // ボールの速度を無効にする
  70.             flag = false;
  71.         }
  72.         
  73.         /**
  74.          * フレーム毎に実行される処理です(アニメーション用途で設定しています)
  75.          */
  76.         private function enterHandler(e:Event):void 
  77.         {
  78.             // ボールをドラッグ中はアニメーションを無効化
  79.             if (flag) return;
  80.             
  81.             //重力
  82.             vy += .5
  83.             
  84.             // 摩擦
  85.             vx *= 0.97
  86.             vy *= 0.97;
  87.             
  88.             // ボールに物理演算を適用
  89.             ball.x += vx; 
  90.             ball.y += vy;
  91.             
  92.             // 画面の端からはみ出さないようにする処理
  93.             if(ball.x + ball.width/2 > stage.stageWidth)
  94.             {
  95.                 ball.x  = stage.stageWidth - ball.width / 2;
  96.                 vx *= -0.7;
  97.             }
  98.             else if(ball.x - ball.width/2 < 0)
  99.             {
  100.                 ball.x  = 0 + ball.width / 2;
  101.                 vx *= -0.7;
  102.             }
  103.             if(ball.y + ball.height / 2 > stage.stageHeight)
  104.             {
  105.                 ball.y  = stage.stageHeight - ball.height / 2;
  106.                 vy *= -0.7;
  107.             }
  108.             else if(ball.y - ball.height / 2 < 0)
  109.             {
  110.                 ball.y  = + ball.height / 2;
  111.                 vy *= -0.7;
  112.             }
  113.         }
  114.     }
  115. }
noswf
Get Adobe Flash Player