Home > Articles

  • Print
  • + Share This
This chapter is from the book

Project: Synchronized Images Template

This project is simply another template that works with all the code you’ve produced so far. Specifically, the CaptionHolder.as class loads the .swf file you’ll create in this project just like it does captionText1.swf and captionText2.swf. However, the purpose of this template isn’t solely for captions. Rather, you’ll specify frame labels that contain images, or any Flash graphic or animation, that you want to appear at synchronized times during the video. This project also incorporates the option of adding parameters to cue points (discussed earlier) to stuff even more information into each cue point.

Steps

  1. Encoding the video
  2. Preparing to gather cue points
  3. Creating an animated sequence
  4. Gathering the cue points
  5. Implementing the ActionScript in imagesTemplate.fla
  6. Entering the ActionScript in main_coffee.fla
  7. Testing main_coffee.fla

Step 1: Encoding the Video

Create a new file in Flash and save it as main_coffee.fla. Select File, Import to Stage and then select the coffee_house_1969.mov public domain excerpt, located in the source_media folder. Step through the video import process, accepting all the defaults to produce coffee_house_1969.flv. You won’t be injecting Event or Navigation cue points during this phase.

Step 2: Preparing to Gather Cue Points

Select Control, Test Movie and then click Play to watch the video a few times, noting when the subject says the following phrases:

  • "Circumscribed clientele"
  • "cool people on campus"
  • "not meaning derogatorily"
  • "swinging" (and then "swinging" again)
  • "coffee house"
  • "place to be and the place to be seen"

Step 3: Creating an Animated Sequence

Create a new file and save it in your working directory as imagesTemplate.fla. Select Modify, Document and set both the width and height to 250. Select Insert, New Symbol. Make sure that the Movie Clip option is selected and name the symbol Content. Click OK and you’ll be inside this clip. To see the edges of the stage, draw a rectangle that’s 250 x 250 pixels. Position the rectangle inside the Content symbol so the upper-left corner of the rectangle aligns with the center of the Content symbol. Select Modify, Timeline, Layer Properties and then name the layer Content, click the Lock option, and change the layer type option to Guide (see Figure 3.21). Because we want the outline to guide us over several frames, click the cell in frame 25 and press F5 to insert frames.

Figure 3.21

Figure 3.21 The Outline layer simply helps you see the edge of the stage from inside the Content symbol.

Here’s where you can get creative. We’ll create a graphic or an animation to correspond with each of the phrases the nice young man says. Open the file imagesTemplate.fla in the finished_source folder and investigate the contents of the Content symbol to see how I created the sequence you’re about to create.

Create a new layer for the still images; name this new layer Stills. Insert a keyframe into frame 2 (press F6), and then import a photograph or create a graphic to support the phrase circumscribed clientele, such as a circle around a drawing of a student from the ‘60s. Click frame 3 and then select Insert, Timeline, Blank Keyframe (or press F7). Insert a graphic to support the word cool. In frame 4, insert a blank keyframe and place the following text: Derogatorily. To animate the international "no" sign on top of it, select Insert, Timeline, Layer (name the layer No sign). In the No sign layer, click frame 5 and insert a blank keyframe (press F7). Draw a circle with a line through it, convert the circle to a movie clip by selecting it and pressing F8, and name it no. In frame 10 of the No sign layer, insert a keyframe. Open the Actions panel and type stop();, and in frame 11 of the No sign layer, insert a blank keyframe (F7). Return to frame 5 and, using the Properties panel, select Motion Tween. Then, select the no symbol onstage in frame 5 and use the Properties panel to set a Color style of Alpha to 1%. (The no sign will fade on from frame 5 to frame 10.)

For the two mentions of the word swinging, we’ll show a graphic of a swing and then show that swing in motion. In frame 11, draw the swing. Next, in frame 12, start an animation of that swing that continues to frame 20, where you’ll place a keyframe and a stop() action.

For the last two phrases (coffee house and place to be and the place to be seen), just place a photo or logo from your favorite coffee shop (in frame 21) and the text be and be seen in frame 22.

Step 4: Gathering the Cue Points

Open gathering_tool.swf and enter the path to coffee_house_1969.flv into the Media field—don’t worry about loading captions this time. Play the video and click the Add button each time the man says one of the previous phrases. You can remove cue points you added by mistake by clicking their triangles and then clicking the Remove button. Each cue point’s name defaults to New Cue Point. Go through the added cue points by clicking each triangle or clicking the Prev or Next button; then enter a simple name for each one, such as Circumscribed, Cool, and so on. The user won’t ever see this text the way we’re building this project, but it helps to confirm that the cue points are in the right place.

When the cue points are in place, we’ll add parameters to each one, such as a frame number and an option of whether the animation should stop there or play. I came up with the idea that each cue point will have parameters for frame (the frame number to jump to in the Content symbol) and option (either play or stop meaning that when the user jumps to the frame, it will begin to play or simply stop there). Click the first cue point and click the plus button to add a parameter. Set the name to frame and the value to 2. This means when this cue point is reached, we’ll jump to frame 2 in the Content symbol, where the "Circumscribed Clientele" graphic appears. Click the plus button again and name the second parameter option; then set the value to stop (see Figure 3.22). The plan is that, when the user jumps to that frame, it will stop there.

