Q:偵測目前的scene
A:var myParentSrc:String = page.branch;//取得paga路徑 ex:index/nav/home
if(ExternalInterface.available){//只有ExternalInterface可用时才执行JS调用。
Tracking.track(“alert”, route);
}
Q:一開始發布甚麼都沒有居然會自己有背景!!
A:new Scaffold(this);這行註解調
Q:左上角的menu如何刪除
A:先刪除每個page的new Scaffold(this);這行,
再把Scaffold.swf刪掉
Q:換頁中間的loading哩?
A:跟一開始LOADING依樣
Q:
取得上一層的路徑
A:var myParentSrc:String = page.getParent().src;//但是nav= =
Q:直接去某一頁
A:Gaia.api.goto("index/nav/about");
Q:
右鍵不要menu
A:<site title="Gaia Framework Site: %PAGE%" menu="false">//menu設為false
Q:
除了page nav跟preloading切開?!不能直接發!?
A:放在INDEX.FLA(待測,MAIN等於一個LOADER
Q:preloader一直是黑色的!?
A:一切都是誤會!!沒有什麼顏色效果設定需要改,把場景上的刪掉再重新拉出來就變彩色的了...
Q:一執行一片空白!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
A:可以用ADDED_TO_STAGE來載入 BUT仍有一些問題
或是寫隻CLASS!(待測...
如果用ADDED_TO_STAGE來載入除了preloader跟nav有些問題之外,其他page好像ok
Q:menu 跑的影格名稱找不到!
A:無解!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
用原始方法解決吧.........
/**
* Gaia Framework Global Nav Lesson
* @author Steven Sacks
*/
package pages
{
import com.gaiaframework.templates.AbstractPage;
import com.gaiaframework.events.*;
import com.gaiaframework.debug.*;
import com.gaiaframework.api.*;
import flash.display.*;
import flash.events.*;
import com.greensock.TweenMax;
public class NavPage extends AbstractPage
{
private var buttons:Array;
public var homeBTN:MovieClip;
public var aboutBTN:MovieClip;
public function NavPage()
{
super();
alpha = 0;
//new Scaffold(this);
initButtons();
}
public function initButtons():void
{
homeBTN.branch = "index/nav/home";
aboutBTN.branch = "index/nav/about";
buttons = [homeBTN, aboutBTN];
var i:int = buttons.length;
while (i--)
{
buttons[i].buttonMode = true;
buttons[i].mouseChildren = false;
buttons[i].addEventListener(MouseEvent.CLICK, onClick);
buttons[i].addEventListener(MouseEvent.MOUSE_OVER, onOver);
buttons[i].addEventListener(MouseEvent.MOUSE_OUT, onOut);
}
Gaia.api.afterGoto(onAfterGoto);
updateButtonStates(Gaia.api.getCurrentBranch());
}
public function onOver(event:MouseEvent):void {
event.target.gotoAndPlay("up");
}
public function onOut(event:MouseEvent):void {
//event.target.gotoAndPlay("selected");
TweenMax.to(event.target, .5, {frame:1});
}
private function onClick(event:MouseEvent):void
{
Gaia.api.goto(MovieClip(event.target).branch);
}
private function onAfterGoto(event:GaiaEvent):void
{
updateButtonStates(event.validBranch);
}
private function updateButtonStates(branch:String):void
{
var i:int = buttons.length;
while (i--)
{
var btn:MovieClip = buttons[i];
if (branch != btn.branch)
{
btn.gotoAndStop("up");
btn.enabled = true;
btn.addEventListener(MouseEvent.MOUSE_OUT, onOut);
btn.addEventListener(MouseEvent.MOUSE_OVER, onOver);
}
else
{
btn.removeEventListener(MouseEvent.MOUSE_OVER, onOver);
btn.removeEventListener(MouseEvent.MOUSE_OUT, onOut);
btn.gotoAndStop("selected");
btn.enabled = false;
}
}
}
override public function transitionIn():void
{
super.transitionIn();
TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
}
override public function transitionOut():void
{
super.transitionOut();
TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
}
}
}
--------------------------------------------更正版--------------------------------------------------------
/**
* Gaia Framework Global Nav Lesson
* @author Steven Sacks
*/
package pages
{
import com.gaiaframework.templates.AbstractPage;
import com.gaiaframework.events.*;
import com.gaiaframework.debug.*;
import com.gaiaframework.api.*;
import flash.display.*;
import flash.events.*;
import com.greensock.TweenMax;
public class NavPage extends AbstractPage
{
private var buttons:Array;
public var homeBTN:MovieClip;
public var aboutBTN:MovieClip;
private var flag :Boolean = false;
private var _Str :String;
private var mcmc :Object = null;
public function NavPage()
{
super();
alpha = 0;
//new Scaffold(this);
addEventListener(Event.ADDED_TO_STAGE, onAdd);
addEventListener(Event.REMOVED_FROM_STAGE, onRemove);
}
private function onRemove(e:Event):void
{
removeEventListener(Event.REMOVED_FROM_STAGE, onRemove);
}
private function onAdd(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, onAdd);
initButtons();
transitionIn();
}
public function initButtons():void
{
homeBTN.branch = "index/nav/home";
aboutBTN.branch = "index/nav/about";
buttons = [homeBTN, aboutBTN];
var i:int = buttons.length;
while (i--)
{
buttons[i].buttonMode = true;
buttons[i].mouseChildren = false;
buttons[i].addEventListener(MouseEvent.CLICK, onClick);
buttons[i].addEventListener(MouseEvent.ROLL_OVER, onOver);
buttons[i].addEventListener(MouseEvent.ROLL_OUT, onOut);
buttons[i].addEventListener(Event.ENTER_FRAME, BTNEnterFrame);
}
Gaia.api.afterGoto(onAfterGoto);
updateButtonStates(Gaia.api.getCurrentBranch());
}
private function BTNEnterFrame(e:Event):void
{
if (mcmc != null) {
var _mc:MovieClip =mcmc as MovieClip;
if (flag) {
if (_mc.currentFrame != _mc.totalFrames) {
_mc.nextFrame();
}
}else {
if (_mc.currentFrame != 1) {
_mc.prevFrame();
}
}
}
}
public function onOver(event:MouseEvent):void {
flag = true;
mcmc = event.target;
}
public function onOut(event:MouseEvent):void {
flag = false;
mcmc = event.target;
}
private function onClick(event:MouseEvent):void
{
Gaia.api.goto(MovieClip(event.target).branch);
}
private function onAfterGoto(event:GaiaEvent):void
{
updateButtonStates(event.validBranch);
}
private function updateButtonStates(branch:String):void
{
var i:int = buttons.length;
while (i--)
{
var btn:MovieClip = buttons[i];
if (branch != btn.branch)
{
btn.gotoAndStop("up");
btn.enabled = true;
btn.addEventListener(MouseEvent.ROLL_OUT, onOut);
btn.addEventListener(MouseEvent.ROLL_OVER, onOver);
}
else
{
btn.removeEventListener(MouseEvent.ROLL_OVER, onOver);
btn.removeEventListener(MouseEvent.ROLL_OUT, onOut);
btn.gotoAndStop("selected");
btn.enabled = false;
}
}
}
override public function transitionIn():void
{
super.transitionIn();
TweenMax.to(this, 0.3, { alpha:1, onComplete:transitionInComplete } );
}
override public function transitionOut():void
{
super.transitionOut();
TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
}
}
}