Now Loading...
の...が点滅(?)するようにしようと思ったのですが、できませんでした。どうやらタイマーによるイベントハンドラが呼ばれていないようです。(違うかもしれません)
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.utils.Timer;
import flash.events.TimerEvent;
/**
* ...
* @author DefaultUser (Tools -> Custom Arguments...)
*/
public class Main extends Sprite
{
public var loadedNum:int = 0;
public const MEDIA_NUM:int = 11;
public var loadTim:Timer = new Timer(1000);
public var txtFil:TextField = new TextField();
public var nowLoCou:uint = 0;
public var head:Loader = new Loader();
public var piece:Loader = new Loader();
public var bottom:Loader = new Loader();
public var sword:Loader = new Loader();
public var sarada:Loader = new Loader();
public var crown:Loader = new Loader();
public var bgm:Sound = new Sound();
public var cut:Sound = new Sound();
public var whistle:Sound = new Sound();
public var snareroll:Sound = new Sound();
public var result:Sound = new Sound();
public function LoadCompleted():void
{
this.loadedNum++;
if (loadedNum == MEDIA_NUM);//本編開始
}
public function Load():void
{
this.head.load(new URLRequest("head.PNG") );
this.head.contentLoaderInfo.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.piece.load(new URLRequest("piece.PNG") );
this.piece.contentLoaderInfo.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.bottom.load(new URLRequest("bottom.PNG") );
this.bottom.contentLoaderInfo.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.sword.load(new URLRequest("sword.PNG") );
this.sword.contentLoaderInfo.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.sarada.load(new URLRequest("sarada.PNG") );
this.sarada.contentLoaderInfo.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.crown.load(new URLRequest("crown.PNG") );
this.crown.contentLoaderInfo.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.bgm.load(new URLRequest("bgm.mp3") );
this.bgm.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.cut.load(new URLRequest("cut.mp3") );
this.cut.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.whistle.load(new URLRequest("whistle.mp3") );
this.whistle.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.snareroll.load(new URLRequest("snareroll.mp3") );
this.snareroll.addEventListener(Event.COMPLETE, this.LoadCompleted);
this.result.load(new URLRequest("result.mp3") );
this.result.addEventListener(Event.COMPLETE, this.LoadCompleted);
}
public function NowLoading(event:TimerEvent):void
{
this.nowLoCou++;
var flag:int = this.nowLoCou / 6;
if(flag==0) this.txtFil.text = "Now Loading...";
if(flag==1) this.txtFil.text = "Now Loading..";
if(flag==2) this.txtFil.text = "Now Loading.";
if(flag==3) this.txtFil.text = "Now Loading";
if(flag==4) this.txtFil.text = "Now Loading.";
if (flag == 5) this.txtFil.text = "Now Loading..";
this.addChild(this.txtFil);//※表示されなかった
}
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
txtFil.text = "Now Loading...";
txtFil.width = 512;
txtFil.x = 129;
txtFil.y = 160;
var myForm:TextFormat = new TextFormat();
myForm.bold = true;
myForm.font = "Comic sans MS";
myForm.size = 36;
txtFil.setTextFormat(myForm);
//this.addChild(txtFil);//※イベントハンドラが呼び出されているか調べるためコメントアウト
this.loadTim.addEventListener(TimerEvent.TIMER, this.NowLoading);
}
}
}
わかる方おねがいします。