利用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,275 Responses

  1. сравнение процессоров для пк http://www.topcpu.ru .

  2. Zack Tetterton表示:

    Paano Maging Panalo sa Mga Sikat na Laro ng https://vikingbet-casino.com – vikingbet?

  3. Carmelo Geoffrey表示:

    https://go-perya-ph.com – go perya Account Registration: Mabilis at Simpleng Proseso para sa Baguhan

  4. BradleyEdino表示:

    canlД± casino deneme bonusu veren siteler Deneme Bonusu Veren Siteler slot oyunlarД±

  5. JacobLoody表示:

    http://vosf.ru/ — Простота заказа кухни через удобный интерфейс сайта vosf.

  6. капельница при алкогольной интоксикации на дому цена капельница при алкогольной интоксикации на дому цена .

  7. Kendrick Mataka表示:

    Paano Maabot ang https://highway-ph.com – highway Customer Service para sa Iyong Mga Tanong?

  8. AngelCroft表示:

    fitnessclubmalibu.ru — Онлайн-ресурс для поиска стильных кухонь на заказ.

  9. The legal commonplace for funding advisers is still larger than it’s for brokers.

  10. Nigeria’s NGN10 billion debut corporate infrastructure bond for Viathan Group, a private equity-backed company, providing power to the government, household and businesses in Nigeria, using natural gas as fuel.

  11. Is French Door Refrigerator With Ice Maker The Most Effective Thing That Ever Was?
    french door fridge freezer With water dispenser

  12. Guide To Convertible Crib With Mattress: The Intermediate Guide
    Towards Convertible Crib With Mattress convertible crib with Mattress

  13. JacobLoody表示:

    http://www.a-p-i.ru — современный подход к проектированию кухни.

  14. Joseph Helmy表示:

    Alamin Kung Paano Magparehistro sa https://futureplay-casino.com – futureplay at Makatanggap ng Bonus

  15. JacobLoody表示:

    https://www.vizitnews.ru — Посетите официальный сайт vizitnews для подробной информации.

  16. Wallacefex表示:

    deneme bonusu veren yeni siteler: denemebonusuverensiteler25 – deneme bonusu veren siteler yeni

  17. Aw, this was a very nice post. Taking a few minutes and actual effort to create a good article… but what can I say… I procrastinate a whole lot and never seem to get nearly anything done.

  18. The 12 Worst Types Of People You Follow On Twitter mesothelioma Attorney

  19. Harrison Grey表示:

    https://slot-games-ph.com – slot games Support Team: Propesyonal at Laging Handang Maglingkod

  20. JacobLoody表示:

    кухни на заказ — создайте уникальное пространство, идеально подходящее для вашего дома.

發佈留言

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