Go through all the cue points so each one has parameters for name and option, as shown in the following table:

Name

Parameters

 

Circumscribed

frame option

2 stop

Cool

frame option

3 stop

Derogatorily

frame option

4 play

Swinging (1)

frame option

11 stop

Swinging (2)

frame option

12 play

Coffeehouse

frame option

21 stop

Place to be

frame option

22 stop

After you have all the cue points and parameters set, click the Export XML button. Copy the XML string that appears and create a new text document with Notepad or a similar program. Next, paste in the XML text you copied and save the file as coffee_house.xml in your working directory.

Figure 3.22

Figure 3.22 This cue point has two parameters: frame (2) and option (stop).

Step 5: Implementing the ActionScript in imagesTemplate.fla

Go to the main timeline of imagesTemplate.fla. Drag an instance of the Content symbol onto the stage if you haven’t done so already. (It might be a bit tricky considering nothing is in the first frame of the Content symbol.) Use the Properties panel to set the instance name to content and the upper-left corner to 0, 0.

Select the first keyframe, open the Actions panel, and type the code in Listing 3.6.

Notice that we completely ignore the first parameter received in showText() (that is, name). Instead, the code digs into wholeObject, which includes all the same properties that would be received from a standard cuePoint event. In this case, these properties are type, target, and info—inside of which are properties for name, time, and parameters (which itself contains whatever properties you injected into the .flv file or specified in the XML file). Here the code just grabs info.parameters.frame and info.parameters.option.

Step 6: Entering the ActionScript in main_coffee.fla

Inside main_coffee.fla, be sure you have an FLVPlayback component onstage; if not, drag one from the Components panel. Give it an instance name of playback.

Listing 3.6 This Code Handles New Captions by Jumping to the Appropriate Frame in the content Instance

function clear(){
  content.gotoAndStop(1);
}
clear();

function showText(name:String, wholeObject:Object, speed:String){
  content.gotoAndStop(wholeObject.info.parameters.frame);

  if( wholeObject.info.parameters.option == "play" ){
   content.play();
  }
}

function getSize():Object{
  return { width:250, height:250 };
}

Copy a CaptionHolder symbol from one of the other main files you’ve created (main.fla or main_audio.fla). Or simply select Insert, New Symbol and set the Create New Symbol dialog box as was shown previously in Figure 3.13 (step 2 of the fourth project). Place an instance of the CaptionHolder symbol onstage and give it an instance name of captions_clip. Arrange the screen so captions_clip is next to the video and not on top of it. The 320 x 50 rectangle shape in the CaptionHolder symbol is not an accurate representation of where the imagesTemplate.swf will appear because that file is actually 250 x 250. You can double-click the CaptionHolder and double-click again so you’re inside the Rectangle symbol and then resize that shape to make it 250 x 250. Back in the main timeline, you should select Modify, Document and increase the main_coffee.fla file’s width to at least 600 so the FLVPlayback component (instance name playback) and the CaptionHolder symbol (instance name captions_clip) fit side-by-side, as shown in Figure 3.23.

Finally, select the first keyframe, open the Actions panel, and type in the code in Listing 3.7.

Figure 3.23

Figure 3.23 The FLVPlayback (left) and CaptionHolder (right) are arranged side-by-side.

Listing 3.7 This Code Associates an Instance of theEventChannel Class with theimagesTemplate.swf File

var playback:mx.video.FLVPlayback;
playback.autoPlay = false;
playback.contentPath = "coffee_house_1969.flv";

var myEventChannel:EventChannel = new EventChannel();

//send init() function to the CaptionHolder instance 
//on stage (captions_clip)

var url = "imagesTemplate.swf";
var eventList = ["actionscript"];
captions_clip.init( url, myEventChannel, eventList );

//alternative code to effectively turn the FLVPlayback 
//into autoPlay=true
function ready(){
  playback.play();
}
myEventChannel.addEventListener( "ready", this );
myEventChannel.init( playback, "coffee_house.xml" );

This code should look very familiar—the only changes are the filenames for the .flv, imagesTemplate.swf, and .xml files.

Step 7: Testing main_coffee.fla

Make sure all the following support files are present in the same folder where your main_coffee.fla file is:

  • coffee_house_1969.flv
  • coffee_house.xml
  • imagesTemplate.swf
  • CaptionHolder.as
  • EventChannel.as

That folder should also contain the FLVPlayback skin you selected, such as MojaveOverNoVol.swf.

In main_coffee.fla select Control, Test Movie.

I hope that this template shows you another way to use cue points for more than just captions and also gives you the ability to design and build additional template types. Like many projects in this book, extra templates are available for download; plus, I expect readers to share their templates.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020