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

  1. Coffee loophole recipe表示:

    This post is fantastic! Filled with helpful insights and extremely clear. Many thanks for offering this.

  2. Ernesto Tartaglione表示:

    Ang https://drake-ph.com – drake App ay may mabilis at makatarungang gaming environment. I-download at i-install ito upang maranasan ang optimized na interface ng app para sa mas magaan na paglalaro. Mag-enjoy ka sa iyong mga paboritong laro nang walang delay.

  3. Brandonnot表示:

    trustworthy canadian pharmacy: canadian online drugs – canada drug pharmacy

  4. American-Style Fridge: 11 Thing That You’re Failing To Do amazon american fridge freezer

  5. AndreDib表示:

    medication canadian pharmacy https://mexicaneasypharm.com/# reputable mexican pharmacies online
    top 10 online pharmacy in india

  6. Marshall Christensen表示:

    Mga Dapat Mong Malaman Tungkol sa Withdrawal Process ng https://nn777-8.com – nn777

  7. рейтинги производительности процессоров рейтинги производительности процессоров .

  8. JacobLoody表示:

    umalutki.ru — Надежный партнер для выбора качественных и современных кухонь.

  9. Michal表示:

    How Buy B1 Driving License Online Without Exam Has Become The
    Top Trend In Social Media svensk körkort (Michal)

  10. Eliseo Schepers表示:

    https://marvel-ph.com – marvel: Platform na Puno ng Sikat na Laro at Bonus

  11. AngelCroft表示:

    https://www.freshlyme.ru/ — Онлайн-сервис для проектирования и заказа кухонь.

  12. Lorna Botelho表示:

    Sa https://dailyspins-casino.com – dailyspins, nag-aalok kami ng patas at makatarungang laro sa lahat ng manlalaro. Subukan ang mga sikat na laro tulad ng poker, roulette, at sports betting. Higit pa rito, makakuha ng maraming bonus na eksklusibo para sa mga loyal na customer.

  13. Reda Zanter表示:

    https://howl-ph.com – howl Withdrawal: Mga Hakbang para Makuha ang Iyong Panalo

  14. Walker Guiltner表示:

    Alamin Kung Paano Mag-log In at Magparehistro sa https://wildfortuneio-casino.com – wildfortuneio Nang Madali

  15. CurtisBam表示:

    Best Indian pharmacy: Online pharmacy – Indian pharmacy that ships to usa

  16. Vennie Mcgrory表示:

    Paghahanda sa mas magaan na paglalaro? I-download at i-install ang https://hellowin-ph.com – hellowin App at simulan ang isang optimized na gaming journey na puno ng excitement at mabilis na paglalaro!

  17. Dominique Auyong表示:

    I-download at i-install ang https://hejgo-casino.com – hejgo App upang mas mapadali ang iyong paglalaro. Ang optimized interface ng app ay naghahatid ng mas magaan na gaming experience, kaya’t madali mong makakamtan ang mga panalo.

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

  19. Reena Cassaday表示:

    https://melbet-8.com – melbet Customer Support: Lutasin ang Iyong Mga Isyu Nang Mabilis

  20. Why No One Cares About Head Injury Lawyer Near Me
    Injury Lawsuit

  21. рейтинги производительности процессоров рейтинги производительности процессоров .

  22. helpful hints表示:

    bookmarked!!, I like your blog.

發佈留言

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