1

我是 Flash 新手,不幸的是我们的老师没有教我们如何进行过渡。我曾尝试研究它们,似乎有 100 种方法可以做到这一点。在我的例子中,我还没有找到有效的方法。如何在正在加载的图片之间进行过渡?

import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import fl.transitions.*;
import fl.transitions.easing.*;

home_btn.addEventListener(MouseEvent.CLICK, takeToHomeZerg);
sarahkerrigan_btn.addEventListener(MouseEvent.CLICK, addsarahkerrigan);
izsha_btn.addEventListener(MouseEvent.CLICK, addizsha);
abathur_btn.addEventListener(MouseEvent.CLICK, addabathur);


var sarahkerriganAdd:Loader = new Loader();
var izshaAdd:Loader = new Loader();
var abathurAdd:Loader = new Loader();


var sarahkerrigan:URLRequest = new URLRequest("zerg/sarahkerrigan.jpg");
var izsha:URLRequest = new URLRequest("zerg/izsha.jpg");
var abathur:URLRequest = new URLRequest("zerg/abathur.jpg");


sarahkerriganAdd.visible = false;
izshaAdd.visible = false;
abathurAdd.visible = false;


addChild(sarahkerriganAdd);
addChild(izshaAdd);
addChild (abathurAdd);


function takeToHomeZerg (evt:MouseEvent):void{
    gotoAndStop(1);
    removeChild(sarahkerriganAdd);
    removeChild(izshaAdd);
    removeChild (abathurAdd);

}

function addsarahkerrigan (evt:MouseEvent):void{
    sarahkerriganAdd.load(sarahkerrigan);
    sarahkerriganAdd.x = 275;
    sarahkerriganAdd.y = 32;
    sarahkerriganAdd.scaleX = .2618;
    sarahkerriganAdd.scaleY = .28;
    sarahkerriganAdd.visible = true;
    izshaAdd.visible = false;
    abathurAdd.visible = false;

}

function addizsha (evt:MouseEvent):void{
    izshaAdd.load(izsha);
    izshaAdd.x = 275;
    izshaAdd.y = 32;
    izshaAdd.scaleX = .2618;
    izshaAdd.scaleY = .28;
    izshaAdd.visible = true;
    sarahkerriganAdd.visible = false;
    abathurAdd.visible = false;


}
function addabathur (evt:MouseEvent):void{
    abathurAdd.load(abathur);
    abathurAdd.x = 275;
    abathurAdd.y = 32;
    abathurAdd.scaleX = .2618;
    abathurAdd.scaleY = .28;
    abathurAdd.visible = true;
    izshaAdd.visible = false;
    sarahkerriganAdd.visible = false;

}
4

2 回答 2

0

有很多方法可以进行转换,但我认为最方便(和优化)的是 GreenSock 库。看看他们的示例页面

PS你也可以只用AS3原生工具来做,但不会那么简单。

于 2013-04-02T07:40:54.460 回答
0

以下是在没有 GreenSock 的情况下淡出影片剪辑的方法:

// add a listener that calls a function on each frame 
// (i.e. 15, 24 or 30 times per second depending on your movie settings)
stage.addEventListener(Event.ENTER_FRAME,fadeOutMyClip)

function fadeOutMyClip(e:Event) {
    if (myClip.alpha > 0) { 
// decrease the transparency of the mc by 1 percent each frame
// at 30 fps, it'll take 3.3 seconds, and at 15 fps it'll take 6.6 seconds
        myClip.alpha-=0.01
    } else {
// don't forget to remove the listener when it's no longer needed
// you could also remove the now-transparent movieclip from stage completely, 
// if you're not planning on fading it back again
        stage.removeEventListener(Event.ENTER_FRAME,fadeOutMyClip)
    }
}
于 2013-04-02T09:19:24.220 回答