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

10,423 Responses

  1. You have made some good points there. I looked on the web to learn more about the issue and found most individuals will go along with your views on this website.

  2. I was very happy to find this website. I need to to thank you for your time due to this wonderful read!! I definitely enjoyed every little bit of it and I have you bookmarked to see new information in your site.

  3. Exsaxx表示:

    buy speman generic – himplasia tablet finasteride sale

  4. I was able to find good advice from your articles.

  5. How To Dispute You Will Need To On Credit Rating Card 신용불량자 대출

  6. 0773781.xyz表示:

    How Do I Explain Electric Fireplace To A 5-Year-Old
    0773781.xyz

  7. Lynn Bolvin表示:

    15 Funny People Working Secretly In Electric Fireplace Wall Lynn Bolvin

  8. 1559014.Xyz表示:

    7 Small Changes That Will Make A Huge Difference In Your Boot Scooter 1559014.Xyz

  9. Spot on with this write-up, I seriously believe this website needs a great deal more attention. I’ll probably be returning to read more, thanks for the information.

  10. Five Qualities That People Search For In Every Good Oil Filled Radiators http://Www.9779342.Xyz

  11. Edda Fay表示:

    Are You Sick Of Bunk Bed Shop? 10 Inspirational Sources To Bring Back Your Passion Edda Fay

  12. Asbestos Mesothelioma Lung Cancer Explained In Less Than 140 Characters
    cassylawn.top, http://Www.cassylawn.top,

  13. 822547表示:

    Why People Are Talking About Coffee Maker Right Now 822547

  14. Who’s The Top Expert In The World On Situs Alternatif
    Borneoslot? http://www.287682.xyz

  15. Solving Credit Cards Problem 디딤돌 대출

  16. How To Get Your Own Sam’s Discover Card 다바오 골프장 호텔

  17. Tip On Playing Roulette 에볼루션 모노폴리 (http://www.icchan-farm.com)

  18. Get A Home Loan With Bad Credit: Tricks For Success
    중기청 대출

  19. Best Bad Credit Personal Loans – 5 For Faster Personal Loan Approval 중소기업 대출

  20. 10 Expressions To Avoid In Sales Communication 발로란트 에볼루션 매치

  21. pbn 백링크表示:

    How Create Links Through Optimized Articles And Backlinks pbn 백링크

  22. Refinancing A Less-Than-Perfect Credit Home Loan Saves
    Money Monthly 다바오 포커 vpn

  23. When I originally left a comment I appear to have clicked the -Notify me when new comments are added- checkbox and from now on every time a comment is added I get four emails with the exact same comment. Is there a means you can remove me from that service? Thank you.

  24. YtMp3表示:

    This is a really good tip particularly to those fresh to the blogosphere. Short but very accurate info… Thank you for sharing this one. A must read article.

  25. Strategies For The Most Popular Online Gambling Games 에볼루션 조작영상

發佈留言

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