Tween - Examples

Example 1

This example supposes the user’s score is retained in the variable SCORE and that the page has three tweens – one called tweenPass which is a celebratory animation and the second called tweenFail which is suggests the user try again. The third is showScore which has 100 frames each with a graphical representation of the relevant score (obviously this last element could also be done with multiframes)

This script makes showScore jump to the frame for the current score and then checks whether the score is above a certain level and plays the appropriate tween.

showScore.GotoAndStop(SCORE)

if (SCORE >=75)

{

tweenPass.Play()

}

else

{

tweenFail.Play()

}

 

Example 2

In this example we suppose a page has a tween object called KaraokeTrainer which displays individual lines of lyrics to a song. Each of the three verse and chorus sections begins every 50 frames. At the final frame (number 151) there is simply a static piece of text showing all the lyrics on one page.

There are also a set of buttons allowing you to pick where you start or whether to just review the lyrics as a whole.

The script checks a set of radio buttons (with self-explanatory names) and plays the tween from the relevant frame.

if (fromStart==true)

{

KaraokeTrainer.Play()

}

if (fromVerse2==true)

{

KaraokeTrainer.GotoAndPlay(50)

}

if (fromVerse3==true)

{

KaraokeTrainer.GotoAndPlay(100)

)

if(learnLyrics==true)

{

KaraokeTrainer.GotoAndStop(151)

}

Close