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

21,049 Responses

  1. Jerryacast表示:

    https://fastfromindia.com/# Fast From India
    Fast From India

  2. Aaroncrasy表示:

    Fast From India: п»їlegitimate online pharmacies india – online shopping pharmacy india

  3. ThomasGooks表示:

    trustworthy canadian pharmacy
    https://expresscanadapharm.com/# Express Canada Pharm
    certified canadian pharmacy

  4. 20 Trailblazers Setting The Standard In Buy A2 Driving License Online online füHrerschein a2 beantragen

  5. Henryutisa表示:

    Fast From India: Fast From India – п»їlegitimate online pharmacies india

  6. Aaroncrasy表示:

    Online medicine home delivery: Online medicine order – indian pharmacy online

  7. Guide To Situs Togel Terpercaya: The Intermediate Guide In Situs Togel Terpercaya situs togel terpercaya

  8. ThomasGooks表示:

    canadianpharmacyworld com
    https://expresscanadapharm.com/# Express Canada Pharm
    canadian compounding pharmacy

  9. Best Cots Uk Tools To Make Your Daily Life Best Cots
    Uk Trick That Everybody Should Learn best Cots uk (http://www.cyberpetro.com)

  10. Roxanna表示:

    2 In 1 Car Seat And Pram Tools To Ease Your Everyday Lifethe Only 2 In 1 Car Seat And Pram
    Technique Every Person Needs To Learn 2 in 1 car seat and pram (Roxanna)

  11. Candida表示:

    How To Get More Benefits Out Of Your Online Crypto Casino best online crypto casino – Candida

  12. Clemmie表示:

    There’s A Reason Why The Most Common Order A2 Driving License Class A2 Digital Debate Actually Isn’t As Black And
    White As You Might Think online führerschein a2 shop – Clemmie

  13. 20 Resources To Help You Become Better At Buy A2
    Driver’s License Online Online FüHrerschein A2 Bestellen

  14. Buy Category C Driving License Strategies
    That Will Change Your Life Comprar Carta de condução categoria B

  15. Guide To Cheap Double Buggy: The Intermediate Guide To Cheap Double Buggy cheap double Buggy

  16. WalterCherm表示:

    The staff always ensures confidentiality and privacy.
    https://lisinoprilpharm24.top/
    Their worldwide delivery system is impeccable.

  17. Julienne表示:

    Guide To Fabric Corner Recliner Sofa: The Intermediate Guide The Steps To Fabric Corner Recliner
    Sofa fabric corner recliner sofa – Julienne,

  18. Jasonzitte表示:

    Efficient service with a personal touch.
    how to get lisinopril
    A touchstone of international pharmacy standards.

  19. WalterCherm表示:

    A trailblazer in international pharmacy practices.
    https://gabapentinpharm24.top/
    A universal solution for all pharmaceutical needs.

發佈回覆給「Aaroncrasy」的留言 取消回覆

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