設定 scaffold color effect=None
設定 PreloaderScaffold 的 outline layer=Guide
並新開一層 layer 加入新的 loading 特效.
in pages.PreloaderScaffold.as
調整 onResize function
private function onResize(event:Event = null):void
{
//x = (Gaia.api.getWidth() - width) / 2;
//y = (Gaia.api.getHeight() - height) / 2;
}
完整 code 如下:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pages | |
{ | |
import com.gaiaframework.templates.AbstractPreloader; | |
import com.gaiaframework.api.Gaia; | |
import com.gaiaframework.events.*; | |
import com.greensock.TweenMax; | |
import flash.display.*; | |
import flash.events.*; | |
import flash.text.*; | |
public class PreloaderScaffold extends Sprite | |
{ | |
public var TXT_Overall:TextField; | |
public var TXT_Asset:TextField; | |
public var TXT_Bytes:TextField; | |
public var MC_Bar:Sprite; | |
public var loading:MovieClip | |
public function PreloaderScaffold() | |
{ | |
super(); | |
alpha = 0; | |
visible = false; | |
mouseEnabled = mouseChildren = false; | |
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); | |
} | |
private function onAddedToStage(event:Event):void | |
{ | |
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); | |
stage.addEventListener(Event.RESIZE, onResize); | |
onResize(); | |
} | |
public function transitionIn():void | |
{ | |
alpha = 1; | |
visible = true; | |
TXT_Asset.visible = MC_Bar.visible = TXT_Bytes.visible = false; | |
} | |
public function transitionOut():void | |
{ | |
TweenMax.to(this, .1, { autoAlpha:0 } ); | |
} | |
public function onProgress(event:AssetEvent):void | |
{ | |
// if bytes, don't show if loaded = 0, if not bytes, don't show if perc = 0 | |
// the reason is because all the files might already be loaded so no need to show preloader | |
visible = event.bytes ? (event.loaded > 0) : (event.perc > 0); | |
// multiply perc (0-1) by 100 and round for overall | |
//TXT_Overall.text = "Loading " + Math.round(event.perc * 100) + "%"; | |
//TXT_Overall.text = String(Math.round(event.perc * 100)) + "%"; | |
TXT_Overall.text = String(Math.round(event.perc * 100)); | |
// individual asset percentage (0-1) multiplied by 100 and round for display | |
var assetPerc:int = Math.round(event.asset.percentLoaded * 100) || 0; | |
TXT_Asset.text = (event.asset.title || event.asset.id) + " " + assetPerc + "%"; | |
TXT_Asset.autoSize = TextFieldAutoSize.LEFT; | |
// progress bar scale times percentage (0-1) | |
MC_Bar.scaleX = event.perc; | |
// if bytes is true, show the actual bytes loaded and total | |
TXT_Bytes.text = (event.bytes) ? event.loaded + " / " + event.total : ""; | |
TXT_Bytes.autoSize = TextFieldAutoSize.LEFT; | |
} | |
private function onResize(event:Event = null):void | |
{ | |
//x = (Gaia.api.getWidth() - width) / 2; | |
//y = (Gaia.api.getHeight() - height) / 2; | |
} | |
} | |
} |
沒有留言:
張貼留言