利用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...

14,982 Responses

  1. The rest of the gang members hold McClain accountable for the lost money and demand that he retrieve it.

  2. Therefore, an organization resident in Mauritius promoting shares of an Indian company is not going to pay tax in India.

  3. On the most elementary level, binary options are exactly how they sound and there are two binary options currency trade: the currency will either go up or come down.

  4. From Around The Web Twenty Amazing Infographics About Truck Accident Attorney Near Me
    Best Truck Accident Attorney

  5. Why it is necessary for your business to succeed and how you are defining success in this case.

  6. These parts can add a pop of coloration and vitality, making the house really feel vibrant and thrilling, perfect for an animated surroundings.

  7. 10 Things That Your Family Taught You About Ignition Key Replacement Cost Ignition Key Replacement Cost

  8. JacobLoody表示:

    http://sklad-ymov.ru — Выбор, которому доверяют наши клиенты. Оформляйте заказ прямо сейчас!

  9. Renault Clio Key Replacement Explained In Less Than 140 Characters
    New Renault key card price

  10. te.legra.ph表示:

    This Is The One Article Rewriter Ai Trick Every Person Should Be
    Aware Of Article rewrite ai – te.legra.ph,

  11. Jamesknowl表示:

    http://mexicanpharmacy.store/# buying from online mexican pharmacy

  12. Brianchoky表示:

    http://indianpharmacy.win/# indian pharmacy paypal

  13. JacobLoody表示:

    кухня под заказ — индивидуальный подход к каждому клиенту.

  14. ClaytonGauct表示:

    is canadian pharmacy legit: best online canadian pharmacy – canadian pharmacy checker

  15. LarryHom表示:

    https://canadianpharmacy.win/# my canadian pharmacy

  16. JacobLoody表示:

    a-p-i.ru — уникальные кухни для каждого.

  17. нарколог на дом вывод из запоя ростов нарколог на дом вывод из запоя ростов .

  18. вывод из запоя на дому ростов-на-дону вывод из запоя на дому ростов-на-дону .

  19. Windowdoctor表示:

    Guide To Windowdoctor: The Intermediate Guide Towards Windowdoctor Windowdoctor

  20. Brianchoky表示:

    https://indianpharmacy.win/# best online pharmacy india

  21. Jamestus表示:

    canadian pharmacy com canadian pharmacies legitimate canadian pharmacies

發佈留言

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