2013-04-01 117 views
1

我是flash新手,不幸的是,我們的老師並沒有教會我們如何進行轉換。我試圖研究它們,似乎有100種方法可以做到這一點。在我的例子中,我還沒有找到一個有效的方法。我怎樣才能加載圖片之間的過渡?Flash Actionscript 3.0中的轉換

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; 

} 

回答

0

有很多方法可以進行轉換,但我認爲最方便(也是最優化的)是GreenSock庫。看看他們的examples page

P.S.你也可以使用AS3本地工具來完成它,但它不會那麼簡單。

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) 
    } 
}