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

  1. Remote Vacuum表示:

    15 Things You’ve Never Known About Cleaning Robots Remote Vacuum

  2. Jerryacast表示:

    https://fastfromindia.com/# п»їlegitimate online pharmacies india
    top online pharmacy india

  3. Aaroncrasy表示:

    best india pharmacy: Fast From India – best online pharmacy india

  4. 15 Unexpected Facts About Bunk Beds With Slides And Stairs You Didn’t Know
    bunk bed with slide And stairs

  5. Henryutisa表示:

    Fast From India: reputable indian online pharmacy – Fast From India

  6. Aaroncrasy表示:

    Fast From India: buy prescription drugs from india – Fast From India

  7. Düşük bahislerle oynadığımda bile Razor Shark’tan büyük kazançlar elde ettim.

  8. ThomasGooks表示:

    cheap canadian pharmacy
    https://expresscanadapharm.shop/# canadian pharmacy in canada
    online canadian drugstore

  9. JamesMax表示:

    top online pharmacy india Fast From India top 10 online pharmacy in india
    top 10 pharmacies in india

  10. mostbet_qcEi表示:

    скачать мостбет официальный сайт mostbet34.com.kg .

  11. What’s The Current Job Market For Treadmill Desk Uk Professionals?
    treadmill Desk Uk

  12. Buy Goethe Certificate A1 Online: It’s Not As
    Difficult As You Think Goethe Institut

  13. Slot oyunlarında her spin büyük bir heyecan, bu casino mükemmel bir platform!

  14. 5 Killer Quora Answers On Situs Toto Situs Toto, http://Wsszn.Com,

  15. How To Become A Prosperous Honda Key If You’re Not Business-Savvy honda key case

  16. 5 Killer Quora Answers To Buy European Driving License Uk Online Buy European Driving license Uk online

  17. Тут можно преобрести продвижение медицинского сайта продвижение медицинского центра

  18. 11 Ways To Completely Revamp Your Exercise Bicycle Exercise Bicycles For Sale – https://Writeablog.Net,

  19. Jerryacast表示:

    http://fastfromindia.com/# Online medicine home delivery
    Fast From India

  20. The Hidden Secrets Of Buy Arvin Biewer Yorkshire Terrier Mini Bismarck welpen Yorkshire terrier kaufen​

  21. Chloe表示:

    The Worst Advice We’ve Received On Where
    To Get Pallets where to get pallets​ (Chloe)

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

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