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

30,296 Responses

  1. I really enjoy the blog. Really Cool.

  2. RobertCex表示:

    deneme bonusu veren siteler: casino siteleri – guvenilir casino siteleri casinositeleri1st.com

  3. KevinBless表示:

    visit this site right here Card

  4. GarrettMom表示:

    casino siteleri slot casino siteleri bahis siteleri slot oyunlarД± casinositeleri1st.shop

  5. RobertCex表示:

    sweet bonanza oyna: sweet bonanza – sweet bonanza yorumlar sweetbonanza1st.shop

  6. BradyGem表示:

    casino siteleri 2025: casino siteleri – deneme bonusu veren siteler casinositeleri1st.com

  7. HerbertDrilk表示:

    A tiny rainforest country is growing into a petrostate. A US oil company could reap the biggest rewards
    swell network
    Guyana’s destiny changed in 2015. US fossil fuel giant Exxon discovered nearly 11 billion barrels of oil in the deep water off the coast of this tiny, rainforested country.

    It was one of the most spectacular oil discoveries of recent decades. By 2019, Exxon and its partners, US oil company Hess and China-headquartered CNOOC, had started producing the fossil fuel.? They now pump around 650,000 barrels of oil a day, with plans to more than double this to 1.3 million by 2027.

    Guyana now has the world’s highest expected oil production growth through 2035.

    This country — sandwiched between Brazil, Venezuela and Suriname — has been hailed as a climate champion for the lush, well-preserved forests that carpet nearly 90% of its land. It is on the path to becoming a petrostate at the same time as the impacts of the fossil fuel-driven climate crisis escalate.

    While the government says environmental protection and an oil industry can go hand-in-hand, and low-income countries must be allowed to exploit their own resources, critics say it’s a dangerous path in a warming world, and the benefits may ultimately skew toward Exxon — not Guyana.

  8. Billynot表示:

    Mist and microlightning
    solflare
    To recreate a scenario that may have produced Earth’s first organic molecules, researchers built upon experiments from 1953 when American chemists Stanley Miller and Harold Urey concocted a gas mixture mimicking the atmosphere of ancient Earth. Miller and Urey combined ammonia (NH3), methane (CH4), hydrogen (H2) and water, enclosed their “atmosphere” inside a glass sphere and jolted it with electricity, producing simple amino acids containing carbon and nitrogen. The Miller-Urey experiment, as it is now known, supported the scientific theory of abiogenesis: that life could emerge from nonliving molecules.
    For the new study, scientists revisited the 1953 experiments but directed their attention toward electrical activity on a smaller scale, said senior study author Dr. Richard Zare, the Marguerite Blake Wilbur Professor of Natural Science and professor of chemistry at Stanford University in California. Zare and his colleagues looked at electricity exchange between charged water droplets measuring between 1 micron and 20 microns in diameter. (The width of a human hair is 100 microns.)

    “The big droplets are positively charged. The little droplets are negatively charged,” Zare told CNN. “When droplets that have opposite charges are close together, electrons can jump from the negatively charged droplet to the positively charged droplet.”
    The researchers mixed ammonia, carbon dioxide, methane and nitrogen in a glass bulb, then sprayed the gases with water mist, using a high-speed camera to capture faint flashes of microlightning in the vapor. When they examined the bulb’s contents, they found organic molecules with carbon-nitrogen bonds. These included the amino acid glycine and uracil, a nucleotide base in RNA.

    “We discovered no new chemistry; we have actually reproduced all the chemistry that Miller and Urey did in 1953,” Zare said. Nor did the team discover new physics, he added — the experiments were based on known principles of electrostatics.

    “What we have done, for the first time, is we have seen that little droplets, when they’re formed from water, actually emit light and get this spark,” Zare said. “That’s new. And that spark causes all types of chemical transformations.”

  9. RobertCex表示:

    slot casino siteleri: casino siteleri 2025 – casino siteleri casinositeleri1st.com

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

  11. BradyGem表示:

    sweet bonanza giris: sweet bonanza slot – sweet bonanza yorumlar sweetbonanza1st.shop

  12. Heya i am for the first time here. I came across this board and I to find It truly useful & it helped me out much. I hope to provide something back and aid others such as you aided me.

  13. RobertCex表示:

    betganyon: casino siteleri 2025 – deneme bonusu veren siteler casinositeleri1st.com

  14. Weldonsib表示:

    casino siteleri: casino siteleri 2025 – casino siteleri 2025 casinositeleri1st.com

  15. AnthonyFat表示:

    Scientists redid an experiment that showed how life on Earth could have started. They found a new possibility
    safepal
    In the 1931 movie “Frankenstein,” Dr. Henry Frankenstein howling his triumph was an electrifying moment in more ways than one. As massive bolts of lightning and energy crackled, Frankenstein’s monster stirred on a laboratory table, its corpse brought to life by the power of electricity.

    Electrical energy may also have sparked the beginnings of life on Earth billions of years ago, though with a bit less scenery-chewing than that classic film scene.

    Earth is around 4.5 billion years old, and the oldest direct fossil evidence of ancient life — stromatolites, or microscopic organisms preserved in layers known as microbial mats — is about 3.5 billion years old. However, some scientists suspect life originated even earlier, emerging from accumulated organic molecules in primitive bodies of water, a mixture sometimes referred to as primordial soup.

    But where did that organic material come from in the first place? Researchers decades ago proposed that lightning caused chemical reactions in ancient Earth’s oceans and spontaneously produced the organic molecules.

    Now, new research published March 14 in the journal Science Advances suggests that fizzes of barely visible “microlightning,” generated between charged droplets of water mist, could have been potent enough to cook up amino acids from inorganic material. Amino acids — organic molecules that combine to form proteins — are life’s most basic building blocks and would have been the first step toward the evolution of life.

  16. Carlospoogy表示:

    Mindful wellness challenges
    If you’re the type of person who thrives on challenges and pushing your limits, this doesn’t mean you need to shy away from wellness challenges altogether. But before diving in, take a step back and ask yourself if you’re pursuing the challenge for the right reasons, McGregor said.
    velodrome finance
    Some people want to try these challenges because they believe something is missing from their life, and they’re looking to attain “worth” or receive validation, McGregor noted.

    A good way to assess your motivation is by considering whether the challenge will benefit your health or if it’s about showcasing your accomplishments on social media or some other reason.

    Before trying any new trend, make sure you have the foundation to handle it and be aware of any potential risks, McGregor said.

    For casual runners, this might mean signing up for a 5K but building your endurance gradually while incorporating other strength training exercises into your routine. For more intense challenges, such as a marathon, McGregor encourages people to consult with professionals or a coach who can monitor your progress and condition along the way.

    Focusing on sustainable habits
    Both McGregor and Curran emphasize the importance of fostering sustainable health habits before embarking on more extreme challenges.

    Rather than chasing the idea of being “healthy,” McGregor suggests focusing on actual healthful behaviors and starting small.

    If you’re a highly sedentary person and want to add more movement to your day, try doing lunges while brushing your teeth or taking short walks throughout your typical routine.

  17. RobertanAew表示:

    Family affair
    rhino fi
    Americans Brittany and Blake Bowen had never even been to Ecuador when in 2021 they decided to move to the South American country with their four children.

    Tired of “long commutes and never enough money” in the US, the Bowens say they love their new Ecuadorian life. “We hope that maybe we’ll have grandkids here one day.”

    Erik and Erin Eagleman moved to Switzerland from Wisconsin with their three children in 2023.

    “It feels safe here,” they tell CNN of their new outdoorsy lifestyle in Basel, close to the borders with France and Germany. Their youngest daughter even walks to elementary school by herself.

    For adventures with your own family, be it weekend breaks or something longer-term, our partners at CNN Underscored, a product review and recommendations guide owned by CNN, have this roundup of the best kids’ luggage sets and bags.

    Starry, starry nights
    For close to 100 years, Michelin stars have been a sign of culinary excellence, awarded only to the great and good.

    Georges Blanc, the world’s longest-standing Michelin-starred restaurant, has boasted a three-star rating since 1981, but this month the Michelin guide announced that the restaurant in eastern France was losing a star.

    More culinary reputations were enhanced this week, when Asia’s 50 best restaurants for 2025 were revealed. The winner was a Bangkok restaurant which is no stranger to garlands, while second and third place went to two Hong Kong eateries.

    You don’t need to go to a heaving metropolis for excellent food, however. A 200-year-old cottage on a remote stretch of Ireland’s Atlantic coast has been given a Michelin star. At the time of awarding, Michelin called it “surely the most rural” of its newest winners.

  18. BradyGem表示:

    deneme bonusu veren siteler: casino siteleri – lisansl? casino siteleri casinositeleri1st.com

  19. Davidled表示:

    https://casinositeleri1st.shop/# deneme bonusu veren siteler

  20. KennethTwisa表示:

    Challenging our perceptions of ‘perfection’
    traderjoexyz exchange
    With health influencers raising the bar for success, the wellness space now often feels like a performative space where people strive to showcase peak physical and mental strength.

    While seeing others’ achievements can be motivating, it can also be discouraging if your progress doesn’t match theirs.

    Each person is chasing the perfect version of themselves — whether it’s a body or a lifestyle — which is dangerous because this is typically an impossible or dangerous version to achieve, Curran said. He added that this type of comparison creates a dangerous cycle in which people constantly feel dissatisfied with their own progress.

    “It’s a fantasy in many ways, and once you start chasing after it, you constantly find yourself embroiled in a sense of doubt and deficit,” he said.

    Curran also noted that wellness challenges can be particularly damaging for women who struggle with perfectionism, as they tend to be bombarded with impossible beauty standards and societal expectations.

    Renee McGregor, a UK-based dietitian who specializes in eating disorders and athlete performance, encourages people to approach wellness trends with curiosity and skepticism. That’s because some influencers and celebrities could be promoting products because there’s a financial benefit for them.

    “The thing to ask yourself about the person you’re taking advice from is what do they gain from it?” McGregor said. “If they are going to gain financially, then you know that they (could be willing) to sell you a lie.”
    Whether you want to try a new challenge or product that promises amazing results, McGregor suggests doing your research and seeking diverse perspectives, including consulting with doctors when possible.

  21. WilliamNug表示:

    New design revealed for Airbus hydrogen plane
    renzo protocol

    In travel news this week: Bhutan’s spectacular new airport, the world’s first 3D-printed train station has been built in Japan, plus new designs for Airbus’ zero-emission aircraft and France’s next-generation high-speed trains.

    Grand designs
    European aerospace giant Airbus has revealed a new design for its upcoming fully electric, hydrogen-powered ZEROe aircraft. powered by hydrogen fuel cells.

    The single-aisle plane now has four engines, rather than six, each powered by their own fuel cell stack.

    The reworked design comes after the news that the ZEROe will be in our skies later than Airbus hoped.

    The plan was to launch a zero-emission aircraft by 2035, but now the next-generation single-aisle aircraft is slated to enter service in the second half of the 2030s.

    Over in Asia, the Himalayan country of Bhutan is building a gloriously Zen-like new airport befitting a nation with its very own happiness index.

    Gelephu International is designed to serve a brand new “mindfulness city,” planned for southern Bhutan, near its border with India.

    In rail travel, Japan has just built the world’s first 3D-printed train station, which took just two and a half hours to construct, according to The Japan Times. That’s even shorter than the whizzy six hours it was projected to take.

    France’s high-speed TGV rail service has revealed its next generation of trains, which will be capable of reaching speeds of up to 320 kilometers an hour (nearly 200 mph).

    The stylish interiors have been causing a stir online, as has the double-decker dining car.

    Finally, work is underway in London on turning a mile-long series of secret World War II tunnels under a tube station into a major new tourist attraction. CNN took a look inside.

  22. BradyGem表示:

    en iyi canlД± casino siteleri: casibom guncel giris – en iyi yasal bahis siteleri casibom1st.com

  23. Davidled表示:

    https://casinositeleri1st.shop/# deneme bonusu veren slot siteleri 2025

  24. Jamesacids表示:

    Wellness perfectionism doesn’t exist. Focus on these sustainable habits
    sushiswap
    ou’re scrolling through your phone when you stumble upon the next viral trend: an influencer claiming that following their incredibly strict diet will help you achieve their jaw-dropping physique. Or you see a fresh-faced runner swearing you can run a marathon without any training — just like they did.

    Whether or not you’re actively searching for wellness advice, it’s nearly impossible to avoid hearing about the latest health craze making bold guarantees of transformation.

    As you wonder if these claims hold any truth, you might also question why people often feel motivated to dive into intense challenges — when seemingly simple habits, such as getting enough sleep or eating more vegetables, often feel much harder to tackle.

    Many of us are drawn to these extreme challenges because we’re craving radical change, hoping it will help prove something to ourselves or to others, experts say.

    “We always see these kinds of challenges as opportunities for growth, particularly if we’re in a phase of our life where we’ve let ourselves go,” said Dr. Thomas Curran, associate professor of psychology at the London School of Economics and Political Science and an expert on perfectionism. “Maybe we feel that we need to be healthier, or we just had a breakup or (major) life event.”
    With social media amplifying these movements, it’s easy to see why people are increasingly drawn to the idea of achieving the “perfect” version of themselves. But before jumping into a new wellness challenge, it’s important to take a moment, reflect on your goals, and consider where you’re starting from.

  25. Weldonsib表示:

    sweet bonanza siteleri: sweet bonanza giris – sweet bonanza giris sweetbonanza1st.shop

  26. Weldonsib表示:

    slot casino siteleri: online kumar siteleri – casino siteleri casinositeleri1st.com

發佈回覆給「Weldonsib」的留言 取消回覆

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