STEP 13 preloading for STREAMING


With a series of actions, you can preload a good part of your file so that the rest will stream, hopefully, without a glitch.

I use the same basic preload technique for almost all my files. Flash has a preload code included, but it has to be set up properly. In essence, here's what my preload action does:

  • Checks to see whether a particular frame has been loaded.

  • If the frame has not been loaded, continues preloading assets.

  • When the frameand all the desired assets included up to that framehave been loaded, begins playing.

Note

I use labels, thus the "labels" layer in all of my file setups, rather than frame numbers because it's far easier to adjust your timing with them. You can just drag the label keyframe to a new location rather than reopening the Frame Properties dialog and altering the code.


Here are the steps for establishing the preload for the spot:

  1. In the label layer, double-click the blank keyframe in frame 1 to open the Frame Properties dialog.

  2. From the Label tab, enter home into the Name text field and make sure that the Label option is selected. Click OK when you're done.

    A label named home is inserted.

  3. Repeat steps 12 on frame 4 to create a label named "start."

  4. Repeat steps 12 on frame 25 to create a label named "load" (see figure 03:29).


    Figure 03:29.

    graphics/03fig29.jpg


  5. In the action layer, double-click the keyframe in frame 1 to open the Frame Properties dialog again.

  6. From the Actions tab, choose the plus symbol (+) button and select If Frame Is Loaded from the drop-down list.

    The If Frame Is Loaded script is written into the script window as shown in figure 03:30.


    Figure 03:30.

    graphics/03fig30.jpg


  7. Select the Label option and choose Load from the drop-down list.

    Now you need to tell Flash what to do if the frame you specify has been loaded.

  8. Select the plus (+) button again and choose Go To from the drop-down list.

  9. Enable the Go To and Play option as shown in figure 03:31.


    Figure 03:31.

    graphics/03fig31.jpg


  10. Choose the Label option and choose Start from the drop-down list (see figure 03:31).

  11. Click OK when you're done.

    For this action to work properly, another loop must be added.

  12. In the action layer, add another keyframe to frame 2 and double-click it to open the Frame Properties dialog.

  13. In the Actions tab of the Frame Properties dialog, add a Go To action, specifying the home label. Be sure to enable the Go To and Play option. This creates a loop that sends the playhead back to the script in frame 1, until that script returns a positive.

    Imagine your computer talking to itself : "No, frame 'load'is not cachedI'll go to and play frame label 'home'" The computer is forced to ask the question again and stays in this loop until the answer is "Yes, frame 'load'is cachednow I'll go to and play frame label 'start'."

Now that a preload loop has been established, you can easily adjust what gets preloaded by moving the "load" label from one frame to another. If the label is on the same frame as another element's keyframe, such as a sound effect, that elementand all the elements inserted prior to that onewill be loaded.



Flash Web Design The Art Of Motion Graphics
Flash Web Design oder: the art of motion graphics
ISBN: 3827256623
EAN: 2147483647
Year: 2005
Pages: 192

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net