利用GreenSock Tweening Platform製作動畫

因為馬老師剛開始利用程式製作補間動畫的Class是Tweener,所以前面介紹了很多篇這方面的文章,但當然這方面的Class不是只有Tweener而已,所以接下來介紹一個目前發展起來比Tweener還要棒很多的Class,它是由GreenSock研發的Tweening Platform(補間平台),其中包含了:「TweenNano」、「TweenLite」、「TweenMax」、「TimelineLite」、「TimelineMax」。

為什麼說他發展得比較好呢?除了Tweener能做到的幾乎它都可以以外,也因為Tweener已經停止開發,所以未來將不會有新增的功能,但TweenMax還在不斷的更新中,在官網還有以下的比較案例:

各種補間動畫 速度測試

從上面的案例可以看出來利用GreenSock所研發的Tweening Platform的執行效能會比其他的好(FPS越高越好),所以接下來就來看看GreenSock Tweening Platform的簡介。

TweenNano、TweenLite與TweenMax算是同樣功能,但在製作後檔案容量是TweenNano<TweenLite<TweenMax,也就是說利用TweenNano所製作出來的動畫容量是最小的,舉個例來說,像這樣的動畫效果,TweenNano製作後swf大小為:5KB、TweenLite:8KB、TweenMax:21KB,不過在功能上面也是TweenNano<TweenLite<TweenMax,也就是說TweenMax可以掌控的效果比較多,也更具有彈性,例如:TweenNano就沒有辦法執行:pause()、play()、restart()…等,而TweenLite沒辦法執行:貝茲曲線運動、濾鏡…等,所以要用哪個版本的Tween,端看想要製作的動畫效果來考量,官方也有針對此三者製作比較表供大家參考。

另外TimelineLite和TimelineMax算是同樣功能,但看到後面的英文單字應該可以了解與上述具有相同的關聯,而這方面的Class是可以掌握時間軸上面的變化,在Tweener中,我們只能用Delay來控制動畫先後順序,而在GreenSock所研發的Tweening Platform中則可以利用TimlinelineLite或TimelineMax來處理。

馬上來介紹有關這個Class的一些使用方式,與Tweener一樣的是必須先下載備用載點),然後在需要使用的Flash檔案中import該Class,下載解壓後會有以下的資料夾:

  • badges:GreenSock圖標。
  • com:主要Class資料夾。
  • demo_swfs:裡面有很多swf的展示,對於想要了解本Class非常有幫助。
  • docs:參考文件。

在import時,看你想要使用的Class來import,例如需要使用TweenNano則:

import com.greensock.TweenNano;

若需同時使用TweenLite和TweenMax則:

import com.greensock.TweenLite;
import com.greensock.TweenMax;

想偷懶,則:(別擔心,Flash只會內嵌有使用到的部分)

import com.greensock.*;

至於製作補間的程式碼,其實官方就有製作swf來給大家參考,這邊也把官方的範例放進來給大家參考:

基礎動畫製作 範例檔

上面的案例可以讓你測試動畫效果,下方也會產生該段動畫的程式碼供你使用,實在是非常方便。另外關於Tween的語法也可以改成下面這種版本:

TweenLite.from(mc, 1.5, {y:0, alpha:0});

一個是告訴動畫要去哪,另一個是告訴動畫要從哪開始變化,關於Tweener可以使用的delay、onComplete、onStart、onUpdate…等,這個Class也都可以使用,例如:

TweenLite.to(mc, 1.5, {x:100, ease:Elastic.easeOut, delay:1, onComplete:okFn});
function okFn() {
    trace("動畫執行完畢");
}

這個Class還有很多特別的動畫效果,例如:濾鏡、短距離旋轉、貝茲曲線、聲音、色彩變換…等,大家也可以參考官方製作的swf來參考動畫效果與取得程式碼:

特殊動畫效果 範例圖

在動畫控制上面可以使用如下的程式碼來控制動畫:

var myTween:TweenLite = new TweenLite(mc, 1, {x:100, y:100});

myTween.pause();
//暫停動畫播放

myTween.resume();
//恢復動畫播放

myTween.reverse();
//反向播放

myTween.play();
//播放動畫

myTween.restart();
//重播動畫

myTween.invalidate();
//移除補間並使元件恢復原始狀態

myTween.kill();
//清除補間動畫

TweenLite.killTweensOf(mc);
//清除所有物件之補間動畫

以上是有關GreenSock Tweening的介紹,接下來介紹有關TimelineLite與TimelingMax的部分。

就像上面有提到在Tweener中我們如果希望三個元件在不同的時間點開始移動,就只能使用delay或是另外寫程式來控制,現在我們可以使用Timeline相關的Class來完成這樣的任務,甚至還可以讓時間軸倒著播放也沒問題,以下就是有關TimelineLite的官方範例:

TimelineLite 範例檔

另外是TimelineMax的範例檔,供大家參考:

TimelineMax 範例檔

以上就是針對GreenSock Tweening Platform大致的介紹,建議有空可以前往官網鑽研更多其他的功能,另外其實GreenSock另外還有TransformManagerLoaderMax,各位也可以先參考官網文章或是未來再跟大家分享我的使用心得。

註:本範例所使用的範例版權屬於GreenSock公司所有。

You may also like...

