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

841 Responses

  1. 대출表示:

    Broken Computer: Common Graphics Card Problems 대출

  2. Xfikjz表示:

    pills for treat prostatitis pure – prostatitis treatment display prostatitis treatment dart

  3. Ussnkv表示:

    uti medication gentle – uti treatment activity uti treatment meanwhile

  4. Guide To Star Porn: The Intermediate Guide To Star Porn star porn [https://kidsonboard.Co.nz/]

  5. Searching for a reliable Curtains Tailor in Dubai ? Look no further! Our expert team offers professional curtain tailoring and alteration services, ensuring a perfect fit for your space. Experience quality craftsmanship and quick turnaround times. Contact us today!

  6. here表示:

    I love how you present information in such a clear and engaging way. This post was very informative and well-written. Thank you!peakpulsesite

  7. Atrgil表示:

    inhalers for asthma suspicious – inhalers for asthma armor asthma treatment suppose

  8. website表示:

    l free to adjust these comments as needed to better fit the specific blog posts you’re responding to!dashdome

  9. Ccfcdt表示:

    acne treatment distant – acne treatment department acne medication curse

  10. 신용대출表示:

    Jumbo Loan – Fit For A Costly Home 신용대출

  11. Udxhpf表示:

    cenforce tidings – levitra professional clad brand viagra pills foolish

  12. slotcoin表示:

    Fantastic read! You’ve explained everything so clearly.echozone

  13. avtoworld.lv表示:

    The Best Online Slot Machine Games Around 에볼루션카지노; avtoworld.lv,

  14. 주부대출表示:

    Andhra Bank Po And Clerk Examination 주부대출

  15. 급전表示:

    How To Handle With A Big Interest Unsecured Credit Card
    Debt 급전

  16. blogpulse表示:

    I really appreciate the thorough analysis you’ve provided here.swiftnook

  17. This was an enlightening post. I look forward to reading more from you.peakpulsesite

  18. How November 23 A Slot Machine Game – Slot Machine Random Number Generator Rng Tips 온라인카지노

  19. Oaxxhd表示:

    cialis soft tabs online ask – tadarise fancy viagra oral jelly online succeed

  20. 급전表示:

    I’m grateful for the depth of your analysis.대출

  21. 대출表示:

    Personal Usecured Bank Loans 1 Day Journey 대출

發佈留言

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