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

  1. Terri表示:

    14 Misconceptions Common To Double Glazing Repairs Crawley commercial
    windows near me (Terri)

  2. 9 Things Your Parents Taught You About Upvc Window Repairs Upvc Window Repairs

  3. 9 Lessons Your Parents Taught You About Upvc Window Repairs
    Near Me Upvc Window Repairs Near Me

  4. attorney表示:

    The No. Question That Everyone In Personal Injury Claim Must Know How To
    Answer attorney

  5. installation表示:

    Are You Responsible For The Window Repair Budget? 12 Top Notch Ways To Spend Your Money installation

  6. www.e-odi.Com表示:

    10 Healthy ADHD Private Diagnosis Habits private adhd assessment cornwall (http://www.e-odi.Com)

  7. The Companies That Are The Least Well-Known To In The Double Glazing Fitters Near Me Industry double glazing unit (cs.xuxingdianzikeji.com)

  8. Guide To Employers Liability Act Fela: The Intermediate Guide In Employers Liability Act Fela Liability Act fela

  9. 3 Reasons Three Reasons Your Demo Gatotkaca Pragmatic Is
    Broken (And How To Repair It) Gatot Kaca – Cn.Kd-Glbl.Com

  10. erb's Palsy表示:

    See What Erb’s Palsy Lawsuit Tricks The Celebs Are Utilizing erb’s Palsy

  11. 12 Stats About Medical Malpractice Attorney To Make
    You Take A Look At Other People medical malpractice lawyer

  12. Seven Reasons Why Upvc Window Repair Near Me Is So Important
    upvc Windows repairs near me

  13. 8 Tips To Up Your Car Accident Case Game Car Accident Attorneys

  14. escape rooms表示:

    Hi there, just became alert to your blog through Google,
    and found that it’s truly informative. I am gonna watch out for brussels.

    I will appreciate if you continue this in future.

    A lot of people will be benefited from your writing. Cheers!
    Escape room

  15. How To Know If You’re Ready For Testing For ADHD In Adults
    testing Adhd In adults

  16. 5 Laws That Can Help The Upvc Window Repairs Industry upvc Window Repairs near me

  17. What’s The Job Market For Upvc Front Doors Professionals?
    upvc front Doors

  18. 10 Real Reasons People Dislike New Upvc Door New Upvc Door Upvc door replacement panels

  19. Why Do So Many People Would Like To Learn More About Cerebral
    Palsy Case? Cerebral Palsy Lawyers

  20. You’ll Be Unable To Guess Double Glaze Repair Near Me’s Benefits double glaze repair near me

  21. Ten Taboos About Malpractice Case You Shouldn’t Post On Twitter Malpractice Lawsuit

  22. The 10 Most Terrifying Things About Medical
    Malpractice Attorneys medical malpractice attorneys

  23. tubidy表示:

    Saved as a favorite, I like your web site.

  24. Car Accident表示:

    What’s The Current Job Market For Car Accident Litigation Professionals?
    Car Accident

  25. Do Not Buy Into These “Trends” About Motor Vehicle Claim
    Motor Vehicle Accident

  26. What Is The Reason Why Semi Truck Lawyer Are So Helpful During COVID-19 semi truck accident Attorneys

  27. 20 Fun Details About Case CSGO Sites Csgo cases (wiki.team-glisto.com)

  28. Are You Confident About Malpractice Attorneys? Answer This Question malpractice law Firm

  29. Malpractice Lawyers Tools To Help You Manage Your Everyday Lifethe Only Malpractice Lawyers
    Trick That Everyone Should Learn Malpractice lawyers (forum.reizastudios.com)

發佈留言

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