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

7,455 Responses

  1. plise perde表示:

    plise perde | Plise perde modelleri arasında yapılan karşılaştırmalar, hangi modelin ihtiyaçlarıma daha uygun olduğunu anlamama yardımcı oldu.

  2. hjreborn表示:

    Hi there, I do believe your site might be having internet browser compatibility problems. When I look at your blog in Safari, it looks fine but when opening in IE, it’s got some overlapping issues. I just wanted to give you a quick heads up! Aside from that, great blog.

  3. May I simply just say what a relief to discover somebody that really knows what they are talking about on the net. You certainly know how to bring a problem to light and make it important. A lot more people have to check this out and understand this side of the story. I can’t believe you are not more popular because you certainly possess the gift.

  4. I’m impressed, I must say. Seldom do I encounter a blog that’s equally educative and entertaining, and without a doubt, you have hit the nail on the head. The problem is something too few people are speaking intelligently about. Now i’m very happy that I stumbled across this in my search for something regarding this.

  5. Если вы искали где отремонтировать сломаную технику, обратите внимание – ремонт бытовой техники

  6. Профессиональный сервисный центр по ремонту планшетов в Москве.
    Мы предлагаем: ремонт планшетов
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  7. konteyner表示:

    konteyner | Bu kadar açık ve net bir anlatım beklemiyordum, tebrikler!

  8. Good article. I will be experiencing some of these issues as well..

  9. konteyner表示:

    konteyner | Yazınızı okurken çok şey öğrendim, emeğinize sağlık!

  10. Hey there! I simply want to give you a huge thumbs up for your excellent info you’ve got here on this post. I will be coming back to your site for more soon.

  11. Perfectly composed subject matter, thanks for selective information .

  12. Wcrfonert表示:

    Advances in technology have allowed Marcelle and her team to extend her reach across the globe through WomentoWomen.
    Helpful treatment is available when you buy lexapro vs celexa many more details.
    Carcinoid tumors are more common in women and among African Americans.

  13. Jorge Shott表示:

    You made some good points there. I checked on the web to find out more about the issue and found most individuals will go along with your views on this site.

  14. konteyner表示:

    konteyner fiyatları | İçeriğiniz çok faydalı oldu, çok teşekkürler!

  15. An impressive share, I simply given this onto a colleague who was doing a little analysis during this. And the man the fact is bought me breakfast since I ran across it for him.. smile. So let me reword that: Thnx for your treat! But yeah Thnkx for spending time to go over this, I’m strongly over it and enjoy reading more on this topic. If you can, as you become expertise, do you mind updating your blog site with additional details? It really is highly a good choice for me. Big thumb up due to this writing!

  16. Right here is the right web site for everyone who would like to find out about this topic. You know so much its almost hard to argue with you (not that I personally would want to…HaHa). You definitely put a brand new spin on a subject which has been written about for decades. Excellent stuff, just wonderful.

  17. This page truly has all the info I wanted concerning this subject and didn’t know who to ask.

  18. Howdy! I could have sworn I’ve been to this site before but after browsing through many of the articles I realized it’s new to me. Nonetheless, I’m definitely delighted I came across it and I’ll be bookmarking it and checking back frequently.

  19. 오피表示:

    I see this topic in a new light now.오피

  20. It’s rare knowledgeable folks with this topic, but the truth is sound like what happens you are talking about! Thanks

  21. I am not sure where you are getting your information, but good topic. I needs to spend some time learning much more or understanding more. Thanks for excellent information I was looking for this information for my mission.

  22. HotPromoCodes表示:

    This is the perfect site for everyone who hopes to find out about this topic. You realize a whole lot its almost tough to argue with you (not that I personally will need to…HaHa). You certainly put a new spin on a topic that’s been written about for decades. Great stuff, just excellent.

  23. Excellent post. I appreciate the time you put in to provide such beneficial content. It’s clear and very educational.

  24. Good day! I know this is kinda off topic but I’d figured I’d ask. Would you be interested in trading links or maybe guest writing a blog article or vice-versa? My site discusses a lot of the same subjects as yours and I think we could greatly benefit from each other. If you’re interested feel free to send me an e-mail. I look forward to hearing from you! Superb blog by the way!

  25. HotPromoCodes表示:

    Excellent blog you have got here.. It’s difficult to find high quality writing like yours nowadays. I really appreciate people like you! Take care!!

  26. Если вы искали где отремонтировать сломаную технику, обратите внимание – тех профи

  27. anus表示:

    Dedicated Server Hosting offers exclusive access to an entire server’s resources, ensuring optimal performance, security, and reliability for high-traffic websites, applications, and businesses. Unlike shared hosting, where multiple websites share resources, a dedicated server provides a fully customizable environment with complete control over server configurations, operating systems, and software. dedicated server hosting

  28. Alphabites表示:

    Appreciated this post. It’s extremely detailed and filled with helpful details. Fantastic work!

  29. There couple of interesting points at some point in this article but I don’t determine if I see they all center to heart. You can find some validity but I most certainly will take hold opinion until I check into it further. Excellent write-up , thanks so we want more! Included with FeedBurner likewise

  30. certainly like your web site but you need to check the spelling on several of your posts. Several of them are rife with spelling problems and I find it very troublesome to tell the truth nevertheless I will definitely come back again.

發佈留言

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