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

769 Responses

  1. Write more stories, more chapters.

  2. Thanks for posting this. Looking for these resources 😀

  3. I am glad to talk with you and you give me great help

  4. Hello this is kinda of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding knowledge so I wanted to get advice from someone with experience. Any help would be enormously appreciated!

  5. Greetings, have tried to subscribe to this websites rss feed but I am having a bit of a problem. Can anyone kindly tell me what to do?’

  6. yzfdgjqt表示:

    hydroxychloroquine tablets buy online buy hydroxychloroquine 200 mg hydroxychloroquine 200mg for arthritis

  7. You are a very smart person! 🙂

  8. diltiazem er doses cardizem cd savings diltiazem and metoprolol together for rate control diltiazem this med has to be taking with what

  9. zanaflex 2mg表示:

    zanaflex generic name zanaflex capsule cost zanaflex 4 mg oral tablet how many zanaflex can i take at once

  10. Good post. I study something more difficult on different blogs everyday. It’s going to always be stimulating to learn content material from other writers and observe a little bit one thing from their store. I’d prefer to use some with the content material on my blog whether you don’t mind. Natually I’ll give you a link in your web blog. Thanks for sharing.

  11. I am glad to talk with you and you give me great help

  12. Its wonderful as your other blog posts : D, regards for putting up.

  13. This blog post is excellent, probably because of how well the subject was developed. I like some of the comments too though I could prefer we all stay on the subject in order add value to the subject!

  14. cialis 40 mg how long does viagra take female viagra over the counter what would happen if a woman takes viagra

  15. gykebdtn表示:

    purchase hydroxychloroquine online other names for plaquenil how to get hydroxychloroquine tablets

  16. Took me time to read the material, but I truly loved the article. It turned out to be very useful to me.

  17. Your idea is outstanding; the issue is something that not enough persons are speaking intelligently about. I’m very happy that I stumbled throughout this in my seek for one thing regarding this.

  18. Surprisingly good post. I really found your primary webpage and additionally wanted to suggest that have essentially enjoyed searching your website blog posts. Whatever the case I’ll always be subscribing to your entire supply and I hope you jot down ever again soon!

  19. neurontin 400表示:

    viagra doses black ant viagra australia what does viagra do to women what is cialis used to treat

  20. avana 100表示:

    levitra pens buy levitra when will levitra be generic whats better viagra or levitra

  21. Lightyear表示:

    I would share your post with my sis.

  22. hddaywlq表示:

    plaquenil generic name what is hydroxychloroquine used for

  23. Our community leaders need to read this, and look at developing some of your recommendations.

  24. Our communities really need to deal with this.

  25. Slonmob表示:

    4bk86

    eb35y

    p0mk

  26. Slonmob表示:

    86ckz

    eipvf

    60if

發佈留言

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