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

22,681 Responses

  1. Jeraleepisn表示:

    gay catholic dating
    gay internet dating
    gay dating east tennessee

  2. construccion表示:

    Good points – – it will make a difference with my parents.

  3. Gladipisn表示:

    hispanic gay dating sites
    best gay dating site
    dating a bipilar gay guy

  4. Polish Tiles表示:

    Well, I don’t know if that’s going to work for me, but definitely worked for you! 🙂 Excellent post!

  5. I just added your web site to my blogroll, I hope you would look at doing the same.

  6. Wow, amazing blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is wonderful, let alone the content!

  7. Wow! Thank you for your thorough write up. Very informative!

  8. It sounds like you’re creating problems yourself by defining this as such a comprehensive, almost unknowable problem. Isn’t that self-defeating?

  9. Is it okay to put a portion of this on my weblog if perhaps I post a reference point to this web page?

  10. We are a Biomedical and Sterilizer services company. We work on all surgical and all medical equipment. We provide all Annual and Semi-annual service needs for surgical and physicians suites. https://biomedical-total-care.com

  11. Gwenorepisn表示:

    best us online casino
    free no deposit bonus casino
    best online casino welcome bonus

  12. Fifinepisn表示:

    best usa online casinos
    casino online usa
    best casino online usa

  13. Sheelaghpisn表示:

    how to get vpn free
    vpn protection
    vpn for firefox

  14. Sheelaghpisn表示:

    best vpn multiple devices
    vpn vanish
    best free vpn for kodi

  15. you’re in reality a just right webmaster. The web site loading velocity is incredible. It sort of feels that you’re doing any distinctive trick. In addition, The contents are masterpiece. you’ve performed a great process on this topic!

  16. A friend of mine advised this site. And yes. it has some useful pieces of info and I enjoyed scaning it. Therefore i would love to drop you a quick note to express my thank. Take care

  17. Laurellapisn表示:

    pcmag best vpn
    whats a vpn
    proton vpn download

  18. Carolinpisn表示:

    bonus online casino
    free no deposit
    no deposit casinos

  19. Very often I go to see this blog. It very much is pleasant to me. Thanks the author

  20. Kelseypisn表示:

    browser vpn free
    how to create a vpn
    atlas vpn free

發佈回覆給「ksi vs pineda live free」的留言 取消回覆

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