「デザイン02-1」の編集履歴(バックアップ)一覧に戻る

デザイン02-1 - (2009/01/08 (木) 18:47:05) の編集履歴(バックアップ)


ランダムにムービーを再生


[[サンプルファイル・ダウンロード>http://www34.atwiki.jp/ninja22?cmd=upload&act=open&pageid=42&file=test_dIn_randm.swf]]
およそランダムに3つのムービーのうち1つを再生する。
(swfを貼り付けようと思ったのですが、このwikiでは不可能らしい。)

使うもの:flash

(1) ムービークリップを3つ作っておく。
(2) ステージにそれらを置く。
 それぞれに、インスタンス名「sq、tr、cr」を指定する。
(3) ボタンを作る。
 ボタンに、以下のアクションスクリプトを書き込む。
on(press){
 nMax = 3;
 nMin = 1; 
 // nMinからnMaxまでのランダムな整数を返す
  var nRandomInt = Math.floor(Math.random()*(nMax-nMin+1))+nMin; 
 //trace(nRandomInt); //出力ウィンドウで表示したいときに
 
 if( nRandomInt==1){
  _root.sq.gotoAndPlay(1);
 }
 else if( nRandomInt==2){
  _root.tr.gotoAndPlay(1);
 }
 else if( nRandomInt==3){
  _root.cr.gotoAndPlay(1);
 }
 _root.d1.text = nRandomInt;
 
}






today: -
yesterday: -