16,107 Responses

  1. What?s Taking place i am new to this, I stumbled upon this I have found It positively helpful and it has aided me out loads. I hope to contribute & help different users like its aided me. Great job.

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

  3. купить электрокарнизы купить электрокарнизы .

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

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

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

  7. Jessewrify表示:

    The Cruciality of Vibrations Control Systems in Industrial Equipment
    In manufacturing settings, machinery and turning equipment serve as the backbone of production. Nonetheless, a of the most widespread concerns that could obstruct their functionality and durability is vibration. Oscillation may bring about an array of issues, ranging from reduced perfection along with productivity resulting in heightened erosion, eventually leading to high-cost interruptions as well as fixes. Such a situation is why vibration control apparatus becomes critical.

    Why Vibrations Mitigation is Important

    Oscillation in equipment might bring about numerous adverse outcomes:

    Minimized Functional Performance: Excessive vibrations could result in misalignment as well as imbalance, minimizing total efficiency of the equipment. This may bring about slower output times and increased power consumption.

    Heightened Erosion: Continuous resonance accelerates the deterioration of machine components, bringing about additional servicing and an potential for unforeseen malfunctions. This does not just elevates maintenance expenses and shortens the lifespan for the devices.

    Safety Hazards: Excessive resonance may present substantial security risks to both the equipment and the workers. In, extreme situations, such vibrations might result in disastrous system collapse, jeopardizing personnel along with resulting in significant devastation to the environment.

    Exactness and Production Quality Concerns: In sectors that depend on precise production, such as production or space industry, vibration could result in inaccuracies in the production process, producing flawed products and increased waste.

    Reasonably Priced Options towards Vibration Control

    Investing in vibration control apparatus is not just necessary and a sound investment for all businesses that any organization involved with machines. Our advanced vibration management systems are engineered to eliminate vibrations in any machinery or spinning equipment, guaranteeing uninterrupted and productive processes.

    What differentiates our tools from others is its cost-effectiveness. We understand the importance of cost-effectiveness in the competitive market of today, which is why our offerings include premium vibration control solutions at rates that remain budget-friendly.

    Through selecting these tools, you aren’t simply protecting your machinery and increasing its efficiency but also investing in the long-term success of your company.

    In Conclusion

    Resonance mitigation is a necessary aspect of maintaining the operational performance, safety, along with lifetime of your equipment. Using these reasonably priced vibration control equipment, it is possible to be certain your operations run smoothly, all manufactured items maintain top quality, along with your workers remain safe. Don’t let resonance jeopardize your operations—invest in the appropriate systems today.

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

  9. Jessewrify表示:

    vibration analysis
    The Importance of Resonance Management Equipment in Mechanical Systems
    Within industrial environments, equipment along with rotating equipment are the foundation of manufacturing. Yet, an of the highly frequent issues which may hinder its efficiency as well as lifetime exists as oscillation. Vibration may lead to an variety of complications, including minimized perfection and productivity leading to elevated erosion, eventually leading to expensive delays along with fixes. Such a situation is the point where vibration regulation equipment proves to be essential.

    Why Vibrations Mitigation remains Critical

    Oscillation inside machinery might lead to numerous harmful effects:

    Minimized Operational Productivity: Exaggerated vibration can lead to misalignment and imbalance, minimizing the efficiency of such systems. Such a scenario could lead to delayed production times as well as higher energy consumption.

    Increased Deterioration: Continuous vibrations speeds up total wear and tear in equipment components, leading to increased maintenance and the chance of unexpected unforeseen malfunctions. Such a situation doesn’t merely increases operating costs but also decreases the longevity of the existing devices.

    Security Risks: Excessive vibration could bring substantial security risks for the machinery and the machinery and the personnel. In, severe cases, these might lead to cataclysmic machinery failure, threatening operators and resulting in considerable devastation in the environment.

    Precision and Manufacturing Quality Challenges: For sectors where demand high precision, including production or aerospace, vibrations might lead to discrepancies with production, resulting in flawed products and greater waste.

    Economical Options for Vibration Control

    Putting money into vibration management equipment is not just a necessity but a wise choice for all businesses that any organization involved with machinery. We offer modern vibration control systems are designed to designed to mitigate vibrations from all equipment and rotating machinery, guaranteeing smooth along with efficient operations.

    What sets these apparatus apart is its its economic value. We understand the importance of cost-effectiveness in the current market, thus our offerings include high-quality vibration management solutions at costs that remain budget-friendly.

    Opting for our systems, you aren’t simply preserving your machinery as well as enhancing its operational effectiveness but also putting resources towards the sustained success of your operations.

    Conclusion

    Vibration management remains a necessary component in preserving the effectiveness, safety, and longevity of your industrial equipment. Through our affordable vibration management tools, you can make sure your operations run smoothly, your products are of high quality, and all personnel stay safe. Do not permit resonance jeopardize your business—invest in the appropriate systems immediately.

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

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

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

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

  14. Sazrvlw表示:

    Добрый день!
    Заказать документ о получении высшего образования
    hitrostidomashnie.ru/category/moda-i-stil

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

  16. An impressive share, I recently given this onto a colleague who was simply carrying out a little analysis within this. Anf the husband actually bought me breakfast due to the fact I found it for him.. smile. So well then, i’ll reword that: Thnx for any treat! But yeah Thnkx for spending plenty of time to debate this, I’m strongly about it and really like reading much more about this topic. If possible, as you grow expertise, might you mind updating your blog site to comprehend details? It can be extremely great for me. Large thumb up just for this short article!

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

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

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

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

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

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

  23. автоматические карнизы автоматические карнизы .

  24. The the next occasion Someone said a weblog, I’m hoping that this doesnt disappoint me just as much as this blog. After all, Yes, it was my solution to read, but I actually thought youd have something intriguing to say. All I hear is often a lot of whining about something you could fix should you werent too busy interested in attention.

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

發佈留言

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