Search Tutorials
Layer 3: actions This layer drives the whole show. To begin with, place 4 keyframes in the first 4 frames of the layer. Like this:
In the first frame place the following code toload the variables in the text file:
Load Variables ("tipdata.txt", 0)
In the second frame we will check to ensure that all the variables have loaded by ensuring the last variable in the list, 'tips' is greater that 1. If it isn't then the text file hasn't finished loading so it loops back to frame 1. If it has then it jumps to frame 3. If (tips <1) Go to and Play (1) Else Go to and Play (3) End If The third frame is where the action happens. This code generates a random number which then points to the variable matching that number and displays it in the text field, 'text'. This is also where the code on the button, mentioned previously, points to generate a new tip of the day.
Set Variable: "c" = Random(tips)+1
Set Variable: "text" = Eval("text"&c)
And finally we place a stop action on the last frame to make it nice and tidy.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|