利用Tweener製作動畫 – 廣告看板

依然是Tweener範例清倉,本篇範例大致是搭配Tweener讓目標物移動到指定座標的效果,話不多說看範例吧!

Tweener 橫幅廣告 範例:主要為利用Tweener針對廣告看板進行移動,以下為本範例的程式碼:

import caurina.transitions.Tweener;
var i:int;//迴圈用變數
var pic:int = 1;//播放張數紀錄變數
var clock;//計時器變數

//按鈕變色與監聽
btnChange();
function btnChange()
{
	for (i=1; i<=4; i++)
	{
		this["b" + i].gotoAndStop(1);
		this["b" + pic].gotoAndStop(2);
	}
}
for (i=1; i<=4; i++)
{
	this["b" + i].addEventListener(MouseEvent.CLICK,clickFn);
}
function clickFn(e:MouseEvent)
{
	clearInterval(clock);
	clock = setInterval(autoChange,5000);
	pic = e.currentTarget.name.substr(1,1);
	bannerChange();
	btnChange();
}

//計時器設定(每5秒更換)
clock = setInterval(autoChange,5000);
function autoChange()
{
	pic++;
	if (pic>4)
	{
		pic = 1;
	}
	bannerChange();
	btnChange();
}
//圖片切換函數
function bannerChange()
{
	Tweener.addTween(banner, {x:(pic-1)*-560, time:1, transition:"easeOutQuint"});
}

橫幅廣告 範例 原始檔 下載


Tweener 移動看板 範例:與上面範例大致相同,不過本範例增加了縱向的移動。

import caurina.transitions.Tweener
var i
var j
var targetX
var targetY

for(i=1;i<=3;i++){
	for(j=1;j<=3;j++){
		this["b"+i+j].addEventListener(MouseEvent.CLICK,moveFn)
	}
}
function moveFn(e:MouseEvent){
	targetX=(e.currentTarget.name.substr(2,1)-1)*-450
	targetY=(e.currentTarget.name.substr(1,1)-1)*-450
	Tweener.addTween(nb, {x:targetX, y:targetY, time:2, transition:"easeOutQuint"});
}

移動看板 範例 原始檔 下載

You may also like...

15,079 Responses

  1. 12 Companies Leading The Way In Psychiatrist Private private psychiatrist toddington

  2. key mazda表示:

    A Peek Into The Secrets Of Mazda Dealership
    Key Replacement key mazda

  3. JacobLoody表示:

    http://osmio.ru — идеальное сочетание цены и качества.

  4. Guide To Pallet Wood For Sale: The Intermediate Guide
    To Pallet Wood For Sale Pallet wood For sale

  5. You’ll Be Unable To Guess Car Key Fob Repair Near Me’s Benefits Car Key Fob Repair

  6. Wilbert表示:

    14 Common Misconceptions Concerning Audi A4 Key Replacement replace audi key fob (Wilbert)

  7. In February 2010, the U.S.

  8. 30 Inspirational Quotes About Online Mystery Box online Mystery box sites

  9. From the start, it had been planned that the European ponycar would be assembled at the Halewood facility in the United Kingdom, plus the Cologne and Saarlouis plants in Germany.

  10. And make sure the rewards get extra spectacular as the game goes on.

  11. There were no Soviet players both, and so they wouldn’t return to international competitors till the next year.

  12. вызов нарколога на дом круглосуточно вызов нарколога на дом круглосуточно .

  13. Car Seat Newborn: The Good, The Bad, And The Ugly top Rated baby car seats [marvelvsdc.faith]

  14. Brianchoky表示:

    https://mexicanpharmacy.store/# п»їbest mexican online pharmacies

  15. JacobLoody表示:

    кухни на заказ от производителя — качественные кухни по индивидуальному проекту без посредников.

  16. What Is How Much Does It Cost To Replace A Porsche Key And How To Utilize It Porsche Boxter Key

  17. Joan表示:

    The Most Effective Fridge Freezer Samsung Tips To Change Your
    Life samsung refrigerators (Joan)

  18. 23 starting goalkeeper for the CONCACAF-CONMEBOL Olympic qualifying playoff towards Colombia, conceding two targets in two matches as U.S.

  19. JacobLoody表示:

    a-p-i.ru/ — воплощаем в жизнь уникальные проекты кухонь.

  20. Heriberto表示:

    Why You’ll Want To Learn More About Adults Toy For Men adult toys on sale, Heriberto,

  21. Jamesknowl表示:

    https://canadianpharmacy.win/# best canadian pharmacy online

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。