Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Digital Audio, Video > Adobe Flash

  • Print
  • + Share This
Like this article? We recommend Setting a Source Video File

Setting a Source Video File

Next you will create ActionScript using a code snippet that loads and plays an external .flv video file into the FLVPlayback component when the page2_mc clip is clicked. The previous two code snippets that you added worked correctly without modifying the code at all. Often, however, you will need to make some adjustments to the ActionScript created by a code snippet to get it to do what you want. The code snippets that ship with Flash CS5 offer helpful comments that provide instruction on how to make changes to the code.

  1. On the Flash stage, select the page2_mc clip.
  2. In the Code Snippets panel, open the Audio and Video folder.
  3. Double-click the “Click to Set Video Source” Snippet. In the Actions panel below the previous code that was added, the code in Figure 3 will be inserted.
  4. The code that is in gray contains ActionScript comments. Comments have no functionality but instead are typically used to make notes that can be helpful to the programmer or others reading their code. Multiline comments in ActionScript are contained within the forward slash-asterisk (/*) and asterisk – forward slash (*/) characters. Adobe includes many comments in its code snippets to help you understand and modify the ActionScript that the code snippet creates. The code snippet you just added contains instructions that explain how to customize the code.

    As explained in Step 1, you will alter the code so that a loaded video file plays in the FLVPlayback component in the page2_mc movie clip.

  5. Locate the line of code that reads:
  6. video_instance_name.source = "http://www.helpexamples.com/flash/video/water.flv";
  7. Alter this code to read:
  8. page2_mc.vidPlayer.source = "http://www.helpexamples.com/flash/video/water.flv";
  9. Test the movie. When you click the page2_mc tab, the water.flv video clip should download from http://www.helpexamples.com and play. If you have your own flash video files in the .flv or .f4v formats, you could modify the code to set the source path, and your video files will play instead.
  10. Close the codesnippets_start.swf file to leave the Flash testing environment and return to the authoring environment.
  • + Share This
  • 🔖 Save To Your Account