Flash Professional 8 Beyond the Basics

Flash Professional 8 Beyond the Basics

with Shane Rebenschied

 


Have you completed the Flash Professional 8 Essential Training course, or are you already up to speed on the fundamentals of Flash? If so, you're ready to move beyond the basics with this series of step-by-step video tutorials. In Flash Professional 8 Beyond the Basics, Shane Rebenschied will expand your Flash skill set by guiding you through the production of a complete website built with Flash and ActionScript. Exercise files accompany the training videos, allowing you to follow along and learn at your own pace.
Topics include:
  • Integrating Fireworks, Photoshop, and Illustrator content ActionScript Classes, Objects, Methods, and Properties Using the LoadVars Class to build scrolling text fields Using HTML and CSS with Flash Integrating usability and functionality Building an ActionScript-driven navigation system Building a dynamically loading slideshow with text and images Building a Preloader Using Components to create a feedback form Testing and publishing your final project

show more

author
Shane Rebenschied
subject
Web
software
Flash Professional 8
level
Intermediate
duration
10h 45m
released
Mar 07, 2006

Share this course

Ready to join? subscribe


Keep up with news, tips, and latest courses.

submit Course details submit clicked more info

Please wait...

Search the closed captioning text for this course by entering the keyword you’d like to search, or browse the closed captioning text by selecting the chapter name below and choosing the video title you’d like to review.



Introduction
Welcome
00:00>> Hi, I'm Shane Rebenschield and welcome to Flash Professional 8, Beyond the Basics.
00:04In this video training title, you're going to be learning intermediate to advanced level flash action scripting
00:10and the context of building a fully functional flash 8 website.
00:14I'm not going to keep you around here any longer, let's just get straight to it.
Collapse this transcript
1. What You Should Know
Exercise files
00:01>>For those of you that have premium subscriptions to the Lynda.com movie library, or who have purchased a CD ROM for this particular title,
00:09there are exercise files associated with this title that you're gonna want to copy onto your computer.
00:14On the CD ROM or, again, if you're a premium subscriber, make sure that you get access to those exercise files and copy them to your desktop.
00:23Now if you're on Windows, you might also need to right click, or Control, Click on that LA Eyeworks
00:28folder that contains those exercise files, and choose from that contextual menu "Properties."
00:34Under "Attributes" make sure that "Read Only" is unchecked, and then click "Apply."
00:40You want to make sure that you apply these changes to the folder, subfolder, and files, and click "OK."
00:46That way as you open, work with, and save those files inside that folder, you won't encounter any errors, and then just click "OK."
00:54If you do not have access to those exercise files and would like to get them, you can either purchase the CD ROM for this title,
01:01or at MovieLibrary.Lynda.com, which you may be accessing this video title through. You want to make sure that you sign
01:08up for the premium subscription so that you can get access to those exercise files.
01:13Now if you don't have access to those exercise files and don't want to sign up for the premium subscription or purchase the CD ROM,
01:20as we encounter exercises that require those exercise files, I'll do my best to explain for those of you who don't have access
01:27to the exercise files, what we're about to do and how you can work with those particular files.
01:33Unfortunately because of the complexity of some of the topics that we're gonna be discussing in this title, again because it is an intermediate
01:40to advanced level title, there are some occasions where some of the provided files might be a little difficult for you to reconstruct.
01:47But again, as we come across that content I'll make sure that for those of you who don't have access to the exercise files are aware of that.
Collapse this transcript
Things you should know
00:01>>Before you make the pretty heavy commitment of working though all the exercises in this title,
00:06it's important that you understand first what it is that you're getting into.
00:09First, go to "MovieLibrary.Lynda.com," once you're there click on the "Browse All Titles" link.
00:20From there scroll down to the "Macromedia" offerings, and then under "Flash," click on "Flash Professional 8 Essential Training."
00:31Look through this list and make sure that you understand everything that's covered in this title.
00:37As you can see it covers topics such as the Interface, Drawing and Color, Animating Essentials, Dealing with Shape tweens and Motion tweens.
00:46Working with the Library, Timeline Effects, Masking, Working with text inside of Flash, Bitmap graphics, Filters, Buttons.
00:56Working with Movie Clips, How to use simple action scripts such as getURL, Stop, and Play, Creating pop up menus, and the Scrolling Text.
01:05Loading JPEG's, GIF's and PNG's, Building a Preloader, Working with Components, as well as Sound and Video, and even Publishing your document.
01:15Make sure you understand first all of the topics that are covered in the essential training title,
01:21because that is going to be expected as the base amount of knowledge that you have.
01:26If you don't know all of those items, or if you feel like you're a little bit sketchy on some of them, it might pay to go back
01:32and look at the Flash 8 Essential Training title to brush up,
01:35either on the topics that you're a little fuzzy with, or to learn ones that you don't know.
01:40That way as you go into the intermediate Flash 8 title, you have a really good, strong understanding of those basic elements.
01:47So that as you work forward everything should make a lot more sense to you.
Collapse this transcript
New features
00:01>>If you're migrating from Flash MX 2004, or an earlier version, into Flash 8, it's probably also important that you learn a lot of the new features
00:09that are available for your use now here inside of Flash 8.
00:13Instead of rattling off all those individual features, I'd recommend looking at www.macromedia.com/software/flash/flashpro/productinfo/features.
00:26At this URL it has a little video introduction that lists a lot of the new features that are available inside of Flash 8.
00:39And then if you scroll down there's also a breakdown of each item that is new inside of Flash 8.
00:45There's new filters, blend modes, a new way of rendering type inside of Flash, which is really nice, called Flash Type.
00:52Features like Bitmap caching, custom easing control when you're dealing with Motion and Shape tweens, improved Text tool,
00:59Stroke properties. One of the big things is video inside of Flash. [00:01:03.736 A brand new Kodak has been introduced called the "On2 VP6 Video Kodak."
01:08It also has support for alpha channel, so you can have video with alpha channels inside of your flash content.
01:15And there's also embedded cue points that you can introduce into your video so you can actually add cue points to your video content
01:23and then have different functions trigger when those cue points are reached for extra interactivity.
01:29It also has a new method of working with action script, which is actually a repurpose of an old method called Script Assist,
01:36which used to be called Normal Mode inside of Flash MX and prior.
01:40There's also a new method of working with the Library, an object drawing model, and so forth.
01:46So there's actually a lot of new content, and then again, rather than going over each of these items individually,
01:52I would encourage you to go to this URL and read all the various features that are new inside of Flash 8.
01:57If you'd rather, you can also watch a title that I recorded that briefly covers a lot of the new features that are available inside of Flash 8
02:05by going to the "MovieLibrary.Lynda.com" and then again if you go to browse "All Titles," if you're a member of the Movie Library you can scroll
02:16down to the Flash section and go to Flash Professional 8, New Features.
02:20Where again, it briefly covers a lot of the new features that are available for your use inside of Flash 8.
02:26So if you're upgrading from a previous version of Flash, and now working with Flash 8, you should probably take a little bit of time
02:32to familiarize yourself with a lot of these new features.
Collapse this transcript
Updating Flash
00:01>>One other item to check before you start going through the exercises in this video title, is to make sure that you have the latest version
00:08of the Flash plug-in, as well as the latest, if any updates, to Flash itself.
00:14In your web browser, navigate to www.macromedia.com/software/flashplayer.
00:24From here you can get the latest version of Flash Player 8.
00:27Now when you install Flash 8, it automatically asks you, and should have installed Flash 8 for you, but if there have been any updates
00:35since the time you installed Flash 8, to the time you're going through this title, you can download those latest updates to the Flash plug-in by going
00:43to this URL and clicking on the "Download Now" button to get the latest version of the Flash Player, and I'd recommend that you go do
00:50that before you get started with the rest of the exercises in this title.
00:54Additionally, if there are any updates to Flash itself, you should see that listed on the front page of MacroMedia.com on their website,
01:02or inside of Flash if you have the Start page open. In the bottom right
01:07of the Start page it usually notifies you if there are any updates to Flash itself.
01:12At the time of recording this title there are no updates available for Flash 8.
01:17But again, if there are any by the time you view this title,
01:20it should tell you here inside the Flash 8 Start page, or on the front page of MacroMedia.com.
01:27So again, before you get started make sure you have the update to the latest version of the Flash Player
01:32for your web browsers, as well as for Flash 8 itself.
Collapse this transcript
Sample site tour
00:01>>Before you get started let's take a quick tour of the site that you're going to be building throughout this training tutorial.
00:08Open up your preferred web browser and navigate to the URL: www.lynda.com/intflash8/laeyeworks.
00:19When you go to that URL you'll see the website load.
00:24In the middle of the page is a splash screen that is animated and it loops over and over again.
00:30Up at the top is a Navigation bar, allowing the viewer to navigate to "About Us," "Frames," "Locations," and "Contact Us."
00:47Go ahead and click the "About Us" option.
00:50When you do that you'll see some text that loads on the stage.
00:53Additionally, if the viewer has access to a submenu for this section that allows them to view information
00:59about the history of LA Eyeworks, or the staff of LA Eyeworks.
01:03Now the text that you see here up here on the stage, is actually loaded in dynamically using action script,
01:10and the text that appears there is external to the Flash file itself.
01:15All of this text actually resides in a separate text file, and by using action script that text is dynamically loaded in
01:22and placed inside of a text field here on the stage.
01:26Additionally, the text is formatted using HTML tags and then styled, such as these hyperlinks here that have a roll over state to them,
01:35as well as the bolded text, is all done using cascading style sheets.
01:40The cascading style sheets itself is also external to flash.
01:45It's a separate .css file that is loaded in, dynamically using action script, and applied to this text here.
01:53The viewer can also click on some buttons to scroll both down and up through that text.
01:59By selecting the "Our Staff" option, you can see that there's the same dynamic text,
02:04but inline embedded inside of that text are some animated swift files.
02:10Next, go ahead and click on the "Frames" option from the Menu bar at the top.
02:18What you will essentially see is a slide show of frames that the viewer can look at available at the LA Eyeworks store.
02:25By clicking on the "Next" or "Back" buttons, the viewer can navigate both forward and backward through the slides in the slide show.
02:32You'll also notice as you flip through the various slides, that the information to the left hand side
02:38of each image also updates as you navigate through the images.
02:43Additionally, beneath the image, it also updates to show you which frame style you're looking at, and how many there are total.
02:51Pretty much everything that you see here on this section is dynamic.
02:55The images, which are actually separate JPEG files, are loaded in dynamically using Action Script.
03:01The descriptive information that you see to the left hand side of the image is also dynamically loaded, and styled,
03:07and formatted using Action Script, HTML, and Cascading Style Sheets.
03:12Underneath the image where it specifies which image you're looking at, and how many there are total, is also Action Script driven.
03:21Next click on the "Contact Us" option from the top Navigation bar.
03:25When you do that you'll see a Feedback form appear here on the stage.
03:29If you click inside the "Name" file and type your name, you'll notice that the text that appears inside of these form fields is styled.
03:40Not only is it using a specific font, but it's also using a specific font size and color as well.
03:47You'll also notice that the text that appears inside of there looks nice and smooth.
03:51That's because it's anti-aliased, it has a nice smoothed edge around the outside.
03:56When the viewer has completely filled out that form, they can then click on the Submit button to send those results to the web server,
04:03where a CGI then processes those results, and then emails them to the email address that you can specify.
04:10So that, in essence, is essentially the website that you're going to be constructing throughout this training tutorial.
04:16There's quite a lot of stuff to cover, so even though on the surface it may look pretty easy and simple to set up,
04:22you're going to be learning intermediate to advanced level Action Script in order to program all the elements that you've seen here.
04:29There's a lot of stuff to cover, but it's a lot of fun.
04:32So go ahead and get that cup of coffee, or do jumping jacks, or whatever you need to do, and continue on to the next chapter.
Collapse this transcript
2. Where Do I Start?
The site construction process
00:01>>As you go forward and begin to develop websites for yourself or for a client,
00:06it's important that you have at least a basic understanding of the site construction process.
00:11Now keep in mind, as I go through these points, that the site construction process is really a sort of a subjective thing.
00:17It's not something that is the same for everybody that develops websites.
00:21It's going to change depending upon your style of developing websites and building them, as well as the people that you'll be working with.
00:28So just keep that in mind as we go through the following points,
00:31and that this is mainly just to give you a good starting place as you go to develop your own content.
00:37The first step in the site construction process, and the process of taking a site from the idea phase
00:43to the final phase is - "what is the content that you have to work with?"
00:48In the case of the LA Eyeworks website, I know that I had some information about the company, the history of the company for example,
00:55the staff that worked there. I also wanted to display some information about the glasses frames that they sold.
01:01I also knew that I had a video to work with, as well as some audio.
01:06So I knew from the get go the basis of the content that I had to work with.
01:10Once you have a decent understanding of what you have to work with, the next step is to figure out who is the target audience.
01:18The target audience is who is going to be viewing your content.
01:21And that's really one of the most important parts of the early phases of developing a website.
01:26You need to figure out who is going to be looking at the stuff that you're going to be designing.
01:31It's really important, because depending upon who is going to be visiting your website and the stuff that you design,
01:36it's going to have a large effect on whether or not you're using Flash altogether.
01:41What kind of colors you use, what kind of type you use, and so forth.
01:44For example, if you're designing a website that is mostly going to be visited by elderly people, you don't want to have real small type
01:51on your website, because it's going to be more difficult to read. You'd want us use larger type in that case.
01:56And that's just one example of how the target audience really has a heavy bearing on how your website is both designed and developed,
02:03as well as what type of technology is appropriate to use.
02:06In the case of the LA Eyeworks website, our target audience is people
02:10who would most likely buy LA Eyeworks frames, and buy those particular glasses.
02:16More than likely those are people who live in the LA area.
02:19So we know that they probably have a high-speed internet connection, and they probably have a newer computer,
02:25because those are the types of people that visit the LA Eyeworks store.
02:29So that is going to be our target audience.
02:31Now because we know they have a high-speed internet connection, and because they probably have a newer computer,
02:36we know for sure that we can use Flash, because that is appropriate for that particular target audience.
02:41Not only that, but we know we can also get away with having more in the site, such as rich media, like MP3 files and video, because again,
02:50they're on a high speed internet connection, so having a lot of media in the site is appropriate because the viewer can download
02:57that appropriately on their high speed internet connection.
02:59So again, once we know who the target audience is, we can better craft and develop this site specifically for that particular target audience.
03:09Once you have an idea of what the content is, and you know who you're going to be developing and showing that content to,
03:15the next stop is to start with the layout and design.
03:19In particular, starting with a flowchart is a good place to begin working with developing the layout and the design of the site.
03:27Now as it name implies, a flowchart is a chart that depicts the flow of the website.
03:32How is the viewer going to navigate through your website?
03:35Now flowcharts come in a variety of different forms.
03:38One of those is as you see here, which is basically just a chart that shows all the main elements of your website.
03:45For example, up at the top you can see that the main file is "master.swf."
03:50The "master.swf," as you'll see in the next chapter, is sort of the main Flash SWF file that all the other content loads into.
03:57That's where, as you can see again here in the flowchart, where the splash page, the main menu, and the MP3 player are presented.
04:05That's the first section that the viewer is going to see.
04:08Oftentimes that is called tier 1, the first section that your visitors to your website will be presented with.
04:15From the main menu, the viewer can then navigate to the "About Us," "Frames," "Locations,"
04:21and "Contact Us" sections, and that is depicted here in this flowchart.
04:26Now the lines and arrows depicted in this flowchart also show how the viewer can navigate from section to section.
04:32So you can see that the main menu is being presented in "master.swf" and from the main menu the viewer can navigate to that second tier section.
04:40Which is "About Us," "Frames," "Locations," and "Contact Us."
04:44So the layout of the flowchart, as well as the lines and arrows, depict not only the structure of the site, but as well,
04:51how the viewer is going to flow, or navigate through the various sections of your site.
04:57So the flowchart is a really important part of the layout and design process of the site,
05:02because it gives you a really good understanding before you even start figuring out the design of it all.
05:07How the viewer is going to be navigating around your content.
05:11The next step is to storyboard.
05:14Now this is a term that is actually taken from movies, but it also fits well here when you're developing a website.
05:20Now the storyboard is where you get a little bit more specific as to each individual section of the website.
05:27Now for example, you can see here that this is a storyboard of the very first main page of the website.
05:34Now as you can see here, this is just a simple sketch of the main page.
05:38A storyboard can be something simple like this, or it can be more refined and cleaned up in another graphics editing program of your choice.
05:46Either way, the main purpose of a storyboard is to get more specific with how each page is being presented in your site.
05:52Again, you don't have to draw every single graphic, but the main purpose of a storyboard is to begin to show where the various elements
06:00in each page of your website are going to be presented at.
06:03The purpose of all these steps before you actually get in there and start designing every little nook and cranny of the website,
06:10is to get a lot of the elements figured out before you start spending the time with all the details that make up the website.
06:17The site construction process is sort of like an oil painting. You start from the very general and work your way to the very specific.
06:24That way as you're developing your own work, and even showing that to the client,
06:29a lot of the broad concepts can be ironed out as you work more specific.
06:35So in the end you're left with a well-designed website.
06:38The storyboard is another element in that process.
06:42Now from here, an optional step that you can go to is something called a static mock-up.
06:46And that would be more like a more refined storyboard, where instead of just a simple sketch, maybe you've gone in there
06:53and put in some of the basic layout elements of the website.
06:57You can put in squares where graphics might be and where text might be presented,
07:01but the point is to get a little bit more specific past the storyboard phase, so you're getting yet an even clearer idea
07:08with how each page is going to be laid out and ordered. Again, that's an option step.
07:13From there you can get even more specific and start working on the actual design of each section.
07:19So that is where you'd start going in, laying out your colors, laying out where all the graphics are going to be,
07:24where the text is going to be presented, video, music, and so forth.
07:28Now once you've done all those various steps, by this point you should have a really good understanding
07:33with how the whole website looks, and how each page is going to be presented.
07:38Then once you've done that, you can most likely jump right in and start working on the development and implementation of the website.
07:44So it's at this point that you'd most likely make the transition from working in any old graphic editing program, PhotoShop, Illustrator,
07:51Freehand, Fireworks, and so forth, whichever you're comfortable with, and making the leap into Flash.
07:57You can then start working on laying out the navigation.
08:00Now the reason why I put that toward the top of the development and implementation phase, the navigation is how the viewer is going to go
08:07to each section of your website, so it's a really important key part of the website as a whole.
08:13Once you figure out the navigation, and how that's going to be presented and ordered, it's going to give you as a designer and developer,
08:20a much better idea of how much space you have left to work with to present that information.
08:25So figuring out the navigation is a key part as you start developing and designing the actual website itself.
08:33Once you've decided on the navigation, then you can start designing and implementing the main content,
08:39as well as the content that comes underneath that, sometimes called the tertiary content, or tier 2, tier 3 content.
08:45So you get the navigation figured out, then you can start working on, in Flash, designing and laying out, and actually implementing
08:53and programming all of the interactivity, laying out all the content, and so forth for your website.
08:58Once you get that all laid out, then you can actually start linking all the various pieces together by making the navigation interactive.
09:06So you can take your navigational elements that you laid out in the first part of phase 3,
09:11and actually link those so that they load in or go to your tertiary content.
09:16So the whole thing starts to get interactive.
09:19This is one of the last phases of the development and implementation phase, because this is where you start to see all the pieces come together.
09:27Up until this point you've probably worked on each individual section of the website, but the last phase is to link them all together,
09:34and this is where it all comes together into one cohesive website.
09:38The last step, but certainly not least, is to deploy and upload your website.
09:43So you would take everything that you've been developing on your computer and up load it to your website so you can test it there.
09:49Now this may seem like a minor sort of phase, but it actually is really important, because up until this point, again,
09:56you've been testing your work off of your local computer.
09:59Now when you take that same content and upload it to your website, and you view that content as it is being downloaded off of a web server,
10:07it can change into something complexly different. Because again,
10:11as you're viewing your content locally, it's loading off of your hard drive instantly.
10:15So anytime you're loading text into your Flash project, or movies, or video, or audio, it's all loading in instantly.
10:22Depending upon the way that you've developed your site, Flash can be pretty sensitive as to when things are loading in,
10:28if they're loading in before something else, and so forth.
10:31So when you actually upload your website to a web server and you're viewing it over the internet, things are loading in a different times
10:39and that can have a major affect as to how the website functions as a whole.
10:43So once you've gotten your website finished, it's a really important process to upload it to your website
10:49and make sure that you test it there as it is being downloaded.
10:53Not only that, but it's also important to try to test it on a variety of different computers, operating systems,
10:59internet speeds, and so forth, from different locations if possible.
11:03That way you have a much better idea as to what the end user that is actually going to be visiting your website will see.
11:10Then you can make fine-tuning adjustments based on what you've seen, and how that website is being downloaded off of the web server.
11:17So even though it may seem like a minor point, the deployment and the uploading of your website,
11:22it is actually a very important element in the whole site construction process.
11:26Now again, keep in mind that the points I've mentioned here are just suggestions as a place to start.
11:32Most likely over time you will end up fine-tuning these steps to better suit you or your team's methods.
Collapse this transcript
Installing the site font
00:01>>Throughout the exercises in this video title, you'll also be working with one particular font, and that one's called Bitstream Vera.
00:09There are a few different variants involved in that font as well, Bitstream Vera Sans Bold, Bold Italic, and so forth.
00:16So it's important before you go much further, to make sure that you have that particular font installed on your computer.
00:23Now if you're a premium subscriber to the Movie Library, or if you've purchased the CD ROM for this title,
00:28in the exercise files that accompany that, if you open up the "LA Eye Works" folder, then go into the "Resources" folder,
00:37and into the "Font" folder, you'll see another folder that contains the font face that we're going to use throughout the exercises in this title.
00:44You can open that up, and then take those fonts and install them on your computer.
00:50On Mac OS10, you can take the whole folder and drag it into your "Users" folder, into your "Library" folder,
00:57and within a folder in there is another folder called "Fonts."
01:01You can take this whole folder with the fonts inside of it, and drag it into that "Fonts" folder.
01:06It will then install those fonts in your computer.
01:09You'll also need to make sure before you install the fonts in your computer that you have Flash closed.
01:15Because after you install the fonts you should be able to relaunch Flash, and those fonts should then be available for your use.
01:22Sometimes you also may need to restart your computer for those fonts to be available for you.
01:27On Windows, open up your "C" drive, open up the "Windows" directory, and in there is another directory called "Fonts."
01:39Inside of the "Font" directory that has been included with the exercise files, open up that "TTF Bitstream Vera 1.10" folder.
01:48Select the fonts within that folder, and then drag them into the fonts folder in your Windows system.
01:59That will then install those fonts for Windows, and you can then use them inside of Flash.
02:03Again, make sure that Flash is not launched when you install those fonts, because after you install the fonts you'll launch Flash,
02:11and then those fonts should be available for your use.
02:14Again, sometimes you may need to restart your system in order to be able to use those particular fonts.
02:20Now if you do not have access to the exercise files, open up your preferred web browser and go to "www.gnome.org/fonts."
02:33Here is where that particular font is available for free to download.
02:37There's a link, at the time of recording this title that says, "The fonts are now available here."
02:43If you click on that you can then download one of those archives of fonts and then install them like I just showed you.
02:49So before you go any further make sure that you have those Bitstream Vera font, as well as all the variants of it.
02:55Bold, bold italic, and so forth, installed on your computer.
02:59That was as you continue forward with the exercises, we can all use the same font face so that we're all on the same page.
Collapse this transcript
Integrating Fireworks content
00:01>>One question that I get a lot from students that are working in Flash is:
00:05Which program should I use as I'm designing my graphics that will best integrate with Flash?
00:11And that's a good question.
00:12And as you're beginning to work, and develop, and design your images, which program should you use so that you can minimize the amount of work
00:19that you have to redo as you bring your images into your Flash projects?
00:24In the next few exercises we're gonna look and see how various graphics integrate with Flash that have been created
00:31in other graphics editing programs such as, Fireworks, Freehand, Photoshop, and Image Ready.
00:36If you have access to the exercise files feel free to follow along with the steps as I'm doing them.
00:42If you don't have access to the exercise files, you can still walk away with lots of information, just kick back and watch.
00:49Inside of the LA Eye Works directory that you copied onto your desktop earlier, there's another folder called "File Types."
00:56Inside of there, there are other folders from other graphics editing programs.
01:00Again such as Fireworks, Freehand, Illustrator, Photoshop, and Image Ready.
01:06Inside of those folders are images that have been created with those respective graphics editing programs.
01:12Let's take a look how those graphics hold up once they've been imported into a Flash project.
01:18In this first exercise, let's look to see how Fireworks fares.
01:22Go ahead and open Flash 8, and then go ahead and create a new blank Flash document.
01:31Let's change the stage size of this Flash document to be the same as the graphic that we're importing.
01:37So choose "Control J," or "Command J," or click on the "Size" button in the "Properties Inspector" to open up the document properties dialog box
01:46where you can then get access to the movie dimensions.
01:49Simply change the width to 600 and click "OK."
01:54Next, choose "File," "Import," "Import to Stage," or simply click the keyboard shortcut "Control R" on Windows, or "Command R" on the Macintosh.
02:06Then on your desktop open the "LA Eye Works" folder, open the "File Types" folder, and then open "Fireworks."
02:14Inside of there, there are two files that have been created with Fireworks 8. "Main Menu,"
02:20which is a PNG File, and another "Main Menu," which is a SWF file.
02:24Go ahead and open up the "Main Menu" PNG file by double-clicking on it.
02:28When you do that, Flash is going to open up this dialog box called
02:31"Fireworks PNG Import Settings," and it's gonna ask you a few different questions.
02:36The first is for file structure, "Do you want to import all of the images as a movie clip and retain the layers within that,"
02:43or "Do you want to import the content into a new layer in the current scene?"
02:47Go ahead and select that second option, as we don't want to have Flash automatically create a movie clip to store all the content in.
02:53We just want to have it bring the content right here onto the stage as is.
02:57Under objects, you can choose to rasterize to maintain appearance, or try and keep all the paths editable.
03:05Since we're trying to see how Fireworks can take its graphics that it creates, and bring them into Flash while still trying to keep the editable,
03:13select that second option, "Keep all paths editable."
03:17Under "Text" we get the same options, "Rasterize the text to maintain appearance," or "Keep it editable."
03:23Again, select "Keep it all editable."
03:25Lastly we can choose to import as a single flattened bitmap.
03:29That basically would take all the layers that we have from our Fireworks graphic and squish it into one,
03:34and then just bring that in as a raster graphic here inside of Flash.
03:38In this case we don't want that option to be checked, because again we want to see how the content from Fireworks integrates with Flash,
03:46while still allowing us to edit it after it's been imported.
03:50Once you've set those settings, click "OK."
03:53This is the graphics that we've imported from Fireworks, and this is the main menu for the site that you're going to build throughout this title.
04:00Let's take a look and see how Flash has treated and translated this Fireworks PNG file.
04:05If I select the text for "About Us" in the main menu, and look in my "Properties Inspector,"
04:11I can see that I can get access to all of text properties.
04:14If I double-click on that, I can see that it's an editable text block.
04:19So what's happened is, Flash has actually treated all the text fields here just like as if I created them in Flash itself.
04:27If I click on the graphic underneath it, this green bar, I can see that's actually converted that into a drawing object.
04:35If I double-click on that I can get access to the actual object itself, and it still is a Vector object, just as if I'd created it in Flash.
04:44So I can go back and make any changes to it after the fact if I'd like.
04:48So as you can see, Flash actually treats really well, the graphics that have been created in Fireworks and saved as it's native PNG file.
04:57Now you may get slightly different results depending upon the complexity of the graphics that you're creating in Fireworks.
05:04But again, as you can see, Flash treats the Fireworks PNG files really well.
05:08All my Vector graphics have retained their editability, as well as the text.
05:13I can go back, and I can edit the graphics, and I can edit the text, even after I've imported them into Flash.
05:19Next let's go ahead and take a look to see how Flash treats importing a SWF file that has been exported from Fireworks.
05:26To do that I'm gonna close this FLA,
05:29and not save any changes.
05:31And then I'm gonna create a new FLA, I'm gonna use the keyboard shortcut this time. On Windows it's "Control, Alt,
05:37N," on the Macintosh it's "Command, Option, N," and then again I'm gonna press "Control J," or "Command J" on the Macintosh,
05:45to access document properties, and then I'm just gonna change the width to 600 and click "OK."
05:51Now when I go to import, I'm gonna use the keyboard shortcut this time, "Control R" in Windows, or "Command R" on the Mac.
05:58I'm in that same directory again, but this time I'm gonna import the "Main Menu" SWF file.
06:03Again this file was just saved from Fireworks, the only thing it was saved as was just a simple Flash SWF file.
06:09I'm gonna double-click on that file to import it.
06:13Now when I scroll up to the top of my stage, I can see there's my main menu options. Let's see how Flash has translated that.
06:20I'm gonna click on the first text option, "About Us," I'm gonna look at my Properties Inspector, I don't see my text options anymore.
06:27I can see, however, that it's been inserted into a group.
06:31So if I double click on that text block, which is a group, and now that I go inside that group I can click on that text block,
06:38and now I get access to the text options in the Properties Inspector.
06:43So when Fireworks exports a SWF file, and you then import that into Flash,
06:49what Flash has done when it translated that, is it's taken all the text blocks and grouped them.
06:54So each text block is now in its own group.
06:57I can still go back and edit the text, I just first need to double-click on it to get access to the group, and then I can edit my text within there.
07:06Let's go back to scene one and see how it did with Vector Graphics.
07:10If I click on the Vector Graphic underneath it on the stage, I can see in the Properties Inspector it's a group, and if I double-click on that,
07:18and then select a graphic, I can see that it's still a Vector Graphic here inside of Flash.
07:23This is much the same way that Flash treated a Fireworks native PNG file.
07:27So as you can see, exporting a SWF file from Fireworks, and then importing that into Flash also yields really great results.
07:35The only thing that has happened when exporting a SWF file and then importing that into Flash, is that its added the extra step,
07:41its taken the text blocks and putting them into groups.
07:44Obviously if I wanted to continue working with those here inside of Flash, all I'd have to do is select those text blocks,
07:51and then I could ungroup those by choosing "Modify," "Ungroup."
07:55Now that those are ungrouped I have access directly to the individual text options here inside the Properties Inspector
08:02without having to go into a group.
08:04So again, working with Fireworks and integrating that content with Flash, as you've seen, does really well.
08:11The Fireworks native PNG file translates perfectly inside of Flash, as does exporting a SWF file from Fireworks too.
08:18Again, your mileage may vary depending on the complexity of the graphics that you create inside of Fireworks.
08:24I can't guarantee that some of the things, and especially the more complex things that you build inside of Fireworks,
08:30will translate over exactly into Flash, as you've seen here.
08:34But again, the results are very promising when integrating Fireworks and Flash content.
Collapse this transcript
Integrating Freehand content
00:01>>Next let's take a look and see how Freehand integrates with Flash content.
00:06Again in Flash, go ahead and create a new Flash document, change the dimensions to 600 pixels wide,
00:12and then choose "File Import," again on your desktop in the LA Eyeworks
00:18folder. In the "File Types" folder is a folder called "Freehand," go ahead and open up that folder.
00:25Within there is a file called "Main Menu," and it's a SWF file that's been exported from Freehand.
00:31Go ahead and double-click on that file to import it into Flash.
00:35Then if you scroll to the top of your stage, you can see that there's the main menu, created in Freehand and then brought into Flash here.
00:42If I click on one of the Main Menu options, such as "About Us," I can see that it has been inserted into a group.
00:49If I double-click on that to open up the group, and then select that text field in the stage, and look in the "Properties Inspector" I can see
00:57that it actually is using the font that I choose - Bistream Vera Sans.
01:01However it didn't carry over the type of Bitstream Vera Sans that I wanted, which was Bold Oblique.
01:07However, at least the text is still editable once brought into Flash.
01:11I'm gonna go back to scene one and see how it translated to Vector Graphics.
01:16I'm gonna select that green bar in the background, and in the Properties Inspector I can that it's a group.
01:22If I double-click on that group to open it and then click on that green bar again, I can see that it is still a Vector object.
01:28And if I chose I could always go back in here and make any changes to that Vector graphic that I wanted.
01:34So a swift file exported from Freehand does translate over the text and the Vector objects so that I can still edit them inside of Flash.
01:43The only slight problem with exporting a SWF from Freehand, and then importing that into Flash,
01:48is that the text didn't translate over quite exactly as it was originally created.
01:53All I had to do was go back there and specify that the text was using Bitstream Vera Sans Bold Oblique.
02:00And it didn't translate over the Bold Oblique, but it's still using the same font that I chose when I created it in Freehand originally.
Collapse this transcript
Integrating Illustrator content
00:01>>Now that you've seen how other Macromedia applications fare when importing those graphics into Flash, and they've done rather well,
00:09let's see how Adobe created graphics fare when being imported into Flash as well.
00:15Let's start with Illustrator.
00:17So go ahead and create in Flash a new document, change the stage size to 600 pixels wide, and then choose "Import."
00:26Navigate again to your desktop, into your "LA Eyeworks" folder, into the "File Types" folder, and then in there into the "Illustrator" folder.
00:35There are a series of files in there that have all been created with Adobe Illustrator.
00:39There's a plain Adobe Illustrator document, an EPS, a PDF, and a SWF file.
00:45Let's see how those different file types fare when being imported into Flash.
00:50First let's start with the actual Adobe Illustrator document itself.
00:54Again, the icons that you see here in my Import window, may differ from the icons you see in your window depending upon
01:00if you have those particular programs installed on your computer or not.
01:04Regardless, select and then double-click on the "Main Menu AI" file, again this is inside of the "Illustrator" folder.
01:13In the "Import Options" dialog box, it gives us a few options.
01:18The first set is to "Convert Pages To" and then we can choose either "Scenes" or "Key Frames."
01:23If we had other pages in our Illustrator document, we could have those when imported into Flash, be placed in "Scenes" or "Key Frames."
01:31Now I'm only using one page in this Illustrator document, but for now go ahead and choose "Key Frames."
01:37The next options is to "Convert Layers To," "Layers inside of the Flash file,"
01:42"Layers in the Illustrator file into Key Frames in Flash," or just to "Flatten it."
01:47Go ahead and leave the "layers" in the Illustrator document set to be converted into "layers" here inside of the Flash document.
01:55If I had multiple pages I could also choose all of the pages, or just to import at range of pages
02:02from the Illustrator document into my Flash document.
02:06For now just go ahead and leave it set to "All."
02:07Again, there's only one page in this Illustrator document that we're importing anyway.
02:13Under "Options" there's still a few more things to choose from.
02:16I can have it include or not, invisible layers.
02:19I can have it maintain text blocks, or if I just wanted to make it look just like it did
02:25in Illustrator, I could choose to have it "rasterize everything."
02:29And then once I selected that option, I could choose a resolution for it to "rasterize those graphics at."
02:35In this case, again, I want to test to see how documents created inside of Illustrator, when brought into Flash, retained their editability.
02:43So can I edit the text, can I edit the graphics, and so forth, after I've imported them into my Flash document.
02:49So I'm gonna make sure that "rasterize everything" is not checked.
02:52I don't want to include any invisible layers, so I'm gonna go ahead and uncheck that option.
02:56But I do want to maintain text blocks, so make sure that that option is checked.
03:01Once you've specified all that go ahead and click "OK."
03:05Now I can see that it's having trouble converting the font that I picked inside
03:08of the Illustrator document, to the Flash document here, as it's importing it.
03:14So I'm gonna choose, "Choose Substitute."
03:17I can see that what it's having problems with is the Bitstream Vera Sans Bold Oblique font. Flash isn't understanding what to do with that.
03:25If I click on that option, I could then choose which font to substitute it with.
03:30I'm just gonna choose from this list "substitute it with," instead of the default system font, "Bitstream Vera Sans".
03:38So I'm gonna scroll in my font list until I find Bitstream Vera Sans and then I'm click "OK."
03:44Now if I scroll up, I can see that what it's actually done is it's still gotten a little confused with the text
03:50in my main menu, here once it's been imported into Flash.
03:54So as you can see, it didn't quite like the base Illustrator, the Adobe Illustrator document, after it's been imported into Flash.
04:02It didn't translate it over quite exactly like I had hoped.
04:05Let's take a look at one of the other formats that have been exported from Illustrator.
04:09I'm gonna go ahead and close this FLA file, not save any changes, and repeat that same process over again.
04:15Create a new FLA, change its dimensions to 600 pixels wide, and then choose "File Import."
04:22And this time again, in the same Illustrator directory, I'm gonna import the EPS file that's been exported from Illustrator.
04:29Let's see how that fares.
04:32I get the same import options dialog box. My options should be still set to what they were previously.
04:38The important thing is to make sure that it included visible layers, as well as "rasterize everything" are unchecked,
04:44and that "maintain text blocks" is checked, and then go ahead and click "OK."
04:50Again, I get the same missing font warning dialog box that appears.
04:53I'm gonna do the same thing as before and choose the button "Choose Substitute."
04:58This time I can see that it's automatically set it to be mapped to Bitstream Vera Sans, I'm gonna leave it set to that and click "OK."
05:06Then if I scroll up, I can see that it's done a little bit better with translating the text over, I don't see a bunch of gibberish up there.
05:12But let's see if that text is still editable.
05:15I'm gonna click on the "About Us" option, and I can see that what it's done is that is all one giant text block.
05:21It's put them all together into one text field, instead of separating them into their own separate fields.
05:27It's still editable, if I double-click on it, you can see that I can get in there and edit.
05:32And again, it's actually translated it over to the correct font face, Bitstream Vera Sans, but I can also see here inside my font pull down menu,
05:40that's having a little difficulty mapping it to the correct font.
05:43So if I were working in Illustrator and had exported an EPS file from Illustrator, and then brought it here inside of Flash,
05:51I would want to make sure to select my text, and from the font pull down menu, make sure to choose the correct Bitstream Vera Sans.
05:58That way I'm mapping it to the correct font that I have installed on this particular system.
06:03Beyond that I can also see that it's done some stuff with the color.
06:06This now looks like an 80's florescent green color that it sort of translated everything to.
06:11So not only has it taken my text, which was in separate text blocks, and put them all inside of one text field,
06:18but it's also messed with the colors that I've also assigned to the well.
06:22Let's see what it's done to the Vector Graphics, if I select that green bar in the background I can see that it's inside of a group,
06:30but if I double-click on it, do I still get access to the actual Vector outlines of this graphic?
06:35And as I can see by selecting it, I do.
06:37So Vector Graphics, exported from Adobe Illustrator as an EPS file, translate over correctly.
06:43Now again, it's actually changed the color and the text is been converted into one giant text block, but again at least it's still editable.
06:52So it's not optimal by any means, but a lot of the content that was inside
06:56of the Illustrator document, after being imported into Flash, is still editable.
07:01So if I had some extra time I could still go back and work with this document, I could change the colors,
07:07and take the text and put them in their own text fields.
07:10So all is not lost with an EPS file exported from Illustrator.
07:15Let's take a look at some of the other formats, again, go ahead and close this FLA, don't save any changes, and open up a new FLA.
07:23Change the dimensions to 600 pixels wide, and then choose "File Import" again.
07:29This time let's import a PDF file that has been exported from Adobe Illustrator.
07:33Select that PDF file, and double-click on it to import it.
07:37Again you get the same options.
07:39I'm gonna leave all the options set to what they were previously, and then click "OK."
07:43The same missing font warning dialog box appears, so I'm gonna choose "Choose Substitute."
07:49Make sure that the Bitstream Vera Sans Bold Oblique font is being mapped
07:53to the Bitstream Vera Sans font installed on my computer, and then click "OK."
07:59Then if I scroll up in my stage I can see that unfortunately I'm getting the same results that I did
08:04when I tried to import the base Adobe Illustrator document.
08:07Not only that, but I can see again my colors have been shifted, this time I can see the greens are more desaturated than what they were
08:14when they were originally created inside of the Adobe Illustrator document.
08:17So unfortunately it looks like in this case, the Adobe Illustrator document, exported as a PDF file,
08:23and then imported into Flash, didn't yield very good results.
08:26I'm gonna go ahead and close this FLA, not save any changes, and let's take a look at the last file format that has been exported from Illustrator.
08:36Again go ahead and create a new FLA, change the dimensions, and then import in that same Illustrator folder, a SWF file exported from Illustrator.
08:46Go ahead and double-click on the "Main Menu_SWF" file to import that into Flash.
08:52This time because it's a SWF file, I'm not given any options, or any problems that talk about matching up the font used.
08:58If I scroll to the top of my stage, I can see that there's all my text.
09:03If I click on the "About Us" text, I can see that it's by itself, it hasn't been stuck in a big text field
09:09like it was with the EPS that's been exported from Illustrator.
09:13If I double-click on that group, and then click on that text again, I can see that in the "Properties Inspector" I do have access to the text itself.
09:23But again, it's still mapping it to a system font that isn't quite correct, so I'd want to make sure that I click on that font pull
09:29down menu, and set it to the correct Bitstream Vera Sans.
09:33It also didn't translate over quite exactly how I had it set, which was bold and oblique.
09:39So I'd want to make sure if I was trying to work with a SWF file exported from Illustrator here inside my Flash document,
09:46that I also set the bold oblique, like I had it set inside of the Illustrator document originally.
09:52But the good news is that the text is still editable, and it's in it's own text block.
09:57Again, it hasn't been merged with all the other text inside my file.
10:01Let's take a look and see how it translated to Vector Shapes.
10:04So go back to scene one and click on the green bar in the background.
10:08I can see that it's been inserted, not into a group this time, but inside of a graphics symbol that it's automatically called "Symbol One."
10:15I'm gonna double-click on that symbol to open it up, and then I can see what it's done here, is it's actually created a few different layers.
10:22One layer is a mask, and that it's masking another layer.
10:26Go ahead and lock the top most mask layer for now, and hide it so that you can see what's behind it, the layer that it's masking.
10:34The layer that it's masking is our green bar, but it is in its own group.
10:40If I double-click on that again, and then click on that shape on the stage,
10:43I can see that there is the base Vector Object, and yes, I can still go back and edit it.
10:48So its done some funny things with creating a mask layer, and the Vector shape that we want to get access to is in another masked layer,
10:57but that Vector shape is still there, and I can still take it, cut it out of there, and paste it wherever I needed it,
11:02should I want it then integrate that content into my Flash site.
11:06So we're gonna go ahead and go back to scene one now.
11:08So SWF files, exported from Illustrator, do a fairly decent job at retaining the editability of both the text and the Vector shapes.
11:17Again, it does a few strange things with Vector shapes, and the text doesn't translate over perfectly,
11:23but it is still workable with a little extra work, I could always go back in here
11:27and make it so that I could use it precisely as I intended here inside of Flash.
11:32As you've seen in this video, Adobe Illustrator documents, both the EPS and the SWF file, translate over decently well into Flash.
11:41The Adobe Illustrator document itself, as well as the PDF fared not as well.
Collapse this transcript
Integrating Photoshop content
00:01>>Next, let's take a look at how Adobe Photoshop documents integrate with Flash.
00:05Go ahead and create a new FLA,
00:08change the stage size to 600 pixels wide, and then choose "File Import."
00:14On your desktop navigate to the "LA Eyeworks" directory, into the "File Types" directory, into the "Photoshop" directory,
00:23and in there you'll see a Photoshop document called "Main Menu_PSD."
00:28This is actually a Photoshop document saved out from Photoshop.
00:33Go ahead and double-click on that file to have it be imported into Flash.
00:37Now if you see an error dialog box appear telling you there was an error importing the file,
00:42chances are you don't have QuickTime installed in your computer.
00:45When Flash goes to import a file format that it doesn't understand, it relies on QuickTime to translate that file as it goes to import it.
00:54So if you don't have QuickTime installed, and you would like to be able to import Photoshop documents and other files that Flash doesn't support,
01:02into Flash itself, make sure that you download it and install QuickTime, so that you can then import and utilize those files.
01:11Let's take a look and see what's happened to the Photoshop document that's been imported into Flash.
01:16If I scroll around on my stage, I can see that it all looks pretty good.
01:20But by looking at the outline that's around this graphic I can tell that what's happened is that when Flash has imported this document,
01:27it's actually taken the layered bitmap document that was created inside of Photoshop,
01:31and flattened it into a flat bitmap graphic and stuck it on the stage here inside of Flash.
01:37Inside of my library I can see that there is my bitmap graphic, and it's just a single bitmap graphic, because it's been flattened.
01:44So while it looks great, there's absolutely nothing I can do with it here inside of Flash.
01:48I can't edit the text. I can't edit the graphics, or anything like that.
01:52It looks good, but it's untouchable, and unworkable here inside of Flash.
01:56So if you want to be able to take your documents from Photoshop and bring them into Flash where you can edit it, I'm afraid you're out of luck.
02:04However, in the next exercise you're gonna see how you can take a bitmap document, like this Photoshop document, from Image Ready and export it
02:13as a SWF file, and we'll see what the results are there.
02:16However, if you're set on importing and integrating Photoshop documents, and Photoshop content into your Flash work, which can be really important,
02:24those are two major graphics programs - Adobe Photoshop and Macromedia Flash.
02:29There are a whole slew of techniques and tricks to be able to integrate those two pieces of content.
02:34If you open up your default web browser, and then navigate to "MovieLibrary.Lynda.com" and then click on the "Browse All Titles" link,
02:46and then scroll down to the "Adobe Photoshop" section, you'll see a title there called "Photoshop and Flash Integration," by Michael Ninness.
02:56If you select that title, this is a whole movie library title that covers integrating Photoshop documents and Flash together.
03:04And there's all sorts of tips, and techniques, and tricks to integrating those two different formats.
03:09So if you're really keen and interested on integrating Photoshop and Flash together,
03:14make sure you check out this title before throwing up your hands and giving up completely.
03:18In the next exercise, we're gonna look, however, at taking a file that has been opened in Image Ready and exported as a SWF file,
03:25again from Image Ready, and then see how that works when imported into Flash.
Collapse this transcript
Integrating a SWF exported from ImageReady
00:01>> Lastly, let's take a look at how an image opened up in Adobe Image Ready and then exported as SWF file fares when being imported here into Flash.
00:11Go ahead and create a new blank FLA, change the stage size to six hundred pixels wide, and then choose file import.
00:20Again on your desktop in the LA Eyeworks folder, in the file types folder, is another folder called Image Ready.
00:29Inside of that folder is a SWF file called "Main Menu IR".
00:33Again this is just an image created inside of Photoshop, and then opened in Image Ready, and exported as a SWF file.
00:42Go ahead and double-click on that file to import it into Flash.
00:45When you do, if you scroll around your stage you'll notice that it looks pretty good.
00:50If you click on the text up at the top, such as "About us" and look in the Properties Inspector,
00:55you'll notice that it's a graphic symbol called "symbol five".
00:58And you can see inside your library that a whole bunch of symbols have been created for you.
01:04Go ahead and double-click on that symbol on the stage to open it up, and then click on the text block to select it.
01:10In the Properties Inspector, I can see that it's using the correct font that I chose - Bitstream Vera Sans.
01:16It's even selected full bold for me.
01:18Now in Windows, if I wanted to then utilize this in my Flash project, I would also want to make sure that I set it
01:24to be full italic as well, just like it is in the original layout.
01:28On the Macintosh, you could just choose from your font pull down menu, Bitstream Vera Sans Bold Oblique.
01:34But on Windows because it organizes fonts differently,
01:37you want to make sure that you select Bitstream Vera Sans, and then check the full bold and italic buttons.
01:43But I can see that the text is still editable.
01:46I can double-click on it, I can make any changes to it if I'd like.
01:50So the text from a SWF file that was exported from Image Ready is editable.
01:56Let's see how its treated the vector graphics. Go ahead and go back to scene one and then click once in the green bar that's in the background.
02:04I can see that it, like the text, has been automatically inserted into a symbol called symbol two.
02:10I'm going to double-click on that graphic symbol to open it, and then I'm going to click once on that green bar on the stage.
02:16I can see that its done a little strange things here with the negative space of that green bar.
02:22In other words, where that green is not, it looks like its changed it into a transparent area of the graphic instead of just leaving it alone.
02:30So the vector graphic is still vector, I can go in there and edit it if I chose, but there are a few gremlins with how its translated
02:38that vector graphic over when imported it into Flash.
02:42So all in all, the translation going from Image Ready, exporting it as a SWF file, and then importing that into Flash is not bad.
02:51The text is still editable, so are the vector graphics.
02:55But the text translates over about ninety percent varied.
02:58You might need to make a few minor adjustments to the text and the vector graphics as well.
03:03Has translate them over almost all the way, but again, there's a few small things that's it's done with the vector graphics as you can see.
03:10So going from Photoshop and opening that document in Image Ready and exporting it as a SWF file,
03:16is actually a fairly decent way to go if you are working with Photoshop documents.
03:20Again, the results that you end up with might be a little different than what has been shown here depending upon the types of graphics and the types
03:27of things that you used inside of your Photoshop document when you originally created it.
03:31
Collapse this transcript
3. Getting Started
What are classes, objects, methods and properties?
00:01>> Beginning in this chapter, you're gonna start writing some pretty complex action scripts.
00:06You're gonna start writing what's called the movie clip loader object, which allows you to load SWF and JPG files into your Flash projects.
00:16So before you get too in-depth with some of this heavy duty action script,
00:20it's important that you understand the basic concepts and terminology behind some of these actions.
00:26So before we get going, I'd like to talk a little bit about the basics behind what are classes, objects, methods, and properties.
00:35Classes are really the blueprint that defines a grouping of objects.
00:40For example, if we're referring to a dog, a dog falls under the class of animals.
00:47Animals is a class that really defines a grouping of objects, in this case of a dog.
00:52In Macromedia Flash, movie clips and buttons are also classes.
00:57Both movie clips and buttons have methods and properties that define how those objects behave.
01:04A dog being under the class of animals, also has methods and properties that define how that dog behaves.
01:12So a class is really kind of a grouping of objects.
01:16An object is essentially an instance of a class.
01:21So if you have the class of movie clips, and you take a movie clip and place it on the stage,
01:28that movie clip on the stage is an instance of the movie clip class.
01:33So that instance of that movie clip is actually considered to be an object.
01:38Again, if you take an object like a dog, a dog has properties and methods that define it as a dog.
01:45Objects learn how to behave, they get their properties and their methods that they inherit from the class.
01:52So a class defines the general blueprint, the rules for how an object should behave.
01:59Methods are the behaviors of an object.
02:02For instance, if you take the behavior of a dog, a dog barks and pants and slobbers, and pees all over your furniture for instance.
02:11That is the behavior of a dog, that is the dog's method.
02:15If you apply that to Flash, the neat thing about methods is that you can actually add your own methods to your objects.
02:23Going back to the movie clip object again, a movie clip has built in methods such as "Play", "Stop", "Next frame", and so forth.
02:32So objects, like movie clips and buttons, have behaviors that define them as objects.
02:38Again, those behaviors are called methods.
02:41Lastly, properties are attributes that define an object.
02:46For instance, a dog has legs, eyes, a tail, a mouth, and bad breath.
02:53Those are the properties, the attributes that define in this case the object of a dog.
03:00Going back to the movie clip analogy again, movie clips have properties such as its visibility, its alpha, its rotation,
03:08etcetera. So classes are really the blueprint that defines how objects behave.
03:15An object is an instance of a class.
03:18So if I have the movie clip class, and I take a movie clip and I place an instance of it on my stage, that movie clip becomes an object.
03:27The way that movie clip behaves is the movie clip's methods.
03:32It has built-in methods such as "Play", "Stop", "Next frame", etcetera, and you can even add your own methods to them.
03:39And lastly, properties are attributes that define those objects.
03:44So for a movie clip, its visibility, its rotation, its alpha and so forth define the movie clip object.
03:51So those are the basic concepts behind some of the action scripts
03:55that you're gonna be using throughout the remainder of the movies in these tutorials.
03:59So now when I refer to the movie clip loader class, or for instance the myMCL object, you know exactly what it is that I'm referring to.
04:08And again, if this doesn't make sense initially to you, don't worry too much about it because you're gonna be dealing a lot with classes, objects,
04:16methods, and properties throughout the remainder of these movies in these tutorials.
Collapse this transcript
What are variables?
00:01>> By this point you should have a good understanding of what symbols are.
00:05Symbols are of course containers to hold visual information, be that a bitmap graphic,
00:11a graphic that you've drawn inside of Flash, some text, and so forth.
00:15Now there's another way to create a container that holds data instead of visual images like symbols do.
00:23That other type of container is called a "variable".
00:26As you're working with action script, as you'll see throughout the rest of this title, there are many occasions in which you'd want to be able
00:32to store some data, be that a string of text, some numbers, and so forth for later use and other actions that you're building inside of Flash.
00:41A variable, like a symbol, allows you to store information.
00:45It just allows you to store data instead of visual information like a symbol does.
00:50To give you a quick tour of how a variable is created, and how you can utilize that in Flash, go ahead and create a new empty Flash document.
00:59Then select the very first key frame, and open up your "actions" panel.
01:04An easy way to do that on Windows is to press "F9", on Macintosh you can press "Option" "F9" to open up this actions panel.
01:12Then click inside the actions panel inside the script pane, and first type "var", space, "myVar".
01:21Now "var" defines that as a local variable.
01:24After that you type a space, and then the name that you want to give your variable, the name of the container that's going to hold your information.
01:32Again, this name, much like when you create a symbol and you store that symbol in the library, can be whatever name you want.
01:39Except you want to make sure that you don't put spaces in the name, and no other characters such as exclamation points, an ampersand, and so forth.
01:48It's best if you keep it all one word.
01:50In this case because I essentially have two words in this name, myVar, I capitalize the first letter of the second word
01:59so that you can clearly see where that second word starts.
02:02Now Flash, since Flash MX 2004 and Action Script 2.0 is case sensitive.
02:08So you want to make sure that if you're using upper and lower case, the next time that you refer to that particular action or variable
02:16or function wherever you created this name at, that you also get the capitalization correct.
02:21And again, I'll repeat that as we go through these exercises in this training title.
02:26Now at the end I can insert a semicolon to end that action, as you've probably seen before.
02:32Now what this action does here is it just creates the variable.
02:35So I have essentially an empty container called "myVar".
02:40I can put something inside that container by simply clicking after the name and before the semicolon, and then just type A equals sign,
02:49and then whatever you want to place inside of that variable container.
02:53For example, if I wanted to insert some numbers inside of that variable container, I could just say 1, 2, 3.
02:59Now I'm inserting those numbers inside of that container, so it's storing that information for me.
03:06I can also have that variable container hold a string of text.
03:10When you're working with strings of text, you also want to make sure that you place those within quotation marks.
03:16So I'm gonna type quote, and then maybe I want to store the name Shane inside of that variable container.
03:22So I type "Shane", end quote, like so.
03:26You might also see variables defined with spaces before and after the equals sign.
03:32Either way it works just fine.
03:33Now I can use another action called the "trace function" that will allow me to see what I've stored inside of that variable.
03:41What the trace function does is it essentially executes an action, but instead of it actually utilizing that action,
03:48it just displays the output in another window called the "output panel."
03:53To do that I'm gonna click after the semicolon, press return or enter to create a line break, and then simply type "trace", open parenthesis.
04:02And then the name of the variable that I want to find out what the value of it is, in other words, what's inside of the variable.
04:09So I type "myVar", again making sure that I have the capitalization correct.
04:14And then I'll type in end parenthesis, and a semicolon to end that action.
04:19In Flash, whenever you first create the variable, any other time that you use the name of that variable, in this case myVar,
04:27throughout any other actions that you're working with, instead of Flash just putting myVar there when it executes those actions,
04:34what it actually does whenever it sees that variable name is it takes whatever's inside
04:40of that variable container and it inserts it there in its place.
04:44So whenever you use that variable again, you can somewhat think of you just inserting instead of the variable name whatever is inside of it.
04:53If I test my movie now, in my output window you can see that it spit out the name Shane, and that is what I put inside of that variable container.
05:03So that is the basics of both creating and utilizing a variable here inside of Flash.
05:09Again, if it seems a little confusing to you at first, don't worry because you're gonna be utilizing a lot
05:14of variables throughout the remainder of the exercises in this title.
05:17In the next exercise, you're gonna learn how to strict type a variable, which allows you to clearly define the type
05:24of data that is going to be stored inside of a variable.
05:27And you'll learn the hows and whys of that in the next exercise.
Collapse this transcript
What is Strict typing?
00:01>> Another good habit to get into when creating variables and authoring action script inside of Flash is the use of something called strict typing.
00:11This is also sometimes called strong typing.
00:13And what it is, is that essentially allows you to clearly define the type of data that is going to be stored inside of a variable,
00:22or the sort of data type that's being assigned to an object.
00:25For example, in the last excise you saw how we quickly created a variable called "myVar" and inserted into that variable a string of text.
00:35In this case the string of text "Shane."
00:38Now when Flash goes to execute this action script, it doesn't know what type of information is being stored inside of the variable called "myVar."
00:47And it tries to figure it out by looking to see what is inside of that variable called the value of the variable.
00:54In Flash, there may be many occasions when you create a variable specific to hold a number or specifically to hold a string of text.
01:02And as you're working with those actions you want to ensure that only that specific type of data is to be stored in that variable.
01:10You can do that with this strict typing.
01:13So let's take a quick look at how you can assign strict typing, in this case to a variable.
01:18To do that, simply click after your variable name. So I'm going to click after "myVar."
01:23And then type a colon, and then when you do that you can see this code hinting pop-up.
01:29And it's showing me all the different types of data types that I can assign to this particular variable name.
01:35Since this variable is holding a string of text and I want to make sure that only strings
01:40of text can be inserted into this variable, I'm going start typing string.
01:45S-T, and as I type it you can see that it's actually highlighting string from the list of data types that I can choose from.
01:52If it's highlighting the one I want I can either continue to type out string, or I can simply press "return" or "enter"
01:59and Flash will automatically fill in the rest of that for me.
02:02Now what that does is it strict types this variable so that it can only hold a string of data.
02:10If I tried to insert a number in here instead of that string of text, for example the number one,
02:17and if I then test my movie, Flash is going to give me an error.
02:21It's says, "Hey I found a number where you said a string is supposed to be."
02:26So strict typing allows me to make sure that only specific types of data can be assigned to, in this case a variable.
02:34Obviously I'm going to go ahead and change this back to a string of text "Shane."
02:39Now when I test my movie everything's fine, I don't get any kind of errors because I am actually storing a string of text inside of a variable
02:47that I've used strict typing to tell Flash that only strings of text can be stored there.
02:52You can also assigned strict typing to parameters.
02:55As you'll see later, and I'll just go over it here really quickly, if I'm creating a function,
03:00and I'm going to call that function say, "My function."
03:05If I assign a parameter to that function, I'll call this my parameter, I can actually use strict typing
03:13to tell Flash what kind of data type that parameter's going to be.
03:17For example, if I was passing some number information to this particular function as a parameter,
03:23I could then use strict typing to assign the number data type to that parameter.
03:30Like so. So strict typing can be assigned to variables as you've just seen.
03:34It can also be assigned to parameters of functions as another example of how you can use strict typing as well.
03:41Now strict typing is somewhat optional.
03:44If you do not use strict typing, your action script will still work correctly.
03:48All strict typing allows you to do is to ensure that you know exactly what kind of data types for example, are being assigned to your variables
03:56and to function parameters also as you've seen here.
03:59So even though it is optional, I would recommend as you're going to see throughout the remainder
04:04of the videos in this title, that we do use strict typing.
04:071
Collapse this transcript
What is a function?
00:01>> Throughout this title you're also gonna be making liberal use of something called a function.
00:07Now as you've seen with both variables and symbols that hold stuff, variables hold data, symbols hold graphics essentially,
00:15functions is also another type of container, except functions in essence hold actions.
00:22A function allows you to store actions that you can trigger at any point that you'd like.
00:28One of the nice things about functions is that you can take a whole block of action script, place them inside of a function,
00:35and then you call that function, which then performs all the actions within it at any point that you'd like.
00:42It also enables you to take a block of action script and reuse it as many times as you'd like.
00:48For example, this is useful if you have a series of buttons, like a main menu for your website for example,
00:54and you want to have similar things be performed each time the viewer clicks on a button.
00:59Maybe a sound is played, an animation is performed, and so forth.
01:03Now traditionally you might have added the same action script to each of the buttons.
01:08So whenever you want to make a change to what is performed when the viewer clicks on one of those buttons, you would have to make that change
01:15for as many buttons that you have, because you again have the same actions assigned to each button.
01:21What a function used in that case would allow you to do would be to write your action script once, and then when the viewer clicks on that button,
01:28or interacts with that button, you could have it just trigger that one function, and then all the actions within it would be executed.
01:35In essence however, a function is just a container to hold other action script.
01:39Let's take a look at that using the same examples that we've been working with in the previous videos real quick.
01:45As you've seen in some of the previous exercises in this chapter, here we have a variable called "myVar."
01:51It's been strict to the data type of string, and within that we've inserted the string of text "Shane."
01:57And then we run a trace function to have Flash output in the output window whatever the value of that "myVar" variable is, which is just "Shane".
02:08Now when I preview my movie, those actions are executed immediately.
02:14Let's however take those two actions and place them inside of a function.
02:18I'm gonna go ahead and close these windows, then I'm gonna click before the very first action, press "return" or "enter" to create a line break.
02:26And then on the first line I'm gonna type "function", and again there are a few ways of creating a function, this is one of them.
02:34Space, and then the name I want to give this function.
02:37I'm just gonna keep it simple and call it "myFunction", all one word with a capital "F" in function.
02:43And then I'm gonna type an open parenthesis, and end parenthesis, a space, and then an open curly brace.
02:51The curly brace on your keyboard is if you hold down the shift key, it's the key right to the right of the "P" key.
02:59There's also a bracket on that same key as well.
03:02Now that open curly brace marks the beginning of the function.
03:07You also need to mark where the end of the function is, so click after the trace action, right after that semicolon,
03:15press "return" or "enter" to create one more line break, and then type a close curly brace.
03:20It's the key to the right of the open curly brace, and you have to hold down your shift key when you press it to get that curly brace.
03:27Now actions within functions need to be indented one.
03:32If you allow Flash to automatically format your action script, it will do exactly what I just mentioned.
03:38You can do that by clicking on this "auto format" button at the top of the actions panel.
03:43And you can see that Flash will automatically indent by one tab space the actions within your function.
03:50I personally prefer to do that myself rather than let the auto format function do it for me.
03:55So now these two actions are enclosed within a container function called "myFunction."
04:01If I were to test my movie now, notice that nothing happens.
04:05Before we had the output window open up, and it said in it "Shane", because it was executing these actions.
04:11Well functions are not automatically executed until you call their name.
04:17Let's take a look at that.
04:19Click at the very last line break if you use the auto format feature, or click after the last close curly brace of that "myFunction" function,
04:28and press "return" or "enter" so you have an additional line break underneath it.
04:32Then to have that function be executed, simply type its name, "myFunction".
04:39Make sure you also type an open parenthesis and end parenthesis and a semicolon after it to end that function call.
04:46Now just by saying its name means that this function will be executed when the movie first loads.
04:52So now if I test my movie, notice how now in the output window again I see "Shane", cause those actions within that function is being executed now.
05:02That's just one simple use and example of working with and creating a function inside of Flash.
05:07Again, if that doesn't make absolute sense to you, don't worry about it because we're gonna be using lots
05:11of functions throughout the remainder of the exercises in this title.
05:15One other thing that I want to point out about functions is that you can also assign,
05:20as I briefly mentioned in a previous exercise, parameters to functions.
05:24Now parameters are essentially variables contained within a function.
05:30It allows me to be able to pass information to the function to be utilized within the actions in that function any way I choose.
05:38For example, I'm gonna go ahead and quickly create a button on the stage.
05:43So I'm gonna hide my actions panel for a moment, create a new layer, I'm gonna drag it underneath layer one, and then I'm just gonna go ahead
05:50and quickly select my Rectangle tool, I'm gonna pick a different fill color, and I'm just gonna draw a box on my stage.
05:57This is gonna be my sample button.
05:59Then with my Selection tool selected, I'm gonna click and drag around that entire object.
06:05And then I'm gonna press "F8" to convert that into a symbol.
06:08I'm just gonna go ahead and give it a type of button symbol. I don't need to give it a name right now, and then click "OK".
06:15So that is now a button symbol.
06:17Now if I want my Function that I created in the first key frame of layer one called "myFunction" to be executed when the viewer clicks on this button.
06:26I'm gonna make sure that I have that button selected, and then I'm gonna open up the actions panel.
06:31In the script pane of the actions panel I'm gonna type on open parenthesis, release, then type a close parenthesis, space,
06:43open curly brace, a couple of line breaks, and a close curly brace.
06:48Then click in that empty line break in between the open and close curly braces, and then type the name of the function that you want to be executed
06:57when the viewer clicks on this particular button on the stage.
07:00Again, the name of that function is called "myFunction".
07:03If you want to make sure that you get the spelling and capitalization correct, you can simply select the key frame
07:08that has your action script assigned to it, select the name of that function, in this case we're already called it before so I'm gonna select
07:16that action, control click or right click on that and choose "copy".
07:20And then I'm gonna go back and select that button on the stage back in my actions panel in the empty line break after on release,
07:29I'm gonna click there, right click or control click and choose "paste".
07:33So when the viewer clicks on this button it's gonna execute "myFunction".
07:38Now so that this function is only executed when the viewer clicks on it, I also want to make sure that back here in the first key frame of layer one
07:46that I remove the "myFunction" call where it's automatically executed when the movie first loads.
07:52So I'm gonna go ahead and delete that last action.
07:56So now if I test my movie, notice that nothing immediately appears,
08:01but if I click on this button it's gonna pop open the output window with the variable value of "Shane" inserted into it.
08:08So you can see that this function here on the first key frame of layer one that we created inside
08:13of the "myFunction" function is being executed when the viewer clicks on that button.
08:19Now again, if I utilized a parameter in this case, I could have that button send some information to this function
08:27that could then be utilized in the actions within it.
08:30Now to create a parameter you simply click between the open and close parentheses after the name of the function,
08:37so here again in the first key frame of layer one where it says function "myFunction", open parenthesis, end parenthesis.
08:43Click in between those two parentheses, and then type in the name of the parameter.
08:48And again, this is just like creating a variable.
08:51You can give it whatever name you'd like, just make sure that you stay away from spaces and special characters.
08:56So I'm simply gonna call this "MyParameter."
09:00And because in this example I'm gonna be having this parameter hold a string of text for me,
09:06I'm gonna assign it to the strict type of string by typing a colon string, like so.
09:14And then what I want to do is take the name of my parameter,
09:17and then wherever I want to utilize this parameter I would insert it here in the actions within this function.
09:24So what's gonna happen is when the viewer clicks on the button on the stage,
09:27I'm gonna have it send a bit of text, a string of text to this function.
09:32And then I want that string of text to be utilized within the actions in this function.
09:39So what I'm gonna do is I'm gonna replace the string of text Shane in the "myVar" variable with my parameter called "myParameter".
09:46So I'm gonna select all of "Shane", including the open and close quotation marks, and then type "myParameter".
09:55Again, you can sort of think as a parameter as simply as a placeholder.
09:59It's just almost like a variable.
10:02And then you're going to define the value of that variable, in this case on the button that the viewer's clicking on.
10:08So when I click on the button you're gonna send the value of this "myParameter" value, you're gonna send that value to this function,
10:17and instead of "myParameter" it's gonna have in there whatever value you sent to it,
10:22and that is then gonna be placed wherever you've used that same parameter name throughout your actions.
10:28Back inside of the button that's on the stage, I'm gonna select that button,
10:34go back and open up the actions panel again, and here you can see it says unrelease "myFunction."
10:40Well I want to pass a parameter to that "myFunction" function.
10:44So click in between the open and close parentheses after "myFunction", and here is where you would define what value
10:52of that parameter you want to send to that function.
10:55And then within those parentheses type quote, and then whatever value you want to send to that function parameter.
11:01In this case I'm gonna have it send the string of text "Shane, just like we originally defined inside of the "myVar" variable.
11:09So now when I test my movie, and I click on that button, I'm gonna see in the output window the same results that I did previously.
11:17And you may be thinking well that's a lot of work for the same results, but let me show you where this comes in to be an advantage.
11:23When I close the output window, and then close my preview window, and then on the stage I'm gonna select my button, and I'm gonna make a copy of it
11:31by holding down my "control" and "shift" keys, or on Mac the "option" and "shift" keys, and I'm gonna drag that down.
11:38Then with the copy of the buttons selected, I'm gonna go back and open my actions panel again, and this time in the "myFunction" call I'm gonna change
11:47that string of text to be something else, like lynda.com for example.
11:52Then when I test my movie, and I click on the topmost button, in the output window I get the same results, "Shane".
12:00But when I click on the bottommost button, you can see that in the output window it returns Lynda.com.
12:07Now they're both executing the same function, but the difference between the two is
12:12that each button is passing a different parameter to that function.
12:17In other words, by using parameters, you can have a single function perform and do different things, depending upon the parameters that you pass to it.
12:26Now if you can get your mind around that concept, it's a really powerful feature of working with action script inside of Flash,
12:33and it's one that you'll see being used throughout the other exercises in this video title as well.
12:39So that is the basics of how you can both create and use a function, as well as both create and use parameters within a function.
12:47And again, we're going to be using functions a lot throughout the exercises in this title.
Collapse this transcript
Creating the master .swf and building the MovieClipLoader
00:01>> One of the main focuses of this title is learning how to take an entire website, break it up into individual modules or pieces,
00:10and then load those in, as it's required, into one main master container file.
00:17That one main master Flash file is going to act as the container for all the other pieces of the website to load into.
00:25It's also going to be the container to hold a lot of the action script that is continually re-used throughout these other modules.
00:32That way you minimize the amount of action script that you have to continually rewrite.
00:38This makes it easier on you as you go and need to update that action script at a later time, because instead of having to go
00:45and update all this action script and the various pieces of your website,
00:50you only have to go to one defined location and update your action script once there.
00:55And then, because all these other modules use that same one master script, for example, you only have to update it that one time
01:04and then all those modules will then use that one updated block of action script.
01:09So what you're about to do is to create the master.fla file.
01:14Now, this master.fla file, as I mentioned, is going to act as the container that the other modules of the website load into.
01:22In addition to that, it's going to act as the container to hold reusable action script
01:27that you will use throughout most of these modules in the website.
01:31Inside of Flash, the first step is to create a new blank Flash document.
01:37Then, let's change the stage size so that it fits the size of the website that we've designed.
01:43Open up the document properties.
01:46Again, there are various ways to do that.
01:47One easy way is to use the keyboard shortcut, which is "control" "J" on Windows or "command" "J" on the Macintosh,
01:54and set the dimensions to 600 pixels wide by 400 pixels high.
01:59Then, change the background color of the stage by clicking on the background color swatch and then at the top of the swatch's palette,
02:06let's change the hexadecimal value, which is the pound sign followed by a series of letters and numbers, to "B4CCE5".
02:13That's sort of a desaturated blue color.
02:18Once you type in that hexadecimal value, simply press "return" or "enter" and that will be chosen as the background color of the stage.
02:29Lastly, change the frame rate from 12, which is the default, to 21 frames per second.
02:35Now, because we're also going to want these same settings for the other modules that we create that make up this website, instead of having to go
02:43and reenter in all these same values, the dimensions, the color,
02:46the frame rate and so forth each time you create a new FLA, go ahead and click this button called "Make Default".
02:54When you click that button nothing special happens, but what has just happened behind the scenes is that Flash has taken all of these values
03:02that you specified here in the document properties dialog box and it will now use those as the default every time you create a new FLA file.
03:10That saves you a little bit of work down the line.
03:12And then go ahead and click "OK" to have those document properties applied to the FLA you're currently in.
03:18Next, let's go ahead and save this FLA into the correct location, so choose "File", "Save".
03:25On your desktop earlier, you should have copied the exercise folder called "LA Eyeworks", again, if you have access to the exercise files.
03:35If you don't have access to the exercise files, on your desktop, make sure you create a folder called "LA Eyeworks".
03:42Within that folder, create another folder called "Site".
03:45For those of you that do have access to the exercise files and have copied the "LA Eyeworks" directory onto your desktop,
03:52you should already see a folder in there called "Site".
03:55Go ahead and double-click on that folder to open it up.
03:58As you can see, for those of you that do have access to the exercise files, there are already quite a few provided FLA files as well directories.
04:06However, for right now, just again make sure you're inside that site directory and let's give this FLA a file name of "Master".
04:15On Windows it will automatically enter the .fla for you.
04:19If you're on the Macintosh, you'll probably want to make sure that you type "master.fla".
04:24Then save this FLA into that Site folder.
04:27Now, whenever we publish this master file to create the SWF, it's going to be published in that same directory.
04:33That site directory is going to contain all the files and media that is going to comprise the "LA Eyeworks" website
04:40that you're building throughout this title, so make sure you keep a close eye and keep close tabs on that site directory
04:46as that represents the entire site that you're building.
04:49Next, go ahead and import the bitmap graphic that is going to be in the background of all of the entire website.
04:57So again, still in master.fla, choose ?File?, ?Import?, ?Import the Stage?,
05:04or just simply use the keyboard shortcut ?control? ?R? on Windows or ?command? ?R? on the Macintosh.
05:09And then on your desktop, for those of you that have access to the exercise files, open up "LA Eyeworks", ?Resources?, ?Bitmaps?,
05:19and then in the ?Import? window, choose the file called ?BG?.
05:23This is a JPEG graphic.
05:25Once you've selected that file, go ahead and double-click on it to have Flash import it and place it onto the background.
05:31Now, with that JPEG graphic selected on the stage, in the Properties Inspector, make sure it's set to be at X0Y0, which means that the top left
05:41of this bitmap graphic, there's a line at the top left of the stage.
05:46You'll also notice in the Properties Inspector that the width and the height
05:49of this JPEG graphic are the exact same size that you created for this FLA, 600 by 400.
05:55So that way, this bitmap graphic is the exact same size as the stage and it's aligned correctly with the stage.
06:02Now, because this master.fla file is going to act as the container for all the other modules to load into, this background JPG graphic is going
06:10to be present throughout all the modules in the website, so as each module loads in, you'll still be able to see this JPEG image in the background.
06:19Now for those of you that don't have access to the exercise files, you can leave out this bitmap graphic if you'd like
06:25or you can create one at that looks similar yourself.
06:28And all it is is just a little dark around the edges.
06:32That's it, just to give it a little extra look and feel.
06:35Rename layer 1 to be titled ?BG? and then go ahead and lock that layer.
06:41That's the only thing that's going to be inside that layer.
06:44Then, create a new layer and rename that layer to be titled ?A? for actions.
06:50You can lock that layer as well.
06:52Locking a layer doesn't prevent you from adding action script to key frames in that layer.
06:57It only prevents you from modifying what's on the stage in that layer.
07:01Since this layer, the ?A? layer, the actions layer, is only there to hold actions in key frames
07:07that we assign to it, we can go ahead and keep it locked.
07:11Select the first key frame in the A layer and open up your actions panel by pressing ?F9? on Windows or ?option? ?F9? on Macintosh.
07:20What we want to do now is to create an object called the Movie Clip Loader.
07:25The Movie Clip Loader class itself will allow us to dynamically load in SWFs, JPEGs, PNGs and GIF files.
07:34The ability to load in PNGs and GIFs is new to Flash 8.
07:37The Movie Clip Loader class itself was introduced in Flash MX 2004, but it can only load in SWF files and JPEGs.
07:45But now in Flash 8, you can also load in GIF files as well as PNG files.
07:50And the neat thing about being able to dynamically load PNG files is that you can have PNG files with transparency.
07:56So now you can load in dynamically images and have the transparent parts of those PNG files still be present for your use.
08:03So it allows you to do a lot more dynamically, visually, with your Flash documents.
08:08When creating an object from something like the Movie Clip Loader class, you want to assign it to a name.
08:14That way, as you create the object, it has a unique name that you can refer to it as later.
08:20So if you wanted to tell it to do something, you simply refer to it by the name you give it.
08:25So the first step is to type ?var?, space, ?myMCL?.
08:30And again, make sure that you're in the very first key frame in the A layer since that A layer is going to hold all of our actions for us.
08:38So essentially, this creates a variable called ?MyMCL?.
08:42Let's strict type it so that that variable only holds Movie Clip Loader objects.
08:47So after ?myMCL?, making sure you have the spelling and capitalization correct, type colon, Movie Clip Loader.
08:57Then type space, equals, space, new, space, Movie Clip Loader, making sure to capitalize the ?M? in Movie, the ?C? in Clip and the ?L? in Loader.
09:10And then after that, type in an open parenthesis, an end parenthesis, and then a semi-colon.
09:16What that action does is it creates a new Movie Clip Loader object from the Movie Clip Loader class and it assigns it to a name, ?myMCL?,
09:26which is actually just a variable, and it strict types that name ?myMCL? to the Movie Clip Loader data type.
09:33So essentially all this does, just like if you have a movie clip and you drag an instance of it onto your stage, that's exactly the same thing
09:42that you've done here, just using action script in the Movie Clip Loader class itself.
09:48Now again, this Movie Clip Loader class is going to handle the loading of SWF, JPEGs, PNGs and GIFs that comprise the LA Eyeworks website.
09:57Now, when the Movie Clip Loader begins to download one of those assets, it stops downloading one of those assets,
10:04it's in the process of downloading one of those assets, whenever it does any of that stuff, it's going to be sending out messages
10:11so that we can then listen to those messages to find out what the Movie Clip Loader class is doing,
10:17what this particular object that we gave the name of ?myMCL? to.
10:21What that means is that we can, by listening to that information that this particular Movie Clip Loader class is broadcasting,
10:29we can find out how much of the file that it is downloading has been downloaded up to that point.
10:35That will allow us to create a preloader.
10:37We can also, by listening to when it's finished, tell the preloader when to show itself and when to hide itself and so forth.
10:45So, as this Movie Clip Loader object called ?myMCL? that you just created is working and doing things, it's sending out messages.
10:53We need to create another object that listens to what this Movie Clip Loader object is broadcasting, the messages that it's sending out.
11:01So after the action that you just wrote, type another line break and then type ?var?, space, ?myListener?, colon, object, space, equals, space, new,
11:19space, object, open parenthesis, end parenthesis, semi-colon to end that action.
11:25So what this action does, which is very similar to the first action that you just wrote, is that it creates a variable called ?myListener?.
11:33It assigns that to the object data type and, within that, it inserts a new object.
11:40Now in layman's terms, what that does is it just creates, essentially, an empty container, sort of like,
11:45if you had a movie clip that you dragged onto your stage and there was nothing inside of it.
11:50What we're going to do, though, is tell our Movie Clip Loader object that this listener object that we just created is going to be assigned to listen
11:59to this My MCL Movie Clip Loader object, so it's sort of like creating the ear and then saying, hey,
12:05ear, you're supposed to listen to this thing right here.
12:08So after your new object action that you just wrote, press return or enter a couple of times to create a few empty line breaks.
12:16Then type ?myMCL?, again making sure you have the spelling and capitalization correction, dot add ?listener?,
12:28open parenthesis, and then the name of the listener.
12:30Well the listener you created, the listener object, is called ?myListener:, close parenthesis, semi-colon.
12:38So that action just says hey, this object called ?myListener? is going to listen to what this Movie Clip Loader object called ?myMCL? is doing.
12:47Now, before you go much further, let's save the changes that you've made to this FLA, and the next step you're going to get
12:53into is loading the splash graphic that is going to be displayed when the viewer first comes to your website.
13:00Let's take a look, however, at where that splash graphic is located at.
13:05For a moment, go ahead and hide or minimize Flash 8, and then for those of you that have access to the exercise files, open up the LA Eyeworks directory
13:14on your desktop, then open up the site directory within there.
13:18This is where you saved your master.fla file.
13:21You can see it right here.
13:23In there, amongst the provided FLA and directory and SWF files, you'll see a SWF file called splash.swf.
13:31There's also the splash FLA file that accompanies it.
13:34But for right now, we're just interested in the splash.swf file.
13:38If you double click that splash.swf file to view it in the Flash Player 8, you'll see that it's an animated SWF file that's going
13:46to act as our splash graphic for the LA iWorks website.
13:50What we want to do next is use the Movie Clip Loader object that you just created in master.fla
13:56to load the splash.swf file into that master container.
14:02For those of you that don't have access to the exercise files, feel free to go ahead and create a new FLA and create your splash graphic inside
14:10of that new FLA and export it as a SWF called splash.swf.
14:17Once you've taken a look at the splash.swf file, go ahead and close at that Flash Player 8 window and go back to Flash 8 itself.
14:24So now we know that the master FLA file that you're currently working in, the one that you just created at the beginning of this exercise,
14:32exists in the same directory that the splash.swf file is, the one that we're about to load.
14:37The reason why you want to make sure that you know where that file is located at relative to your master file is because you're
14:44about to instruct the Movie Clip Loader object to load that SWF file in.
14:49Well, you have to know where that SWF file exists so you can tell Flash where it is to be able to load in.
14:54Making sure that you're still in the very first key frame of your A layer in master.fla,
15:00inside of your actions panel, click after the last action you wrote.
15:05Then press Return or Enter a few times to create a couple line breaks.
15:09Let's write the action to load the splash.swf file in using our new Movie Clip Loader object, so type first it's name, ?myMCL?.
15:19We're going to tell that Movie Clip Loader object to do something, so we talk to the name that we assigned to it.
15:25Then type .loadclip and notice, again, as you start to type it, it opens up that little box and highlights what it thinks you're about to type.
15:34If it is highlighting Load Clip, you can just press return or enter and Flash will automatically complete it for you.
15:40After Load Clip, make sure that you've typed an open parenthesis and then, in quotation marks because the file that you want to load is a string
15:49of text, type "splash.swf" Now, if splash.swf existed in another directly,
15:59you would want to make sure that you'd specified the name of the directory here in the file name.
16:04For example, if I had a separate directory called SWFs, I would want to make sure that I specified that here within the quotes.
16:10So before splash.swf I would type SWFs, forward slash.
16:15That forward slash says that that's the directory name to the left of that forward slash
16:19and then after that forward slash is the actual name of the file.
16:23However, again, as I mentioned, because splash.swf exists in the same directory as master, I don't need to specify any sort of directory name.
16:32After the quotation mark, after splash.swf, click there and then type comma, space, and then the number 5.
16:42When you're loading an asset such as a SWF, JPEG, PNG or GIF file, using the Movie Clip Loader class into Flash,
16:49it needs to know where it is going to load that content into.
16:52Now you can choose to load it into a level, which is like an invisible layer above your master.fla file, the FLA file that you're currently in,
17:01and you can do that by just typing in a number here.
17:04So this is essentially loading it into a layer that is five layers above the stage of master.swf.
17:11And again, you can type in 1, you can type in 20, it doesn't matter.
17:16The master.fla stage is considered to be level 0.
17:22Now, if you wanted to instead load this content into a movie clip that you created, when you dragged an instance of that movie clip onto the stage,
17:30you'd want to make sure that you first give it an instance name by selecting it and giving it an instance name in the Property Inspector,
17:37and then you can specify the instance name of that movie clip here in quotation marks.
17:42However, because we're just loading splash.swf above the stage of master.fla, you can just simply type the invisible layer number, 5,
17:54which is called the level, that we want to load that content into.
17:57And then type in ?N?, parenthesis, and a semi-colon to end that action.
18:03Let's test this to see if it works.
18:05Again, go ahead and save your changes, and then choose ?Control Test Movie?
18:09or just use your keyboard shortcut ?control? ?enter? on Windows or ?command? ?return? from the Macintosh.
18:16You should see that splash.swf file appear on the stage here inside your master.swf preview window.
18:23If that happens, you know everything has worked correctly.
18:26What you've actually just done is taken one FLA file, one SWF, which is your master FLA and when you preview, therefore, your master.swf file,
18:34and loaded, using the Movie Clip Loader class, another SWF file into it onto the stage.
18:41That's really important and it's the first step of loading many parts of the website into your master.swf file.
Collapse this transcript
What is a shared library?
00:01>> You've seen how you can use symbols, graphic symbols, movie clips, and so forth,
00:05to reduce the file size of your Flash 8 movie when reusing identical elements, but what if you've broken your Flash movie
00:14up into multiple pieces just as you are going to do as you work and develop the LA Eyeworks website.
00:20Where you take the various pieces of the website, break them up into their own Swiss and then load them
00:26in using the Movie Clip Loader class as you've just seen in the last exercise.
00:31And what if you have a symbol that you want to reuse in all of those SWF files?
00:35Well traditionally you would just duplicate the symbol in each SWF file, or in the case of if you're using text
00:43and fonts you would just embed the font face in each SWF where you're using it.
00:48The bad thing is that that adds to the overall file size of the project.
00:52Because you're causing the user to download the same symbol or the same font outlines multiple times for each SWF file where it's being used.
01:00But I mean, what can you do about it?
01:01You can't have one symbol or one font being used across multiple SWF files, can you?
01:07You actually can.
01:08That is something called a shared library and that's what you're going to be using throughout the remainder of the exercises in this title.
01:14As you'll see, creating a shared library and what comprises a shared library is actually very simple.
01:21A shared library is essentially an FLA file just like any FLA file that you've ever created.
01:27But in that shared library FLA file there's nothing on the stage.
01:31Instead you create a bunch of content and make them into symbols inside of the library.
01:36Then you can assign linkage identification information to the elements in the shared library.
01:42Once you've done that, you can then take those shared elements and bring them into the separate elements of your website.
01:49When the viewer accesses your website, the part of it that's using one of the shared library elements,
01:55it will then trigger to download that shared element.
01:59So essentially you can use those shared elements in as many files as you want inside of your project
02:04without ever adding to the overall download size of your movie.
02:09A shared library element is not actually embedded into the file that you drag it.
02:14So for example, when you create a shared element in your shared library and then drag that into another FLA, say you have a ten kilobyte image
02:23that you have as a shared element and you drag into another FLA.
02:28That ten kilobytes will not be added to the overall file size of that SWF file.
02:33It stays in the shared library.
02:35So you can take a shared element and reuse it as many times as you'd like, essentially it's like a symbol that you can reuse in separate SWF files.
02:44The shared element and the host FLA file is basically just an alias to the original item in the shared library.
02:51So as you can imagine, and as you're probably seeing, it's a really powerful ability being able to have a shared library with elements
02:58that you're going to be reusing across multiple SWF files.
03:01That's what you're going to be constructing and using in the next exercise.
03:051
Collapse this transcript
Creating the shared library
00:01>> Now that you have a basic idea as to what a shared library is, let's go ahead and create a shared library that we will reuse elements
00:09from throughout all the other modules in the LA Eyeworks site.
00:13For a moment go ahead and minimize or hide Flash 8, and then navigate to the site directory, which is in the LA Eyeworks directory on your desktop.
00:21For those of you that have access to the exercise files for this title,
00:26you'll notice that inside of that site directory is an FLA called ?sharedlib?.
00:31For those of you that don't have access to the exercise files, in Flash 8 just go ahead and create a blank FLA file,
00:38and save it inside of this site directory, and call it ?sharedlib?, just like you see here.
00:44Then for those of you that do have access to the exercise files, go ahead and double-click on that FLA to open it in Flash 8.
00:52As you can see, inside of this ?sharedlib? FLA file, there is nothing on the stage.
00:57The only thing that's inside currently of this FLA is a single library element that's a button called ?btn.arrow?.
01:06It's just a button symbol, and inside of that is a circle with an arrow pointing down.
01:12Now right now this is an FLA just like any other, it just has one element in the library.
01:17But there's nothing distinguishable about this FLA file that would define it as a shared library.
01:24However, what we want to do is enable, to begin with, this button symbol to be shared in other SWF files.
01:32To do that, in the library panel of the shared lib fla, select the button arrow button symbol,
01:39and then right click or control click on that and choose ?linkage?.
01:44When you do that, this linkage property's dialog box opens up, and it gives you a few different check boxes under linkage.
01:51Go ahead and check ?export for action script?, which will automatically check for you export
01:57in first frame, and then also ?check export for runtime sharing?.
02:02That last one obviously sounds very much like being able to share that element across multiple SWF files, which is in fact what it does.
02:10Above that it says ?identifier?.
02:13Now this is the ID name that's going to be associated with this particular sharable item.
02:18Let's go ahead and give this an identifier name of ?arrowBtn?, with a capital B in button, again all one word.
02:26In this case I've abbreviated the word button, so it's just Btn.
02:30Now this is the name, the unique name, that is now associated with that particular button symbol.
02:36When you're giving an identifier name to a shared library element, just make sure that you follow the same naming rules
02:43as if you were creating a variable, no spaces in the name, no special characters, and so forth.
02:48The Action Script 2.0 class field is irrelevant for what we're doing at this point, but if you look down toward the bottom
02:53where it says URL, it should automatically say ?sharedlib.swf?.
02:58This is the URL for where this shared library element is gonna be located at, the SWF file for this FLA when we publish it.
03:07Just make sure in your URL field that it still says ?sharedlib.swf?.
03:12After you've given it a name and made sure that those three check boxes are checked, go ahead and click ?OK.
03:18Now that button symbol can now be shared across other SWF files, and it will then just be downloaded from this one shared library.
03:26Now that you've created a button that can be shared, make sure that you save the changes that you've made to this FLA,
03:32and that you publish a SWF file from this FLA by choosing ?file publish?.
03:39Now if you hide or minimize Flash for a moment, and look inside your site directory,
03:44you'll notice that in there now is a new SWF file called ?sharedlib.swf.
03:49That's the shared library that contains that shared button that you just created.
03:55I can now use, as you will see later, that shared button element in any of my other modules for my LA Eyeworks site.
04:02Again, I can use it in one FLA, or I can use it in ten, but the only overhead in the download of that element is the first time it's been used.
04:11So the first time I use that shared arrow button, it will be downloaded to the viewer's computer.
04:17But if I use it once more, or a hundred times more, it will not ever be downloaded again.
04:23So again, it's much like the idea of a symbol that you're using in your movie,
04:27but this is across multiple SWF files, and you can use it as many times as you'd like.
04:32In the next exercise you're going to learn how to create a shared font that you can use throughout all of the other sections in your LA Eyeworks website.
04:41The advantage of this is it allows you to use the same typeface throughout all these movies without adding to the file size each time you use it.
04:50Without a shared library, if you were using the same font in separate SWF files,
04:56each time you use it Flash would embed the outlines for that font in each of those movies.
05:01So each time you use that specific type and embedded the outlines, it adds to the overall file size of that SWF.
05:09What you're gonna learn how to do in the next exercise on the other hand,
05:12is to create a shared font that you can then use throughout all those other SWF files that will not add to the file size of that particular SWF file.
05:21You're gonna learn how to do that in the next exercise.
Collapse this transcript
Creating the shared fonts
00:01>> So far in your shared library you have a button symbol called Btn.arrow that you've made to be able to be sharable
00:08in your other SWF files and your L.A. Eyeworks site.
00:11But there's also fonts that you're going to be using throughout those other SWF files that should also be made sharable in a shared library as well.
00:19Make sure you're in Flash and that you have your ?sharedlib.fla? file still open, also make sure that you can see your library panel.
00:27At the top right of the library panel's an ?options? button.
00:31Clicking on that allows you to choose various options.
00:34The one you're looking for is one that says ?new font?.
00:37Go ahead and select that option.
00:40This will open up the ?font symbol properties? dialogue box.
00:44Go ahead and choose, if you're on Windows, the font Bitstream Vera Sans.
00:50Make sure that bold and italic are both unchecked.
00:53If you're on Macintosh, for this step, you can also make sure that the font chosen is Bitstream Vera Sans.
01:00Then let's give it a name.
01:02In the name field, go ahead and type ?Vera?.
01:05Also make sure that ?Bitmap text? is unchecked, and at this point the size in the size field here, is irrelevant.
01:12So again, just make sure that the font is Bitstream Vera Sans and that they ?style options? are both unchecked as well as is ?Bitmap text?.
01:21Then click ?OK?.
01:22In your library panel now, you'll now notice that there's another element that says Vera and it has a little ?A? next to it.
01:29That's now a font symbol.
01:31But just like with the button symbol, you need to make it sharable.
01:35To do that, right click, or control click on Vera, and then choose ?linkage?.
01:41Simply check ?export? from action script, which will then automatically check ?export in first frame? and then check ?export for runtime sharing?.
01:50As you can see, the identifier has automatically been entered as the same name that we gave that font symbol when we created it.
01:56So the identifier is ?Vera?, which is exactly what we want.
01:59So go ahead and leave it set to ?Vera? for now.
02:02Then just verify that the URL is still set to ?sharedlib.swf? and then click ?OK?.
02:08So now that font symbol is sharable.
02:11I can take that font symbol and use it in any of my other FLA files and I won't be adding to the file size
02:18of those SWF files when I use text that uses that shared font.
02:23It's an amazing feature.
02:24Now we're also going to be using Bitstream Vera Sans Bold, Bitstream Vera Sans Oblique, and Bitstream Vera Sans Bold Oblique.
02:34So we need to create three more of those shared fonts.
02:37Again, inside the ?sharedlib? library panel, click at the top right and choose again ?new font?.
02:44This time, on Windows, make sure that the font is still set to Bitstream Vera Sans and under ?style? make sure that only bold is selected.
02:54Then for the name, give it a name of ?Vera Bold?, like so.
02:58Now if you're on a Macintosh, from the font pull down menu, you would choose Bitstream Vera Sans Bold.
03:05And again, on a Macintosh, you would make sure that the bold checkbox is not checked.
03:11The way that Windows organizes its fonts as well as the variants of each font differs from how the Macintosh organizes it.
03:19So in this case, Windows and Macintosh users have to follow slightly different steps.
03:24So again, on the Macintosh you would choose, from the font pull down menu, Bitstream Vera Sans Bold, whereas on Windows,
03:31you would choose Bitstream Vera Sans and then you would check the bold style checkbox.
03:38On both platforms you would give it a name of ?Vera Bold?.
03:42Then click ?OK?.
03:43Just like you did with ?Vera?, you need to make it sharable.
03:46To do that, right click or control click on the Vera Bold font symbol in the library and choose ?linkage?, then check ?export for action script?,
03:56?export for runtime sharing?, and then just click ?OK?.
04:01Let's do that again.
04:03New font, I'm gonna choose, on Windows, Bitstream Vera Sans, making sure that the bold
04:10and italic style checkboxes are checked and I'm gonna give it a name of ?Vera Bold Oblique?.
04:18On the Macintosh, make sure that you select from the font pull down menu Bitstream Vera Sans Bold Oblique, and then, again, on the Macintosh,
04:26make sure that the two style checkboxes for bold and italic are not selected.
04:31The name on both platforms will be the same, ?Vera Bold Oblique?.
04:36Then click ?OK?, right click or control click that new font symbol in the library, choose ?linkage?,
04:43check "export for action script", "export for runtime sharing", and click ?OK?.
04:49Lastly, we just want a Vera Oblique, so add another new font symbol.
04:54On Windows, make sure that the font from the font pull down menu is Bitstream Vera Sans
05:01and this time uncheck the bold checkbox so that only the italic checkbox is selected.
05:06On the Macintosh, you would choose Bitstream Vera Sans Oblique as the font.
05:11Then on both platforms, in the name field, give it a name of Vera Oblique and click ?OK?.
05:21Lastly, right click or control click on that font face, choose ?linkage?, ?check export for action script?, ?export for runtime sharing?,
05:31all the other options are automatically set for you, and just click ?OK?.
05:36So now you have a sharedlib, shared library, that not only has four fonts in it that are sharable, but a button symbol as well.
05:45Now because you've made changes to this FLA, the last time you published the SWF file, it just had the shared button in it.
05:53You've made changes since then though, so you wanna make sure that any time you make changes to your shared library, and any time you add more elements
05:59to that shared library, you need to save the changes to that FLA and then publish a new SWF file by choosing ?file publish?
06:08so that it contains all of the new elements that you just added.
06:12Now that you have your shared library completely fleshed out, in the next exercise you're going to learn how to pre-cache that shared library
06:20so that all the elements within that shared library are available for you use in any other SWF file exactly when you need it.
Collapse this transcript
Precaching the shared library
00:01>> The only slight difficultly with how shared library elements work is that when you take a shared library element and you use it
00:09in another SWF file in your movie, the first time that shared library element is used it doesn't just have that one library element
00:17in the shared library be downloaded, it actually forces all the elements in your shared library to be downloaded all at the same time.
00:24So even though in one of your other SWF files you may have only used one of these elements and you would expect that only that one element
00:32from the shared library would be downloaded that one time, unfortunately that's not the case.
00:37It actually downloads them all together, all at the same time.
00:40Now that's not so bad, but it can be a bad thing if used improperly.
00:44For example, if you didn't use one of your shared library elements until a later point of your movie, when the viewer got to that point in your movie
00:52that required that shared library element they'd have to sit there and wait while they waited
00:57for the entire shared library to be downloaded at that moment.
01:01Obviously, that can cause some problems because depending upon the size of your shared library, it could take anywhere from one second
01:07to many minutes while the viewer waits for that entire shared library to be downloaded.
01:12What we're going to do is we're going to cause our shared library to be pre-cached at the beginning of our movie.
01:19That way all of our shared library elements will be available right at the beginning and we can control exactly when that shared library is pre-cached
01:28and ready to go, instead of it just happening whenever we happen to use one of our shared library elements in one of our movies.
01:36Before you continue inside of Flash 8, go ahead and close your shared lib.fla file.
01:42Now what we're going to do is we're going to create a new FLA called "trigger".
01:47And within the trigger.fla file, we're going to place one of our shared library elements.
01:53Then from within our master file, we're going to have that trigger.swf file be downloaded right at the beginning.
02:00When that happens, that's going to cause -- because it's using one of the shared library elements -- the entire shared library to be downloaded.
02:08Then from that point on, we can use any of our shared library elements whenever we want
02:14and they'll be used instantaneously because they've already been pre-cached.
02:18So the first step is to create this trigger file.
02:21Inside of Flash 8, go ahead and create a new FLA.
02:24An easy way to do that is to hold down "control" "alt" on Windows, or "command" "option" on the Macintosh,
02:31and then press "N". Because the last time we created a new FLA, we clicked that "make default" button
02:38in the "Properties" dialogue box it now has the same stage size,
02:43the same stage color as well as the same frames per second as that first movie we created for master.fla.
02:50If yours doesn't because you didn't click on that button, don't worry in this case because the trigger file is only being used
02:56to trigger the downloading of the shared library assets.
02:59It's not that big of a deal.
03:01Then let's go ahead and save this untitled FLA file into the site directory with the rest of our site files.
03:08So in this new blank FLA file choose "file", "save", navigate to your desktop, to your "LA Eyeworks" directory,
03:18to your site directory and give this a file name of "trigger".
03:23On the Macintosh you probably want to type dot FLA at the end of trigger then just click "save".
03:30Then let's just open up the library for the shared lib.fla file.
03:35To do that, simply choose "file", "import", "open external library".
03:43Again, inside the site directory, inside the LA Eyeworks directory which is on your desktop, you should see sharedlib.fla.
03:53Double-click on that sharedlib.fla file to open up just its library.
03:57It should open up in its own panel as you see here.
04:00And there you'll notice there are all your shared library elements that you created, including the button symbol and your four fonts.
04:08In this case, because we're just wanting our shared library to be triggered to be downloaded, let's just utilize this one button symbol.
04:17So take the button arrow button symbol from the sharedlib library and drag it onto the stage of your trigger.fla file.
04:27When you do that, you'll see that that shared button symbol has also been inserted here into the trigger library.
04:33Once you've done that, you don't need your sharedlib library panel open anymore, so go ahead and close that.
04:39Now just to verify that that button symbol is actually shared inside your trigger library panel,
04:45right-click or control click on that new button symbol and choose "linkage".
04:50When you do, in the linkage properties dialogue box you should now see that the check box for import for run time sharing is checked.
04:58The URL where it's getting that symbol from is sharedlib.swf.
05:02So as you can see here, it is actually importing that library element to be used at run time.
05:08I'm going to go ahead and click "cancel" to exit out of that window.
05:13Now I'm also placing this button arrow off to the side of the stage in the gray work space.
05:18That way when the trigger SWF file first loads into our master.swf as you'll see
05:23in just a little bit, it won't actually even appear on the stage.
05:27Next, go ahead and rename layer one to be titled "sharedlibasset".
05:34Then, create a new layer and rename that new layer to be titled "A" so we can enter in some action script here.
05:42Lock the "A" layer, select the first key frame in that layer, and then open up the "options panel" and click in the script pane.
05:50Now what we want to happen is when trigger.swf gets loaded into our master.swf file,
05:57we want our trigger.swf file to trigger the playback of the master file.
06:02In other words, the trigger.swf file is going to trigger the downloading of the shared library.
06:07And once that has happened, once that shared library has been pre-cached we want it to tell the master.swf file
06:14that it's okay to go ahead and play the rest of the content.
06:17So when this trigger.swf file triggers the downloading and therefore pre-caching of the shared library, it actually won't execute any
06:25of the actions inside of our trigger.fla file until that shared library has been completely downloaded.
06:32Once that shared library has been completely downloaded, then we can tell the master Flash file that it's okay
06:39to go ahead and start playing the rest of the content.
06:41So here inside of the first key frame of our "A" layer for actions in trigger.fla,
06:49let's tell that master file that it's "OK" to go and play the rest of the content.
06:54So here in the actions panel, type "_level zero.play".
07:02Open parenthesis, end parenthesis, semi-colon.
07:05Now remember the master.swf file is that SWF file that all the other content loads into.
07:12When you have a structure such as that, the master.swf file is what is called level zero, it's at the very bottom.
07:18Everything else loads into it.
07:20So whenever from one of my other SWF files, whenever I say level zero, that refers to the master.swf file.
07:28So what I'm doing is I'm telling that master.swf file to play.
07:32Again, the way this is going to work is trigger.swf file, because it's using one of the shared library elements
07:38on the stage, is going to be loaded into the master.swf.
07:42And when the trigger.swf file gets loaded in, and Flash sees that it's using a shared library element,
07:48that will cause it to trigger the downloading and therefore pre-caching of all of those shared library elements.
07:55After it's downloaded all those shared library elements, it's going to perform the action script inside of our trigger.fla file.
08:03It's going to say, "Oh, tell the master.swf file to start playing now."
08:07So once those shared library elements have been downloaded,
08:10trigger.swf tells master.swf go ahead and start playing the rest of the content now.
08:16And that's all you need, and that's all that's going on here inside of your trigger.fla file.
08:21So make sure that you save your changes.
08:23Now when you publish your trigger.fla file, you don't want Flash to publish in HTML file along with the SWF.
08:30You don't needed HTML file you just need from your trigger file to publish the SWF.
08:36So still in "trigger.fla", choose "file", "publish settings". inside the "publish settings" dialogue box under "formats",
08:46uncheck HTML so that when you say "file publish", it only publishes the SWF file.
08:53Then in this "publish settings" window, go ahead and click "publish", which will publish that SWF file, click "OK" to close that window,
09:02then save once more your trigger.fla file, and go ahead and close that FLA file, you won't be needing that again.
09:10If I hide or minimize Flash for a moment and go into my site directory,
09:14in the LA Eyeworks directory on my desktop I can now see that there is my trigger.swf file.
09:20Again, in the same directory as the rest of my site.
09:23Next, go back to Flash 8 and make sure that you're in master.fla.
09:29In the first key frame of the "A" layer on line number six currently, we have an action that loads in splash.swf.
09:38But really, I want that action to instead load in the trigger.swf file to trigger the pre-loading and the pre-caching of that shared library.
09:48So instead of "myMCLloadclipssplash.swf,5" I want it to actually be "trigger.swf".
09:57First however, go ahead and select that action, right-click or control click on it and choose "copy".
10:04Then simply change "splash.swf" to "trigger.swf".
10:09Now remember when our movie clip loader gets executed and it loads "trigger.swf", "trigger.swf" will start to load in,
10:17Flash will see that it's using a shared library element so it'll start downloading and pre-caching that shared library.
10:23When that's finished, that trigger.swf file will execute the action in there which tells our master.swf file to start playing.
10:31So what we're going to do is a little further down the timeline in our master file,
10:35we're going to add another action that starts the viewing of the rest of the content.
10:40So in master, select frame ten in your "A" layer, and add a key frame there by pressing "F6" on your keyboard.
10:48Now when the shared library has been pre-cached and the trigger.swf file tells our master.fla, our master.swf file here to start playing,
10:57the play head's going to start playing and it's going to reach ten.
11:00Unless I do something, when the play head reaches frame ten, which is the end of the timeline here,
11:05it's going to just jump right back to the beginning and start that process over again.
11:10However, I want it when the play head gets to frame ten, for it to stop there.
11:14So with key fra,e ten selected in my "A" layer, in master.fla, in the actions panel,
11:20the first thing I'm going to do is I'm going to add a stop action like so.
11:24So when the play head reaches that key frame it stops.
11:27Then, at this point is when I want the master file to load in the splash page.
11:32The action to load the splash page if you remember, is one that I just copied from key frame one just a moment ago.
11:39So after my stop action I'm going to press "return" or "enter" to create a line break, and then paste by choosing "control" "V"
11:46or "command" "V" that action to load in splash.swf.
11:50Now if you remember, the trigger.swf file on key frame one that is being instructed to download is being instructed to download
11:57and be displayed in level five, just like splash.swf is here.
12:02So that means both the trigger.swf and splash.swf are being told to load into the same level.
12:08And in this case, that's okay.
12:10Because once trigger.swf gets loaded in that means that the shared library has also been pre-cached.
12:17So that means that trigger.swf is no longer needed.
12:20We only need it to trigger the downloading and pre-caching of the shared library.
12:24From that point on, we don't need it anymore.
12:27So when splash.swf gets instructed to be downloaded here on frame ten, we can have it load into that same level, level five.
12:34And it'll just kick trigger.swf out and load splash.swf in, in it's place and that's perfectly fine.
12:41Then, because when the play head advances to frame ten, we won't be able to see the background layer anymore.
12:48It disappears after the very first frame.
12:50So that we can continue to see that all the way to the end of the timeline, make sure that you select frame ten in the BG layer,
12:58and add frames up to that point by pressing "F5" on your keyboard.
13:02That way as the play head advances you can still see that background layer all the way out to the very last frame.
13:07Then go ahead and select key frame one in your master.fla file and one thing that's missing from this grouping
13:13of actions that you have here is another stop action.
13:17Because we now have multiple frames in the master.fla file, when this file starts being downloaded to the viewer's computer and it starts playing,
13:25it's going to automatically start playing through that play head.
13:28We want the play head to stay here on frame one until trigger.swf is downloaded and the shared library is downloaded and pre-cached.
13:38Once that happens again, the action in trigger.swf is executed which then tells the master.swf play head to start playing.
13:46Only at that point is when we want the play head to start playing.
13:49Until then it should be paused here on the very first frame.
13:54What that means is that we just need to add a stop action here on the first key frame of our master file.
13:59So again in key frame one in the actions layer, click before the very first action, press return or enter once to create a line break,
14:08and then select that new empty line break at the top of the actions panel.
14:12Then just add a stop action there.
14:15So now that play head will stay paused on the first frame until it gets told by trigger.swf that it's okay to start playing.
14:23Lastly, let's go ahead and just make sure that everything works as it's suppose to.
14:27At this point, what should happen is that when the viewer first comes to your website, master.swf is the first SWF file they encounter.
14:35The first thing that master.swf does here on the first key frame is it starts downloading trigger.swf.
14:41All trigger.swf has in it is one of the shared library elements on the stage and then an action
14:47that says, "Tell master.swf to start playing."
14:50That action of course, won't be executed until the entire shared library and all the elements within it
14:56that we're going to be sharing have been downloaded.
14:59So trigger.swf starts downloading, it in turn starts downloading to shared library elements, once all that has been downloaded
15:07and pre-cached, it then tells master.swf to start playing.
15:11Master.swf starts playing.
15:13It reaches the last key frame here which stops it right there.
15:16And then it loads the splash.swf file.
15:20So that's how everything's currently set-up.
15:22Go ahead and save the changes you've made to master.fla and test your movie.
15:27In the test movie, visually nothing has changed.
15:32But let's see what's going on behind the scenes.
15:35Inside of your preview window, choose view bandwidth profiler.
15:39This will separate the window into three pieces.
15:42In the bottom part is the actual visual portion of your SWF file.
15:46On the right is a graph break down of the file sizes of all the frames in your movie.
15:50And on the left-hand side is a more data break down on what's going on. How big each frame is, what's being download and so forth.
15:57It's this top left portion of the window that we want to give more room to, so we can see more information
16:03about what is being downloaded and how the progress is occurring.
16:06So make that part of your window as big as possible.
16:10So I'm going to make my window as big as I can get it, and then drag that vertical bar over to the right as much as I can
16:18so I have as much space as I can for that top left portion.
16:23Then I want to choose a modem speed to preview the streaming download of this SWF file.
16:29To do that again choose "view", "download settings", and then you can specify a modem speed
16:35to test how the SWF file will be viewed as it is being streamed off of one of these speeds.
16:41For now I'm going to choose a 56K modem to test this on.
16:45Then I'm going to choose "view", "simulate download".
16:50And what Flash will do is it will simulate how it will be downloaded on a 56K modem.
16:55Go ahead and choose simulate download and you can see right now that it's downloading the sharedlib.swf file.
17:01It says that the total file size is eighty-three kilobytes and that it's about fifty percent finished.
17:07Notice on the stage that it's just blank and empty.
17:09You'll finish that in just a second.
17:11Once that's all finished, it advances to frame ten and then it downloads the splash.swf file and displays it.
17:18So by looking here at the bandwidth profiler we can see that the entire shared library is actually getting downloaded and pre-cached,
17:26and that means that all the elements inside my shared library can now be used in any of my other SWF files instantly.
17:32That's exactly the results that you want to see.
17:35In the next movie, we're going to clean this up a little bit.
17:37Because right now when the viewer comes to your website and they see your master.swf file, they sit there as you saw,
17:44staring at a blank screen while the shared library SWF file is being downloaded and pre-cached.
17:49It would be better to give them a little visual feedback that tells them that something is being downloaded, somethings happening, don't leave.
17:56The site's not broken, everything is okay, and hang out and wait while we pre-load and pre-cache this content.
18:02You're going to finish this up in the next movie.
18:041
Collapse this transcript
Creating a loading message
00:01Now that you've verified that your shared library is being downloaded and pre-cached appropriately, let's add a little text message
00:09to the very first frame of your master.swf file that tells the viewer that it is loading content because, again, right now,
00:16all they see is a blank screen while the shared library is being downloaded and cached.
00:21Obviously that's not a very good thing to let the viewer just sit there and stare at a blank screen and the slower their internet connection is,
00:28the longer they'll be sitting there staring at that blank screen.
00:31Back inside of Flash, if you still have your preview window open, go ahead and close it.
00:36So let's first go back to the master FLA file and add a new layer to hold that loading message.
00:42Go ahead and create a new layer and rename this new layer to be titled loading message.
00:48Now, it's good practice to always keep your actions layer, the layer that's holding your actions, at the very top of the rest of your layers.
00:57The reason why is because, as you've probably seen up to this point, you can easily have many many layers inside of your document.
01:05Instead of having to search through all the layers that you may have in your FLA to try to find the layer that has your actions in it,
01:12it's always best if you keep that layer all the way at the very top above all the other layers.
01:17That way you'll always know where to go to look for your actions and the layer that holds them.
01:23In the loading message layer, make sure you have that selected and then select your Text tool.
01:30In the Properties Inspector, let's change the font that's being used.
01:34Now, the message that we're going to have appear on the screen is just going
01:37to say "loading assets", and we want that message to appear instantaneously.
01:42In other words, we don't want to embed any font outlines for the font that we choose because that would then take time for Flash to download.
01:50Since we want it to appear instantly, let's just have Flash use a font that's on the viewer's computer.
01:57The ability for us to do that is something called a "device font".
02:01So, in your "Properties Inspector", after you've selected your Text tool from the font pull down menu,
02:07scroll through until you find the font called "_sans".
02:11The fonts with the underscores before them are called device fonts and that means that they're just going to use whatever the default sans serif,
02:19serif, or monospace typewriter font is on the viewer's computer.
02:23So it's not actually adding any file size to the overall SWF file by using one of these device fonts.
02:30I'm going to choose underscore sans.
02:33You notice when you do that, the font rendering method is automatically set to use device fonts.
02:40Then, I'm going to choose a color of black.
02:42I'm going to make sure that faux bold and faux italic or not selected.
02:47I'm going to make sure that my "text type" is set to "static text" and then, again, making sure that my loading message layer is selected,
02:55I'm going to click my stage, and I'm going to type "loading assets", and then I'm going to press "escape" to get out of text editing mode.
03:05Now, I can see that that text is a little small.
03:07So with that text block still selected back in my properties inspector, I'm going to change the font size from 9 to 11.
03:14I'm going to also make sure that I have my text set to be align center.
03:20That way, should I make any changes to it later, it will stay automatically aligned in the center.
03:25However, what I also want to do is make sure that this text block itself is aligned, therefore, in the center of the stage as a whole.
03:32To do that, simply select your Selection tool, make sure that text block is still selected, and open up your Align panel.
03:40You can do that easily by choosing "control" "K" on Windows or "command" "K" on the Macintosh.
03:46Then in the align panel, make sure that two stage button is depressed, and then click on the "align horizontal center" button and "align vertical center".
03:57Once you've done that, you can close the align panel again by pressing the same keyboard shortcut "control" "K" or "command" K". So now
04:05that "loading assets" message, it's aligned right in the center of the stage.
04:09So that's the message the viewer is going to see as the shared library assets are being downloaded and pre-cached.
04:16However, once that has happened, and the playhead starts playing forward, we want that message to disappear because the assets have been downloaded.
04:25What that means is in your loading message layer select frame two and add a blank keyframe there by pressing F7 on your keyboard.
04:34So then the "loading assets" message only appears in the very first frame as those assets are being downloaded
04:41and as soon as they have finished being downloaded, and the play has started playing, the message disappears.
04:47Since you won't be needing that layer, or what's on the layer again, make sure that you lock the loading message layer,
04:53save the changes you've made to master.fla, and let's test our movie one last time to make sure everything is working like we want it to.
05:01So choose "control test movie".
05:04Again, I'm going to maximize the amount of space my preview window has so I can look at my bandwidth profiler.
05:09I'm going to maximize the amount of space the top left of my bandwidth profiler has so I can view more information
05:17about what's being downloaded and what's going on inside of my SWF file.
05:21I still have my 56K modem speed selected, so all I need to do is choose view simulate download again,
05:29and I can see my sharedlib.swf file is being downloaded but now on the stage I see my message that says "loading assets".
05:35So now the viewer knows that something is going on in the background.
05:39Something is not broken.
05:41That's why they're not seeing anything, in fact, assets are being downloaded.
05:44When that finishes, the message disappears.
05:47It continues on to frame ten where the splash.swf file is being downloaded.
05:51Once it's downloaded, it appears on the stage.
05:54Everything is hunky dorey and well with the universe.
05:57So there, you now have the completed pre-cached downloaded shared library and all of the elements inside of that shared library are now available
06:06for immediate use in whatever SWF file you'd like to use them in.
06:10In the next chapter we're going to start using some of those shared library elements, particularly the font face in some scrolling text
06:18that you're going to create on the stage of the "About Us" module.
06:21However, congratulations on making it this far.
Collapse this transcript
4. Using the LoadVars Class
Previewing what you're building
00:01>> In this chapter, you're going to learn how to utilize another action script class called LoadVars to be able
00:08to load text dynamically into another section of the LA Eyeworks website.
00:13So you can get a better idea of what it is exactly that you're building before you get started.
00:18Open up your default web browser and navigate to www.lynda.com/intflash8/laeyeworks
00:33At that URL you'll see the sample LA Eyeworks sites.
00:37From the top navigation bar, click on the link "About Us".
00:42By default when the "About Us" section loads, the "Our History" subsection loads and shows a bit of loaded text
00:50that gives some information about the history of LA Eyeworks.
00:53It's this particular section in the "About Us" module that you'll be constructing throughout this chapter.
00:59Most of it is constructed using the LoadVars class.
01:03To take this text which exists in an external text file and use action script to dynamically load it in to this text field that exists here
01:12on the stage and then allow it to be scrollable with a little bit more action script that is triggered when the viewer clicks on those buttons.
01:20That's what you're going to be building.
Collapse this transcript
Importing the shared fonts
00:01The first step for those of you that have access to the exercise files is to open up a pre-built
00:07"About Us" FLA module to begin working and constructing this section.
00:12In the LA Eyeworks directory on your desktop, inside of the site directory, you'll notice that there's a pre-built FLA called "aboutus.fla".
00:22Go ahead and open that FLA open up inside of Flash 8.
00:28Inside of that FLA you'll notice there's a few things that have already been built there for you.
00:33In the bottommost layer is a guide layer called "Available Space".
00:37Inside of that layer on the stage has been imported a bitmap graphic.
00:42It's a JPEG graphic called "availablespace.jpeg".
00:46For those of you that don't have access to the exercise files, don't worry about this background graphic, essentially that background graphic is there
00:54so that, as we begin to develop our site inside of Flash, we can see, based on the designs that we've done in our graphics editing program,
01:03we can see how much space we have to work with as we begin to construct this content here inside of Flash.
01:08So it just gives us a better idea of the amount of space we have to work with.
01:12Above that, is another layer called "About Us" text and on the stage is just a static text field with the text "About Us" inside of it.
01:23Additionally, on the stage is a dynamic text field as you can see down here in the Properties Inspector
01:29when I have it selected that is set to be multi-lined.
01:32So, if you don't have access to the exercise files, go ahead and create that "About Us" static text as well as the dynamic text field beneath it
01:40and to the right that gives us enough space to display that initial text on the stage.
01:47Additionally, in the library there are also two movie clips: MC Our History and MC Our Staff.
01:53The only thing inside of those movie clips is a bit of text inside of dynamic text fields. One says "Our staff" and the other one says "Our history".
02:03So, if you don't have access to the exercise files, you'll need to create those yourself.
02:07Now, the first step in this process is to import the shared fonts
02:12so that we can utilize those shared fonts where we're using text inside of this module.
02:17Again, that way, as we're working with text inside of this separate swift file About Us,
02:23we won't actually be adding to the file size of this swift whatsoever.
02:27That is the reason why we're using a shared library to begin with.
02:31So, when you have Aboutus.fla open, make sure that's the only FLA you currently have open, choose "file", "import", "open external library",
02:42the navigate to your site directory and the LA Eyeworks directory on your desktop and locate your sharedlib.fla file.
02:50Double-click on the FLA file to open up just the library for the sharedlib file.
02:56Then, select all four of those shared fonts inside of the sharedlib library panel and simply drag them into the About Us library.
03:06As soon as you do that it makes a dynamic link to those shared library elements so that, again,
03:11these are essentially just referring to the originals.
03:14They are like an alias that points to the original font symbols inside of the sharedlib library but now that they've been imported into the
03:22About Us library panel, we can then utilize those shared fonts wherever we're using text inside of our About Us movie.
03:31Once you've done that, you can go ahead and close the "sharedlib" library panel.
03:35Then on your stage in the Aboutus.fla file, click on the text "About Us".
03:41In the Properties Inspector, again, as you can see it's a static text field but from the font pulldown menu let's choose one
03:48of the shared fonts that we just brought in to the "About Us" file.
03:51Then from the font pulldown menu, scroll down in your font list until you see the font Vera Bold with an asterisk next to it.
04:00These four fonts here with the asterisks that follow those names, are the four shared fonts that you just brought over from the sharedlib library.
04:08In this case we want About Us to use the font Bitstream Vera Sans Bold which we gave the name
04:16when we created it inside of the sharedlib library of Vera Bold.
04:20Go ahead and select that.
04:22Now on Windows you'll also need to make the extra step of making sure that the faux bold button is depressed in the Properties Inspector.
04:30Then, click on the "dynamic text field" on the stage and, again, in the Properties Inspector from the font pulldown menu scroll
04:39until you locate Vera with the asterisks after the name and then go ahead and select that.
04:46So now the "About Us" text, as well as the text that we'll eventually load into this dynamic text field,
04:53are both using shared fonts that way they're not adding to the file size of this About Us swift file when we export it.
05:00Now that you've brought in your shared fonts and assigned them to where you're using text inside of the aboutus.fla file,
05:07in the next few exercises you're going to learn to both utilize comments in your action script as well as write the LoadVars,
05:14object that's going to handle the loading dynamically of that external text and placing it inside of this dynamic text field here on your stage.
05:23Before you continue on to the next movie, however, make sure that you save the changes you've made to this aboutus.fla file.
Collapse this transcript
Adding comments
00:01>> Before we continue much further and get more in-depth with working with action script inside of Flash,
00:07it's important that you have a good understanding of something called commenting.
00:11And commenting, as its name sounds, allows you to add comments to your actions as you're working with them.
00:18Now, adding commenting in your actions panel actually serves a few different purposes.
00:23One very important purpose is the ability for you to comment your action script as you write it.
00:30Now, while it may make great sense to you to what your actions are doing as you're writing them, you also have to keep in mind that you may have
00:37to come back to your Flash files and look and work with this action script again six, eight, twelve months down the line.
00:45So what may make great sense to you now may not make great sense to you in a year from this point.
00:51So commenting will allow you, as you come back to your action script at a later point or, if a co-worker or somebody else is going to be looking
00:59at your action script, to allow yourself to be able to clearly define and state what is doing what.
01:06So again, it makes more sense to you as you come back to it later or if somebody else is going to be looking at it.
01:12Another great use of commenting is to temporarily disable a particular action by what's called commenting out an action.
01:20You can prevent that action from being compiled when you create your SWF file.
01:25So essentially it temporarily disables the action so that, for example, for troubleshooting purposes, you can temporarily turn that action off.
01:34Let's take a look real quick at adding a simple comment to your actions panel.
01:39Here is just a sample function I wrote.
01:42I'm going to click at the very beginning of that first action, press "return" or "enter" to create a line break,
01:48and in that new empty line break I created, I'm going to type two forward slashes.
01:53Notice as soon as I type that second forward slash, they immediately become grayed out.
01:58Flash grays out those two forward slashes because that marks the beginning of a comment.
02:04Then I can just type whatever comment I have.
02:05I'm going to type space and say, "This is my sample function."
02:12Notice, again, how that's all gray.
02:15As you're working with action script, especially as your actions become more complex, it will be very beneficial and useful to you
02:22if you add simple comments like this one to your actions that are descriptive as to what those particular actions are doing.
02:29Again, so if you come back to this action script later or if you're passing it on to someone else to look at or work with,
02:36they don't have to sit there staring at this action script and trying to figure out what it is doing.
02:41If you leave them a nice, well-defined comment, they should have a perfect understanding of what's going on inside of your action scripts.
02:48So that is just a simple comment.
02:51Now what if I wanted to temporarily disable this action that says "var sample object equals new object?"
02:57What if I wanted to take that action and prevent it from being executed and compiled in the SWF file that I generate from this FLA.
03:06I can temporarily take that action and, without deleting it -- which, if I needed it later, I'd have to go back in there and rewrite it.
03:13If I just wanted to temporarily disable it, I can click before that action and type two forward slashes.
03:21This is the same as adding a comment.
03:22However, notice that as soon as I do that, not only do those two forward slashes become grayed out, but also does everything else on that line.
03:31That means that this action has been commented out and will not be executed or compiled in the SWF when I publish the FLA.
03:39So I have temporarily disabled this.
03:41Again, rather than deleting it, because I may need to go back and work with it again later,
03:45I can just comment it out so that it's not executed and compiled in the SWF.
03:51However, what if I wanted to prevent this entire function from being executed?
03:55What if I wanted to comment out this entire function?
03:58How would I go about doing that?
03:59Do I have to put forward slashes at the beginning of every line?
04:03That would be a hassle if I had a fifty-line function, for example.
04:06There is actually a little easier way to do it.
04:10I'm going to go ahead and delete those two forward slashes that I've already written and then I'm going to click at the beginning of my function
04:16and press "Return" or "Enter" to create another line break.
04:19Then I'm going to click in that empty line break that I just created and type a forward slash and an asterisk.
04:26An asterisk is "Shift 8" on your keyboard.
04:29Notice how now, everything after that has been grayed out.
04:33That forward slash asterisk marks the beginning of my comment out.
04:39Now, I need to tell it where to stop commenting out because I may have actions underneath it that I still want to be enabled,
04:44so I'm going to click after the last curly brace that ends that function.
04:48Press "Return" or "Enter" and then just duplicate that comment, but in reverse.
04:53So I'm going to type asterisk, forward slash.
04:56And now if I were to have another action after that point, like so, you can see how it's not grayed out.
05:07That action is still functional and will still work correctly.
05:10Everything in between the forward slash asterisk and the asterisk forward slash is going to be commented out
05:17and will not be performed when this FLA is compiled.
05:21So that is a quick example of using commenting to both leave yourself comments to make it easier for yourself or somebody else
05:27to understand what's going on in your action script at a later time, as well as using commenting to comment out
05:34or temporarily disable the usage of action script inside your actions panel.
05:39Again, both those instances are very useful and you're going to be seeing those quite a bit
05:44as we work forward with the exercises in this training tutorial.
Collapse this transcript
Writing the LoadVars object pt. 1
00:00>> In this exercise you're gonna write the LoadVars object that is gonna deal with loading text that is external to Flash,
00:09and bringing it in and utilizing it in your various modules.
00:13In this case we're gonna write the LoadVars object that loads the external text, and places it inside of the text field here on the "About Us" stage.
00:22Now you might start to think that because we're gonna be loading text into this FLA itself that we would then write our action script in this FLA.
00:31In actuality however, because we're going to be utilizing the LoadVars object throughout many of the modules,
00:38because each of those modules is also going to load in dynamic text that is external to Flash itself, instead of writing it in each of those modules,
00:48we're gonna write it in the master.fla file so that we can reuse that LoadVars object throughout all of the other modules.
00:56Again, this goes back to just writing your action script one time, and then being able to reuse that action script whenever you need it,
01:04instead of writing the same action script over and over again, which would just increase the amount of time it would take for you to maintain
01:11that action, as well as fix any bugs that might occur.
01:14So with your "About Us" FLA still open, hide or minimize Flash for a moment, and then navigate to your site directory
01:21in the LA Eyeworks directory on your desktop.
01:24You should find in there the master.fla file that you created earlier.
01:28Go ahead and open that up inside of Flash.
01:31Then select key frame one in the "A" layer, and open up your actions panel.
01:37It's here earlier where we wrote the movie clip loader object, as well as the action that instructs
01:42that movie clip loader object to load the first external SWF, trigger.swf.
01:46Now that you've learned more about commenting, let's add a few comments to the actions panel
01:52to help us later better identify what's going on inside this script.
01:57Click after the stop action, press return or enter once to create a new line break,
02:03type two forward slashes, a space, and then a series of hyphens, like so.
02:10Then type another space and two backslashes.
02:13Again, a comment in its base form is just two forward slashes.
02:18The only reason why I'm putting all of these hyphens and the backslashes is just to make it
02:22so that I can more clearly identify it visually as I'm scanning through my actions.
02:27So again, all you really need are the two forward slashes, everything after that is entirely up to you.
02:32I'm gonna click in between the two forward slashes and the two back slashes at the end,
02:39and then I'm gonna type a less than symbol, MCL, and a greater than symbol.
02:45Again, this is so that as I scan through my action script I can clearly see where the beginning of my movie clip loader, the MCL script is.
02:54Then I should also define where the end of the movie clip loader script is.
02:58So I'm gonna select that comment line, copy it, click after the add listener action,
03:06press return or enter once to create a new line break, and then paste that same comment line.
03:12This time in the comment line before MCL I'm gonna click and type a forward slash to signify the end of the movie clip loader class.
03:21Next let's add a comment before the load clip action so that we know,
03:25again just visually scanning through our actions, what this particular action itself does.
03:31Click at the beginning of your myMCL.load clip action, press return or enter once to crate a new line break, click in the empty line break
03:40above that action that you just created, type two forward slashes, a space, and then the comment trigger the MCL to load these assets.
03:53So now again by adding that comment in there we can clearly see that oh yes, that action there uses the movie clip loader class to load that asset.
04:01Next let's add one more comment line that marks the beginning of the LoadVars object that you're about to write.
04:08Click after the last action in your actions panel, which is the load clip action, and press return
04:13or enter a few time to create a couple of line breaks.
04:18And then remember I still have the MCL comment line in my clipboard.
04:23So what I'm gonna do is I'm gonna paste that in this bottommost empty line break that I've created.
04:29Then I'm gonna change where it says MCL to instead read "LoadVars", to mark the beginning of my LoadVars object.
04:39Then click after that comment line, and press return or enter again to create another empty line break beneath that.
04:45This next action that you're about to write you're gonna see is very similar to the movie clip loader action that you created earlier.
04:52Let's start off by creating a variable name that we're then going to assign our LoadVars object to.
04:58So type var space mylv for my LoadVars, colon, LoadVars, space equals space, new space LoadVars, open parenthesis, close parenthesis, semicolon.
05:17And again, if you look at that action, you'll see many similarities between how it's structured and how the action
05:23that defines the movie clip loader object is also structured.
05:27You start off by declaring a variable called mylv, strict typing it to the LoadVars data type,
05:33and then placing inside that mylv variable a new LoadVars object.
05:39Now that you've added some commenting to your action script here in master.fla, as well as created a new LoadVars object,
05:46you're gonna pick this back up again in the next exercise where you're going to expand more and add more functionality to that LoadVars object
05:54to get it so that you can start loading information, text, from external text files, and bringing that and placing it inside of your Flash projects.
06:03Before you continue on to the next exercise, make sure that you save the changes you've made to your master.fla file.
Collapse this transcript
Writing the LoadVars object pt. 2
00:00>> Now that you've written your first LoadVars object, you might think that the next step, somewhat like the Movie Clip Loader object
00:08that you wrote earlier, would be to tell that LoadVars object what content to load in, just, again, like you did with the Movie Clip Loader object.
00:16Unfortunately, that's not really the case with the LoadVars object when you're dealing with loading external text, external variables,
00:23from a separate text file and then bringing that into your Flash project.
00:26The reason why is because when you're dealing with transmitting information over the internet, information being progressively downloaded off
00:34of a web server for example, you need to find out when all of that information,
00:39all of those variables that is being downloaded using this LoadVars object has been completely downloaded,
00:45because only when it's been completely downloaded can you actually do something with it, can you then take that text
00:52and put it in the appropriate text field, for example.
00:55So to do that, to be able to tell when it's been completely downloaded and not just partially downloaded,
01:00you're going to use something called an event handler.
01:03Now, some objects, like the Movie Clip Loader object as you'll see later and like our LoadVars object,
01:09have the ability to find out how things are progressing.
01:13So have your variables just started to be downloaded, have they finished, how much have they been downloaded, and so forth.
01:20You can find out that information by using event handlers that are assigned to these particular objects.
01:26So the first thing we're going to do is we're going to write an event handler that is triggered when the text has been completely downloaded,
01:34when our variables that we're going to load in have been completely loaded, because again, at that point, we can then take that text, those variables,
01:42and place it inside of a text field of our choosing.
01:46So, again, still in master.fla with the first key frame in your A layer selected,
01:52in your actions panel, click at the end of the bottom-most action there.
01:58Then, press Return or Enter a few times to create a couple line breaks.
02:02Then, type the name of your LoadVars object, which is myLV, dot, and then the name of the event handler.
02:10I'm going to type onLoad.
02:14Now, event handlers need to be assigned to functions, so after onLoad, type space, equals, space, function, space, open parenthesis,
02:24and then the parameter success, close parenthesis, space, an open curly brace,
02:32a couple of lines breaks and a closed curly brace to end that function.
02:37So not only do we have an event handler, but when our LoadVars object successfully downloads all of the variables from the text file
02:45that we're targeting, it's going to broadcast the message out to the onLoad event handler, and it's going to send a parameter that's going to be true
02:53or false to the onLoad function that says whether or not it was successful.
02:59If it's successful, and that's where this parameter here comes in, it will send true to the onLoad function.
03:06If not, it will send false.
03:08Now, because this parameter here in the onLoad function is going to be a true or false result,
03:15we should strict type this success parameter to the data type of boolean.
03:21Boolean is true or false.
03:23So after success, click there, type a colon and then start to type boolean.
03:30Again, as you start to type it, you should see a window pop open and highlight "boolean".
03:35If you do, go ahead and just press Return or Enter and Flash will automatically complete that for you.
03:41Now at this point, you may be saying to yourself, how does he know what the different event handlers are for the LoadVars object?
03:49Like, how would I know that there is an onLoad event handler and how would I get more information about that?
03:55You can press F1 on your keyboard to open up the Help panel.
03:59If you open up the action script 2.0 language reference book, action script classes, and then scroll down to LoadVars,
04:08there is lots of information about working with LoadVars in that book.
04:12For example, if you scroll down, you can see the different event handlers, such as On Data, On HTTP status, onLoad, and so forth.
04:21So there is lots of information about working with the event handlers as well as the LoadVars class itself inside of the Help panel.
04:29So again, that's how I get the information about, when I'm working with loading information, using the LoadVars object,
04:35exactly what I can do with that LoadVars object and what features are available for my use.
04:41You can also see here again is says the onLoad equals function, success, boolean, open parenthesis,
04:47close parenthesis, which is essentially what you just created.
04:50Back in the master.fla file, there is still a few more steps that we need to take.
04:55When we instruct the LoadVars object that we've called myLV to load the variables from a text file,
05:02once those variables have been completely loaded, the LoadVars object is going to broadcast out a message
05:08to the onLoad event handler saying whether or not it was successful.
05:12Now, we need to be able to find out if that loading was successful or not.
05:17To be able to do that, we need to set up a conditional.
05:20A conditional is an if statement; if this happens, do this.
05:25Otherwise, do this other thing.
05:28So make sure that you're inside of the onLoad function.
05:31You should have an empty line break in between the open curly brace and the closed curly brace of that function.
05:37Click on the empty line break.
05:39Then type if, space, open parenthesis, success, closed parenthesis, space, open curly brace, a couple of line breaks, and a closed curly brace.
05:53Now, in the if conditional where it says "if success," that means if it is true, in other words, if the data has been completely downloaded,
06:02if the LoadVars object sends a message to the onLoad event handler that it was successful,
06:09that success is true in loading the variables from a text file, what should happen?
06:14Well, if the LoadVars object, myLV, was successful in getting the text from this external text file that you'll see in a little bit and loading that in
06:24and everything worked out okay, then what should happen?
06:27Well, if that's true, then by gum, we want to take the text that is inside of that text file and finally have Flash insert
06:35that text into a text field so that we can actually see it.
06:38That would be nice.
06:40So click in the empty line break between the if, open curly brace and the closed curly brace.
06:47Then, you would want to specify where the text field is that the text should be loaded into.
06:54Now remember, in this case, because right now we're working on the "About Us" module, if I switch over to that and look at the stage, in this case,
07:02I want the text to be loaded into this text field here in the "About Us" stage.
07:07Now, keep in mind, we're writing this LoadVars object not in the "About Us" module, but we're writing it in master.fla.
07:15Again, the reason why we're writing it there is so that we can use this same LoadVars class for all
07:22of the modules that we'd like to throughout the entire site.
07:26In other words, the action that you're about to write that tells the LoadVars object to take the loaded text
07:32and put it in the text field, it has to work throughout all of the modules.
07:37It can't be specific just to this one "About Us" module, for example.
07:43What that means is that when I tell Flash to take the text and put it into a text field, I have to tell that action which text field.
07:52What is the name of the text field to take that text and put it into.
07:56All that that means for you as a developer is that when you're using, in any of the modules, the LoadVars object to load text and then put that text
08:06into a text field, is that the text fields that you're going to have that text be inserted into should all have the same instance name.
08:15That way, as you reuse the LoadVars object that you've written into the master file,
08:21it can stay the same no matter what module you're using that LoadVars object for.
08:27So back in master, in the first key frame in layer A, in your actions panel, in the if statement in between the open
08:35and closed curly braces, type in underscore level 5.
08:40If you remember, level 5 is where we're currently loading in the splash screen.
08:45Now, as the viewer is navigating around, as you'll see in a later chapter, as they're navigating around your website,
08:52you're going to have all the contents load into that center area where the splash screen currently is.
08:59That is called level 5.
09:01So, in this case, for this particular website, level 5 is going to be, really, the loading area for the website.
09:08As the viewer selects a section of the LA Eyeworks website to navigate to, it's going to load that content into level 5.
09:16So again, as you'll see later with the "About Us" module, when the viewer clicks on the "About Us" button in the navigation bar,
09:24it's going to load that module into level 5, as well as any other module, such as Frames, "Contact Us" and so forth.
09:32So whenever you specify in your action script underscore level 5, you're referring to the content that the viewer is currently looking at.
09:41Now, in level 5, what do we want to do?
09:43And again, remember this action is telling the currently loaded module to take the loaded text and insert it into the text field.
09:51What is the name of that text field?
09:54Well, as of yet, you haven't given it a name, which is what you'll do in just a minute.
09:58The name that you're going to assign the text field to take the loaded variable text and place it inside of is going to be called Loaded Info.
10:07So after underscore level 5, type .LoadedInfo.
10:12And again, when you're assigning an instance name to a text field, as you're about to do,
10:19you follow the same naming conventions as if you were creating a variable.
10:23Make sure that it's all one word, make sure you have your capitalization correct whenever you reuse that name again and make sure
10:29that you don't have any spaces or special characters in the name.
10:33So in this case, because I essentially have two words, Loaded Info,
10:36I made them all one word by capitalizing the first letter of the second word, Info.
10:42That way, as I'm looking at it, I can see where the separation in words is.
10:45Now, what do I want to do with that text field?
10:48Well, I want to insert some text into that text field.
10:52Not only that, but as you'll see later, you're going to inserting HTML formatted text so that you can define things
10:59as bold, define hyperlinks, and so forth within that text.
11:03Because the text is going to be HTML formatted, we want that text that is going to be inserted into that text field to be HTML text.
11:13So after LoadedInfo, type .htmlText with a capital T in text.
11:20Now, htmlText is simply a property that tells Flash that the text that is being inserted into the text field is going to be HTML formatted,
11:30so that any tags that reside in the text variables that you're loading in that have HTML tags in it aren't just displayed by Flash.
11:40Instead, they'll actually be parsed.
11:43So when Flash sees an anchor tag, for example, instead of just displaying that anchor tag in the actual body
11:49of the text, it will parse it as an actual anchor tag.
11:53So that's what this .htmlText property does.
11:56So so far, you've told Flash where that text field resides at and what it's name is and you're going
12:03to insert some HTML formatted text into that text field.
12:07Now, you need to tell Flash what text you're going to insert in there.
12:11In the next exercise, you're going to tell Flash which text file it's going to be loading the variables from.
12:17Now, when you do that and Flash actually loads the variables from the text file, it's going to place those variables
12:26and its values in the LoadVars object that you've called myLV.
12:32So when you want to get access to that loaded variables and values, you're going to want to specify and tell Flash that they're in myLV.
12:41So after .htmlText, click after that line and type space, equals, space, myLV, which is your LoadVars object where the text will reside
12:53in once it's been loaded, and then you need to tell Flash what is the variable name
12:59that has the value text that you want to be inserted into this text field.
13:04You haven't yet created this, but the variable name that you're going to assign to your text in the external text file is going to be called Info.
13:14So after myLV, type .info.
13:18Then type a semi-colon to end that action.
13:21So in plain English, the actions that you've written so far says create a new LoadVars object called myLV.
13:29Once it's been detected that the text has been completely loaded into Flash, the variable value pairs have been completely loaded into Flash,
13:38take that text, take the value of the Info variable and place it within the text field called Loaded Info and make sure that it's HTML formatted text.
13:50Now that you've told Flash what to do, if the text has been loaded successfully --
13:55remember, this says if the text was loaded successfully, then do this.
13:59Now that you've specified that, in the next exercise, you're going to specify what should happen if that doesn't happen.
14:07For example, if there was some problem locating the text file to load or some problem in the loading process, what should happen then?
14:15That's what you're going to specify in your action script in the next exercise.
14:20Before you continue, as always, make sure that you save the changes to your master.fla file.
Collapse this transcript
Writing the LoadVars object pt. 3
00:01>> Since you specified what should happen if your text has been successfully loaded, you should also specify what should happen
00:10if the text, for some reason, is not successfully loaded.
00:13Again, make sure you're in master.fla, you have the first key frame in the A layer selected and you have your actions panel open.
00:22Then within your onload function, you should see your conditional "if statement".
00:28The if statement says if success, open bracket, and then an action, and then a closed bracket.
00:35Click after that closed bracket and type space, else, space, open bracket, to mark the beginning of that else statement, a couple of line breaks,
00:46and a closed curly brace to mark the end of that else statement.
00:50The way an if conditional is structured is you say if this is true then do this, otherwise, do this other thing, and that's what the "else" is.
01:00The else means otherwise.
01:03After the else you have an open curly brace and then after that a closed curly brace,
01:07to mark the beginning and the ending of what else should happen.
01:11Now if the text does not load in for some reason, what should we do?
01:16There's of course many different things that you could have happen, but in this case we're gonna have a string of text be inserted
01:22into this same loaded info text field, but of course, because the text has not been loaded in, we can't tell that text,
01:30as you have done within the if statement, to go ahead and appear in that text field.
01:34We're going to have an error message, instead, appear inside that text field, so in between the open curly brace and the end curly brace,
01:42after else, click in the empty line break, and target that same text field that you did before, underscore level five.loaded info.
01:54This time we're not going to put html formatted text in there, we're just going to put plain text inside of that text field, so type .text.
02:04then type space equals space, and we're just going to have a string of text be put inside of that text field, so type quote,
02:12there has been an error loading the requested information, please contact the webmaster and report your error,
02:33end quotation mark and a semicolon to end that action.
02:37So what this currently says is, if the text has been successfully loaded in, take the value of the info variable text,
02:46which again you will specify that info variable later inside of the text file that you're going to be loading,
02:52take that text and insert it into the loaded info text field as html formatted text,
02:59otherwise just insert this bit of text inside that same text field.
03:04And that bit of text, that you just wrote, is essentially an error message that says I'm sorry,
03:09but we couldn't load the text, contact the webmaster for help.
03:13So there is your LoadVars object.
03:16Now remember, you wrote this inside of the master.fla file.
03:20So this LoadVars object that you wrote is going to be used and reused throughout most of the modules in the LA Eyeworks site.
03:28In the about us module, it's going to be used to display the our history and our staff text.
03:34In the frames module, it's going to be used to display the information about each pair of eyeglasses frames.
03:41So as you can see, it's going to be used quite a few different times in the various modules that make up the LA Eyeworks website.
03:48So you've spent time writing this LoadVars object and the onload event handler to make it all work,
03:55but the advantage is that you can reuse it throughout these other modules.
04:00Because it is going to be reused, you've written it in such a way that you can reuse it without being too specific about the exact SWF file
04:09and the exact text field that all of this content is going to be loaded into.
04:13Now sure, you have specified that it is going to be loaded into a text field called loaded info.
04:18What that means is when you're working in the other modules, such as about us, frames, and so forth,
04:25that when you're going to be using this LoadVars object to load text from a separate text file and place it inside
04:32of a text field, that you name that text field loaded info.
04:37That way your script will go oh, okay, I'm supposed to load the text into that specific text field.
04:43Next and last, let's go ahead and mark where the end of this LoadVars object is using our commenting.
04:51Again, still in the actions panel, select the beginning LoadVars comment and copy that.
04:57Then click at the bottom of the last closed curly brace in the onload function,
05:03press return or enter to create a new line break and paste that comment in there.
05:09Then simply click before the word LoadVars in that comment and type a forward slash to mark the end of that LoadVars object.
05:16Then simply make sure that you save the changes to your master.fla file and because you've made changes to it,
05:24you should publish a new SWF file from your master.fla.
05:29So still in master, choose file, publish.
05:33That way the master SWF file has the most up to date action script that you've just written in it.
05:39In the next exercise, you're gonna learn how to then use this LoadVars object and target it from the about us module to load your external text
05:49from a separate text file into the about us module and have it be displayed just as you'd like.
Collapse this transcript
Loading the Our History text
00:00>> Now that you've written the LoadVars object into your master file, let's go and take a look at the text
00:07that we're going to be loading in to the "About Us" module.
00:11For a moment, hide or minimize Flash and then navigate into your site directory, into the LA Eyeworks directory.
00:19In there, you'll notice that there's another directory called Vars.
00:23For those of you that don't have access into the exercise files, make sure that you create a folder within your site folder called Vars.
00:30Then open up that folder.
00:32In there, you'll notice that there are a few text files that have been provided for you.
00:37One of them is called Our History.
00:40Go ahead and open up that text file.
00:42You can open it up on Windows in a simple text editor such as Notepad, or on Mac OS10 you can open it up in Text Edit.
00:49Any simple text editor will do, such as BB Edit, for example, or even Word if you're working in plain text format.
00:57In this text file is just a block of text.
01:00If you don't have access to the exercise files, just create a blank text file and fill it with some text
01:06and save it as ourHistory, with a capital H in History, all one word, .txt.
01:13Now, this is just a bunch of text.
01:15Your LoadVars object doesn't just load a bunch of text. It loads a variable value pair.
01:23That means that you need to assign a variable to this text.
01:27Inside of the ourHistory text file, click at the very beginning before the words "Los Angeles" and type info, equals.
01:37Remember, when you wrote your LoadVars object and you told Flash which text field it was going to load it into, you said that the text you were going
01:45to load into the text field was in the myLV LoadVars object and it was called Info.
01:53That's where Info here comes in.
01:55That's the name of the variable.
01:57Then you put an equals sign and then a bunch of text.
01:59Make sure there is no space both before and after the equals sign.
02:03That equals sign says to the left is the variable, to the right is the value of that variable.
02:11Now, we won't be dealing with this in this title, but if you wanted to,
02:14you could have multiple variable-value pairs in a single text file that you load into Flash.
02:20You could do that by typing an ampersand, as you can see here at the very end, the name of your next variable -- I'll call this Info 2 --
02:29equals, and then a bunch of text as the value of that new variable.
02:34And then if I wanted another variable-value pair, I could just type in another ampersand, my next variable, and so forth.
02:41So the ampersand inside of your text marks the separation between the end of a variable-value pair and the beginning of another.
02:50Now, at this point, some of you might actually be wondering, what if you want to put an ampersand
02:55and have it actually be displayed in the body of your text?
02:58For example, maybe you had the name of a business that was like Samson & Sons or something like that and you wanted the ampersand
03:05to actually be displayed instead of having Flash think that it's just a separation between a variable and value pair.
03:13In that case, you need to use something called URL encoded text.
03:17You can get more information about the various ways of displaying special characters like that by going to Macromedia's website,
03:31choosing their Flash support -- in this case, I'm going to the support home -- and I'm choosing to search for Macromedia Flash support.
03:41Search for the string URL encode, like so.
03:48One of the responses is URL encoding: Reading special characters from a text file.
03:59At that URL it has a chart that lists any special characters that you might need to use.
04:04As you can see, there is ampersand, and it says that the code you use is percent 26.
04:11So if you wanted to have an ampersand actually be displayed in the body of your text, instead of typing ampersand,
04:19you would type percent 26 to have the ampersand character be displayed in the body of the text.
04:25There is also a whole bunch of other special characters here that you might want
04:28to be displayed inside of the text instead of being translated by Flash.
04:33So, you can simply go to this web page and look up the character here.
04:39Back inside of the text file for ourHistory, I'm going to delete all the ampersand information that I was just showing you.
04:45In this case, however, all you need to make sure that's happening inside the ourHistory text file is that at the very beginning, it says info,
04:53make sure you have the spelling and capitalization correction, no spaces, it just say info equals,
05:00and then it starts with the text, Los Angeles, and then goes down from there.
05:04After you've made that change to this text file, save it and then go back to Flash.
05:11Then, switch to your aboutUs.fla and the next step would be to make sure that the text field
05:17that you're loading the text into has been given the appropriate name.
05:21So again, in aboutUs.fla, click once in that dynamic text field on the stage and look in your Properties Inspector.
05:29In your Properties Inspector, on the left-hand side, underneath this text type pull-down menu,
05:34which should say Dynamic Text, you'll see a field that says instance name.
05:38This is a unique name that you can assign to this text field, and if you remember, in the action script you wrote in master.fla,
05:46you've already defined the name of the text field that your text is going to be loading into.
05:51You called it loaded info.
05:54So again, making sure that dynamic text field is selected on the About Us stage, in the Properties Inspector, click in that instance name text field
06:03and type in there loadedInfo, making sure you have the spelling and capitalization correct.
06:09It should all be lower case and all one word, except for the I in Info should be upper case.
06:16Then I'm going to press Return or Enter.
06:19Now that you've assigned an instance name to that text field, the last step to load the text into that text field is here in the aboutUs.fla file,
06:28writing the action that tells the myLV LoadVars object that you wrote in the master.fla file to actually load a particular text file in.
06:39In Zbout Us, click the topmost layer and create a new layer.
06:45This layer is going to hold the actions for this particular module, "About Us".
06:49So rename that layer to be titled A. Then, because it is just going to be holding action script,
06:55lock that layer so that we don't accidentally put anything on the stage in that layer, select the first key frame and open up the actions panel.
07:04Now, because you've already done most of the legwork in the LoadVars object and you've written all that inside of master.fla,
07:12to get the text to load in only requires one line of code, and again, the nice thing about that is that, in any of your other modules,
07:20whenever you want to use your myLV LoadVars object to load text into the text field called Loaded Info only requires one line of code.
07:30What you write here inside of the aboutUs.fla or any other module where you want to use the myLV LoadVars object to load text,
07:40is you simply first tell Flash where the myLV LoadVars object is located at.
07:47Remember, it's located here in the master.fla file.
07:51If you also remember because the master.fla file, the actual SWF file that comes from the FLA, sits at the very bottom, everything else loads into it,
08:01whenever you want to talk to the master.swf file or any action script in it, you refer to it as underscore level 0.
08:10So here in About Us, in the first key frame of the A layer, in the actions panel, type underscore level 0 and then .myLV,
08:20making sure you have the spelling and capitalization, again, correct.
08:25And then type .load.
08:27So we're telling the myLV LoadVars object, which is in the master.swf file, level 0, to load something.
08:36After .load, type an open parenthesis and then the name and location of the text file that you want to load the variable value pairs from.
08:45If you remember, the name of the text file we want to load is ourHistory.txt, but it is located in a separate directory called Vars,
08:55so after the open parenthesis, type quote vars, which is the name of the directory that is holding all of these separate text files, forward slash,
09:05ourHistory, all one word with the capital H in History .txt, and then type an end quote, an end parenthesis, and a semi-colon to end that action.
09:19That is the only action that you need here inside of aboutUs.fla to load the variable value pairs from ourHistory.txt and then have that value
09:30of that variable be inserted into the text field that you have on the stage here in About Us.
09:36Now that you've added that action here to About Us, save the changes that you've made to this file and publish a new file SWF file from this FLA.
09:45Again, when you're loading SWF files, one into another as you're doing throughout this entire title, you're loading the aboutUs.swf
09:52into master.swf, any time you make a change to one of those module SWF files such as About Us,
09:58you need to make sure you save your changes and publish a new SWF file.
10:02I can't tell you how many support e-mails I've gotten from people who make changes to their content and when they go
10:08to view what they've changed inside of their site, they're not seeing any of those changes.
10:13And the reason why is because when they make that change, they're forgetting to publish an updated SWF file,
10:19so when they view their master.swf file and it loads in the separate modules, they're actually looking at old content.
10:27So again, make sure that you save your changes to About Us and publish a new SWF file from this FLA by choosing file, publish.
10:37Now currently, master is still set to load and show a splash page.
10:42Eventually, in a later chapter, you're going to be constructing a main menu so the viewer can click on which section they want to view and load.
10:50However, until you construct that main menu, all we're doing is we're changing the action inside of master.fla
10:57to tell it which SWF file, which module, we want to view.
11:01So go ahead and switch back to master.fla.
11:04If you accidentally close it, you can open it back up again.
11:07It's in your site directory.
11:08And inside of your master.fla file, select key frame 10 in your A layer.
11:15Select the action in your actions panel that loads in splash.swf and copy that action.
11:26Then, click at the end of that selected action, press Return or Enter once to create a new line break and paste that copied action.
11:35Simply change that copied action, instead of saying to load splash.swf, have it load about underscore us .swf.
11:43Have it load into the same level, which is level 5.
11:48Now, since we don't want both of those SWF files simultaneously loading into the same level, comment out the action that loads splash.swf.
11:57So click before the myMCL.loadclipsplash.swf action and type two forward slashes at the beginning of that action.
12:07So now, the only SWF that's being loaded into level 5 is aboutUs.swf.
12:12Save the changes you've made to master.fla and preview your movie by choosing Control Enter or Command Return.
12:21When the "About Us" module is automatically loaded, you should see your dynamic text appear there on the stage.
12:30Now, while initially, you may go, "Oh big deal," keep in mind that this text exists in a separate text file and you used the LoadVars object
12:40to load that text dynamically from that separate text file and bring it into your Flash project.
12:46As you've heard me mention before, the fantastic thing about that is that whenever you or the client wants
12:53to update any of this text, you don't have to open Flash.
12:57You don't have to open the FLA.
12:58You don't even have to own a copy of Flash.
13:00The client or you can simply go into the text file, make the change that you want to make, and then the next time somebody views your content,
13:09it will automatically show and display that updated content.
13:13So it makes, and again, as you'll see reiterated throughout this title, it makes updating and maintaining your content so much easier.
13:21That is the fantastic thing about this.
13:23So even though it may initially look, on the surface, like a simple thing, it actually is very beneficial
13:28in the long run for both maintenance and ease of use.
13:31Now that you've gotten your text to dynamically load in using your LoadVars object, in the next exercise,
13:38we're going to make sure that if there's a problem loading in the text, that the error handling that we wrote works correctly as well.
Collapse this transcript
Verifying the error handling
00:01Now that you've verified when the text loads incorrectly, that everything works just fine, let's also check the error handling that you wrote earlier
00:09to make sure that the error message appears if there is a problem loading the text file.
00:14Go ahead and close your preview window if you still have it open and again, if you remember, on the first key frame of your master.fla file,
00:23in your onLoad function, you specified what should happen if the text is loaded in and parsed correctly.
00:30However, in the else statement within your if conditional, you also wrote what should happen if there is a problem loading the external text.
00:38Let's check and make sure that this works.
00:41An easy way to do that is to simply navigate into your Vars directory inside the site directory, inside the LA Eyeworks directory on your desktop
00:51and change the name, temporarily, of the ourHistory text file.
00:56So I'm just going to change its name real quick to be something like ourHistory2.txt.
01:03Go back to my Flash project and again preview master.swf.
01:11You can see that not only does the output window in Flash, which, when the viewer comes to your website, since they're not viewing it inside
01:17of Flash itself, they're viewing it in the web browser, they won't see this output window.
01:22What they will see, however, is this error message that you should now see in the "About Us" content.
01:27It says, "There has been an error loading the requested information.
01:31Please contact the web master and report your error," which is that message that you typed inside of your action script in the master.fla file.
01:40And to give myself a little more room from now on, I'm going to close the bandwidth profiler.
01:44So we can see that the error message is, in fact working just as we intended.
01:49Now that I've verified that, I'm going to go back and make sure that you change your ourHistory text back to ourHistory.txt instead of ourHistory2.
01:59Just to make sure that everything still works okay, I'm going to go back to master and test my document once more.
02:08Now that you've gotten this dynamic text to load in, wouldn't it be nice if the viewer could actually scroll through it
02:15so that they can view all the text you have in here.
02:17If you remember, the text field, the dynamic text field, on the "About Us" stage is at a fixed size, which is how much you're currently seeing.
02:26However, there is a lot more text that can actually fit inside of that text field.
02:31It extends beyond the borders of that text field, so what we're going to do in the next few exercises is give the viewer the ability to scroll
02:39through that text by creating some buttons that the viewer can click on to enable them to scroll through that content.
02:46You're going to complete that in the next few exercises.
Collapse this transcript
Making the text scroll pt. 1
00:01>> Fortunately, making your dynamic text scroll in a dynamic text field, as simple scrolling method, is actually pretty easy to do.
00:09To start off with, make sure that you're in the About Us FLA file and that you have that up and inside of Flash.
00:15Then the next thing that we need is something that the viewer can click on to scroll through the text.
00:21That means we essentially need a button for the viewer to click on.
00:24Now there's actually already a button inside of the shared library that we can use for this purpose.
00:30So choose file, import, open external library, navigate to your desktop to your LA Eyeworks folder
00:40and into your site folder where you have your sharedlib.fla file at.
00:45Then go ahead and double-click on that to open up just the library.
00:49Earlier you selected the fonts inside of the shared library and linked them to the About Us library in the AboutUs.fla file,
00:57but there's also the button arrow button symbol that's a shared element that you can also use for this purpose inside of the shared library.
01:05Select that button.arrow button symbol and simply drag it onto the About Us library panel.
01:13That will then make a dynamic link to that button so that I can use that button as many times as I'd like
01:18and it will never actually add to the file size of the aboutUs.swf file.
01:23Because, again, it resides in our pre-cached and preloaded shared lib library.
01:29Then go ahead and close the shared lib library panel and then we wanna create a new layer to hold this button.
01:36So select the layer beneath the actions layer, create a new layer, and rename that new layer to be titled "scrolled buttons".
01:48Then in the About Us library panel select the button arrow button symbol and drag that out onto the stage.
01:56I'm gonna position mine so that it's down toward the bottom and aligned with the bottom portion of that text field.
02:04Then for my up arrow button, I'm gonna hold down my control and shift keys, on the Macintosh that would be option and shift, and I'm gonna click
02:13and drag that bottom facing arrow button toward the top.
02:17Then I'm gonna let go of my mouse and then let go of the keys on the keyboard.
02:21I've just made a copy of that downward facing arrow button, but with that copy selected, I can then choose modify,
02:29transform, flip vertical to have my up facing button.
02:33Then I just need to realign it so that the top of the button is aligned with the top of the text field, so while holding my shift key,
02:40I'm just gonna click and drag that down a little bit.
02:43So there I have my scroll up and scroll down buttons that the viewer will click on and interact with to scroll through the text in that text field.
02:51Now what you're about to do may be something utterly ground- breaking for you and completely different from what you're used to.
02:58You may be thinking okay, you have some buttons on the stage and the viewers gonna click on those buttons to make the text
03:03in this text field scroll, so that must mean you select the button, you open your actions panel
03:09and you start writing the action script on that button to make it interactive.
03:14That's not what you're gonna do in this case, as well as through the majority of the rest of the construction of the LA Eyeworks website
03:21as you're adding functionality to buttons and movie clip symbols.
03:25You're not going to add action script to those symbols.
03:28You're not gonna add it to the button symbols, you're not gonna add it to the movie clip symbols.
03:32Instead, you're gonna add the action script to your timeline.
03:36You heard me correct.
03:37What that means is you're gonna be adding action script to your timeline that is going
03:42to control the functionality of your buttons and movie clip symbols.
03:47Now the reason why you would wanna do such a thing is mostly for ease of use and enabling you to be able to look
03:54at all your action script all together so you can more easily see how everything is interacting with one another.
04:00If you add your action script directly to your symbols, as you may be used to doing, as you work with all the action script, both in your timeline
04:09and on your symbols, it can be somewhat confusing because you have to switch over and select one of those symbols, like a button symbol,
04:15open up your actions panel, look at the actions that you've assigned to that particular symbol and then click back in your key frames,
04:22look at the action script you've assigned there, and so you're constantly switching back and forth between actions that you've assigned
04:28to symbols and actions that you have in your timeline.
04:32So by keeping all of your action script in your timeline and by not assigning action script
04:38to individual symbols, you don't have to keep switching back and forth.
04:42You can look at all of your action script all together and you can see how it's all interacting with one another much easier.
04:49The first step in that process is to assign individual instance names to the symbols
04:56that you're going to be assigning action script to from the timeline.
04:59What that means is that you simply need to click once on the scroll down button on the stage in your About Us module,
05:07then in the properties inspector, click in the instance name field.
05:12We need to give that particular symbol its own unique name so that we can target it with our action script from the timeline.
05:20Again, when you're assigning instance name to symbols, you need to keep the same naming conventions as if you were creating variables.
05:27No spaces in the name, no special characters and so forth.
05:31So let's give this downward facing arrow and instance name of scrollDown, all one word with a capital D in Down.
05:40Then select the arrow that's pointing up and give it an instance name of, yep, you guessed it, scrollUp with a capital U in Up.
05:49Then select the first key frame in the A layer and open up your actions panel.
05:55So that we can better define in the actions panel where the functionality for our scroll buttons are, let's add some comments in here.
06:03Again, make sure you're in the first key frame of the A layer in aboutUs.fla file and that you have your actions panel open.
06:10In there you should see the one action you've written so far.
06:13Click at the end of that action and press return or enter a couple of times to create a few empty line breaks.
06:20Then type two forward slashes, a space, a series of hyphens, a space, and then two back slashes.
06:29Then click in the middle of all that, type a less than sign and then write scroll buttons and a greater than symbol.
06:39Select that comment that you just wrote, copy it, click at the end of that comment, press return or enter a few times and paste that copied comment.
06:51Then in that pasted comment, simply click before the word scroll and type a forward slash to mark the end of the scroll buttons functionality.
06:59Then click in the empty line break in between those two comments and here is where you're gonna write the action script
07:05that defines the functionality of both the scrolling down and the scrolling up of the text.
07:10Let's first start by getting the text to scroll up.
07:13Now when you say scroll up, the text is actually moving up, but the viewers clicking on the down button because they're clicking on the button
07:20that marks their intention, they wanna see what's down.
07:23Let's target that button that we've assigned the instance name scroll down to.
07:29Now we can do that a few different ways.
07:30We could actually write the name that we assigned that button symbol here inside of the actions panel or to prevent any kind of mis-capitalizations,
07:39or misspellings, we could simply click on this button at the top of the actions panel called insert a target path.
07:46Again, make sure that you're blinking insertion icon is here, in between the two comment lines.
07:52Then click on that "insert a target path" icon.
07:55In this insert target path dialogue box, it'll show you all the text fields and symbols that you've assigned instance names to.
08:03Select the one that says "scroll down".
08:06When you do that it'll automatically insert this .scrollDown in the field at the top, and then just click OK.
08:13You might also need to make sure that the radio checkbox "relative" is selected instead of "absolute".
08:20Then click OK.
08:22Now this is a key word that refers to this timeline that we're writing this action in.
08:28Because we're writing this action in the root of the About Us timeline, this refers to the main About Us timeline, so it says from here,
08:37there is a symbol called scroll down and that's what you're targeting and that's correct.
08:41Later, you'll see how the key word this actually changes and when it's okay and not okay to use it.
08:49In this case, just leave the keyword this there, so it says this.scrollDown.
08:54So now that we've targeted that button symbol, we wanna tell
08:57that button symbol what the viewer's going to do to it to trigger some kind of functionality.
09:03We want it, when the viewer clicks on that scroll down button for something to happen,
09:07so after scroll down type .onRelease with a capital R in Release.
09:14Then that mouse event needs to be assigned to a function, so type space, equals, space, function, open parenthesis, close parenthesis, space,
09:26open curly brace to mark the beginning of that function, two line breaks and a close curly brace to mark the end.
09:33That is how you can assign mouse events to symbols from a key frame.
09:39You simply tell Flash where that symbol is located at, the mouse event that you want to be triggered, in this case on release,
09:46when the viewer clicks on it and then you assign that to a function.
09:51Then within the open and close curly braces of that function you can tell flash what should happen when the viewer performs that mouse event
09:59on that symbol that you're targeting, on this case when you click on it.
10:02Now the viewer clicks on that text field, we want the text to move up one line.
10:08Fortunately there's a property for a text field called the scroll property.
10:12But first, let's tell Flash which text field we're targeting.
10:16If you remember, the instance name that we assigned to the text field that we wanna control the scrolling
10:20of is called loaded info, so type loadedInfo, with a capital I in Info.
10:28Now what we wanna do is modify the scroll property of that text field, so type .scroll.
10:34The way you wanna modify it is you wanna add one onto whatever it currently is.
10:40What this will do, is it will cause the text within that text field to move up one line, so after .scroll, type space,
10:49plus equals, space, one and then a semicolon to end that action.
10:55What this plus one does is it tells flash to set the scroll property of the loaded info text field to be whatever it is, but add one onto that number.
11:06That's the same, by the way, as if you wrote that the scroll property's equal to whatever the loaded info.scroll property is, but add one.
11:17So instead of having to write all that, you can simply just say plus equals one, it does the same thing, so you're setting the scroll property
11:28of the loaded info text field to be whatever it is but you're adding one onto that number.
11:33Let's test to see if this actually works as we intend it to.
11:37So before you continue, save the changes to your aboutUs.fla file and publish a new SWF from this FLA by choosing file, publish.
11:47Then switch over to master.fla and test your movie there.
11:53I can see there, my scroll down and scroll up buttons on the stage and when I click on the scroll down button, sure enough, the text scrolls down.
12:01When it gets to the end, since there's no more text to scroll to, it just stops.
12:05Now we haven't yet assigned any action script functionality to the up button, so when I click on it, nothing yet happens.
12:11But that's what you're gonna complete in the next exercise.
Collapse this transcript
Making the text scroll pt. 2
00:01>> So now that you've gotten the scroll down text functionality to work correctly, let's slightly modify that script
00:07to allow the up button to scroll up through the text.
00:11If you still have your preview window, go ahead and close it, and make sure that you're back in aboutUs.fla.
00:18Inside the first key frame on your A layer, inside of your actions panel within the scroll buttons comments,
00:25is the scrolldown.onrelease function you wrote that enables that scroll down button to actually scroll through the text.
00:32Let's copy that entire function and paste it just below it and slightly modify it to get it to work correctly for the scroll up button.
00:41So select that function.
00:42There should be three lines, this.scrolldown.onrelease all the way to the last closed curly brace.
00:48Select all three of those lines and copy them.
00:51Then, click after that closed curly brace, press Return or Enter once to create a new line break, and then paste that copied script.
01:01There's only a few things we need to change here.
01:03In the copied script, you're not targeting scroll down anymore; you're targeting the scroll up button,
01:09so change scroll down to scroll up with a capital U in Up.
01:14Then, we don't want to have the text scroll up one line, we want to have it scroll down one line, so change that plus equals one to a minus equals one.
01:26That's it.
01:27Save the changes you've made to aboutUs and publish a new SWF file.
01:34Then once more, return to master.fla and test your movie.
01:39If you click on the scroll down button, it should scroll down through the text and if you click
01:43on the scroll up button, it will scroll up through the text.
01:46So there you have really easy-to-add functionality that will allow the viewer to scroll through your dynamically-loaded text.
01:54Now, in the next few movies, which I'm marking as optional -- I'm not going to cover it in the main body of these exercises --
02:01is a separate set of optional movies that, if you like, you can walk through that shows you how to make more advanced scrolling text.
02:08The way this text is currently set up is that you have to continually click over and over on the down and up arrow buttons
02:16to scroll both down and up through your dynamically-loaded text.
02:20Sometimes, people want functionality that allows the viewer to just hold down the mouse button and, while they have the mouse button depressed
02:28on these down and up arrows, it continually scrolls down and up through the text.
02:33In the optional set of movies after this, I demonstrate how to script such a feature if you'd like it, but again,
02:40I'm not including that in the main body of the exercises as it's an optional feature.
02:45Regardless, you should give yourself a big clap on the back for not only getting your text to scroll, but before that,
02:51writing the LoadVars object that dynamically loads text from a separate text file and places it inside of the text field on your stage.
03:00It's not only an accomplishment to do that, but it's also an accomplishment because the way you wrote it and the way you got it to work enables you
03:08to use that same LoadVars object throughout any other module in the entire site
03:13and have that content still be loaded correctly with that one LoadVars object.
03:18That's a big accomplishment unto itself and you should be proud of the work you've done so far.
Collapse this transcript
Building an advanced text scroller pt. 1 (optional)
00:01>> Up until this point, you've learned how to dynamically load text into a text field and then how to allow the viewer to scroll
00:08through that text one line at a time by clicking on a few buttons.
00:13The problem with how this is currently set up is that many viewers would actually prefer to have the text scroll as long
00:20as their mouse button is depressed on either the down arrow or the up arrow buttons so that they don't have to continually click over
00:28and over to have the text scroll one line at a time.
00:32Now, to be able to have that text to just continually scroll as long as the viewer's mouse button is depressed on one of our scroll buttons,
00:40the way to do that is to write a bit of action script that is looped.
00:44So our actions are going to be similar to what you've written so far, which just tells the text to scroll down one line or up one line,
00:51but the major difference is that those actions are going to be placed inside of a loop
00:57so that the action is continually repeated over and over again for as long as you specify.
01:02Essentially, what you're going to tell Flash to do is, as long as the viewer's mouse button is depressed on the down arrow button,
01:09to have the text scroll down one line and perform that action over and over again.
01:15But as soon as they let their mouse button go, stop that process.
01:20The same applies, but in reverse, for the up arrow button.
01:23So the first step you need to take is to actually write the looping action that loops through the scrolling process over and over again.
01:32To do that, make sure that you're in aboutUs.fla.
01:35If you have it closed, you can open it back up again.
01:38Otherwise, you should still have it open from previous exercises.
01:42And then make sure that you select the first key frame in the actions layer and open up your actions panel.
01:48Here are the actions that you should have so far: You have your first line of code which loads the text into the text field and then the actions
01:56that specify when the viewer clicks on the scroll down button or the scroll up button to scroll the text inside
02:03of the loaded info text field, either down one line or up one line.
02:07Again, the first thing we need is a way to loop through a series of actions.
02:12In Flash, there are a few different ways to go about doing that.
02:15One of the methods is something called "on enter frame".
02:19An on enter frame is an event handler that basically repeats whatever actions you place inside of it
02:25over and over again until that event handler is deleted.
02:30The other way to loop through a series of actions is a function called "set interval".
02:36Now, both of those methods have advantages and disadvantages.
02:40The advantage of the on enter frame clip event is that it's very easy to set up.
02:45It doesn't require a lot of action script to write, so it's fairly easy to use and get started with.
02:51The disadvantage of it is that you don't have a lot of control over how fast it repeats the actions within it over and over again.
02:59It's essentially locked to the same frame rate of your movie.
03:03Our movies are currently set up to be 21 frames per second, so if I use an on enter frame event handler to create my looping action script,
03:12it's going to perform those actions 21 times per second until I delete it, as I mentioned previously.
03:19On the other hand, if I use a set interval function, I have more control as to how often the actions within this set interval function are performed.
03:29The set interval function gives me a lot of control as to how fast the actions are looped.
03:36The disadvantage of a set interval function is that it requires a little bit more thought and foresight
03:42and action script to actually set up and get working properly.
03:46In this case, because it is a little easier to set up and use,
03:49we're going to use the on enter frame event handler to create our looping action script.
03:54So again, in the first key frame in your actions layer, in the aboutUs.fla, click after your closed bracket after the scroll up dot
04:04on release function, press Return or Enter once to create a new line break, and let's start by creating the function
04:12that is going to hold our on enter frame event handler.
04:16So again, we're just going to start by creating a new function, so type function, space, scroll text, and then open parenthesis, end parenthesis,
04:27space, open bracket, a couple of line breaks, and a closed bracket to create the beginning of our function and the end of the function.
04:36Then, click in the empty line break in between the open and closed brackets and then now, let's go ahead and create the on enter frame function.
04:45Now, when you're creating an on enter frame function, you have to assign it to a timeline,
04:50be that a movie clip symbol instance, or to a timeline itself.
04:55In this case, we're going to assign it to the aboutUs.swf file timeline.
04:59To do that, simply type underscore root.
05:02Underscore root refers to the SWF files timeline itself.
05:07Then, type dot on enter frame.
05:12Then, we're going to assign this to a function by typing space, equals, space, function, open parenthesis, closed parenthesis, space, open bracket,
05:24and again, a couple of lines breaks and a closed bracket.
05:27Now you might be wondering why we have one function placed inside of another function.
05:32Essentially, we have nested functions.
05:34The first function we have is called scroll text and then we have another function within that
05:39that has been assigned to the on enter frame event handler.
05:43The reason why we're doing that is because if we didn't put the on enter frame event handler inside of another function,
05:50as soon as the About Us movie is played, it would automatically start looping through the actions that we placed within this
05:56on enter frame event handler that we've assigned to a function.
06:00In other words, whatever actions we place inside of this function would be automatically looped over and over again as soon as the movie first loads.
06:09Well, we don't want that to happen.
06:11We want the on enter frame event handler, and the actions we placed within its functions, to only be looped over and over again when we tell it to.
06:20In other words, when the viewer clicks on the down arrow to scroll through the text, or the up arrow,
06:26only at those points do we want this looping to occur.
06:30That's why we're placing it inside of another function.
06:33This function, and the loop inside of it, won't be triggered until we tell it to.
06:38Now, there are a few different ways to go about writing the action script to scroll through the text.
06:46What we're going to do is when the viewer presses their mouse button either on the down arrow or the up arrow button to start scrolling
06:53through the text, we're going to first set a variable, and that variable is going to store a simple string
06:59that says that the viewer is either clicking on down or up.
07:03That way, we can write one function to do the scrolling and it's simply going to check whether or not the viewer is clicking on the down arrow
07:10or the up arrow button and then it can scroll through that text in the right direction.
07:15So the first thing we want to do in our loop is check to see whether or not the viewer is either clicking on the down arrow or the up arrow button.
07:24So click inside of the on enter frame function on that empty line break you created there earlier, and then type if, space, open parenthesis,
07:35and then the name of the variable which you haven't yet created but will in just a little bit, that is going to store whether
07:41or not the viewer is clicking on the down arrow or the up arrow button.
07:45We're going to call that variable scroll direction, so type scroll, direction, again, this is all one word with a capital D in Direction,
07:55space, equals, equals, space, quote, up, end quote, end parenthesis, and then a space, an open bracket,
08:08two line breaks and a closed bracket to end that if conditional statement.
08:13So again, all this if statement says, so far, is: If the value
08:18of the scroll direction variable is exactly equal to up, then what are we going to have it do?
08:25Well, that means if the scroll direction variable is holding the text string up,
08:31that means the viewer is clicking on the up arrow, so we want the text to go up.
08:35Well, you've already written the action that does that earlier.
08:38Up above, you can see you have this dot scroll up dot unrelease equals function.
08:43And within that, it says loaded info dot scroll, minus equals one.
08:48That line right there is the line that scrolls the text up.
08:52So simply take that line, select it, and then click and drag it to move it within the if statement.
09:00Again, you're dragging it between the if open bracket and the end bracket.
09:06So if the value of that scroll direction function is up, scroll the text up.
09:11Now obviously, we need to also tell it what to do if the viewer is clicking on the down arrow, so to do that, click after the closed bracket,
09:20after your first if statement -- it says if scroll direction is up, loaded info dot scroll minus equals one, and then a closed bracket --
09:27click after that closed bracket, and then type space, else, space, if, which essentially means otherwise, if this is true, do this, else if,
09:41means otherwise, and then you're going to specify what else to do.
09:45After else if, type space, open parenthesis, scroll, direction, space, equals, equals, space, quote, down, end quote, closed parenthesis, space,
10:03open bracket, a couple of line breaks and a closed bracket.
10:08So, in plain English, what you've written so far says, if the viewer is clicking on the up arrow, scroll the text up one line.
10:16Otherwise, if they're clicking on the down arrow, scroll the text down.
10:23And again, you've already written the action that scrolls the text down one line.
10:27It's within the this dot scroll down dot on release function and it says loaded info dot scroll plus equals one.
10:35Select that loaded info dot scroll plus equals one line and then, just like you did with the loaded info dot scroll minus equals one line,
10:45you're going to click and drag it here in between the open and closed brackets after else if.
10:53So there is your completed looping script.
10:56When that script is performed, it's going to check to see whether the viewer is clicking on the down or up arrow button and then scroll the text
11:04down or up repeatedly over and over again until this function is deleted, which I'll show you how to do, again, in a little bit.
11:13But you've just completed the engine that is going to scroll the text repeatedly down and up as long as the viewer is clicking
11:20and holding their mouse button down on the scrolling arrows.
11:24In the next movie, I'm going to show you how to use this engine and hook it into those arrows so that, as the viewer is clicking on the down
11:31and up arrows, it actually scrolls through the text, and, more importantly,
11:36once they let go of the mouse button, to actually stop that scrolling from occurring.
Collapse this transcript
Building an advanced text scroller pt. 2 (optional)
00:00Now that you've written the scrolling engine which is the scroll text function here that looks to see whether the viewer is clicking on the
00:08up arrow or the down arrow and then scrolls the text appropriately in the correct direction,
00:13now that you've written that, you need to hook it in to the buttons.
00:17So that as the viewer is clicking on the down or up arrows to scroll through that text, it executes this function and tells it
00:24which button, down or up, the viewer is clicking on.
00:28Again, we're still inside the About Us FLA file.
00:31You should still have the first key frame in your actions layer selected and you should have your actions panel still open.
00:38Toward the top of your actions panel, you should see the actions that you've written previously,
00:44this dot scroll down dot unrelease equals function as well as this dot scroll up dot unrelease function.
00:52They're currently empty though there's nothing inside of those functions because in the last movie, you moved the actions within those functions
00:59into the on enterframe loop so that the text would be scrolled either down or up if the appropriate statements result to be true.
01:08However, you now want different things to happen when the viewer clicks on either the scroll down or the scroll up buttons.
01:15The first thing you want to happen when the viewer clicks on the scroll down button is to place a string, a bit of text,
01:23inside of a variable called scroll direction which you defined down here inside of your on enterframe function.
01:30Again, all this is is just a variable, a container, that is going to store a bit of text.
01:36The bit of text that it's going to store is whether or not the text should be scrolling up or down.
01:43So after your scroll down dot unrelease function click in the empty line break between the open bracket and the closed bracket
01:51and then type scroll direction space equals space quote down end quote semi-colon.
02:03So when the viewer clicks on that scroll down button the first thing that happens is
02:08that Flash is going to put this text down inside of that variable.
02:13Once you've done that, then you can execute the scroll text function which will then tell the on enterframe loop to start occurring to start playing.
02:23So after scroll direction equals down semi-colon click after that line press return or enter to create a line break and then execute
02:31that scroll text function simply by typing its name.
02:34Scroll text.
02:37Then type in open parenthesis end parenthesis semi-colon at the end.
02:43Now, as you can imagine you want to do the same thing for the scroll up dot unrelease function.
02:48So when the viewer clicks on the up arrow, it's going to perform these same actions but obviously instead of scroll direction being
02:55down because they're clicking on the up arrow scroll direction will be up.
03:00So select those two actions that you just assigned to the scroll down dot unrelease function right click
03:06or control click anywhere on that selection and choose copy.
03:10Then, click on the empty line break after scroll up dot unrelease function the empty line break being between the open bracket and the closed bracket
03:20and then right click or control click there and choose paste.
03:24If one of the lines is indented a little bit as you can see here just click before that line
03:29and then press back space or delete so that they're all lined up correctly.
03:33Then change scroll direction equals down to scroll direction equals up.
03:39Making sure to keep your quotation marks there, everything else can stay the same.
03:45Now I can test what I have so far, even though it isn't quite finished, by saving my file Control S or Command S
03:52on the Macintosh and then publishing a new SWF file.
03:56So I can choose file publish to publish a new SWF file from this FLA then go back to master, remember, you need to always test your other movies
04:08from master because they're all loaded into the master dot SWF file and then test your movie there.
04:14When the text loads in, if I click on my down arrow button even if I hold my mouse button down and then let go,
04:22it'll continually scroll through the text until it gets to the end, but if I let my mouse button go halfway
04:28through its scrolling process, it'll still keep going.
04:31It doesn't stop when I let go of the mouse button and that's because we haven't yet told our on enterframe event handler, that looping action,
04:41when it is supposed to stop that loop but now we can see that at least the scrolling part is working, so we know that part is working correctly.
04:49Now we just need to tell it when to stop.
04:52If you verify that your scrolling is working correctly, go ahead and close your preview window and go back to the About Us FLA file.
05:00Again, you should still be in the first key frame in your actions layer with your actions panel open.
05:06Now we want the scroll down and the scroll up to actually scroll through that text not when they click on the scroll down
05:14and scroll up buttons but when they press their mouse button down.
05:18When they release their mouse button, is when we want the scrolling text to stop.
05:23So the actions that you have written in the top of your actions panel, scroll down and scroll up dot unrelease,
05:30we want to change those two unreleases to be unpress instead.
05:35So for this dot scroll down dot unrelease change the unrelease to be unpress.
05:42Do the same thing for this dot scroll up.
05:47So, now, when the viewer presses the mouse button down that press will initiate the scrolling text.
05:53Now we need to define what should happen when they release their mouse button on both the scroll down and the scroll up buttons.
06:01Click after the closed curly brace after this dot scroll up dot unpress function, in this case mine's on line 11,
06:10click after that close curly brace and then press return or enter to create a new line break.
06:17Then, type this dot scroll up dot unrelease space equals space function open parenthesis close parenthesis space open curly brace a couple
06:32of line breaks and a closed curly brace then click on that empty line break between the open and close curly braces and then to stop
06:41that looping action from looping, which is causing the text to scroll, as I mentioned previously you need to delete it and remember,
06:49when you created that on enterframe event handler, I mentioned that you had to assign it to a timeline.
06:55In this case we assigned it to the underscore root timeline, the root timeline of the aboutUs.swf file.
07:02So when you go to delete it Flash needs to know, also, where it is located at.
07:07So you need to make sure that you specify the timeline that you assigned the on enterframe event handler to.
07:14So type delete space underscore root dot on enterframe making sure you have the capitalization correct
07:24and then type a semi-colon at the end to end that action.
07:29So that action just simply says delete the on enterframe event handler that has been assigned to underscore root.
07:37You want to do that same thing again but for the scroll down button.
07:42So click after the close curly brace that ends the unrelease function for scroll up press return or enter once to create a new line break
07:52and then type this dot scroll down dot unrelease space equals space function close parenthesis open parenthesis space open curly brace a couple
08:06of line breaks and then close curly brace.
08:09Then just like you did with the scroll up dot unrelease click in that empty line break
08:16and type delete space underscore root dot on enterframe semi-colon.
08:24So that action simply says when the viewer releases their mouse button from the scroll down button delete that loop
08:33so that it no longer loops through the actions thereby making the text scroll.
08:37Let's see if that does the trick.
08:39Go ahead and save the progress that you've done so far to this FLA.
08:43Make sure that you publish a new SWF file by choosing file publish and then go back to master dot FLA and test your movie there.
08:55So now, if I press my mouse button down on the down arrow, it should scroll through the text
09:01until I let the mouse button go at which point it should stop, and it does.
09:07I'm going to do the same thing for the up arrow, and I can see that as long as I have my mouse button depressed on either the down arrow
09:14or the up arrow, the text continually scrolls but as soon as I let my mouse button go, the text stops scrolling.
09:22So all that is essentially happening, if I go back and look at the action script again.
09:27Is that as the viewer presses their mouse button down on either the scroll down or the scroll up buttons, it simply sets a variable that says
09:37which direction the text should scroll, down or up, and then it executes a function called scroll text.
09:44Inside that scroll text function I've created a method to loop through a series of actions.
09:50In this case we used the on enterframe event handler that we assigned to the root timeline of the aboutUs.swf file
09:58and that on enterframe event handler loops through the actions that we place inside of its function over
10:04and over again until I delete that on enterframe event handler.
10:09In this case the actions that it is looping through simply checks to see whether or not that variable says down or up
10:17and then scrolls the text either down one line or up one line based on whether or not the viewer is pressing their mouse button
10:24down on either the scroll down or the scroll up buttons.
10:28As soon as the viewer lets their mouse button go, it simply deletes that on enterframe event handler which stops that loop
10:37from occurring thereby stopping the text from scrolling.
10:40So that is how you create some scrolling text inside of your projects that allows the viewer to continually scroll through the text for as long
10:49as the viewer has their mouse button depressed on the scrolling buttons and then stops as soon as they let go.
Collapse this transcript
Using the TextArea component
00:01>> As an aside, if writing all this action script -- writing all the LoadVars object, writing all the other action script
00:08to get your scrolling text to load in, and again, allowing the viewer to scroll through it -- if all that is just too much for you,
00:15and you would rather just have a block of text that the viewer can scroll through without all the hassle involved with it,
00:22there's a component that you can also use that will enable you to do just that.
00:27Now, in the way I'm going to show it to you here, and again there are ways around it to make it so that it is dynamic,
00:32but in the method I'm going to show you here, the text that will be displayed inside of the scrolling text field will not be dynamic.
00:39But it allows you to create some scrolling text with hardly any thought or any work on your part at all.
00:45Just for this sample, I'm going to go ahead and create a new FLA file and then I'm going to open up my components panel.
00:53To do that, I'm going to choose Window, Components.
00:59Now, the Components panel will differ depending upon if you have Flash Professional 8 or Flash Basic 8 installed.
01:06I have Flash Professional 8, so I can see additional components in here, such as data, FLV playback, and so forth.
01:14Regardless, on both Professional and Basic versions of Flash 8, you should see a component inside
01:20of the user interface section, a component called Text Area.
01:26Go ahead and drag that Text Area component out onto your stage, and again, this is just a new, blank FLA so I can demonstrate this component to you.
01:34Then I'm going to go ahead and close my components panel and what I'm going to do is I'm going to increase the size of this component a little bit
01:42so that when I put text inside of it, you can actually see that text.
01:45To do that, I'm going to select that component, and then select my free Transform tool from the toolbox.
01:51Once I do that, I can then drag on one of these corner sliders to make that text area component a little larger.
01:58The next thing I want to do is open up the parameters for this component.
02:03An easy way to do that is to choose Window, Component Inspector.
02:08This allows me to take a look at the various parameters for the specific component that I have selected.
02:13Now you'll see in here all the various sort of parameters that you can specify for the component that you currently have selected.
02:20In this case, the one we're interested in is the parameter called Text.
02:25Now let's get some text first to put inside of that component.
02:29To do that, I'm going to hide or minimize Flash for a moment, go into the LA Eyeworks folder, into the site folder, into the Vars folder,
02:38and then double-click and open the ourHistory.txt file.
02:43This is the same text file that you were working with earlier when you created your own scrolling text.
02:48Then inside that text file, I'm going to select everything except the first info equals.
02:53I'm going to copy that text, and then I'm going to go back to Flash and then double-click on this value field in this row called text.
03:03Once I get in there, I'm going to paste that text that I have copied.
03:07And then simply press Return or Enter.
03:11Now, when I test my movie, you can see that I have an easily created block of scrolling text.
03:17It has a button I can click on to scroll down and up through the text just like yours did that you created by hand,
03:23and it also has a scroll bar that I can drag on to scroll through the text.
03:28So if you just want the ability to allow the viewer to scroll through a block of text without actually having to write all the action script to get
03:36that to work properly, the text area component may be what you're needing.
Collapse this transcript
5. Using HTML and CSS
Previewing what you're building
00:01Before you get started with this chapter, let's first take a quick look at exactly what it is that you're going to be constructing in this chapter.
00:08Open up your preferred web browser and navigate to www.lynda.com forward slash intflash8, intflash8, all one word forward slash LA Eyeworks.
00:22Then, when that section loads, click on the About Us option from the main menu at the top.
00:28When the About Us, Our History text loads in, which is what you got to load in in the previous chapter, take a look at how the text is formatted.
00:37Notice, unlike what you completed in the previous chapter, there's a paragraph break in this block of text, the word "Los Angeles" is bolded
00:46and there's a hyperlink that changes when you move your mouse over it much like some hyperlinks do on regular HTML web pages.
00:54It's this formatting: The paragraph break, the bolded text, the hyperlink with the A hover,
00:59it's all that that you're going to be completing in this chapter.
01:02You're going to learn how to use a combination of HTML and cascading style sheets to give yourself that kind of styling
01:09and that sort of functionality in your dynamically loaded text.
01:13The challenge, as I'm sure you're aware of, is probably up until this point whenever you wanted to make some text bold, for example,
01:21you simply double-clicked on the text block, selected the text inside of Flash, and then either choose a bold font
01:28or clicked on the faux bold button in the properties inspector to make that text bold.
01:33The problem here, or the work around that you have to try and find, is: Because the text is loaded dynamically and the text actually exists outside
01:42of Flash you can't exactly select it inside of Flash and tell it to be bold.
01:47So how do you stylize your text?
01:49How do you make some text bold?
01:51How do you put paragraph breaks?
01:52How do you create hyperlinks and so forth.
01:55Again, you're going to do that by using a combination of HTML in CSS, and that's what you're going to accomplish in this chapter.
Collapse this transcript
Formatting text using HTML
00:01If you remember in the previous chapter, when you told the text to be placed inside of this Text Field, which is called loaded Info,
00:10you told Flash in your LoadVars object that the text that was going to be displayed inside this Text Field would be HTML formatted,
00:19that means that within your text that is going to be loaded into this Text Field you can use HTML tags and those tags instead of being displayed
00:28in the text will actually be parsed and used in the text.
00:32So, for example, if you wanted to create a line break you could use the BR tag to create that line break
00:38and that line break would actually be incorporated into the text itself.
00:42The question I'm sure you're probably wondering is, "Well what HTML tags does Flash support, which can I use?"
00:49If you open up your help panel by press F1 on your keyboard and then navigate to the book called Learning Action Script 2.0 in Flash.
00:59And then choose working with text and strings and then choose using HTML formatted text and then lastly choose about supported HTML tags it's going
01:13to show you various lists of HTML tags that Flash supports.
01:18It supports anchor, bold, break, font, image, italic, list items, paragraphs, spans, text format and the underline tag.
01:27You can get more information about how to use each of those tags by selecting them from the links here or within the
01:33about supported HTML tags book selecting any one of those tags that you want to get more information on.
01:39So, while you may initially get really excited thinking about how Flash supports HTML,
01:45temper that with knowing that it doesn't support a whole lot of HTML tags.
01:49It supports a core list of HTML items that you can use,
01:53but you should still be able to do quite a bit with the various HTML tags that Flash does support.
01:59First let's go ahead and start adding some paragraph breaks to your Our History dynamic text.
02:05For now go ahead and close your help panel, hide or minimize Flash for a moment and then on your desktop go into the LA Eyeworks directory
02:16into the site directory into the Vars directory and open up your Ourhistory.txt file.
02:24In this file let's go ahead and use HTML tags to create some paragraph breaks.
02:29Now for those of you that do have experience with HTML you may think,
02:33when you want to include some paragraph breaks, that you use the P or paragraph tag.
02:38In this case Flash does not translate that P or paragraph tag into an actual paragraph break as it does in straight HTML.
02:46To get a paragraph break you actually have to use two line breaks, two BR tags back-to-back to create that visual paragraph break.
02:56So let's create a paragraph break after the text "LA Eyeworks store in 1979", click after that and then type less
03:08than BR greater than and then do that one more time, like so.
03:14Let's insert another break about midway down through the text you'll see "LA Eyeworks works flow of intent reculture".
03:21Click after that period and then again type in two more break tags.
03:26Again, let's add another paragraph break a little further down from that you'll see "architect and artist deeply rooted in the city's culture".
03:36After "city's culture" click and type in another couple of break tags.
03:42Lastly again a little further down from that, you'll see another block of text that says "deeply rooted in the city's culture" and that's followed
03:50by "Gai Gheradi" click after city's culture period and again add lastly two more line breaks.
03:59Accept. Save the changes that you've made to the OurHistory.txt file navigate back
04:07to Flash select the master.fla file and then test your movie.
04:15When you do that, and your text loads notice how the HTML tags are actually being displayed instead of being parsed.
04:23In other words, we don't want to see break break we actually want to see a line break.
04:29Now some of you might be wondering, wait a second didn't we actually already tell the text that was going to be inserted in here
04:35to be HTML formatted text and yes we did but there's actually one more step in there in that we need to tell the Text Field called loaded Info
04:45that this text is being loaded into to parse those tags.
04:49So there's actually one more step in there to do that, close your preview window and return to your AboutUs.fla file.
04:59Select that dynamic Text Field called loaded Info on the stage and in your properties inspector next
05:06to the line type pulldown menu you'll see three buttons selectable, render text as HTML, and show border around text.
05:15Select that middle button which is render text as HTML.
05:20The same option which you're setting here manually by the way can also be set using action script.
05:25In this case we're just going to go ahead and set it manually.
05:28Once you have made that change, again, save the changes to this file and then publish a new SWF file from this FLA by choosing file publish.
05:39Once more return to master.fla and test your movie.
05:43When you do that notice how the break tags are no longer being displayed.
05:48Instead they're now actually being parsed or utilized.
05:51So if I scroll down, I'll see those line breaks that I created inside the text.
06:01So far, so good.
06:02You've added a few line breaks or paragraph breaks to your dynamically loaded text.
06:07Next let's go ahead and add a hyperlink to this dynamic text.
06:11Go ahead and close your preview window, hide or minimize Flash for a moment, and then go back to your OurHistory.txt file.
06:20Toward the top of that text file you'll see the name Neal Denari.
06:24Let's make that name a hyperlink.
06:27Click before the word Neal and type a less than A space href, href,
06:36equals quote the pound sign which is shift 3 end quote and the greater than symbol.
06:46Then click after the word Denari, type a less than symbol a forward slash A and a greater than symbol.
06:55So the beginning -- so the less than symbol and the letter A marks the beginning of the anchor tag and then after the word Denari the less
07:05than forward slash A greater than that tag marks the end of the anchor.
07:11So the words Neal Denari is now a hyperlink the pound sign means that it doesn't really go anywhere it's just a mock hyperlink,
07:18but it will still allow us to test the hyperlink here inside of Flash.
07:23Save the changes you've made to the Our History text file.
07:27This time you don't actually need to go back into Flash if you would like inside the LA Eyeworks folder in your desktop
07:34in the site folder you already have a up to date version of the master.swf file you can simply double-click
07:41on master.swf to open it up in the stand alone Flash player 8.
07:47When you do that you'll notice that Neal Denari which you added a hyperlink to does not look like a hyperlink but,
07:53if you move your mouse over it, notice how you get the hand icon representing that it is, in fact, a hyperlink.
08:00In Flash unlike with standard HTML viewing in a web browser hyperlinks don't automatically get a color assigned to them.
08:09Later you will learn how to use cascading style sheets to assign a color as well as that A hover where it changes
08:16when you roll your mouse over it for a hyperlinks in your HTML content.
08:22For now, however, it still is a hyperlink, and we can still have stuff happen when the viewer clicked
08:27on it but again right now its color is not changing.
08:30Lastly you might also notice how the text looks sort of bunched together.
08:34The ledding or the space in between each line is quite close together makes it a little more difficult to read.
08:41Let's use an HTML tag specific to Flash called the text format HTML tag that will allow us to modify the amount of ledding in between each line.
08:52To do that first close your preview window and return to your OurHistory.txt file after Info equals but before the word Los in Los Angeles,
09:03click after that equals sign type a less than symbol and then write text format space ledding equals quote 7 end quote greater than symbol.
09:19What the text format does is, among other things, allows us to specify the ledding or the amount of space
09:25in between lines you have written this text format tag right at the beginning of all the rest of the text
09:31that is going to be displayed in the Our History section.
09:35Let's specify where the text format tag should end.
09:38It's actually going to end all the way at the very end of all of this text.
09:42So click after the last period at the very bottom of the text file and then type less than forward slash text format greater
09:52than save the changes you've made to the OurHistory.txt file then go back
09:59to your site folder again and once again double-click on master.swf.
10:04When you do that notice how now your text looks much more spaced apart, so you can read it much easier now by changing the ledding
10:12and by making each line a little further apart from one another it makes it much easier for you to read through it
10:18where as before it was bunched closer together and a little more difficult to read.
10:22So, so far, you've made, actually, quite a bit of progress.
10:25You've learned how to use a few HTML tags to add paragraph breaks in the text, how to create a hyperlink, and then how to use the text format tag
10:34to be able to add more ledding to the block of text that you have loaded in here.
10:38In the next exercise you're going to learn how to use cascading style sheets to actually style this dynamically loaded text.
Collapse this transcript
Styling text using CSS pt. 1
00:00>> Now that you've learned how to use html tags in Flash to be able to format your dynamically loaded text, in the next few exercises you're going
00:10to learn how to use cascading style sheets to style that dynamically loaded text.
00:15Now, much like you were probably wondering when you learned about html inside of Flash,
00:20you're also most likely wondering what cascading style sheets tags that Flash supports.
00:25To answer that, go ahead and open up Flash, open up your help panel by pressing F1, and choose the book on the left hand side,
00:33Learning Action Script 2.0 in Flash, Working With Text and Strings, Formatting Text With Cascading Style Sheets,
00:43and then from within there, Supported CSS Properties.
00:47On the right hand side, it'll show you a list of the various CSS properties that Flash does support for your use.
00:54You can use text align, font size, text decoration, margins, font weight, kerning, font style, letter spacing, text indent, font family and color.
01:07So as you can see, there's quite a lot of CSS properties that you have available for your use
01:12as you're beginning to style your dynamically loaded text.
01:16As this isn't a title about cascading style sheets and to help you get a leg up on getting started with it, for those of you who have access
01:24to the exercise files, I've already created a starter style CSS file to get you going.
01:31If you hide or minimize Flash and then navigate to your site folder, which is in the LA Eyeworks folder on your desktop,
01:39you'll notice there's another folder in there called Styles.
01:42For those of you that don't have access to the exercise files, in your site folder make sure you create another folder called Styles.
01:50Within that folder there's another file called styles.css.
01:55CSS, of course, for cascading style sheets.
01:59You can create that file in just a simple text editor or you can create a new CSS file inside of Dreamweaver.
02:06Now if you have Dreamweaver 8 installed on your computer, which you probably will by the end of this title,
02:12you can open up that styles.css file directly in Dreamweaver and edit and create the cascading style sheets there.
02:19If you do that, this is what you're going to see.
02:23The styles.css file has a few different styles already pre-defined for you.
02:29Now as you can see in this styles.css file, using cascading style sheets, the paragraph tag, wherever that's being used inside
02:38of your text file is going to be reformatted so that the font being displayed is Bitstream Vera Sans at the size 11 pixels.
02:47Additionally, an anchor tag, a link for the anchor tag, is going to be formatted with a color as well as having a text decoration of an underline.
02:55Also for the anchor, on hover, which means when you roll over an anchor,
02:59the color is going to be changed and the text decoration is going to be set to none.
03:04As well, there are a few CSS classes that have been defined, highlight, alight right and color blue,
03:11which you will be able to utilize in later exercises.
03:14Now, depending upon which platform you're using, Windows or Macintosh, to author your Flash documents and your styles.css content,
03:24there is a few slight changes, depending upon, again, which platform you're using.
03:29Notice here, in styles.css, it's changing the font family to be Bitstream Vera Sans.
03:36As you may remember me mentioning earlier, I talked about how Windows and Macintosh had slight differences with how they organize fonts as well
03:45as font variants, such as bold and italic and so forth.
03:49Now which font family you define here, because again, we wanna use our shared font that's been defined and set up in the shared library.
03:58So if you wanna do that, what should you enter here when you wanna use one of those shared fonts?
04:03Should you use the linkage identification name that you assigned when you created that linked shared font?
04:09Or should you use the name of the actual font itself?
04:13Right here, currently it says Bitstream Vera Sans.
04:16You wanna make sure that the name of that font family matches up with the name of the font when you created the shared font in Flash.
04:25If you open Flash back up and then open the sharedlib.fla file, I can do that by choosing open recent and then seeing if sharedlib is in that menu,
04:36which it is, I'm gonna go ahead and open up sharedlib and there's my Vera font inside of the sharedlib library.
04:43If I right click, or control click on that and then choose properties, I can see that the font inside
04:49of the font pull down menu is set to be Bitstream Vera Sans.
04:53You wanna make sure that the font listed here in the font pull down menu is the same name as the font you're defining here in your styles.css file.
05:03So if you're on the Macintosh, for example, and if you wanna use the font Bitstream Vera Sans Bold, on Windows you can't do that,
05:11you have to use Bitstream Vera Sans and then you would have to use the highlight class to define that as using the font weight of bold.
05:22On the Macintosh, however, because you do get access directly to Bitstream Vera Sans bold, you can enter that name directly in here.
05:30Now at the top of the styles.css file, on both Macintosh and Windows, we wanna use the same font, Bitstream Vera Sans.
05:39However, in later exercises, we will be using the class highlight.
05:44Now currently, it says that the font weight is bold.
05:48On Windows, since this is going to be applied within where this CSS for the P tag is being defined as Bitstream Vera Sans,
05:57that font weight of bold will work fine as we're authoring it under Windows.
06:02On the Macintosh, however, you would wanna change that so instead of it being font weight bold,
06:08you would instead need to replace this with font family Bitstream Vera Sans Bold.
06:14Again, that goes back to the differences between how Macintosh's and Windows' computers organize their fonts as well
06:21as the various parts of the fonts, bold, oblique and so forth.
06:25So if you're on Windows leave the styles.css file just like it is as you can see in this video.
06:33If you're on the Macintosh, in styles.css that has been provided for you if you have access to the exercise files,
06:41under highlight change font weight bold to instead be, and I'm gonna go ahead and select it here, font family, I'm gonna copy that,
06:52under highlight I'm gonna select where it says font weight and I'm gonna replace that with what I've copied, except,
06:59again this is only for Macintosh users, instead of Bitstream Vera Sans, it's gonna be Bitstream Vera Sans Bold.
07:06Again, that change should only be made to Macintosh users.
07:10Now you may also be wondering, does that mean that Macintosh viewers that are visiting my site will see something different than Windows viewers?
07:19And no, it doesn't.
07:20It's only when you're authoring your Flash content does it actually differ.
07:25Because remember, when you go and you create your sharedlib file and when you're creating all those other modules
07:31that use those shared fonts, it's referring on your platform to these names.
07:36So you need to make sure in the styles.css file that you're also referring to those same names that are being used in the shared fonts.
07:45Now that doesn't mean anything for the end viewer.
07:48They will see exactly the same thing regardless of their platforms.
07:51It's only when you're authoring it that you need to make sure to take into account the differences between how the platforms handle their fonts.
07:59I'm gonna undo these changes since I'm demonstrating all of this on a Windows computer,
08:04but on a Macintosh computer, this is how your styles.css file should be set up.
08:09On a Windows computer, on the other hand, it should look like this.
08:12Now that you've seen the various CSS properties that Flash supports as well as how the provided styles.css is constructed,
08:20in the next exercise we're going to be applying some of these CSS styles to the our history text enabling us
08:28to style some of the elements within it to our liking.
Collapse this transcript
Styling text using CSS pt. 2
00:00>> What we're going to do next is use cascading style sheets to tell the text
00:07in the R history.txt file to be formatted using this paragraph information.
00:12In other words, that it uses the font family Bitstream Vera Sans at eleven pixels high to be displayed.
00:20Hide or minimize Dreamweaver if you opened your styles dot CSS file in there, or whichever application you used to view your styles dot CSS file.
00:28Then return to your R history dot TXT file.
00:33Now what I want to do is tell all the text inside of here to be formatted using that CSS paragraph format.
00:41So after text format ledding equals quote seven end quote greater than before the word "Los" in Los Angeles,
00:50I'm going to click and type in a less than P greater than.
00:56That marks the beginning of the paragraph tag declaration for that CSS.
01:01Then at the very end after together dot and before the end text format tag, I'm going to click right after that period and type less
01:10than forward slash P greater than to mark the end of that paragraph tag.
01:16So that essentially means that everything between the opening paragraph tag and the ending paragraph tag is going
01:22to be formatted using what I defined inside of the styles.css file.
01:27Again, returning to Dreamweaver in this case.
01:30You can see that it's going to be formatted using Bitstream Vera Sans at eleven pixels.
01:36Next what I want to do is, I want to define that the first words "Los Angeles" is bold.
01:42To do that, I'm going to use this hilight class.
01:45And again on Windows I'm simply using CSS to change the font weight to be bold.
01:51On Macintosh it's changing the font family to be Bitstream Vera Sans bold.
01:56Back inside of R history.txt after the less than P greater than, after that greater than and before the word los,
02:05click and type less than span class equals quote hilight, H-I-L-I-G-H-T, end quote greater than.
02:21So we're using the span declaration to set the class to be hilight, which is what we defined in the styles.css file
02:28to mark the beginning of where we're making some text bold.
02:32After the colon after Los Angeles, click there and mark the end of that span declaration by typing less than forward slash span greater than.
02:44So only the words "Los Angeles" and that colon will be marked as being defined using that span class of hilight.
02:52The anchor tag which you created earlier that is being applied to the text, Neil Denari is already being modified in the styles.css file
03:01so that the hyperlink is going to be changed color, and it's going to have an underline underneath it.
03:07As well it has an A hover declaration so that when the viewer moves the mouse over it, the color changes and the underline disappears.
03:15So you've already defined a hyperlink inside of the R history.txt file, and the styles.css file already has information in it
03:25to modify how that hyperlink is going to appear and be used when the viewer interacts with it.
03:31Going back to R history.txt, save the changes that you've made to this file and return to Flash.
03:40I'm going to close this font symbol properties dialogue box as well as this sharedlib.fla file that I was using to show you earlier.
03:49In the next exercise, you're going to learn how to write a little bit of action script to dynamically load that external styles.css file
03:58and use that to apply those style sheets to the dynamic text field in the about us module.
04:05Not only that, but you'll also be scripting it in a way that those styles will be always applied to the text field in any module called loaded info.
04:15That way you can use that one style sheet to affect how text in any of the other modules is being styled.
04:221
Collapse this transcript
Styling text using CSS pt. 3
00:00Now that you've seen how the styles.css file is set-up, as well as how those styles are now applied to the text inside
00:09of your OurHistory.txt file, you're going to write the actions script now to dynamically load that styles.css file and apply it
00:19to the loaded info text field here on the About Us stage.
00:23Now one important thing to know as you're doing what you are about to do, which is to dynamically load a style sheet and apply it to a text field,
00:31where dynamic text is being loaded in to, is that the styles have to be loaded
00:37and applied to the text field before the text can then be loaded and placed inside of that same field.
00:44So the field first has to know what style sheets are being applied to it before the text can be then loaded into it.
00:51So we just need to make sure, as we're writing our action script in this exercise, that we keep that load order in mind.
00:58First the CSS styles has to be loaded and applied and then the text can be loaded in after that point.
01:03To start, make sure that you're in Flash 8 and that you have the AboutUs.fla file open.
01:10Then, select the first key frame in layer A and open up the actions panel.
01:16Again, your actions script that you'll see here in the actions panel might differ slightly from what you see here in this video depending upon
01:24if you followed the additional extra optional steps available when creating the advanced scrolling text functionality.
01:31Additionally, the actions script you're about to write, that loads in the cascading StyleSheets file and applies it to the text field on the stage,
01:39the way it is written and set-up is very similar to the LoadVars scripting that you wrote in a previous chapter because of
01:47that similarity they're really almost identical to each other in terms of how it's written and how it all works, because of that,
01:54we're going to sort of speed through the action script in this exercise.
01:59Now first, let's go ahead and write a couple comment lines to sort of cordon off an area of our actions panel reserved
02:05for our cascading style sheets based actions scripts.
02:09To start off, with go ahead and select the comment line for scroll buttons just to give us a little starting point.
02:16Right click or control click on that comment line and choose "copy".
02:20Then, click before the topmost action press return or enter a few times
02:26to create a couple line breaks select the topmost empty line break in the actions panel and paste that copied comment.
02:35Then, change the word scroll buttons to read "loadcss".
02:42Then, select that comment line copy it and then click after that comment line press return or enter a few times
02:51to create some line breaks and then paste that copied comment again.
02:55This time in the copy comment click before the word "load" and type a forward slash to mark the end of that load CSS section.
03:04Much like the LoadVars scripting that you did previously, the first step is to create the new text field dot Stylesheet object.
03:12Much like the LoadVars object that handles the loading of external variables and their values into Flash, there's also a separate object
03:21for dealing with the loading and applying of external style sheets.
03:25It's called the text field dot style sheet object.
03:28So this first action you're going to write is going to create one of those new objects.
03:33In the empty line break between your two comment lines, click there and type bar space CSS Styles with a capital S in styles colon Text Field
03:47with a capital T in Text and a capital F in Field dot StyleSheet all one word with a capital S in Style and a capital S
03:57in Sheet space equals space new Text Field dot StyleSheet open parenthesis end parenthesis semi-colon.
04:10So what this does is it creates a new name, CSS styles, and assigns it to the Text Field dot StyleSheet data type
04:19and within that variable name CSS Styles it creates and assigns a new text field dot StyleSheet object.
04:27This is the equivalent of essentially a new LoadVars object except this object handles the loading and applying of external stylesheet files.
04:36Next let's use that CSS styles Text Field dot StyleSheet object to load our external StyleSheet file.
04:44So after the action you just wrote, press return or enter to create a new line break and then type CSS styles, which is the name
04:52of that Text Field dot StyleSheet object you just created, dot load.
04:57Then type open parenthesis quote and then the name and location of where that StyleSheet file is located at.
05:07If you remember, it's located in a directory called Styles.
05:11So type Styles forward clash and the name of that style sheet.
05:17If you again remember that, it's called styles.css.
05:22Then type a close quote, a close parenthesis, and a semi-colon to end that action.
05:29Now very much like the LoadVars object, when you go to use that load Vars object to load the variable value pairs from an external text file
05:38into Flash, that object is then going to start loading in.
05:42We can use an event handler to find out if that loading process was successful or not.
05:49So after the action you just wrote, press return or enter to create a new line break, then type CSSStyles.unload.
05:59Again, you should remember something identical from the LoadVars unload event handler as well where we did the same thing there
06:06and then type space equals space function space open parenthesis success colon and let's strict type this to the Boolean data type and type BOOL
06:20and it will auto complete it for you and then type a close parenthesis space an open curly brace a couple of line breaks and a closed curly brace.
06:30Then click in the empty line break between the beginning and ending of that unload function and again just like the LoadVars object,
06:38type "if" space, open parenthesis "success" closed parenthesis, space, open curly brace a couple, of line breaks, and then a closed curly brace.
06:51So, if the CSS file was loaded successfully, what do we want to happen?
06:57Well the first thing we want to happen is we want to write an action that tells Flash to then take those styles and apply it
07:03to the loaded Info text field that's on the About Us stage.
07:08So click in the empty line break between the open and closed curly braces for the if conditional statement and then write loaded Info
07:17with a capital I in Info, making sure, you, of course, have the capitalization and spelling correct dot StyleSheet which is the property
07:27of a Text Field we're applying a StyleSheet to that Text Field then we just need to tell Flash what is the name
07:34of the StyleSheet we're applying to that text field.
07:36The name of the StyleSheet is the name that you gave the Text Field dot StyleSheet object, CSS styles.
07:44So after loaded Info dot StyleSheet type space equals space CSS styles semi-colon to end action.
07:52Again, make sure that you have the spelling and capitalization correct.
07:55I may sound like a broken record each time I say that but, more often than not, many of the support questions I get for any of my titles
08:02or books almost always come back to misspelling or getting a capitalization incorrect.
08:07Now, if the CSS styles have been downloaded successfully not only do we want those CSS styles to be applied to the loaded info Text Field
08:16on the stage but at that point, and only after it's been downloaded and applied, can we then tell our LoadVars object to then load the text
08:26from the external text file and insert it into that Text Field as well.
08:30Further down in your actions panel, you already have an action that you've written previously, that tells that LoadVars object
08:37in the main master.swf file to load the variables from the OurHistory.txt file in.
08:45So in your if statement, right after the action you just wrote loaded Info dot StyleSheet equals CSS Styles, click at the end of that action
08:54and press return or enter once to create a new line break and then just drag it
09:00into that new empty line break you created within the if conditional statement itself.
09:05So now what happens is you've told the CSS Styles Text Field dot StyleSheet object to load the styles from Styles.css.
09:14If that is successful, you've told it to then take those styles and apply them to the loaded Info Text Field on the stage.
09:24After it's done that, you've then told the myLV LoadVars object which is back in master.swf to then load OurHistory.txt.
09:36So only after the StyleSheets have been downloaded and applied to the Text Field and only then do you tell the myLV LoadVars object back
09:44on master.swf that it's okay to start downloading the Our History.txt file and the variable value pairs within it.
09:53Now, again, just like the LoadVars object, you've written so far what should happen if the downloading of the StyleSheet is successful,
10:02on the other hand, you should also write what should happen if it is, for whatever reason, not successful in downloading that StyleSheet,
10:09for example, if it can't find it, or if the file is just misspelled.
10:13After the if statement click after the closed curly brace that ends that if conditional statement click there
10:21and type space, "else", space, open curly brace, a couple of line breaks, and a closed curly brace, then click in the empty line break between the open
10:32and closed curly braces that make up this else statement and type loadedInfo.txt, space, equals, space, quote, and then we're going
10:43to have a string of text be inserted into the Text Field on the stage should there be a problem downloading the StyleSheet.
10:50Let's basically type the same error message that we used in the LoadVars object.
10:55"There has been an error loading the requested information, please contact the webmaster
11:10and report your error", end quote, semi-colon to end that action.
11:17So there you have the completed action script to download the Styles.css file and all the styles within it,
11:26apply those styles to the loaded Info Text Field on the stage, once that has happened to then load the variable value pairs from OurHistory.txt
11:36and that script that does that, again, is in the master.swf file and once that information has been loaded it'll then take that text
11:45and insert it into the Text Field for you on the stage.
11:48Should there be a problem loading the styles.css file an error message will appear in that same Text Field
11:55that says there has been an error loading the requested information please contact the webmaster and report your error.
12:02So that is the script that makes up the functionality of dynamically downloading
12:06and applying the cascading StyleSheets file called styles.css.
12:10There's quite a lot going on in there but, if you look at it, you'll notice that it is very similar in structure and the way it's written between it
12:18and the LoadVars object that you wrote earlier in master.fla.
12:23Save the changes you've made to About Us and publish a new and updated SWF, again, because you've obviously made quite a few changes
12:31to this FLA file, you want to make sure that you publish an updated SWF from it by choosing file publish.
12:38Then, switch back to master.fla and test your movie.
12:43When you do, you'll notice a few things have changed.
12:47One, if you notice closely, the font that's being used for this text is the font that you're using throughout the rest
12:54of this site Bitstream Vera Sans, not only that but because of our StyleSheet file the words "Los Angeles" is bold
13:02and our hyperlink Neil Denari is now red and there's an underline underneath it.
13:08That's because of the "A" link information in that styles.css file.
13:13Within that same file there's also, of course, the "A" hover information that should change the color of that hyperlink as well as remove the underline
13:22when the viewer moves their mouse over that hyperlink, and I can see that if I move my mouse over that link.
13:28So in this chapter you learned both how to format your text using HTML tags,
13:33you used two break tags to insert paragraph breaks throughout the text, you also used the text format tag
13:41to increase the ledding between each line of the text.
13:44Additionally, you used the anchor tag to add an anchor to the text Neil Denari.
13:50After that you learned how to dynamically download and apply an external styles.css file and have that format text that is loaded
13:58into your dynamic text field. You learned how to use those styles in the StyleSheet to make text bold, to change the font,
14:06as well as to style hyperlinks both the regular link as well as the "A" hover information.
14:11So, you learned quite a lot of styling information and formatting information in this chapter alone and as you can see you can do quite a lot
14:19by using HTML and CSS to style dynamically loaded text.
14:24It's actually really exciting being able to do all that stuff to text that's dynamic, not only that, but because your text is external as well
14:33as the styles.css file, that means that you and or the client can go and not only update the text that is being dynamically loaded
14:41and placed inside of this module, but you can also modify the StyleSheet information, so should you or the client come back
14:48and later decide you want to change the color of the hyperlink or change which words are bolded and so forth you can easily do
14:55that by modifying the StyleSheet and or even the text file itself.
15:00So being able to use that external information such as the external text and the external StyleSheet, gives you a lot of control over being able
15:08to maintain and update this content at any later time.
15:12Again, as I mentioned, it also gives the client the ability to do that as well.
15:17Now the last thing that we should double check before calling this finished, is to make sure that the error handling works appropriately
15:24if there's a problem downloading and applying the cascading StyleSheets file.
15:29As you saw with the LoadVars object there's an easy way to test this and that's simply by changing the name temporarily of the styles.css file.
15:38If you have your preview window open, go ahead and close that for a moment and then hide or minimize Flash 8.
15:44Then go on to your desktop into the site folder and in there into the Styles folder.
15:52That's where your styles.css file is located at for now temporarily change the name to be something else like styles2.css for example
16:03and then go back up one directory until you locate the master.swf file.
16:08Open that SWF file in Flash 8.
16:13As you can see, it says "there's been an error loading the requested information, please contact the webmaster and report your error."
16:20That's the error message that we told Flash to display if there was a problem loading the styles.css file.
16:27So I can see based on that message that our error handling for the Text Field dot StyleSheet object is working perfectly fine.
16:35Now before I leave I want to make sure that I go back and change the name of my StyleSheet back to what it was previously of course.
16:42So back in the styles directory I'm going to change the name of that file back to just styles.css and, just to make sure it works,
16:52I'm going to reopen master.swf, and I can see that my text now loads appropriately, and it's styled the way I chose.
16:59So there you have it text that is not only imported from an external text file
17:04but is also formatted dynamically using HTML tags and styled using external CSS StyleSheet.
Collapse this transcript
6. Using the TextFormat Class
Previewing what you're building
00:01>> Before we get started with this chapter, let's first take a quick tour of exactly what it is that you're going to be building.
00:08Open up your preferred web browser and navigate to www.lynda.com forward slash int slash eight forward slash LAEyeworks.
00:20Once that website loads, click on the About Us option from the navigation bar at the top.
00:27In the last chapter, you learned how to construct the art history section that dynamically loads in this text as well
00:33as format it using html tags, and styles it using cascading stylesheets.
00:39In this chapter, you're going to learn how to build this little sub- menu over here on the left hand side that allows the viewer to navigate
00:46between the different sections of the About Us section.
00:50The default section it loads, as you built in the last chapter, is our history.
00:55But, by clicking on the our staff option, the viewer can switch to this other sub-section in the About Us section.
01:02So, in this chapter, you're going to be learning how to build this sub-menu using a new action script class called the Text Format class,
01:10which will allow you to use action script to dynamically modify how this text is being displayed and styled.
01:17So, let's get started.
Collapse this transcript
Adding the submenu
00:01Make sure that you have AboutUs.fla open inside of Flash and the first step that we want to do is
00:08to create a new layer that's going to hold our submenu.
00:11So select the layer that's underneath your "A" layer and create a new layer, rename this new layer to be titled submenu, then if you look in the library
00:23of your AboutUs.fla file you'll see a couple of pre-made movie clips for your use.
00:29One's called MC Our History, and the other is called MC Our Staff.
00:35If you don't have access to the exercise files, you can create these movie clips yourself.
00:40All that's inside of those movie clips is a dynamic text field, as you'll see in just a minute,
00:46with the text "Our History" and the other movie clip has the text "Our Staff".
00:50That's all that's inside of those movie clip symbols, then select the MC Our History movie clip symbol and drag it out onto the stage
00:59and position it to the left of the loaded Info dynamic Text Field that's on the stage, like so.
01:05You might also want to drag it around so the auto alignment feature aligns it to the top of that dynamic Text Field.
01:12Then let's open up that movie clip symbol.
01:15Select the dynamic Text Field inside of it and make sure that the font is set correctly as well
01:20as the styling for that particular dynamic Text Field.
01:24So once you drag that movie clip onto the stage double-click on it to open it up and then make sure the dynamic Text Field inside of that is selected.
01:33First, click on the font pulldown menu in the Properties Inspector and choose the shared font that you copied over earlier Vera Oblique.
01:44Again, you want to make sure you choose the shared font which is defined as having the little asterisks after the name.
01:52Then just make sure that the font rendering method is set to anti-alias for readability which is the new anti-aliasing method here inside of Flash 8.
02:00And then if you're on Windows make sure that you check the faux italic option,
02:05on Macintosh you don't need to do that but, again, on Windows you do.
02:09Now because we're going to be using action script to modify how the text inside this dynamic Text Field looks, we need to give it an instance name.
02:19So, again, make sure that you have the dynamic Text Field inside of the MC Our History movie clip symbol selected and then in the properties inspector
02:28in the instance name field give it an instance name of ourHistory, all one word with a capital H in history.
02:36As you'll see later and, again, you will be using action script to modify this dynamic text you'll be changing it using action script
02:44from Vera Oblique to Vera Bold Oblique as well as changing it's font size from 11 to 12 pixels.
02:52Once you've assigned that dynamic text field and instance name go back to scene one by clicking its tab up here above the timeline.
03:00We also need to give the movie clip symbol instance itself on the stage its own instance name as well.
03:06So make that you are that you have that movie clip symbol selected on the stage and in the properties inspector click
03:12in the instance name field then just type ourHistoryMC with a capital H in history and MC at the end capitalized as well.
03:23So now the movie clip symbol as well as that dynamic Text Field inside of it both have unique instance names.
03:30So whenever I want to be able to talk to both the movie clip as well as that dynamic text field inside
03:35of it since they both have names I can easily do so.
03:39Now we want to do those same steps for the MC ourStaff movie clip symbol that is inside of the library as well.
03:47So make sure, again, with the submenu layer still selected in scene one of aboutUs.fla take
03:53that MC ourStaff movie clip symbol and drag that out onto the stage as well.
03:59Again, I'm going to position that to the left-hand side of that dynamic Text Field on the stage.
04:05Then I'm going to double-click on that movie clip symbol to open it up with that dynamic Text Field selected I'm going to change the font
04:12to Vera Oblique, the shared font, then, because I'm on Windows, I'm going to make sure that I select the faux italic button,
04:23and I'm going to give it an instance name of Our Staff.
04:27Then I'm going to go back to scene one, make sure that that movie clip instance itself is selected
04:34and give it an instance name of ourStaffMC, like so.
04:39Now, I just want to make sure that my two movie clips symbols with the text inside of them is aligned where I want them to be aligned.
04:48So I'm going to move the ourHistory over just a little bit, like so, like that, a little closer together
05:06and there is the beginnings of the submenu for the About Us section.
05:11What you're going to do in the next exercise is begin to write the action script that will allow the Text Fields inside of these movie clip symbols
05:19to be dynamically changed using action script, that way as the viewer is interacting with these movie clip symbols, moving their mouse over them
05:26and moving their mouse off, you can use action script to tell the text inside those dynamic text fields to change as well.
05:33We're going to do that in the next exercise but before you continue on, of course,
05:38since you've made some pretty good changes to this FLA make sure that you save your FLA first.
Collapse this transcript
Writing the TextFormat objects
00:00>> Now that you have your submenu options placed in your stage, which again all those are is essentially movie clip symbols.
00:09And inside of each of the movie clip symbols is a dynamic text field with some text inside of it.
00:15The only important parts of that is that both the dynamic text field as well as the movie clip that it sits in, both have instance names.
00:24That way using action script we can not only talk to the movie clip symbol itself but to the dynamic text field inside of it as well.
00:32So now that you have those, the next step is to create a few text format objects that define how the text inside
00:40of those movie clip symbols is going to look when the viewer moves their mouse over and then off those options.
00:46Select the first key frame in the "A" layer in the aboutUs.fla file and open up your actions panel.
00:54We're going to add the action script to modify how that text looks in the submenu options at the bottom of the rest of the action script
01:02that you've already added to the aboutUs.fla file.
01:05So in the actions panel, scroll all the way down to the very bottom, click after that last comment, and create a couple line breaks.
01:15Then let's just add a comment so that later when we come back to this action script, we can clearly see what's going on here.
01:21To do that just type a couple of forward slashes, space, and then write create text format objects that define the states of the submenu options.
01:38Now you've been hearing me say that we're going to use a text format object.
01:43Now what the text format class itself allows you to do is to be able to modify how text in either a static or dynamic text field looks.
01:52You can modify the font, the font styling, such as italic or bold, you can modify the font size and so forth.
02:00So the text format object as its name implies, allows you modify the formatting of the text.
02:07We're going to use that class, rather an object of that class, to be able to modify the text that appears in our sub menu options.
02:16So the first thing that we're going to do is we're going to create a new text format object
02:20that will change how the submenu option looks when it's been disabled.
02:26In other words, when the viewer's currently looking at one of the subsections within the About Us section,
02:32the current subsection you're looking at, that option will be disabled.
02:36To put it another way, when the viewer is actually looking at the R history subsection of the about us section,
02:44in our submenu that R history option will be disabled.
02:49The viewer can't click on it because they're already viewing that subsection.
02:53So what we're doing to do is we're going to create a text format object that will change how that submenu option looks when it's been disabled,
03:02when the viewer is currently looking at that subsection.
03:06After the comment that you've just written inside of your actions panel, press return or enter to create a new line break.
03:12Then write var space btn disable.
03:18All one word with a capital D in disable.
03:22Then, strict type this to the text format data type by typing colon text format.
03:30Then, just as you've seen many times before so far in this title,
03:34type space equals space new space text format open parenthesis closed parenthesis semi-colon to end that action.
03:45So what this does is it creates a new text format object, and it assigns that to the name button disable.
03:52We will then use this text format object later to tell the submenu option text to change to look one certain way or another.
04:01What we'll actually be doing is within the parenthesis after new text format, within those set of parenthesis right there,
04:09we'll be writing how we want the text to be formatted for this button disable text format object.
04:16We can again define the font, the size, the styling, whether it's bold or italic, and so forth.
04:22There's lots of different things that we can do.
04:24If you'd like to get more information about how the text format object itself works you can open up your help panel by pressing F1,
04:33navigating to on the books on the left side, the action script 2 language reference, action script classes.
04:42Scroll down until you locate Text Format, and then if you look
04:47on the right-hand side it'll give you a little description about how the text format class works.
04:53You can see all the different various things that you can modify such as a line, bold, bullet, font, indent, italic, kerning, ledding and so forth.
05:02Additionally if you keep scrolling down, you can see there are a few different ways of writing the text format object.
05:09Notice how it says text format and then an open parenthesis at the beginning and a closed parenthesis at the end,
05:15but in between there are all the different sorts of options and properties that you can modify.
05:21First comes font, then size, then color, bold, italic, underline and so forth.
05:29Now that's important because what we're going to do is, again in between the open and close parenthesis we're going to write
05:36and define how we want the text in our submenu options to appear when that particular option is, in this case, disabled.
05:44So we want to specify the font, what font we want to use when that option is disabled, what size,
05:50what color, if it's bold, if it's italic and so forth.
05:54It also tells you what type of data type is going to be entered for those particular options.
06:00The font is going to be a string, the size is going to be a number as well as the color. Bold and italic as well as underline on the other hand,
06:08will be boolean, that means true or false.
06:11So when we're writing our text format object in between the open and closed parenthesis,
06:17we just want to make sure that we have the order right, that we're specifying how the text should look.
06:21I'm going to go ahead and close my help panel for now and then I'm going to click in the actions panel in between the open and closed parenthesis
06:30after new text format, which is what you just wrote.
06:33The first step is to write which font I want the text to use, when that button is disabled.
06:39So in other words, if the viewer is looking at a current section, we're going to have that current section submenu option be disabled.
06:46So how should it look?
06:48The font that the submenu options are using by default is Bitstream Vera Sans oblique.
06:54When that option becomes disabled I want it to use Bitstream Vera Sans bold oblique.
07:01Now on Macintosh you can define that actual font itself.
07:05You can just write, and this is what you should do if you're on the Macintosh, type quote bitstream vera sans bold oblique.
07:17If you remember again that's the name of the font that you chose when you created that shared font in the sharedlib library.
07:23And then type in end quote.
07:25So Macintosh users in the opened and closed parenthesis, after new text format, write quote Bitstream Vera Sans bold oblique.
07:35Windows users have to do that a little bit differently.
07:38Instead for Windows users, just type quote Bitstream Vera Sans end quote, like so.
07:47Then after the quote, type comma space twelve comma space null comma space true comma space true.
08:02Now again, you may be going what is the comma twelve comma null, what does that mean?
08:07Again, that's why I pointed out in the help panel to begin with, under the text format option, down towards the bottom in the help panel,
08:18it specified the order that you get to choose how the text is going to be formatted.
08:22First the font, then the size, then the color.
08:27Now in that option, we chose null.
08:30That's what we wrote when we were defining the text format object.
08:33That's means that we're not modifying or having modified the color of the text.
08:37We just wrote null which means leave it the color that it already is.
08:41And then we wrote on Windows, true comma true.
08:45That means bold should be true, that yes that text should be bolded as well as italic.
08:51True comma true means use bold, use italic.
08:54Now Macintosh users don't have to do that step because they get to choose precisely the font they want to use.
09:00Bitstream Vera Sans bold oblique.
09:03But on Windows again, we just need to tell Flash itself that we want to use bolding and we want to use italic styling as well.
09:10I'm going to again, close my help panel.
09:14So what that text format object does, when we activate it, when we say take the dynamic text field and apply the button disable text format object
09:23to it, it's going to make that text Bitstream Vera Sans bold oblique on the Macintosh.
09:29And on Windows it's going to use Bitstream Vera Sans and it's going to use the styling of bold and oblique because we specified that as true and true.
09:39So on Windows, this is how your button disabled text format option should look.
09:44It should say var button disable, colon, text format equals new text format open parenthesis quote bitstream vera sans end quote comma twelve comma
09:57null comma true comma true end parenthesis semi-colon to end the action.
10:03Now the space after the comma is optional.
10:06I add it in there because it's a little easier to read as you read through the action.
10:10Macintosh users on the other hand, your button disabled text format option should look like this.
10:26So it should say new text format open parenthesis quote bitstream vera sans bold oblique end quote comma twelve.
10:35That's it.
10:36Because you can specify the exact font face, including the styling bold oblique.
10:41In the font name itself and the only other option that you're modifying is the size.
10:46It's going be twelve point because I'm recording this title under Windows, I want to go back
10:51and leave it set to the changes that it was at for Windows.
10:55So you've just specified a new text format object called button disable, that when you apply it to a dynamic text field will set the font
11:05to be Bitstream Vera Sans twelve point bolded and italic.
11:10Next you want to create another text format object that changes how the text should look when it is not disabled.
11:17Again, you're only going to apply this text format object that you've just created to one of the submenu options when it becomes disabled,
11:26when the viewer is currently looking at the section.
11:29Now when they're not looking at that section, and the viewer can then click on that option if they'd like,
11:34we're going to create another text format object to style the text a different way.
11:39So at the end of the action that you just wrote, create another empty line break and this time type var space btn Enable, with a capital E in enable,
11:54colon text format space equals space new text format open parenthesis closed parenthesis semi-colon.
12:05Again as always, make sure that you have your spelling in capitalization correct.
12:09When you're writing text format, the T in text and the F in format should be capitalized.
12:16Then you need to specify within the parenthesis how you want the text to look with this text format object called button enable is activated.
12:25So click in between the open and close parenthesis after new text format,
12:29and on Windows write quote Bitstream Vera Sans end quote comma space eleven comma space null comma space false comma space true.
12:48Now what this means again on Windows, is that when the button enable text format object is selected, it's going to change the text
12:56to be Bitstream Vera Sans eleven point, we're not modifying the color, we don't want it to be bolded, that's what false stands for in this case.
13:06But we still want it to be oblique.
13:08So we'd leave that set for true.
13:10On Windows that is what you'd write.
13:12On the Macintosh however-- let me delete all that-- you would write quote Bitstream Vera Sans oblique end quote comma space eleven.
13:26So on Macintosh you're simply saying that you want the text to be displayed as Bitstream Vera Sans oblique at eleven point.
13:34Now again because I'm on Windows, I'm going to undo those changes so that I'm back to the way it should be formatted under Windows.
13:41Now the awesome way about how the text format object works is as you can see, it's very easy to specify a text format object and then just write
13:50in how you want the text to appear when that particular text format object is applied to your text.
13:56So here we just have two text format objects, one that is going to be selected when the text is disabled when the viewer's
14:02on that current section, and one when the text is enabled when the viewer is not on that current section.
14:09What you're going to beginning doing in the next exercise is to start defining
14:13when those text format objects should be applied to the text field submenu options on the stage.
14:20Before you continue on, make sure that you save your changes.
14:221
Collapse this transcript
Autosizing the submenu options
00:00>> Now that you've written the text format objects button disable and button enable,
00:06the next step is that you should probably disable the submenu option that is the same as the section that loads by default.
00:14If you remember, in the About Us section, when the viewer gets to that section,
00:19when that SWF file first loads, the Our History section loads by default.
00:24So when the viewer is navigating through your website and they click on the About Us option
00:29and that section loads, Our History is the section that first is visible.
00:34So we want that option to be disabled.
00:37We don't want the viewer to be able to click on it because they're already looking at that content.
00:41What we're gonna do is we're gonna utilize the button disable text format object to have that submenu option be disabled
00:49when the viewer first comes to the aboutUs.swf file.
00:52In the actions panel, again with the first key frame in your "A" layer in aboutUs.fla selected, in your actions panel click the end
01:02of the last action you wrote, then press return or enter a few times to create a couple empty line breaks.
01:08Then just write a quick comment that reads, forward slash, forward slash, space,
01:14disable the submenu option that corresponds to the currently loaded section.
01:27And then type an empty line break after that.
01:31Next, we need to target the dynamic text field that we wanna modify the text format styling of.
01:38So click on the "insert a target path" button at the top of the actions panel, open the Our History MC movie clip symbol
01:47that you see in that window and choose the text Our History.
01:51At the top of the insert target path dialogue box, you should see it, enter the path this.ourhistorymc, which is the name of the movie clip symbol
02:00on the stage, .ourhistory, which is the name of the dynamic text field within that.
02:06Make sure it's set to relative and then just simply click OK.
02:10Flash will enter the path to that dynamic text field in the actions panel.
02:15Then to apply the button disable text format object to that text field that you've specified write .setTextFormat, all one word with a capital T
02:29in Text and a capital F in format, open parenthesis, and then the name of the text format object that you want to apply to that text field.
02:38In this case, button disable.
02:42Close parenthesis, semicolon.
02:45That's it.
02:46It's actually really easy to work with and apply to your dynamic text fields.
02:51So now that you've written that, let's actually test this and see how it's working so far.
02:55Save the changes you've made to aboutus.fla and publish a new SWF file by choosing file, publish.
03:04Now you don't even need to switch over to master.fla here inside of flash, you haven't made any changes to that content, so if you'd like,
03:13if it's easier, you can hide or minimize Flash, open the LA Eyeworks directory on your desktop and open the site directory
03:21in there then simply locate master.swf and double click on that to open it in Flash Player 8.
03:29As soon as the About Us section loads, you'll notice that Our History now looks different than Our Staff.
03:36It's one point size bigger and it's not only just oblique, or italicized, it's also bolded as well.
03:42So your text format object has been correctly applied to your Our History text field on the stage.
03:49Perfect. Except now, the only thing that obviously is really wrong with it is that your text is getting cut off.
03:55If you remember, your text field that this text resided in was at a fixed size and while it was fine while the text was formatted as Our Staff is,
04:04now bolded and at 11 point, it fit and displayed that text just fine.
04:10But now you're changing the size of the text and making it bolded so it no longer fits in the size that you defined for that dynamic text field.
04:18What we're going to do next is write an action that will automatically resize that text field if the text inside
04:25of it changes size or changes to bold or italic or so forth.
04:30Once you've verified, however, that the Our History text is one point size bigger and bolded,
04:37go ahead and close your player window and return to Flash 8.
04:41Let's write the actions that tell those text fields to be auto sized before where you've written the text format objects.
04:49So again, back in aboutUs.fla, with the first key frame and layer A selected, in your actions panel,
04:56click before the comment that reads create text format objects that define the states of the sub menu option.
05:02Click before that comment line and then press return or enter a few times to create a couple empty line breaks and move all that content down.
05:11Then select backup in those empty line breaks that you created and write a new comment that reads two forward slashes, space,
05:21set the alignment of the submenu options to auto size right.
05:31Now even though you may think auto size right, that means expand to the right,
05:35don't we want them to expand to the left so that they're all aligned the same on the left?
05:40That's what auto size right, as you're about to see, does.
05:43It keeps the right hand side of the text field in the exact same space and it auto sizes or expands that text field out to the left.
05:52Once you've written that comment, go ahead and press return or enter to create another line break underneath that.
05:57Then let's start by telling that our history text field on the stage to auto size itself.
06:04So click on the insert a target path button at the top of the actions panel and once again open up the ourHistorymc movie clip symbol
06:12and then select Our History in there and then click OK.
06:18Then after that, type .autoSize, all one word with a capital S in Size, space equals space, quote, because when you specify the auto size alignment
06:32of a text field, it's a string, so you type quote, right, end quote, semicolon.
06:39That's it.
06:40Now we should also specify, while we're here, the auto size alignment of the other text field.
06:46So press return or enter on your keyboard, click on the insert a target path button at the top of the actions panel,
06:54this time open up the ourstaffmc movie clip symbol and select the text our staff inside of there and click okay.
07:03Then I can either type out .autoSize equals right or I can select that part of the action that we just wrote previously and while holding
07:11down my control key on Windows, or option on the Macintosh, I can drag that down after our staff to copy it.
07:19So now you've specified that the text fields, our history and our staff, in the respective movie clips in the stage will be auto sized to the right.
07:28That means that the right hand side of the text field will stay in the same place and will automatically expand out to the left.
07:36When you're working with auto size, the other options that you have available to you instead of right is also center and left,
07:43so you can have your text fields, when you're using them for your own uses, automatically expand both to the left
07:49and right if you have the auto size set to center, or if you have auto size set to the left,
07:54it will automatically expand the fields out to the right hand side.
07:59So now let's just make sure that it's working and displaying our text fields correctly.
08:04So save the changes you've made to about us, publish a new SWF file from this FLA by choosing file, publish, hide or minimize Flash, and then again,
08:15back in your site directory, double click on master.swf and you should now see your our history text be displayed correctly without getting cut off.
08:25That's because you specified that the auto size property of that dynamic text field should be on the right hand side,
08:31so the right hand side of the text field stays in the same place and it expands out to the left.
08:36Now remember, your Our History text, when you created it inside of Flash, looked just like our staff does.
08:42It's just italic at 11 point.
08:45But you used the text format object in action script to set the Our History text one point size bigger and bolded as well,
08:54so that Our History styling is because of the text format object that you wrote with action script.
09:00Now that you've defined how that Our History text should look, in the next few exercises, you're going to define how the text should behave
09:08as the viewer moves their mouse over and off of them.
09:12But before you continue on to the next exercise, go ahead and close your Flash Player 8 window and return back to Flash inside of aboutUs.fla.
Collapse this transcript
Creating the RollOver and RollOut states of the submenu
00:00>> In this exercise, you're gonna write a few actions that define what should happen to the submenu options
00:07when the viewer moves their mouse both off and then on to those submenus themselves.
00:13Now a lot of this is just purely review.
00:15You've already used action script inside of a key frame to modify what should happen when the viewer interacts with a button on the stage
00:24as you did when you dealt with the scrolling text inside of this aboutUs.fla file itself.
00:30You're gonna do the same thing here, but you're just going to modify what should happen
00:34when the viewer interacts with those submenu options themselves.
00:38So first, make sure that you're in aboutUs.fla, that you have the first key frame and layer A selected, and in the actions panel scroll all the way
00:47down to the bottom, then click at the end of the very last action, press enter or return to create a couple empty line breaks,
00:57and because you're going to write a decent block of actions, let's first sort of cordon off these actions with a few comment lines, so that, again,
01:06as we're scrolling down and looking at all our comments, we can clearly see where the action script
01:11that controls the interactivity for these submenu options is located at.
01:15You can either start typing in this comment from scratch or you can just scroll up until you locate one of the other long comment lines,
01:22like scroll buttons here, select that and copy it, and then just paste it.
01:27I'm gonna choose the latter option, I'm gonna select this comment line, copy it,
01:33scroll down to the bottom empty line break that I created and paste it.
01:38Then I'm just gonna change the comment name here in the middle to instead read Our History option.
01:46Then I'm gonna select that comment line, copy it, click at the end of that comment line, press return or enter a few times
01:56to create some empty line breaks and then paste that comment line.
02:00Then to mark the end of that comment, I'm gonna click before the word "our" and put a forward slash there.
02:06Now again, as you saw with the scrolling text buttons when you wanna modify the interactive behavior of a movie clip
02:14or a button symbol, you have to attach it to a function.
02:18So first, let's target the movie clip symbol that the viewer is going to be interacting with.
02:23Let's start, as the comment implies here, with the Our History option in the submenu buttons.
02:29Click in the empty line break in between those two comment lines and click on the insert a target path button at the top of the actions panel.
02:38Then from that dialogue box, select ourhistorymc and click OK.
02:44It will then insert the instance name of that movie clip symbol that we wanna modify the interactive properties of.
02:51Then after ourHistorymc, type .onRollOver, space, equals, space, function, open parenthesis, closed parenthesis, space,
03:05open curly brace, a couple of line breaks and a closed curly brace.
03:12So we're gonna modify the on rollover properties of that history mc movie clip symbol on the stage.
03:19Now what should happen when the viewer rolls their mouse over the Our History movie clip?
03:24For now, ignore the fact that we already wrote an action that tells that particular movie clip symbol, and the text inside of it,
03:32to look like it's disabled, how we want disabled to look, which is at a size of 12 pixels and bolded.
03:38Ignore that fact for now, because we're going to be defining, in this case, how we want, if all things were being equal,
03:45how we want those options to appear as the viewer interacts with them.
03:50Click in between the open and closed curly braces for that on rollover function and what we want to happen, when the viewer rolls their mouse
03:58over one of our submenu options is we want that submenu option to appear like it's disabled.
04:04It's gonna get one point size bigger and bolded.
04:07So essentially want we wanna do is exactly the same thing we did previously to make that submenu option, Our History, look disabled.
04:15We're gonna set the text format of the dynamic text field inside that movie clip symbol to be disabled.
04:21So inside of this on rollover function, click in the empty line break and write this.ourHistory.settextformat, open parenthesis,
04:35ETN disable, close parenthesis, semicolon to end that action.
04:42Now you may be saying to yourself, wait a minute, what is this.ourHistory?
04:46Don't you need to say ourHistorymc.ourHistory.settextformat?
04:51Well that's where the this keyword comes in handy.
04:55In this case we're writing some action script within a function and that function is attached to the movie clip symbol called ourHistorymc.
05:06When you're writing action script within a function that's been assigned to a timeline or a movie clip symbol, like ourHistorymc,
05:13inside of that function where you use the key word this means essentially that you're starting
05:19from where this function is being applied to, ourHistorymc.
05:23So when I use the key word "this", that means from the ourHistorymc movie clip, within there is Our History and then what we're doing
05:32to that is we're modifying the set text format property.
05:36So inside of a function that's been attached to a timeline or movie clip symbol,
05:41the "this" keyword references from that timeline or movie clip symbol down.
05:47So this means ourHistorymc, essentially, and then Our History set text format button disable.
05:55So when the viewer rolls their mouse over the Our History movie clip symbol on the stage it's going to change the text format of the text field inside
06:04of that movie clip symbol to be button disabled, in other words, it's going to appear bolded and one point size bigger.
06:10Now we need to define what should happen when the viewer moves their mouse off of that movie clip symbol.
06:16We're gonna write that below this function that you've just created.
06:20So after the closed curly brace that marks the end of the on rollover function, click after that closed curly brace
06:26and press return or enter to create a new line break.
06:30Then select that whole function, the three lines, this.ourHistorymc, that whole function all the way to the closed curly brace that ends
06:38that function, select those three lines, right click or control click on that and choose copy, then click on the empty line break
06:45that you've just created underneath that function and paste that.
06:50In this case, there's a few things we want to change.
06:53We want to change that it's not on rollover, but instead, in roll out.
06:58Now when the viewer rolls their mouse out, or off, of that movie clip symbol, we don't wanna set the text format of the dynamic text field
07:07in side that movie clip to be button disable, we wanna change it back to be what it is by default, which is button enable,
07:14so inside of the on roll out function, change this.ourHistory.settextformatbuttondisable
07:23to be button enable, like so, without the S of course, button enable.
07:29Sow when it's base functionality, that's how the Our History submenu functionality is going to work.
07:36All things being equal, when the viewer rolls the mouse over the Our History submenu option it's gonna change the text
07:43to appear one point size bigger and bolded, that's what this line here does.
07:48When they move their mouse off of that option it's gonna set it back to the way it was,
07:52which is not bolded at 11 pixels, that's what this line here does.
07:59We want the our staff option to behave the same way, so let's go ahead and take the action script that we've already written, this functionality,
08:07and copy it and just repurpose it for the our staff option.
08:12Click after the last comment line that ends the Our History option, create a couple of empty line breaks by pressing return or enter a few times,
08:20and then select all the Our History option action script, including the comment lines.
08:26So I'm gonna select all that content, again including the comment lines, and then I'm gonna hold down my control key on Windows,
08:33or option on the Macintosh, and drag that whole selected block of action script down to the bottom most empty line break that I created.
08:42Then I just wanna change anywhere I see the word "history" with "staff", so even in the comment line I'm gonna change it to be our staff option
08:52and in the closed comment line, our staff option, and then in the first action in here, I'm gonna change where it says ourHistorymc to ourStaffmc,
09:02making sure to keep the capitalization and spelling correct, and from within there I'm gonna change this.ourHistory to this.ourStaff.
09:12And then again, beneath that, ourHistorymc should be ourStaffmc and then this.ourHistory should be this.ourStaff, and there you have it.
09:23That's the base functionality for how the submenu options are going to work.
09:28Let's save these changes and test to see what we've done here has effect our submenu options.
09:34So in about us, save the changes you've made to this file and publish a new SWF file from this FLA.
09:41Then hide or minimize Flash, go into your site directory and open up master.swf.
09:50When you roll your mouse over Our Staff, you see that it becomes bolded and one pixel size bigger.
09:56It goes from 11 to 12.
09:57When you move your mouse off of it, it goes back to the way it was again.
10:01Now Our History, if you roll your mouse over that, and then off of it, you'll notice that it changes back to the way it was.
10:08Now because Our History is the section that's currently loaded, we don't want the viewer to be able
10:13to interact with that option because they're on that section.
10:17They shouldn't be able to interact with the Our History submenu option at all.
10:21It should be disabled.
10:22They shouldn't even be able to interact with it.
10:24That's what we're gonna do in the next exercise.
10:27But as you can see here, you've already accomplished quite a lot.
10:30You've created rollover options for your submenu options entirely with action script.
10:36All that you're doing is you're using the text format object to modify how the text should appear when the viewer rolls their mouse over
10:43and then off of the movie clip that contains those fields.
10:47But again, you don't want the viewer to be able to interact with the submenu option
10:51that corresponds with the section they're currently looking at.
10:54Since this is the Our History section, the viewer should not be able to interact with this option at all, as they can currently.
11:01In the next exercise you're going to fix that with a little bit more action script.
11:05Once you're finished checking to make sure everything works, close your Flash Player 8 window and go back to Flash 8 itself.
Collapse this transcript
Disabling interactivity for usability
00:00>> In the last exercise I mentioned that we were gonna prevent the viewer from being able to interact with the submenu option that correspond
00:09with the section that they are currently looking at.
00:11In other words, if they were looking at the Our History content, the Our History submenu option should be disabled.
00:18They can't interact with it.
00:20Well, how do you go about doing that?
00:22Luckily, there's a movie clip and button symbol property called enabled that you can set to be true or false depending upon if you want
00:32that symbol, the button or the movie clip symbol, to be able for the viewer to interact with it.
00:38It's actually quite easy to do and that's what you're gonna set in this exercise.
00:42Now because the Our History section is the one that loads when the viewer first comes to the About Us module, you want that option to not only look
00:52like it's disabled, where it's bold and it's 12 pixels instead of 11, but you also want that option itself to have it's interactivity turned off.
01:00The viewer shouldn't be able to interact with that option, which they currently can.
01:05So again, make sure that you're in the aboutus.fla file, that you have the first key frame
01:11and layer A selected, and that you have your actions panel open.
01:15Then scroll in the actions panel until you locate the comment
01:19that says disable the submenu option that corresponds to the currently loaded section.
01:24And here's where we already have one action that changes the way the text looks
01:29in the ourHistorymc movie clip symbol so that it looks like its disabled.
01:34Let's add one more action onto that that also disables the interactivity of that option as well.
01:41Below that, you've already written what should happen when the viewer rolls their mouse over
01:45and rolls their mouse off of that particular movie clip symbol.
01:49The action that you're about to write essentially disables all of that functionality, and that's, in this case, exactly what we wanna do.
01:57So click after the action this.ourHistorymc.ourHistory.settextformatbuttondisable, semicolon,
02:06click at the very end of that action and press return or enter to create another line break.
02:12Then click on the insert a target path button at the top of the actions panel and select the ourHistorymc movie clip symbol and click OK.
02:22Now again, movie clips and button symbols have a property called enabled, so after ourHistorymc,
02:29type .enabled, then you can set that to be true or false.
02:34True being that the button or movie clip symbol is enabled, the viewer can interact with it, or false means the viewer cannot interact with it.
02:43When they move their mouse over that movie clip or button symbol they won't see the hand icon appear, nothing will happen.
02:48They cannot interact with it, so after enabled type space, equals, space, false, semicolon to end that action.
02:58Now if you save the changes you've applied to the about us FLA file and publish a new SWF file, and then hide or minimize Flash
03:08for a moment and in your site directory open up master.swf.
03:13before, when you moved your mouse over the Our History option and then moved your mouse off of it,
03:18it would go back to looking the way Our Staff does, it would interact just like this, but now that we've added that action,
03:25when you move your mouse over and off of it, you can see that nothing happens.
03:29You've effectively disabled any kind of functionality or interactivity applied to that movie clip or button symbol.
03:36So now the viewer cannot interact with it.
03:38It's just like some plain text.
03:40I can't do anything to it at all, and that's exactly what you want.
03:44So the viewer can interact with an option that they're not currently viewing the section for, but when they're looking at a particular section,
03:51you want that button to not only look like its disabled, in this case bold and 12 pixels, instead of 11,
03:57but also physically disable its interactivity as well.
04:00In the next exercise, you're not only going to specify what should happen when the viewer clicks on one of these options, which you haven't
04:07yet set the on release functionality for any of these buttons, but you're also gonna specify when these buttons should become re-enabled.
04:16Right now, again, this Our History option is disabled and we haven't yet said when it can become re-enabled again.
04:24You're gonna do that when the viewer clicks on one of the other submenu options and you're gonna create all that in the next exercise.
04:31Before you continue on, however, make sure that you close your Flash Player 8 window and return back to your aboutUs.fla file inside of Flash.
Collapse this transcript
Enabling interactivity for usability
00:01>> If you remember, back in the sample site, when the viewer clicks on the Our Staff option, a few different things happen.
00:08One, it actually loads the Our Staff content when they click on it.
00:13The second thing that happens is that that particular movie clip symbol becomes disabled, much like the Our History does
00:19by default, so the viewer can actually interact with it.
00:23The third thing that happens is that the Our History option becomes re-enabled
00:28so the viewer can then interact with and navigate to that section if they chose.
00:32A few of those things you're gonna accomplish in this exercise.
00:36I'm gonna go ahead and close my browser window and return back to my aboutUs.fla inside of Flash.
00:42The first step is to add an on release mouse event to the ourStaffmc movie clip symbol.
00:48So again, in aboutUs.fla, make sure that you have the first key frame and layer "A" selected and that you have your actions panel open.
00:57In there, you're gonna wanna scroll all the way down to the bottom of the actions, then let's add an "on release" mouse event to that by between the
01:05on staff option comments, both the beginning and ending comment lines, click at the last closed curly brace that ends the
01:13on rollout function for the ourStaffmc movie clip symbol.
01:17Then press return or enter to create a new line break and I'm gonna go ahead and select this.ourStaffmc and while holding down my control key
01:27on Windows, or option on the Macintosh, I'm gonna drag that down to that empty line break I created.
01:34Then after ourStaffmc.
01:36I'm gonna type onRelease, then of course we wanna attach that to a function so type space, equals, space, function, open parenthesis,
01:47closed parenthesis, space, open curly brace, two empty line breaks and then closed curly brace.
01:54Now the first thing that we want to happen when someone clicks on a submenu option is that it looks like its disabled.
02:01That means, essentially, setting its text format property to be the text format that we created called button disable.
02:09So in between the open and closed brackets for the on release function, click in the empty line break you created and type this.ourStaff,
02:21which is the name of the text field inside of the ourStaffmc movie clips symbol, .setTextFormat, making sure to get the spelling
02:31and capitalization correct, open parenthesis, ETN disable, closed parenthesis, semicolon to end that action.
02:41What that means is that when someone clicks on the Our Staff option in the submenus it actually makes that text look like it's disabled.
02:49It sets it to be bold and it sets it to be one pixel size bigger than the way it was.
02:56Now in addition to that, we wanna make that option to be disabled as well, functionally, so the viewer cannot interact
03:02with it any way, as you've already seen with the Our History option.
03:06Again, as you've already seen, it's actually quite easy to do that.
03:10So after the action that you've just written press return, or enter, to create a new line break, and then type this.enabled, remember this,
03:19the keyword, when added to a function that's attached to a timeline, this refers to that timeline or symbol,
03:27so in this case when I say this, I'm essentially referring to ourStaffmc.
03:33So I'm telling ourStaffmc to set its enabled property to be space, equals, space, false, semicolon,
03:41so that that movie symbol cannot be interacted with by the viewer.
03:45Let's go ahead and test what we've done so far to make sure that it works correctly.
03:49Save the changes that you've made to this FLA and then publish a new SWF file, then hide or minimize Flash and navigate to your site directory
04:00and double-click on master.swf to open it in Flash Player 8.
04:05When you do that, because of the actions that you've already written, Our History is disabled.
04:09Not only does it look disabled, but functionally it is as well, the viewer cannot interact with it.
04:14The action script that you've just written does the same thing to the Our Staff option when the viewer clicks on it.
04:20So let's test that out.
04:21Go ahead and click on the Our Staff option.
04:23And when you do that, sure enough, it stays disabled and the viewer cannot interact with it in any way.
04:29However, now of course, the obvious problem is that none of your submenu options are enabled so the viewer can actually interact with them.
04:37Of course, you're gonna correct that later on in this exercise.
04:40But at least, the first part of this functionality, where the Our Staff option becomes disabled,
04:45both visually and functionally, is working correctly just as we've intended.
04:50Once you verify that that happens, go ahead and close the Flash Player 8 window and return to Flash 8 itself.
04:56Now in this case, because I only have two submenu options, what I can do here for my on staff, on release function is when the viewer clicks on it,
05:06I can just essentially say disable yourself, and then what we're gonna do is we're gonna write two more actions that tells the Our History option
05:13to re-enable itself, to make sure that it looks like it's enabled and to set it's enabled property back
05:19to true so the viewer can actually interact with it.
05:22However, if I was building more submenu options, instead of just two, for example maybe I have five, I wouldn't go to each one release function
05:31for each of the options and in there add actions to tell each other option to make itself be re-enabled again.
05:39Instead, what I would do is I would create a function, maybe I would call it re-enable options, and inside of that function,
05:46I would add all the actions, as you're about to see, to re-enable all the other options.
05:52Then from each of my on release options, I would add an action that just executed that function,
05:59and then after that I would then disable the option that the viewer just clicked on.
06:05That way, I wouldn't have to write the same action script over and over in each of my on release functions for each of my options.
06:14I could just write all of those actions once in a function and then simply execute that function when the viewer clicks on that particular option.
06:22Again, in this case however, because we just have two options in the About Us section that the viewer can click on, Our History or Our Staff,
06:31it would be a little extra, unnecessary work to write a function that did that same thing.
06:36Instead, from the ourStaffmc on release function, I'm just gonna write a couple more lines of code that tells the other option, Our History,
06:46to become re-enabled, so the viewer can then navigate to that other section later if they so chose.
06:52So again, just make sure that you're in the about us FLA, the first key frame and layer "A" is selected and in your actions panel,
06:59scroll down until you locate the this.ourStaffmc.onRelease function.
07:05This is what you've created earlier in this exercise.
07:08Click after the action this.enabled equals false and press return or enter to create a new line break.
07:16Now what we wanna do is tell the Our History option to become re-enabled.
07:20Not only re-enabled visually, but re-enabled functionally as well, so the viewer can then go to that other section later.
07:27So to do that, click on the "insert a target path" button at the top of the actions panel and select the ourHistorymc option and then click OK.
07:37Now remember, the this keyword means that from within a function that is attached to a timeline or symbol, such as the ourStaffmc movie clip symbol,
07:47that the this key word starts from that point and goes down.
07:52So if I leave the this keyword in place that means that I'm starting from the ourStaffmc movie clip symbol and I'm telling Flash to look inside
08:01of there for another movie clip symbol called ourHistorymc.
08:05Well the problem is, that's not how our movie is structured.
08:08OurHistorymc is not inside of ourStaffmc, it's in the main timeline here in about us.
08:15So when I'm using the this keyword inside of a function that's attached to a timeline or symbol,
08:20as it is here, I need to be careful how I use that this keyword.
08:24In this case, I wanna remove it, so remove this., it should just say ourHistorymc.
08:31After that, type .enabled, space, equals, space, true, semicolon
08:38to make the ourHistorymc movie clip symbol re-enabled so the viewer can then interact with it.
08:44Remember, this is all added to the ourStaffmc movie clip symbol, so when the viewer clicks on Our Staff, we want Our History to become re-enabled.
08:52Now that action re-enables it functionally, but not visually.
08:56To do that, we need to change the text format that's being applied to the text field inside of that movie clip symbol.
09:03So after the action that you just wrote, press return or enter to create a new line break, and then again, click on the insert a target path button
09:10at the top of the actions panel, open up the ourHistorymc movie clip symbol,
09:16and select the text field Our History inside of there and click OK.
09:21Again, we wanna make sure that we remove the this keyword at the beginning of that, and then after ourHistorymc.ourHistory, click after that,
09:30and type .setTextFormat, open parenthesis, btn Enable, close parenthesis, semicolon to end that action,
09:42so what those two actions that you've just written do is when the viewer clicks on the Our Staff option it tells the Our History option
09:49to become re-enabled functionally and make it appear like it's re-enabled.
09:55It sets the text format back to the button enabled text format object.
10:00Let's test this first to make sure that it works, so save the changes, and then choose file publish to publish a new, updated SWF file.
10:09Then hide or minimize Flash and in your site directory double-click master.swf.
10:16Now when I click Our Staff, those two actions that you've just written should make Our History become re-enabled.
10:22Go ahead and click Our Staff.
10:23And when you do, sure enough, Our History goes back to the way it was and the viewer can now interact with it just fine.
10:30So I know that that part of the functionality is working correctly.
10:33Perfect. Now, of course, the opposite is now the problem.
10:37When the viewer clicks on Our History, Our Staff does not become re-enabled again, just like it does when the opposite is the case,
10:44so we're gonna go ahead and make that correction next.
10:47Close your Flash Player 8 window and then return back to Flash again.
10:52In your actions panel, scroll up until you locate the Our History actions for the Our History option.
10:59Now to save ourselves a little bit of time, I'm actually going to scroll down again and select all the actions that I've attached as the
11:06on release function to the ourStaffmc movie clip symbol.
11:10To do that, I'm gonna select all of those lines of code, it should start with this.ourStaffmc.onRelease
11:17and all the way down to the last closed curly brace.
11:20Then I'm gonna control click, or right click, on that selected code and choose copy, then I'm gonna scroll up a little bit
11:28until I locate the this.ourHistory.onrollout function and I'm gonna click after the closed curly brace that ends that function,
11:37then I'm gonna press return or enter once to put an empty line break underneath that and choose to paste that copied code.
11:44What I wanna change here, obviously, is any code that refers to ourStaffmc, I wanna switch it over to Our History, so on this top line,
11:52I wanna change ourStaffmc to ourHistorymc and then underneath that I can see
11:58that it says Our Staff set text format button disable, I wanna change Our Staff to Our History.
12:07This.enbabled, because it's simply referring to the same timeline that the function is being attached to,
12:13which is ourHistorymc, that whole action can remain the same.
12:17Underneath that, however, our two actions that set the enabled properties of the Our History option back
12:24to true, so it's gonna re-enable the Our History section.
12:28But because these actions are being attached to the Our History movie clip, we don't wanna set itself to be re-enabled,
12:33we wanna set the our staff option to be re-enabled, so in the bottom two actions,
12:39within the Our History mc on release function, change the word "History" to "Staff".
12:45And in the last action there, ourStaffmc.ourStaff, that way, when the viewer clicks on one option,
13:00it disables itself and then tells the other option to be re-enabled.
13:04The same holds true for the other options.
13:06So each option disables itself and then sets the other to be re-enabled.
13:10And that's exactly what you've just accomplished here.
13:13Let's go ahead and test that to make sure that it works correctly before continuing.
13:16So save the changed you've made to this FLA and publish an updated SWF.
13:21Then hide or minimize Flash and in your site directory, double-click on master.swf.
13:28Currently, because we've written the action to tell it to do so, the Our History option is disabled,
13:33because that is the section that the viewer sees by default, but then click on our staff.
13:39When you do that, instantly the our history option becomes re-enabled so the viewer can then navigate to that section
13:45if they choose, and the Our Staff option becomes disabled.
13:49Now the actions that you've just wrote do the opposite when the viewer clicks on the Our History option, so let's test that out.
13:56When I click on Our History, Our Staff surely enough becomes re-enabled and the Our History option becomes disabled again.
14:03So that part of the functionality works perfectly.
14:06Obviously, the last step to make this About section complete is to actually add the action script to both the Our Staff and Our History options so that
14:15when the viewer clicks on those options it actually does what it's supposed to do and loads in the content for those particular sections.
14:22You're gonna accomplish that in the next few movies.
Collapse this transcript
Loading the text
00:01>> Currently, when the viewer clicks on the submenu options Our History and Our Staff,
00:06besides the options themselves becoming disabled or re-enabled, nothing else actually happens.
00:13The content itself doesn't actually load in, which sort of defeats the purpose of having the submenu options in the first place,
00:19but that's what you're gonna accomplish in this movie.
00:22So when the viewer clicks on the Our Staff option, you want it to load in the Our Staff text just like Our History loads
00:29in when the viewer first comes to the About Us section.
00:32For those of you that have access to the exercise files, I've already created the text content for Our Staff for you.
00:39To view that, hide or minimize Flash, go to your site directory in the LA Eyeworks directory that you copied onto your desktop earlier,
00:48in there go into the Vars folder, and in the Vars folder where your Our History text is that you were working
00:54with earlier, is another text file called ourStaff.txt.
00:59For those of you that don't have access to the exercise files, in notepad or text edit or another simple text edit that you have access to,
01:07create a new, blank text file called ourStaff.txt, for those of you, again, that don't have access to the exercise files.
01:16For those of you that do, open up that ourStaff.txt file, in there you'll see a block of text, this is just greeking text,
01:24text that is just gibberish, that doesn't make any sense, to act as a place holder for us.
01:28But what you'll notice is the variable information as well as the html and CSS information has already been entered in here for you,
01:37just like you did previously for the ourHistory.txt file.
01:41Again, for those of you that don't have access to the exercise files, if you'd like, you can just take the text that's inside
01:47of the ourHistory.txt file, select it, and paste it into your ourStaff.txt document and start from there.
01:56Now what we wanna do is when the viewer clicks on the Our Staff option, we wanna have it load in this Our Staff text,
02:02so go ahead and go back into Flash and make sure, of course, that you're in the aboutUs.fla file,
02:08in the first key frame of layer A and that you have your actions panel open.
02:14As you say in a previous movie, to get the text for the Our History section to load in, required essentially one action
02:22that told the myLV LoadVars object in master.swf to load the content from that particular text file.
02:31Inside of About Us, if you scroll up a bit, you'll locate that action.
02:37You can see that it's here inside of the cssStyles.onload function and it says underscore levelzero.myLV.load inside the Vars,
02:48load the text file ourHistory.txt, select that action and copy it, then scroll down to the Our Staff options and underneath the
03:00on release action is where you're gonna add this action that loads the variables from the ourStaff.txt file into here.
03:09Click after the ourStaffmc.onRelease function, click after that open curly brace, press return or enter to create a new line break
03:17and then paste the action that you have in your computer's clipboard.
03:22Now everything can stay the same, but of course, what you wanna change is the text file that we're loading the variables from.
03:28This action is being added to the Our Staff option, so we wanna load the variables
03:32from the ourStaff.txt file, so change ourHistory.txt to ourStaff.txt.
03:40Conversely, when the viewer clicks on Our History, you want it to, again, load the Our History content.
03:47Because if the viewer comes to your About Us section and they read through the history of the LA Eyeworks stores then they wanna get information
03:55about the staff, so they click on the Our Staff option, which then loads the Our Staff content,
04:01but then if they click back on the Our History option you obviously wanna reload the Our History content.
04:08Now unlike what you had to do when the aboutUs.SWF file reloads, you don't have to reapply and re-download the CSS information.
04:17The CSS information has already been downloaded and applied to that text field when the aboutUs.swf file first loads.
04:24So you don't need to do it again.
04:26When someone click on the Our History option, you don't have to go through all that again, you can just tell it to load the variables
04:32from the ourHistory.txt file, so inside of your actions panel, scroll up until you see the ourHistory.onRelease function,
04:42click at the end of the open curly brace that marks the beginning of that function, create a new line break,
04:49and then paste that action that you still have in your computer's memory.
04:53In this case, it still says use the myLV LoadVars object on the master SWF file to load the variables inside of ourHistory.txt.
05:04Before we continue, let's make sure that this all works correctly.
05:07So save the changes you've made to this FLA and publish an updated SWF file, file, publish.
05:13Then hide or minimize Flash, and I'm gonna go ahead and close the ourStaff.txt file for now,
05:20and then back in your site directory, locate and double click master.swf.
05:26When you do that, and then click on the Our Staff submenu option, the Our Staff text should now load in correctly, and which it does.
05:35When I click back on Our History, the Our History content loads in.
05:39So there you now have an actual, working and functional submenu system.
05:44When the viewer clicks on one of these options, the correct information loads in perfectly.
05:49Now we're gonna spice up this Our Staff subsection by embedding inline some animated SWF files that the text will actually wrap around.
05:59That was a feature that was added to Flash MX 2004 and we're gonna carry it forward to Flash 8, just because it's such a cool feature.
06:06Being able to take your dynamically loaded text and have it wrap around some embedded, inline images,
06:12and you can do it either do it with JPG, SWF, PNGs or GIF.
06:16In this case, because it looks more interesting, we're gonna use animated SWF files that the text will actually wrap around.
06:22When you're finished however, making sure that the functionality works correctly, as you've just seen,
06:27close the Flash Player 8 window, and then go back to your ourStaff.txt file.
06:33If you've closed this by accident, you can go back into your site directory and then open
06:39up the Vars directory and open up your ourStaff.txt file within there.
06:44In the next exercise, we're gonna make a few modifications to the text inside of this text file
06:50to integrate those inline SWF files within the text.
Collapse this transcript
Creating the Our Staff subsection
00:01>> Now before you start editing the ourStaff.txt file to embed inline within this text some SWF files, you should obviously probably know
00:10where those SWF files that you're going to embed in here reside at.
00:15If you go into your site directory again that you copied over earlier, you'll notice there's another folder called SWFs.
00:22S-W-F-S. If you don't have access to the exercise files, go ahead and create that directory now inside of your site directory.
00:30Inside of that SWFs directory, you'll notice that there are a few pre-provided SWFs for you.
00:35The one's we're interested in, in this case, are staff01.swf and staff02.swf.
00:40If you double click on either one of those SWF files, you'll see that it's just a simple image
00:46that actually just animates across three images over time.
00:50It's these SWF files that we're going to embed inline in the ourStaff.txt file so that the text
00:57that we have in there wraps around these animated SWFs.
01:00Again, you could of course do the same thing with JPG's, PNG's, or GIF's.
01:04Once I've previewed that, I'm gonna go ahead and close my Flash Player 8 window.
01:08Now one thing you need to know is how big those images are, in this case, how big this SWF is.
01:15I happen to know because I created those files, that they're 75 pixels wide by 75 pixels high.
01:21If you wanna see how those SWF files were constructed, by the way, for those of you that have access to the exercise files,
01:28if you go back into the site directory and you scroll down a little bit, you'll notice that there are two FLA's called staff01 and staff02.
01:36These are the FLA files that were used to generate those SWF files.
01:41Then go back to ourStaff.txt.
01:45Now one thing that's a little bit different with what you're about to do, in regards to how working with html pages works, is for example,
01:52if this was an html page, and I wanted to embed images inside of it, I would have to first tell my html page
02:01where those images resided based on where my html page was.
02:06For example, if my html page was in one directory and my images were in a separate directory,
02:13I would need to tell my html page where my images reside at.
02:17Hey, they reside in this directory and the image name is called this.
02:22You have to do the same thing here when you're embedding an image or SWF file inline inside of this text,
02:28but you don't write the path to that content relative to where this text file is,
02:33you write it relative to where the SWF file is that this text loads into.
02:39In other words, if I go back into my site directory, in my Vars folder is where this text file resides at, one directory up from that,
02:48where the site directory is, is where the SWF's directory is that contains the SWF files we're gonna place inside of that text file.
02:56Now again, I don't write from the text file within the Vars folder that the SWF's is one directory up in the SWF's folder and then the name
03:05of the SWF is such and such that we're going to load.
03:08I write it relative from where the SWF file that the text in the Vars folder loads into, which is About Us.
03:16So whenever I'm writing in a text file to embed inline a JPG, a GIF, PNG, or SWF file,
03:23I need to write it relative from where the SWF file is that the text is loaded into.
03:29So I don't have to say go up one directory and then go into SWF's,
03:32I just say go into the SWF's folder and the image is inside there that I wanna place.
03:38So back in the ourStaff.txt file, I need to write in the code that embeds that SWF file inline within the text.
03:45I'm gonna have the first SWF be embedded right before the words lorem ipsum delor.
03:51Not only that, but I'm gonna have it be embedded in here before the paragraph tag, so after text format ledding equals seven,
03:58after that greater than symbol, but before the paragraph tag, I'm gonna click right there
04:03and I'm gonna write the html code to embed inline the SWF file within this text.
04:09To do that type less than, IMG, space, SRC, and this part will be very familiar for those of you who are used to creating html content, equals,
04:20quote, SWFs, which is the name of the directory that my content resides in, forward slash, S-T-A-F-F, staff, dash, 01, dot, SWF, end quote, space,
04:37and I need to specify what the width and pixels is of that SWF file, so I type width, equals, quote, 75, end quote.
04:49I also need to specify the height, so I'm gonna type space, height, equals, quote, 75, end quote.
04:57And then I also need to specify how the text is going to wrap around this image, well I want the image to be on the left hand side and the text
05:05to wrap around the left and bottom, so I'm gonna set the alignment of this SWF file to be left so the test wraps around it to the right.
05:13So I'm gonna type now space, align, equals, quote, left, end quote.
05:22I also want a little bit of space to be around the outside, both left and right, the horizontal space, as well as how much space is on the top
05:30and bottom of this SWF file so that the text, as it runs around the image, doesn't run around right to the edge of the image.
05:37I want a little bit of visual space in there, so to do that, I'm gonna type space, H, space, the actual word space,
05:45H Space is horizontal space, equals, quote, 10, end quote.
05:50So I want 10 pixels of space on both sides of my SWF file so the text doesn't run right to the edge.
05:58I wanna add some vertical space in there too, so I'm gonna type space, V space, equals, quote, in this case I'm just gonna add five pixels,
06:07so I'm gonna type 5, end quote and then I'm gonna type a greater than symbol.
06:11Now if I save the changes that I've made to ourStaff.txt, and then go back into my site directory real quick and double click on master.swf,
06:21when I click on the ourStaff submenu option to load the ourStaff.txt file in, I can see when I do that that now
06:29that SWF file appears inline embedded within that text.
06:33Even as I scroll through that text, you can see that that image still stays aligned within that text.
06:39It's a great feature that was introduced with Flash MX 2004 and again we're using it here inside of Flash 8.
06:45I wanna embed one more SWF inline within this text right before this greeking text here.
06:52So I'm gonna go ahead and close the Flash Player 8 window and return to ourStaff.txt.
06:57Rather than write all that information again, like we just did, I'm gonna select everything from that less than symbol before image source
07:06and all the way to the greater than symbol that comes after V space equals five.
07:11Once I've selected that I'm gonna copy it and then I'm gonna locate my span class highlight tag that is further down in the body of text.
07:20Then I'm gonna click right before that span class tag and right after the two break tags and paste that code that I just copied.
07:29The only thing I need to do is change where it says SWFs staff01 to staff02 instead.
07:37Then I'm just gonna save my changes again to ourStaff.txt, go back into my site directory and once more open up master.swf.
07:47when I click on the Our Staff submenu option, I can see that now, both those SWFs load in, and the text inside of the Our Staff content loads
07:55and wraps around those SWF files, again, a really cool feature that we're utilizing here inside of Flash 8.
08:02Now that you've done that, you've completed the entire About Us module.
08:06You've created two subsections, Our History and Our Staff, that both dynamically load external text
08:12that is styled using cascading style sheets and formatted using html tags.
08:18Not only that, but the Our Staff section has embedded inline SWF files that animate as the text wraps around it.
08:26So there's lots of new stuff going on inside the About Us section.
08:30You also learned how to use the text format class to be able to dynamically adjust how the text inside of our submenu options appears,
08:39even as the viewer interacts with those options as well.
08:42As you'll see in a later chapter, you'll be revisiting the text format class to be able to create the main menu at the very top of the site.
08:50But there you have the completed and finished About Us module.
08:54Congratulations on doing that.
08:55In the next chapter, you're going to learn how to create a slide show for the frames section.
Collapse this transcript
7. Building a Slideshow
Previewing what you're building
00:00>> In this chapter, you're going to learn how to create a dynamic slide show, a dynamic slide show that not only uses the LoadVars class,
00:10which you've seen before, but also utilizes the MovieClipLoader class that exists in master.swf.
00:16Before we get too far into it, however, let's take a look at exactly what it is that you're going to be building before we get exerted.
00:23Open up your preferred web browser and navigate to www.lynda.com, forward slash, intFlash8, forward slash, LAEyeworks.
00:37When the site loads up, click on the frames option from the navigation bar at the top.
00:43The image that you see appear there, a picture of a set of eyeglasses frames, does not exist inside of the SWF file or the FLA file.
00:52It is loaded in dynamically as an external JPEG file using action script, specifically,
00:58using the MovieClipLoader class that you earlier wrote in the master.fla file.
01:04To the left-hand side of that JPEG file is a bit of descriptive information about this particular set of eyeglasses frames.
01:12That information is loaded in dynamically from a separate text file using the LoadVars class, again, that you built in the master.fla file earlier.
01:23It's also formatted and styled using HTML and cascading style sheets.
01:29Underneath the glasses frames image, it also states that it's frame style 1 of 10.
01:35You're going to also create that with action script.
01:38You will notice that as you click on the Next button to advance to the next pair of eyeglasses frames,
01:44that that bit of text updates and it now says that it's frame style 2 of 10.
01:49Additionally, the descriptive information about that image also updates as you click on the next button, as does the image itself.
01:57So as you advance through the slide show, the image counter updates, as well as the descriptive information.
02:04Now, when you get to the end of the slide show, and you click on the Next button again, it goes back to the frame style 1 of 10.
02:15It goes back to the first image.
02:17So this slide show is intelligent in that it knows how many images there are total in the slide show itself,
02:24because when it gets to the end, it goes back to the beginning.
02:27Not only can you advance forward through the slide show, but you can also click on the Back button to go backwards in the slide show as well.
02:33So there's quite a few things that are going on here.
02:36Fortunately, a lot of the major pieces, such as the loading of the images and loading of the text, has already been built for you.
02:43You've already constructed the MovieClipLoader class to load the images.
02:47You've already constructed the LoadVars class to load the text as well.
02:51So a lot of the functionality that you're going to be utilizing in constructing the frames slide show is one that you'd already be familiar
02:58with because you've already written a lot of the functionality before.
03:01You're just going to be applying most of it in a different manner than you may have learned before.
03:05When you finish checking out the frames section, go ahead and close your browser window and navigate
03:11to the site directory in the LA Eyeworks directory on your desktop.
03:15It's here where we're going to pick up in the next movie when we start constructing and building the slide show.
Collapse this transcript
Setting up
00:01>> For those of you that have access to the exercise files, again navigate to your site directory in the LA Eyeworks on your desktop.
00:10When you do that, you'll notice that there's an FLA provided for you called frames.fla.
00:16Go ahead and open up that frames.fla file in Flash 8.
00:20For those of you that don't have access to the exercise files in Flash 8, go ahead and create a new blank FLA.
00:27Make sure that it has the same dimensions as the other FLA, six hundred by four hundred.
00:31And then here is where you can begin creating some of the elements as you're about to see that I go over.
00:38Inside the frames.fla file you'll see a few elements that are already provided for you.
00:43Up on the top left, there's a static text field that just says "frames" inside of it.
00:49On the left hand side of the stage, there's also a multi-line dynamic text field.
00:54At the bottom of the stage there's a single line dynamic text field.
00:58And then above that there's a movie clip symbol.
01:01It's called MC empty.
01:02The only thing that's inside of that movie clip symbol is just a black square that's just a stroke, there's no fill on the inside.
01:11Now there's only that black stroke so that you can visually see it here when it's placed on the stage.
01:17We're not going to be utilizing that black stoke at all in the construction of the site.
01:21That's just so that you can see where specifically the dynamic slide show images are going to be loading into.
01:28They're going to be loading into this movie clip and thereby replacing that black stroke that's inside of it.
01:34But because we're going to be working with some text in the construction of this frame slideshow, let's first bring in our shared fonts as well
01:41as that shared button arrow symbol that we can use as the next and back buttons to allow the user
01:46to navigate both forward and backward through the slideshow.
01:49So the first step would be to import some of those items from our shared library.
01:54To do that, go ahead and open up file, import, open external library.
02:01Then navigate to your site directory and double-click on sharedlib.fla.
02:06Then go ahead and select all of the symbols inside of that shared library and drag those into the library for your frames.fla file.
02:16Now we're using all of those shared linked library items and again, we can continue using those as often as we'd like inside of the SWF file,
02:25including the fonts without adding to the file size of the end frames.swf file.
02:31Once you've dragged those shared library elements into your frames library, go ahead and close the shared lib library panel.
02:38Let's go ahead and tell our text fields both static and dynamic, to use some of those linked fonts.
02:45Click on the frames static text fields up on the top left, and in your properties inspector click
02:52on the font pull down menu and choose the shared font Vera bold.
02:56Again, the shared font is the one with the asterisk after its name.
03:01On Windows, you'll also need to make sure that you click the full bold button.
03:05Then click on the multi-line dynamic text field that's on the left-hand side of the stage.
03:11This time in the Properties Inspector from the font pull down menu, choose the shared font Vera.
03:18Then just make sure that the font rendering method is set to anti-alias for readability, that the render text as HTML button is depressed,
03:27because this text that is going to be loaded inside of this text field will be utilizing HTML tags.
03:33And we want those to be parsed not displayed.
03:35And then we also want to make sure that we give this text field an instance name.
03:40Now remember we're going to be using the LoadVars object that we created earlier inside of master.fla
03:46to load text that describes each frame in the slideshow.
03:51Because of that again, as I mentioned previously, we need to make sure
03:54that we use the appropriate text field instance name that the LoadVars object utilizes.
04:00If I switch over to master.fla real quick, select the first key frame in the "A" layer, and open the actions panel,
04:08if you remember the LoadVars action is looking for a text field called loaded info to load the text into.
04:16So in frames, I want to make sure that that dynamic text field also has the instance name of loaded info.
04:24So again, with that multi-lined dynamic text field selected and the properties inspector,
04:29click in the instance name field and give it an instance name of loaded info.
04:35That way we can utilize that LoadVars object to load that descriptive text into that specific text field.
04:41Next, go ahead and click on the single line dynamic text field down toward the bottom of the stage
04:47and from the font pull down menu, choose the shared font Vera bold.
04:53We also need to give it an instance name as well, because we're going to be dynamically inserting some text inside of that text field,
05:01because we're going to be targeting that text field with action script, therefore we need to make sure it has its own unique instance name.
05:08Click in the instance name field and give it an instance name of "frameNum" for frame number.
05:15Make sure that you capitalize the N in numb.
05:18Lastly, because we're going to be telling the JPEG files that make up the slideshow to load into a specific location and not a level
05:27as you've seen the movie clip loader be used previously, ye we need to give the location,
05:32where those frames JPEG files are loading into, a unique instance name.
05:37That movie clip symbol that we're going to have those frames images load into by the way,
05:41is where this black stroke in the middle of the stage is located within.
05:45So click on one of those black strokes to select a movie clip symbol, and then in the properties inspector click in the instance name field.
05:54In that instance name field, type in the name Frames MC for frames movie clip and press return or enter.
06:03So now when we're using that movie clip loader class to load those images dynamically
06:08into our frames.swf file here, we can say load those images into frames MC.
06:14And those images that are the same size as this box, is going to load into this movie clip symbol.
06:21So the first thing that you did is you linked all of your shared library elements.
06:25Your shared fonts, as well as your shared button symbol, button dot arrow.
06:29Then you selected the various text inside of this file and specified that those text items used the shared fonts inside of your shared library.
06:38You also made sure that each of the dynamic text fields, as well as the movie clip symbol had their own unique instance names,
06:45so that they could be specifically targeted with action script.
06:49In the next exercise, you're going write the action script to load the very first image in the frames slideshow.
06:56Before you continue, make sure that you save the changes that you've made to your frames.fla file.
07:02And to make sure that I try to keep my work space as clutter free as possible, I'm going to select the aboutUs.fla which I still have open,
07:10but don't need to use right now, and I'm going to close that and then go back to my frames.fla file.
07:151
Collapse this transcript
Loading the first slide
00:01>> Because this slide show is going to be smart, meaning that it is going to keep track of which slide it is looking at,
00:09how many slides there are total, so that when it gets to the end or last slide of the slide show and the viewer clicks
00:16on the next button it can go back to the beginning, and the same would happen, but in reverse, if the viewer was clicking on the back button,
00:23because of that we're gonna need to keep track of which slide number the viewer's currently looking at,
00:29and we're gonna keep track of that using action script.
00:32Again, make sure that you're in frames.fla and then in the topmost layer, which is called layer A.
00:39Select the first key frame in that layer and open up your actions panel.
00:44You'll notice that there's already quite a bit of action script written in there to start you off with.
00:48For those of you that don't have access to exercise files, you may wanna pause the movie now and in the first key frame, in layer A,
00:57in your frames.fla file, you may wanna write some of this action script in that actions panel that you see here.
01:04I'll scroll down a little bit as well so you can see the remainder of the action script here.
01:11Then in the very topmost empty line break, which is line one, we're gonna create a variable
01:17that keeps track of which slide the viewer is currently looking at.
01:21To do that, type var, space, curFrameNum, for current frame number, make sure the F in Frame and the N in num is capital.
01:34Now because this is gonna hold a number let's strict type it so that it can only hold data of the number type.
01:41To do that, type a colon after curFrameNum, and then type number, then type space, equals, space, zero, semicolon.
01:51As you'll see with many things as you continue to work with Flash such as working with rays and so forth, when Flash starts counting things,
01:59it doesn't start normally counting with one, it starts counting with zero.
02:04Zero, after all, is a number.
02:06And to perpetuate same type of counting inside of flash, we're gonna start counting for our slideshow also at number zero.
02:14Again, starting to think of number zero as the first place to start counting with will help you
02:20as you continue forward using action script inside of Flash because many other things in Flash
02:25in the action script also start counting with the number zero.
02:29Next we're gonna write an action that utilizes the movie clip loader class in master.swf to load in the first frame of our slide show.
02:38So after the action that you've just written press return or enter a few times on your keyboard to create a couple of empty line breaks.
02:45Then remember, the movie clip loader class, called myMCL, which is located on master.swf is thought of as being in underscore level zero.
02:54Master.swf resides at the bottom of all the other SWF's because it loads all of that other content
03:01into it, so it can be considered as being at level zero.
03:05So type underscore, level, zero and then the name of the movie clip loader class, that we gave it earlier, was dot my MCL,
03:16make sure again that you put the dot between underscore level zero and my MCL.
03:20Also make sure that you have the capitalization correct as well.
03:23Now we wanna tell the myMCL movie clip loader object to do something.
03:28We want it to load in an image.
03:30So type dot load clip, then type an open parenthesis.
03:36Now here is where it gets, not tricky, but gets more interesting as you're working
03:41with action script that you may not quite have seen at this level yet.
03:45We don't wanna tell Flash to load in a specific image number, we don't wanna say load in image one dot JPG for example,
03:53the reason why is because later, we may decide that the first image in the slide show
03:58that we wanna load shouldn't be image zero, maybe it should be image five.
04:02Because of that, we're gonna write the action that tells the myMCL movie clip loader object which image to load in.
04:10We're gonna write it in such a way that it doesn't specify an exact image number.
04:15To do that, what we're gonna essentially do is concatenate a few strings of text together with the value
04:22that is currently being tracked by the variable that we created call curFramNum.
04:27So after the open parenthesis, after load clip, type quote, frames, forward slash, frames, end quote.
04:37Now before we continue, you should see where these slide show images reside at so you know where to load them from.
04:44Hide or minimize Flash for a moment and navigate into your site directory which is in the LA Eyeworks directory on your desktop,
04:51and there you'll notice another folder called Frames.
04:55For those of you that don't have access to the exercise files, you should probably create this folder in your site folder.
05:03Open up that frames folder and you'll see a series of JPG image frames that starts with frame zero, which is not coincidentally the same number
05:13that we've placed inside of our curFrameNum variable that you just created,
05:17and it goes all the way to frames nine, meaning that there are 10 slide show images total.
05:23Zero is the first one, and then frames one is image number two and so on and so forth, so there are 10 frames images all together.
05:31Additionally there are also text files associated with each frame.
05:36Notice that they have the same file name, the only thing that differs is the extension at the end of the name, frames0.jpg, frames0.txt.
05:47It's not by accident that they have the same files names and that just the extension at the end differs.
05:52That's going to help us when we go and start writing our action script because we can keep a lot of our action script the same that says go
06:01and load this particular file, frame zero, frames one, frames two and so forth, and when we wanna load in the descriptive information about each one
06:09of those slides, all we have to do in the action script is just say either load in the JPG or load in the TXT file or both, as you're about to see.
06:18So this is the content that we're going to be loading in in the slide show.
06:22The frames images as well as the descriptive information is all located inside of the frames directory, the frames directory is inside
06:31of the site directory, where the rest of our site files are located at.
06:35So back inside of Flash, inside of the frames.fla file, in the first key frame, in layer A, in the actions panel,
06:45what you've written so far in this load clip action says go into the frames directory and in there there's an image called frames,
06:56and we haven't yet specified which frames number to load in, that's where the curFrameNum variable,
07:04with the number zero inside of it is going to come into play.
07:09After the quote that comes after frames, click there and type space, plus, space, curFrameNum, the name of our variable.
07:21Now again, when Flash goes to read through this action, it's not going to put curFrameNum there, it's going to instead replace
07:28that variable with what the value of that variable is.
07:32Well the value of that variable is what's inside the variable.
07:35What's inside the variable in this case, to start with, is number zero.
07:40So when Flash goes to read this action, it's gonna say load the clip frames, which means it's in a directory called frames,
07:47and then the image that it's loading is called frames0.
07:50Because that's what it's gonna replace this variable with.
07:54Now it's not just called frames0, if you remember it also has the dot JPG extension at the end of the name, so after curFrameNum,
08:04click there and type space, plus, space, quote, dot JPG, end quote.
08:12Now what these plus signs do that you see here, is they concatenate.
08:17Concatenate means to essentially add on to.
08:19So what we're doing here is we have a few strings of text, frames forward slash frames, and then it's going to add on to that,
08:27it's gonna concatenate what the value of this variable is, zero.
08:32And then it's going to concatenate onto that another string of text, dot JPG.
08:38So when this is all read through, assuming curFrameNum starts at zero, when Flash reads this action through, it's gonna say frames/frames0.jpg.
08:49The plus signs just concatenate that all together into one long bit of text.
08:54Now that you've specified what we're loading in, in this case for starters, we're loading in frames0.jpg,
09:00we need to tell Flash where we're going to load that image into.
09:04Again, we have a few choices.
09:06We can load it into a level, which is like an invisible layer above our timeline, or we can load it in to a specific movie clip symbol instance.
09:15If you remember, we have a movie clip symbol instance specifically reserved for that purpose on the stage of our frames.fla file.
09:23We called it, if you remember, framesMC.
09:27So after the dot JPG end quote, type comma, space, and then we need to type in the name of that movie clip symbol.
09:36Now you can either do that or you can click on the insert a target path button at the top of your actions panel.
09:43When you do that, inside this insert target path dialogue box,
09:46you'll see that movie clip symbol framesMC, go ahead and select that and then just click OK.
09:53So we're loading in the first frames slide show image, frames0.jpg, into the movie clip symbol called framesMC.
10:02End this action by typing a close parenthesis and then a semicolon to end that action.
10:07You've written enough so far that you can test the work that you've done.
10:10Go ahead and save the changes that you've made to frames.fla and then publish a SWF file from this FLA by choosing file, publish.
10:20Now remember, because our modules, like frames, is utilizing actions script that we've written into master.fla,
10:28including our myMCL movie clip loader object, we can't preview this frames file by itself,
10:34we have to preview it as it's loaded into the master.swf file.
10:39That means that we have to go back and make a slight modification to which SWF file the master is loading in to.
10:45Because right now, the master.swf file is set to load in the About Us module, not the frames module, so go back to your master.fla file,
10:55if you've accidentally closed it you can go back and open it up by going into the site directory and double clicking the master.fla file there.
11:03Then once you've opened that file, select key frame 10 in the A layer,
11:08select the action that says myMCL.loadclipaboutus.swf, select that whole action and copy it.
11:18Then click at the end of that action, press return or enter to create a new line break and paste that action in the new line break.
11:27In the pasted copied action, change the SWF name that it's loading from aboutUs.swf to frames.swf and then,
11:36so we're not trying to load two different SWF's into the same level,
11:40comment out the aboutUs.swf action so that it is only loading in frames.swf.
11:47Then save the changes you've made to master.fla and test your movie,
11:52which will also of course publish a new SWF file by choosing control enter or command return.
12:00When it loads, you'll see the frames module appears, and more importantly, the first image in that slide show actually load and be displayed
12:09in the same location where we had our framesMC movie clip instance on the frames stage.
12:14So the two actions that you've written so far to get started are working perfectly.
12:19In the next exercise, you're going to use action script to determine how many frames there are total in the slide show.
12:25Once you've gotten that bit of information, then you can start writing the action script to allow the viewer
12:30to navigate both forward and backward through the slide show.
12:34Before you continue on to the next movie, however, make sure that you've closed your preview window and return back to frames.fla.
Collapse this transcript
Loading the total slides variable
00:01>> In order for the slide show to know when it reaches the end or the last slide in the slide show, so that when the viewer clicks on the next button
00:09in the slide show it goes back to the beginning, and the same being true for going backwards in the slide show,
00:15it needs to know how many slides there are total in the slide show itself.
00:20Now we could easily create a variable here right inside the FLA file using action script that defined how many slides there were total.
00:28The problem with that is that later if we decided to add more slides onto the slide show, or allow the client to add more slides to the slide show,
00:36they would have to open up the FLA inside of Flash, and you'd have to muck around with the action script to change that number.
00:43Rather than do that, let's try to make it easier for ourselves and the client to update later by just storing that number,
00:50how many slides there are in the slide show total, in the separate text file outside of Flash,
00:55and then use a LoadVars object to load that number in.
01:00That way we can more easily utilize it, as well as more easily update it later if we chose.
01:06I've already created this text file for you that has the total number of slides in it.
01:11For those of you that have access to the exercise files, if you hide or minimize Flash, and then navigate into your site directory,
01:19in there open up the Vars folder, and in the Vars folder you'll notice that there's a text file called slide underscore info.txt.
01:29For those of you that don't have access to the exercise files, go ahead and create a text file with this same name now.
01:36Inside of that text file, if you open it up you can see that it's just one variable value pair.
01:42It says total frames equals ten, that means that there are ten slides total in the slide show itself.
01:49If I or the client ever decided to update the slide show, and add or remove slides from the slide show, all I'd have to do is open up this text file,
01:58make the change to this number, save the file, and the next time the SWF file was viewed, it would then incorporate that up to date number.
02:07So it makes it much more easier to maintain and update the slide show by keeping this number
02:12in a separate text file, and loading it into Flash using a LoadVars object.
02:17Now that you've seen what's inside of this text file, the important thing to remember is the name
02:21of the variable, totalFrames with a capital F in frame.
02:26We're going to need to target that variable name when we create our LoadVars object, which you're going to do next.
02:32After you've seen this text file, go ahead and close it, and go back into your Flash project.
02:39Now we're not going to use the LoadVars object called myLV that you've written into the master.fla file previously.
02:48That myLV LoadVars object is for loading text, and then displaying the value of the variable in a text field called loaded info.
02:58In this case we're not going to be displaying this number in a text field called loaded info.
03:04We're gonna utilize it in our action script, and we're gonna display it in our frameNum field down at the bottom of the slide image,
03:12but we're not gonna be utilizing it in the same way that the myLV LoadVars object was constructed.
03:19Because of that, we're gonna create a separate LoadVars object here inside of frames.fla, just for loading in the total slides number.
03:28To start off with, again inside of frames.fla with the first key frame in the A layer selected,
03:35in the actions panel click before the very topmost action.
03:40Then press return or enter a few times to move all those actions down a couple lines.
03:45And then select that topmost empty line break.
03:48Next, let's create a LoadVars object, so type var, space, slide info, LV for slide info LoadVars, strict type it to the LoadVars data type
04:03by typing colon LoadVars, space equals space, new, space, LoadVars, open parenthesis, end parenthesis; semicolon.
04:15Now we just need to tell that LoadVars object to load that variable value pair from that text file you just looked at.
04:22So press return or enter to create a new line break, and type slide info LV.load, open parenthesis, quote, remember it's in a folder called Vars
04:36so we can just specify that here in the URL, type Vars, forward slash, slide underscore info.txt,
04:46end quote, end parenthesis, semicolon to end that action.
04:50Those two actions that you've just created effectively load in that text file as well as the variable value pairs within it.
04:58So now that you've written the action script to get the total slides number to load in so
05:03that now the slide show knows how many slides there are total, in the next exercise you're gonna start scripting the next slide
05:10and previous slide buttons so the viewer can actually navigate both forward and backward through the slide show.
05:16Before you continue on, make sure that you save the changes to this FLA file.
Collapse this transcript
Adding the next slide functionality pt. 1
00:00>> Now that you've written the action script to load in the total frames variable so that your slide show now knows how many slides there are total,
00:10you can start writing the action script and applying it to the next slide and previous slide buttons.
00:15Go ahead and minimize your actions panel if you have it open
00:18and then select the layer underneath the top most layer called "A". Then create a new layer and rename that new layer
00:26to be titled "buttons". While we're here go ahead and lock the A layer so we don't actually put anything on the stage in that layer
00:34and then in the library for your frames.fla file you'll see the shared button called btn.Arrow
00:41that we copied over earlier from the shared lib shared library.
00:45Go ahead and take the button and drag it out onto your stage now currently that arrow is pointing down,
00:52we want our arrow to go to the next slide in the slide show to point to the right.
00:57So with that button selected on the stage choose modify, transform rotate 90 degrees CCW, Counter Clockwise.
01:07Then drag that button and position it so that it's on the right hand side
01:11of that dynamic text field underneath where the slides themselves actually load.
01:16Next, while holding down your control and shift key on Windows or option and shift on the Macintosh drag that button
01:23over to the left hand side of the dynamic text field and let go.
01:27Then let's flip that button so that it's pointing to the left by choosing modify, transform,
01:34flip horizontal and then again you may need to realign it by dragging it a little bit like so.
01:40So there we have the next slide and previous slide buttons.
01:45Now as you've seen before when adding action script to a key frame in your time line that targets a movie clip or button symbol that's
01:53on the stage you need to give those movie clip or button symbol instances a unique instance name
01:59so that we can tell them what to do with action script.
02:02Click on the next slide button on the stage and in the properties inspector click in the instance name field then type next SlideBtn all one word
02:15with a capital S in slide and capital B in BTN for Button.
02:20Then select the previous slide button on the stage, click in the instance name field in the properties inspector then type
02:27in prev slide Btn with a capital S in slide and capital B in Btn.
02:34Now that each of those buttons symbols have their own unique instance name we can now target them
02:39with action script which is what you're going to do next.
02:43Go ahead and select the first key frame in layer A and open up your actions panel, now because we're going to add some actions script
02:51that modifies the mouse events of some button symbols on the stage that requires a wee bit of action script so it would probably be good
02:58to add some comment lines in there that defined areas of your actions panel as being where the action script for those buttons reside at.
03:07To make my life a little easier, I'm going to select one of the other comment lines, copy it and then click after the action that loads
03:17in the first frame, it starts under score level zero dot myMCL dot load clip, I'm going to click on the end of that action,
03:25press return or enter a few times to line breaks, paste that copied comment line on that location.
03:34Then I'm simply going to select what's between the less than and greater than symbols in that comment line then change it to read "next slide button".
03:46Then I'm going to select and copy that comment line, click on the end of that line,
03:52press return or enter a few times and then paste that comment line.
03:57Then in that pasted line I'm just going to click before the word "next" and type a forward slash to mark the end of the next slide button actions.
04:04Next I'm going to add an on release mouse event to that next slide button on the stage so click in the empty line break
04:11in between the two comment lines that you just created and then click on the insert and target path button at the top of the actions panel.
04:20Inside of that dialogue box that appears, scroll down until you locate the button called next slide button if you don't see the next slide button
04:29or the prev slide button button symbols that's probably because you accidentally skipped over the steps where you attached instance names
04:36to these button symbols, if that's the case you may want to rewind the video a little bit so that you make sure
04:42that you add instance names to those button symbols on the stage.
04:46Once you see those then just select it, make sure that you're targeting it set to relative and then click OK Flash with an insert the name
04:55of that button symbol on the stage preceded by the key word this, This dot next slide button.
05:02Now we want to add an on release mouse event so that we can define what should happen when the viewer clicks on that button.
05:09So after next slide button type dot on release and again as you've seen before when adding mouse events to buttons or movie clips symbols
05:18in this manner you have to attach them to functions so type space equal space function open parentheses, closed parentheses space open curly brace,
05:30a couple of line breaks and a close curly brace to end that function. Now is when you have to stop and think exactly what you want this next button
05:40to do when the viewer clicks on it. When they click on it you may think "Oh well just go to the next slide, load the next slide in the slide show"
05:47but we actually have to do a little bit of checking before we can tell the slide show just to load the next slide.
05:53The first thing we need to figure out when the viewer clicks on the next slide button is if there is a next slide to go and look at.
06:01When they get to the end of the slide show remember we want the slide show not to just stop there
06:07but to go back and display the first slide in the show.
06:11So when the viewer clicks on the next button the first question we need to ask is, are they looking at the last slide in the slide show
06:19or not because if they're not looking at the last slide in the slide show then go ahead and load the next slide in sequence,
06:27however if they are looking at the last slide in the slide show then go back and load the very first slide in the slide show.
06:35So when the viewer clicks on the next slide button we need to ask a few questions first.
06:41You can do that in Flash by using, as you've seen before, what's called a conditional statement, that means writing an if action.
06:50"If this is happening then do this otherwise if its not doing that then do this other thing instead."
06:56That's essentially how you would phrase an if statement in plain English.
07:01So click between the open and closed brackets that starts the on release function and let's start by writing just the skeleton of this if statement.
07:10To do that just write if then open parentheses, end parentheses, space, open curly brace,
07:18two line breaks and a closed curly brace then we need to write the condition of this if statement.
07:24What is the question we're going to ask?
07:27We write that here inside of the open and closed parentheses, so click in there after the word "if".
07:33Now we can find out if the viewer is looking at the last slide in the slide show by comparing what the current frame number is per frame Num
07:44which again is keeping track of the slide the viewer is currently looking at as you'll see here in just a little bit.
07:50We compare that number against how many frames there are total, which we're tracking cause we loaded that number using LoadVars action script,
07:59so we're going to compare which slide the viewer is currently looking at with how many slides there are total. If that is equal then we know
08:08that they're looking at the last slide in the slide show. So in between the open and closed parentheses after if per frameNum,
08:18if current frame number of the current frame the current slide the viewer is currently looking at and then type space, less than, space, slide info,
08:28LV, dot, total frames, now what that action does slide info, LV, dot, total frames, that gives us when we ask Flash
08:38that which number is inside of the slideInfo.txt file.
08:44That number defines how many frames there are total.
08:46Now there's a slight discrepancy with how we're tracking our numbers here, if you remember we're keeping track
08:52of which slide the viewer is currently looking at starting with the number zero because again zero counts as a number.
08:58And again the reason why you're starting with the number zero is to retain consistency with action script inside of Flash as you'll see
09:05as you advance forward with your Flash action script knowledge there are many other cases where Flash starts counting with the number zero.
09:13So we're doing that so that as you advance forward in Flash you get into that mindset of thinking start
09:18with the number zero. However the total frames variable which we're keeping track of inside of our external text file so that we can easily update it
09:27as well as the client later does not take into account that it starts with the number zero. If it did, the total frames variable would not be ten
09:35because we have ten images total, instead it would say nine.
09:39However the reason why we're choosing ten is to make it a little easier for you and the client to understand later.
09:47For example if you have ten frames in your slide show you don't want to tell the client, "Oh by the way don't type in ten
09:54because there are ten frames, type in one less then how many there are total", that would just be confusing to describe to a client.
10:00So what we're going to have to do is take our total frames variable here and we want to compare total frames number against the number
10:09that keeping track of our current frame we simply need to subtract one from this total frames variable.
10:16Again that'll just make it easier for yourself and or the client to update that total frames variable later and all you'll have to do here
10:25when you're comparing it against per frame num variable is just subtract one from that so it's much easier for you to do it here
10:33as your programming the action script then it would be to describe a client to tell them to enter in one less in the total frames
10:40in the total frames variable, so what that means is that after total frames where you are now simply type space, minus, space,
10:48one so our total frames variable is ten and we're going to subtract one from that so its gonna say nine here.
10:56Again the reason why is because with the way per frameNum is tracking the variable, the number nine is the last number of the slide
11:04in the slide show again because we started counting from the number zero.
11:08Now when Flash goes to load in this total frames variable sometimes that can load that in as a string instead of an actual number
11:18in which case it would get confused when it tried to subtract the number one from a string of nine.
11:25All that, that means is that you need to tell Flash specifically that this total frames variable is a number and not an actual string,
11:33to do that simply click before slide info LV and type number open parentheses click after total frames and type a closed parentheses.
11:46Now all that does is it forces Flash to take whatever is inside of the parentheses in this case again
11:52when Flash performs this action script its going to figure out what the total frames variable is inside
11:59of the slide info LV LoadVars object and its going to put that value there.
12:04We're simply forcing Flash to make sure that it's a number by encasing that in parentheses and then by putting the keyword number before it so now
12:13when flash goes to figure out this action its going to take this value which is going to be ten
12:18as a number and subtract it from one so we'll end up with nine.
12:22So our if statement currently says if the number that is inside per frames num variable is less than nine, if that comes out to be true that means
12:34that the viewer is not looking at the last slide in the slide show if that's the case then we can just tell our slide show to go look
12:41at the next slide in sequence, we're going to do that as well as complete the functionality
12:47for the next slide button, button symbol in the next exercise.
12:51Before you continue on however make sure that you save the changes to your FLA file.
Collapse this transcript
Adding the next slide functionality pt. 2
00:01>>So currently, when the viewer clicks on the next slide button to advance to the next slide in the slide show, we ask a question.
00:08We say is the slide they're currently looking at less than how many slides there are total?
00:15If that's the case, then the viewer can simply go to the next slide in sequence, click in between the open and close brackets for the if statement
00:25that you just wrote and type in curFrameNum, plus, plus, semicolon.
00:33What that does is it simply adds one number on to whatever number is inside the curFrameNum variable.
00:41Now the reason why you're doing that, you're just adding one number onto that, is because later, after you've asked these questions,
00:48and then told that curFrameNum variable what number should be inside of it,
00:53you're then going to write an action that says "okay, go and load that slide number."
00:58Now that you've specified what should happen if the viewer is not looking at the last slide in the slide show,
01:04you should also specify what should happen if they are looking at the last slide in the slide show.
01:09In other words, if this question is not true, if it is true, they're not looking at the last slide in the slide show.
01:17If this question is true, that means they are not looking at the last slide in the slide show, however if it is not true,
01:25that means they are looking at the last slide in the slide show.
01:29We're going to do that, as you've seen before, by writing an "else" that comes after our "if".
01:35So if basically says if this is true, do this, otherwise, which is the else, do this other thing.
01:43So after the closed curly brace that ends the if statement, click there, and type space, else, space, open curly brace, a couple of line breaks
01:54and a closed curly brace to end that else statement, then click in the empty line break between the open and close curly braces, after else,
02:03and type curFrameNum, space, equals, space, zero, semicolon to end the action.
02:13So what this currently says is if the viewer is currently looking at a slide that is not the last slide
02:21in the slide show then set the curFrameNum variable, which is just a number that's keeping track of which frame the viewer's currently looking
02:29at in the slide show, set that to be one number greater than what it is.
02:33Otherwise, which means if they are looking at the last slide in the slide show,
02:38set that number to be zero, reset it back to the beginning essentially.
02:42Now once you've written the action script that asks these questions and then sets that curFrameNum variable value to be the correct number,
02:53you then want to tell it okay, now that you've said which frame is supposed to be the current frame, load in that particular frame.
03:01That essentially is the action that you wrote earlier, which does exactly that.
03:06It simply loads in a JPG file that corresponds to whatever that curFrameNum variable value is.
03:14Now you don't wanna just write this here inside of the next slide button dot on release function because, again,
03:20you're not only gonna be utilizing this same action in the next slide button scripting, but also in the previous slide button.
03:28So rather than take this action and duplicate it for as many times as you need it, there's a much better way to do it
03:35and that's by simply enclosing this within a function and then just targeting or executing
03:40that function whenever you need that action to be executed.
03:44That way, should you ever need to make any changes to this action, you wouldn't have to make changes to it every time you used it.
03:50You would just go and make changes to it that one time, there inside the function.
03:54To place that within a function is really easy to do.
03:57Simply click at the beginning at that action, press return or enter once to create a line break above it, then select that empty line break above it
04:06and type function, space, loadFrame, with a capital F in frame.
04:12Again, a function, like a variable, can be whatever name you want, as long as you follow the correct naming conventions
04:17and you don't add spaces in the name or special characters or so forth.
04:21Again, make sure that you have the spelling and capitalization correct and then after loadFrame type open parenthesis, end parenthesis, space,
04:31open curly brace to mark the beginning of that function, and then click at the end of the action underneath that, the underscore level zero,
04:38dot myMCL, dot load clip, click at the end of that action, press return or enter once,
04:44and then create a closed curly brace to mark the end of that function.
04:48Now technically, the actions within a function should be indented one tab space.
04:53To do that click at the beginning of your underscore lever zero dot myMCL action and press tab to indent it one space.
05:01So now, whenever I wanna tell Flash to load in a slide from the slide show that utilizes whatever number is inside of that curFrameNum variable,
05:11I simply tell it to execute this load frame function.
05:15That's what we're gonna do for the next slide button.
05:18Now that the next slide button action script has been written that asks a few questions and then sets that number to be appropriate
05:25to which slide should be loaded next, we can then execute this load frame function to have it actually load
05:32in the slide from the slide show, that might be nice.
05:35To make it easier so we don't accidentally misspell or mis-capitalize the name of the function, select the name of the function, loadFrame,
05:43including the open and closed parenthesis, copy that and then scroll down to the next slide button on release function,
05:52click after the closed curly brace that comes after the else statement, press return or enter once to create a line break there and then paste
06:02that load frame function call and then simply add a semicolon to end that action.
06:09Now make sure that this load frame call comes before the closed curly brace that ends the on release function,
06:16but after the closed curly brace that ends the else statement.
06:20So what happens in order, is that when the viewer clicks on the next slide button, it first asks to find out if they're looking at a slide
06:28that is not the last slide in the slide show, if they're not looking at the last slide
06:33in the slide show it adds one onto the curFrameNum variable value.
06:38If they are looking at the last slide in the slide show, then it sets that number to be zero.
06:44Once it's done either one of those things, then it executes that load frame function, which then loads in the appropriate slide into the slideshow.
06:53So the next slide button functionality is complete.
06:56It now is an intelligent button in that it looks to find out if the viewer's looking at the last slide
07:02in the slide show or not and then takes appropriate action.
07:05However, because we encased the action that actually loads in the first slide in the slide show within a function,
07:13that means it won't be executed by default until we call that function.
07:18So that means, essentially in plain English, when the viewer comes to your frames module,
07:23they will not see the first slide in the slide show appear by itself automatically.
07:28They'll have to click on the next slide button, currently, to actually see the first frame in the frames slide show.
07:35Well because when the viewer comes to the frames module, we want them to see the first slide
07:39in the slide show we need to execute this load frame function.
07:44To do that, again, simply select that loadFrame function name, including the open and close parenthesis and then copy it,
07:52just to make sure we still have it in our computer's clipboard.
07:55Then click after the closed curly brace that ends the loadFrame function,
08:01press return or enter once to create a line break underneath that, and then paste it.
08:07Then simply add a semicolon to end that.
08:09That means, because we're calling that function, that the action within it that loads the first slide
08:15in the slide show will be executed when the frames module first appears.
08:20Again, if we didn't include that, the viewer would come to the frames module and nothing would appear there, no slide,
08:25until they clicked on the next slide button, which then executes that function.
08:30You can now test to see how this works so far by saving your FLA, publishing a new SWF file from this FLA, navigating to your master.fla file
08:41and testing your movie there, or going into your master.swf file in your site directory and double clicking on that.
08:49Since I have master.fla, I'm just going to select that and choose control, test movie.
08:54When you do that, you can see that the first slide in the slide show automatically appears and then when I click on the next button it's going
09:00to load the next slide in the slide show, which again is using our myMCL movie clip loader class
09:07that is inside of the master.fla file to load that JPG image in.
09:13I can keep clicking on that to keep loading the next slide in the slide show.
09:18Now this frame right here is actually frame number 10 in the slide show.
09:23When I click on that button again, it goes back to the very first frame in the slide show,
09:28so that I know that my smart next slide button actually is being smart.
09:33It's figuring out which slide is the last slide in the slide show and then telling, when the viewer clicks on the next button in the slide show,
09:41so now I can tell that my smart next slide button is actually working as intended.
09:47When the viewer clicks on that next slide button, it's figuring out if they're looking at the last slide or not and if they are looking
09:53at the last slide, it tells the slide show to go back to the beginning.
09:57Otherwise, it just tells it to load the next slide in sequence.
10:01So the next slide show button is working perfectly.
10:04In the next exercise, we're gonna take that same script and modify it slightly and apply it to the previous slide show button
10:11so the viewer can navigate both forward and backward through the slide show.
10:16Additionally, we're also going to, later on in this chapter, add some text to this frame num text field here, between the previous slide button
10:24and the next slide button, so the viewer can actually see which slide number they're currently looking at,
10:29as well as use our myLV LoadVars object that's in master.fla to load some descriptive text here on the left hand side of the slide.
10:38That way, the viewer, as a potential buyer for these frames, can actually get some more descriptive information about these actual frames themselves.
10:48Before continuing, make sure that you close your preview window and return to your frames.fla file.
Collapse this transcript
Adding the previous slide functionality
00:00>> Now that you've written the action script to get the next slide button to work correctly,
00:06you've already done a lot of the leg work to get the previous slide button to work correctly.
00:11As a matter of fact, you're gonna take the action script that you've written to make that next slide button work, copy it, paste it,
00:18and make some changes to it for the previous slide button.
00:22In your frames.fla file, in the first key frame of layer "A", with the actions panel open, locate the actions that start
00:31with the comment next slide comment and end with the comment end next slide button.
00:36Select that block of action script, including the comment lines and copy it.
00:42Then click after the comment that ends the next slide button comment, press return or enter a few times to create some empty line breaks,
00:51and then paste all that action script that you've copied.
00:54In the pasted action script, let's start by changing the comment lines.
00:58Change that next slide button, and again, make sure that you're modifying the pasted action script and not the original action script,
01:06change that next slide to read previous slide button.
01:10And then of course, do the same thing for the closing comment line, like so.
01:16Then we wanna make sure that we're targeting the right button with the on release function.
01:20It shouldn't be next slide button, it should be prev slide button.
01:24Another way to do that is to simply select this dot next slide button, click on the insert a target path button at the top of the actions panel,
01:33scroll down until you locate prev slide button and click it and then click OK in the insert target path dialogue box.
01:41Flash will then replace that with the correct name for that button symbol.
01:45Now within that on release function, the questions that we're currently asking with our if conditional statement is
01:52if the viewer is looking at the last slide in the slide show or not.
01:56However, because now with the previous slide button, the viewer's going to be navigating backward through the slide show,
02:02we don't wanna find out if they're looking at the last slide or not, we wanna find out if they're looking at the first slide in the slide show,
02:08because if they are looking at the first slide in the slide show, when they click on the previous button,
02:13then we want it to load the last slide in the slide show so it goes back to the end again.
02:19Otherwise, it can just load whatever the previous slide in the slide show is.
02:23So when the viewer clicks on the previous slide button, the first question that we can ask is,
02:29is the viewer looking at the first slide in the slide show?
02:33In other words, is curFrameNum, the number that's inside that variable, is it zero?
02:39Because if it is, that means the viewer's looking at the first slide in the slide show.
02:44So in the if statement, in between the parenthesis, leave curFrameNum there, but select everything from the less than symbol all the way
02:53to the number one, then delete that and type in equals, equals, two equal signs, space zero.
03:02That double equal sign is called an equality operator.
03:06And what an equality operator does is it checks to see if what's on the left hand side
03:11of it is exactly equal to what's on the right hand side of it.
03:16So in other words, we're checking to see if the value of the curFrameNum variable,
03:21whatever numbers inside of there, is exactly equal to zero, in this case.
03:26The single equal sign that you've seen earlier is called an assignment operator and it just takes what is on the right hand side
03:35of that equal sign and assigns it to what's on the left hand side.
03:39In other words, a single equal sign, in this action right here simply takes the number zero and puts it inside,
03:45or assigns it to what's on the left hand side, the curFrameNum variable.
03:50So the double equal sign checks to see if on the left and the right is equal,
03:55whereas the single equal sign puts one into the other, or assigns one to the other.
04:00Now if this if statement turns out to be true, in other words, if the viewer, when they click on the previous slide button,
04:07is actually looking at the very first slide in the slide show, you want the slide show to then go to the very last slide in the slide show.
04:16So after the if statement, select the action that reads curFrameNum plus, plus and delete that.
04:24Instead type curFrameNum, space, equals, space, we're gonna put something or assign something to that variable curFrameNum,
04:35and we wanna put in that variable the number that is the last slide in the slide show.
04:41If you remember, we retrieve that information in the next slide button on release function, it says slide info LV dot total frames minus one.
04:52To make your life a little easier, you could even select number, open parenthesis, slide info, LV, dot, total frames, end parenthesis, minus one.
05:03Copy that, scroll down to the previous slide button actions, click after the equal sign, after curFrameNum and paste it there.
05:15What this action does, is it says take the number that represents the last slide in the slide show and put it inside of the curFrameNum variable
05:24so when the viewer clicks on the previous slide button, if they are looking at the first slide in the slide show put the number
05:32that represents the last slide in the slide show in that curFrameNum variable, that way, if the viewer clicks on the previous button
05:41and they're on the first frame of the slide show, it will actually go back to the last frame in the slide show.
05:46So the slide show will continually move, even as the viewer's going backwards.
05:51Now if the viewer clicks on the previous slide button and they are not looking at the very first frame in the slide show,
05:58we simply wanna tell it to go to whatever the previous slide is, go back one.
06:03To do that, we simply tell our curFrameNum variable to subtract one from whatever number's inside of it, so in the else statement,
06:12where it says else curFrameNum equals zero, and again, this is inside of the previous slide button on release function,
06:20after curFrameNum equals zero, select equals zero and just type minus, minus, so it says curFrameNum minus minus semicolon.
06:30That means subtract one from whatever number is inside of that variable.
06:35And with those changes you now have a complete back button for you slide show as well.
06:41We can test this to make sure that it works correctly by saving this FLA, publishing an updated SWF, opening up the master.fla,
06:51or simply double click master.swf in your site directory and then if you're in master.swf, you can test your movie.
06:59If I click on the forward button, as we saw earlier, we can navigate forward through the slide show,
07:04if I click on the previous button I can navigate backward through the slide show.
07:08And again, as I continue to click, it'll keep repeating that slide show.
07:13When I'm at the very first slide in the slide show, such as this one, this is frame number zero in the slide show,
07:20when the viewer clicks on the previous button it says, "oh you are looking at the very first slide in the slide show,
07:25so load the very last slide in the slide show," and it continues to do that.
07:31The next slide button, of course, does the opposite when it gets to the last slide in the slide show, which this is, it says,
07:37"Oh you're looking at the last slide in the slide show, then go back to the very beginning and load that image instead."
07:43So you definitely deserve a big congratulations.
07:45You now have a complete, working and intelligent slide show that will loop as the viewer navigates through it.
07:53The last few things that you need to do in the remaining exercises is to add a little counter down here in between the previous slide
08:00and next slide buttons so the viewer can actually see which slide they're looking at out of how many slides there are total, as well as,
08:07on the left hand side of the slide show image, add a little bit of descriptive information
08:12about the particular frames that the viewer is currently looking at.
08:15And you're gonna do that in the next few exercises.
08:19Before you continue though, make sure that you close your preview window and that you go back to frames.fla.
Collapse this transcript
Adding the slideshow descriptive text
00:00>> In this exercise, you're going to load the descriptive slide show information that appears on the left hand side of each slide as it loads.
00:09To get a better idea of what I'm talking about, again, you can always go back to the sample site, by opening up your preferred web browser
00:17and then going to www.lynda.com, forward slash, intFLash8, forward slash, LAEyeworks.
00:25Then, when you're there, clicking on the frames option from the navigation bar at the top.
00:30That will load in the first slide in the slide show, which you've already done, as well as scripted the previous slide and next slide functionality,
00:38and this descriptive information on the left is what you're gonna be completing in this exercise.
00:43As the viewer clicks on the next and previous slide buttons to load the next and previous slides respectively,
00:49you'll notice that this information actually updates as the slide image itself does.
00:54So as I click on the next slide button, you can see that the image itself updates in the text as well.
01:00Now the way that this text loads in, as well as gets styled using cascading style sheet tags, is all review to you.
01:08You've already done that in the About Us module.
01:12So for the most part, this section is review.
01:14So much so that I've actually provided much of the action script to get this to work for you, already in the exercise files.
01:21I'm gonna go ahead and close my browser window and return to Flash in my frames.fla file.
01:28For those of you that have access to the exercise files, inside of the first key frame, in your "A" layer, in the actions panel,
01:36if you scroll down, you'll see some comment lines that read pre-built code for chapter seven.
01:41After that comment line, there's a series of actions, there's some textfield.stylesheet actions,
01:47some auto alignment for text fields and a few other things.
01:52It's that commented out action script that you're gonna utilize for this exercise.
01:56And again, the reason why it's provided for you, so that you don't have to write it all again yourself, is because you've already done it.
02:03You already know how it works.
02:05You've done this exact same thing in the About Us module when you loaded in the text and styled it
02:11in the Our History and Our Staff sections of that About Us module.
02:16So this is all review.
02:18For those of you that don't have access to the exercise files, you may wanna look,
02:22and pause this movie at this point, and write down the action script that you see here.
02:27Again, for those of you that do have access to these exercise files, what you're going to want to do next is to make this code so that it's active.
02:35Currently, as you can see, because of the forward slash asterisks at the beginning, and the asterisks forward slash at the end,
02:43all of this action script is commented out, meaning that it is not compiled into the finished script and therefore does not execute at all.
02:50So that these actions will actually execute, let's take out those comment lines, so that it will actually be compiled into the finished SWF file.
02:59To do that, select the comment line pre-built code for chapter seven as well as the forward slash asterisks and delete those.
03:09Then scroll down to the bottom and delete the asterisks forward slash as well as that last comment line, like so.
03:18Notice how now, that action script is not grayed out, it's color coded and it is not functional
03:23and it will actually work when you publish your SWF file.
03:26What this action script does that you've just uncommented is that it sets the auto size feature of two of the text fields on the stage,
03:34the frameNum text field, which is the text field underneath the slide show that will eventually show the viewer which slide they're currently looking
03:41at and how many slides there are total, and it also sets the auto size feature to write up the loaded info text field,
03:50which is where the descriptive text will be loaded for each slide in the slide show.
03:54Underneath that, again as you've seen before, is a textfield.style sheet object created called CSS Styles that loads in the styles.css file.
04:05The same one we utilized earlier and then there's an on load even handler for that that says if that CSS style has been loaded successfully,
04:14to then apply that style sheet to the loaded info text field and execute the function that we created called load frame, which again,
04:24you created that earlier, up here at the top, and what that does is it loads in the first frame of the slide show.
04:31That action has already been written in here that is executed when the styles.css file is successfully loaded.
04:38If there's a problem in some manner in loading that styles.css file,
04:43there's an else action that inserts some error text into that loaded info text field itself.
04:50So that is the functionality that you just enabled and added to your frames.fla file.
04:56There's a few changes that we need to make to this though.
04:58Namely there is not action yet that tells Flash to load in the appropriate variable file that has the descriptive information in it for each slide.
05:08Now remember, when the viewer clicks on the next slide button or the previous slide button,
05:12it executes the load frame function that you've written up here at the top.
05:16That load frame function that says go and get this current slide number and load it in.
05:22In this same function is where we wanna write the action that not only loads the correct image in,
05:28but also loads the correct descriptive text in and places it in the correct location.
05:34So in the load frame function, toward the top of your actions panel, click after the action, the only action that resides within that function,
05:42the underscore, level zero, dot myMCL, dot load clip action, click at the end of that and press return or enter to create a new line break.
05:51It's in here where you're going to write the action that tells Flash to go get the descriptive text for that particular slide
05:59and display it in the loaded info text field in the stage.
06:03You're gonna do that by utilizing the myLV LoadVars object you've already written quite a few chapters ago in the master.fla file.
06:12If you remember, that myLV LoadVars object has already been scripted so that it takes the loaded variables that you're going to tell it to load in
06:22and it automatically puts them inside of the loaded info text field on your stage.
06:28So because that LoadVars object is in the master.fla file, if you remember, just like the myMCL movie clip loader object,
06:36you have to tell it that it resides in that master.swf file.
06:40So you have to specify that it's on level zero.
06:42So type in underscore level zero dot myLV dot load, open parenthesis, now if you remember, earlier we looked into the frames directory.
06:57And I'll show you again just to refresh your memory, if I hide or minimize Flash and go into my site directory,
07:04in there's another directory called frames, in there, there are all my JPG frames for my slideshow.
07:11They're all called frames zero, frames one, frames two, frames three and so forth.
07:15In that same directory there are text files that are named the same except for the extension at the end, frames zero, frames one, frames two,
07:23frames three dot txt and so forth, so it's from these text files that we're gonna load the variables from.
07:31Back inside of Flash, I need to specify that here inside of my load action.
07:37After the open parenthesis, after load, type quote, frames, they're in the same directory, forward slash frames, end quote, space plus space,
07:50curFrameNum, and as you can see up to this point, it's all the same as the action that loads the JPG image itself, because what we're loading in is
08:00in the same folder, it starts with the same name, frames, and it also has a number after it
08:06and in this case we wanna make sure the numbers are exactly the same, so if it's loading in frames0.jpg, it's also loading in frames0.txt,
08:15so we're having it loading in that same number, but after curFrameNum type space plus space quote, and in the action that loads in the frames image,
08:27we're having it load in the file that ends with dot JPG, in this case, we want our myLV LoadVars object to load in the variables file.
08:37That variables file ends with dot TXT.
08:40So after quote, type dot TXT, end quote.
08:44Now because our LoadVars object handles what should happen with the variables from the text file we're loading,
08:50we don't have to specify where that should load in as we did with the movie clip loader object, so in this case you're done here.
08:57You can simply close that parenthesis by typing shift zero and then ending that action by typing a semicolon.
09:04So every time the viewer clicks on the next slide button or the previous slide button, this load frames function is executed.
09:11The first thing that happens is that it utilizes the myMCL movie clip loader object in the master.fla file to load a frame from the slide show.
09:21When this load frame function is first executed, it loads the file called frames0.jpg and it places it on the stage.
09:30Right after it does that, it then utilizes the myLV LoadVars object, which is also in master.swf, to load in the variables from frames0.txt.
09:42And again, each time the viewer clicks on the next slide or the previous slide button, that curFrameNum variable is updated
09:50with which slide number the viewer's supposed to be looking at..
09:53Because we're utilizing that same variable in both the action that loads the image as well as the action
10:00that loads the variables, they'll both stay in sync.
10:03Now in the actions panel, if you scroll down toward the bottom to where you uncommented the action script that was provided in this FLA,
10:10you'll notice that in the CSS styles object, when our styles.css file is loaded correctly, one of the things that happens
10:20if that's done is that it executes the load frame function.
10:24So once the CSS information has been loaded then it loads the first slide show image as well as the first descriptive slide show image,
10:33in which case this load frames function that we have here is repetitive with another one that we created earlier.
10:39Scrolling up in your actions panel, if you remember, you have this load frame function out here
10:45in the open that's executed when this frames module first loads.
10:50Now because we want that load frame function to be executed now, when the styles information has been download and applied to the style sheet,
10:59we don't need this load frame function that's out in the open here any longer.
11:04Because again, we only want this function to be executed after the styles information has been downloaded and applied to the text field.
11:12So go ahead and, at the end of the frame function, delete that load frame function call, so that again,
11:21it is only executed when the CSS styles object says that it's okay to execute it.
11:26And that's all the changes that you need to make to make sure that that descriptive information about each slide is loaded.
11:33Let's test this by saving this FLA file and publishing an updated SWF by choosing file, publish.
11:40Then I'm just gonna hide or minimize Flash, go into my site directory on my desktop and double click on master.swf.
11:50When my first slide show image loads in, I can see that my descriptive information to the left of it also loads in.
11:58When I click on the next slide button, I can see that that information updates accordingly, both forward and backward.
12:09So there you have some descriptive information that has been added to each slide in your slide show.
12:15Again the reason why that code to make that functionality was provided for you was because it's just simply all review.
12:22You've already done it before in the about us module.
12:25It simply is a new text field dot style sheet object, you then instruct that text field dot style sheet object to load in the styles
12:34from that same styles.css file and once that has been loaded, you use the on load event handler from that CSS style object to then both apply
12:44that style sheet to the loaded info text field and then execute the function load frame,
12:50which then goes and loads the particular slide show file as well as the descriptive text for that same slide show file.
12:58Lastly, you just say if there was a problem loading the styles.css file, display this error message.
13:04So that's the only functionality that was provided for you for this FLA because you already learned how to do it previously.
13:11In the next exercise, you're gonna finish off the frames module by writing a little bit more action script that displays
13:18which slide number the viewer's currently looking at out of how many slides there are total on that dynamic text field on the stage
13:26in between the previous slide and the next slide show buttons.
Collapse this transcript
Adding the current slide counter
00:00>> In the final exercise in this chapter, you're going to learn how to have the current slide number
00:07out of how many slides total appear here between the previous and next slide buttons.
00:13Again, in the sample site, you can see that in between those two buttons it says frame style one of ten.
00:19And then when the viewer clicks on the next button, for example, it updates to say frame style two of ten.
00:26Now some of the text stays the same, it's static, it says frame style, that always is there, as well as the "of" in between the two numbers.
00:35But the number that represents the slide that the viewer's currently looking at,
00:39as well as the number that represents how many slides there are total, changes.
00:43Because again, this number updates depending on the number that is inside of that separate text file.
00:50So if you or the client later goes and makes adjustments to that total number,
00:55that number here that appears here in the text field, as well, will also update.
00:59So that number, as well as the number that represents which slide the viewer's looking at currently, are the two variables inside of this text.
01:08So as you're writing the action to get this text to be displayed inside of there,
01:13you're going to be utilizing both static strings of text as well as variable information.
01:19Additionally the action that places this text within this text field is going to be executed from various places.
01:26Because of that, you're going to create a function that contains the action that places this text within the field, again,
01:33so that you can utilize that same action from multiple places.
01:37Once you've gotten a better idea as to what we're constructing in this chapter,
01:40go ahead and close your browser window, if you have it open, and return to Flash 8.
01:46Inside of frames.fla, select the first key frame in layer "A" and open up your actions panel.
01:53You're going to write this function that tells that text field on the stage what to display underneath your load frame function.
02:01So in your actions panel, locate the function load frame, click after the closed curly brace that ends that function and press return
02:10or enter a few times to create some empty line breaks.
02:13Then create a new function called slide counter by typing function, space, slide counter, open parenthesis, closed parenthesis,
02:25space open curly brace a couple of line breaks and a close curly brace.
02:30Then click in the empty line break in between the open and close curly braces and let's insert some text into that text field.
02:37If you remember, the name of that text field is called frameNum.
02:42You assigned it at the beginning of this chapter, to that text field.
02:46So type frameNum, with a capital N in num, dot txt.
02:52That means we're gonna put some text inside of that text field.
02:56Then type space equals space, and now what text are we gonna wanna insert in there?
03:02If you remember, the text that we're inserting into that text field is a combination of just static text, such as frame style,
03:10as well as dynamic text, such as the variable information that's keeping track
03:14of how many slides there are total and which slide the viewer's currently looking at.
03:19So the first step is to type quote frame style space quote, so the first text that's going to be inserted into that text field says frame style
03:29and then a space, and then type space plus space and then we want to have it to display the current frame number,
03:38that same variable that we're keeping track of to allow us to define which frame number the viewer's currently looking at, so type curFrameNum.
03:49However, remember, we're keeping track of that current frame number starting with the number zero.
03:54It would be a little confusing to the viewer if we showed the viewer that they were currently looking at frame zero of 10, for example.
04:03That would kind of be a little confusing to them.
04:05So to make it a little bit more understandable for them, we're going to add one onto that number.
04:12So even though they're looking at the first slide of the slide show, which we're tracking as zero,
04:17to make it so that they can more easily understand it, we're gonna add one onto that so that it says you're looking at frame style one
04:25of ten, so after curFrameNum type space plus space one.
04:31Now so that Flash performs all of these catenations and additions in the correct order, let's enclose curFrameNum plus one within parentheses.
04:41When you encase expressions such as this within a set of parentheses,
04:45that tells Flash to perform that first before continuing on to the rest of the expression.
04:51So click before curFrameNum and type an open parenthesis, and then click after the one and type a closed parenthesis.
04:59So when this action is first executed, so far it's going to say frame style one.
05:05Now remember there's some more text that we need to insert after that, namely frame style one of 10.
05:12So after the current frame number that's being displayed, we wanna state the string of.
05:18So after the closed parenthesis type space plus space quote space of space end quote.
05:28Again, we're typing spaces in there because we want spaces in between the word "of" and the text
05:34as well as in between "of" and the total slide number itself.
05:38So after that quote, after of, type space plus space and then we wanna insert here how many frames there are total.
05:46As you've seen before, this is simply entered as slide info LV dot total frames.
05:57And then again, to end this action, simply type a semicolon.
06:01So when this function is executed, it's going to insert some text into the frame number text field and it's gonna say frame style,
06:09and again when this is initially executed for that first time it's going to say frame style one of ten.
06:16Now if you just have this slide counter function get initially executed,
06:21you run the risk of having this function be executed before this total frame variable gets loaded from the slide info LV load vars object.
06:32Remember earlier you wrote the slide info LV LoadVars object and instructed it to load the variables from slideinfo.txt.
06:42If you then, right after that, execute the slide counter function, which is then supposed to display the variable that is loading from that text file,
06:51you run the risk of telling it to display before the variable has been fully downloaded.
06:57In which case, if you tried that it would simply say frame style one of undefined because it hasn't loaded it yet.
07:05So what you need to do is slightly modify your slide info LV LoadVars object to add an on load event handler
07:13so that this slide counter function is only executed after it's confirmed that the variables from that text file have been downloaded.
07:22So that's what you're gonna add in now.
07:24Scroll to the very top of your actions panel, click after that very top most action which is the slide info LV LoadVars object creation action,
07:34and then press enter or return to create a new line break underneath that.
07:38As you've seen before, you're gonna write an on load event handler for that specific LoadVars object by typing slide info LV dot on load.
07:50Then type space equals space function space open parenthesis success and then strict type that success to the Boolean data type
08:03by typing colon Boolean close parenthesis space open curly brace two line breaks and a closed curly brace.
08:13Then click on an empty line break between the open and closed curly braces of the onload function and type if space open parenthesis,
08:22and again the space in between the if and the open parenthesis is optional,
08:27after that open parenthesis type success closed parenthesis open curly brace two line breaks and a close curly brace.
08:37So when they slideinfo.txt file is instructed to download and the variable and value pair from that text file is read in, if that download
08:48and parsing of that variable data is successful, what do you want to happen?
08:53Well, if it's successful in downloading it, then you want it to display this slide counter function so that it shows
08:59which frame style the viewer is currently looking at as well as utilizing that number inside of that variable, how many slides there are total.
09:09So back in the if success, in between the open and close curly braces for that if conditional statement, click in the empty line break
09:17and then execute that function by typing slide counter, which again is the name that you assigned that function,
09:25open parenthesis close parenthesis semi-colon to end that action.
09:30However, just as you've specified what should happen if it successfully downloads that variable value pair,
09:36you should also specify what should happen if it's unsuccessful for whatever reason.
09:41After the close curly brace that ends the if statement, click there, then type else space open curly brace two line breaks and a close curly brace.
09:53Then click in the empty line break, after the else curly brace and type frameNum, which is the instance name for that text field
10:04where that frame number information is being displayed at, dot text, meaning we're gonna insert some text in that text field.
10:11Space equals space quote and then simply type error, it's not a big text field so you can't enter in a big error message there,
10:19so we're just gonna type in error, end quote semicolon.
10:23And there you have it.
10:24So with the way things are currently constructed, your slide info LV LoadVars object is created,
10:32it's been instructed to download the variable value pairs from slideinfo.txt,
10:38if that's successful it's going to execute a function called slide counter.
10:43The slide counter function says insert some text into that FrameNum text field that says frame style, and again, when this first loads,
10:52it's going to say frame style one of and then it's gonna utilize the value of the total frames variable
10:59in that text file that it's loaded to display, in this case, ten.
11:03So it's gonna say frame style one of ten.
11:06However, if there was a problem loading the variable value pair from that text file,
11:11it's simply gonna take the text error and stick it inside of that frame num text field.
11:18Now if you saved the changes you've made to frames.fla, publish an updated SWF file, hide or minimize Flash for a moment,
11:27and then double click on master.swf in your site directory, you'll notice that when it first loads,
11:34it displays frame style one of ten, which is awesome.
11:38That's exactly what we want.
11:39However, when you click on the next or previous button, notice that even though the slide itself,
11:45as well as the descriptive information updates, the text itself does not.
11:50Even if I continue clicking on it, it never updates frame style.
11:54It simply just always says frame style one of ten.
11:57I can see why that is by closing my preview window, going back to flash and if I scroll down in my actions panel to locate my next slide button
12:07and previous slide button actions, I can see that each time the viewer clicks on the next slide button, for example,
12:13it executes the load frame function but it does not execute the slide counter function which updates that text field.
12:21So in my next slide button actions, click after where it says load frame to execute that load frame function, press return or enter once
12:31and then simply type slide counter open parenthesis close parenthesis semicolon.
12:38So what will happen is each time the viewer clicks on the next slide button it's gonna execute the load frame function
12:45and then execute the slide counter function.
12:48This will not only load the slide in the slide show and display the descriptive text for that slide, but also update that frame num text field
12:56to display which frame the viewer's currently looking at.
13:00Once you've typed out slide counter open parenthesis end parenthesis semicolon, select that action and copy it then scroll
13:09down to your previous slide button actions, click after the load frame function call there, press return or enter to create another line break
13:18and then paste that slide counter function call right after that.
13:23So each time the viewer clicks on the next slide button or the previous slide button it's going to execute both the load frame function
13:30to show the correct frame and the descriptive text as well as the slide counter function to update that bit of text in the frame numb text field
13:38to show the viewer which frame they're currently looking at.
13:41Now when we last tested our SWF file, I also notice that the frame num text field wasn't displaying the text as I wanted it to.
13:48So I'm gonna hide or minimize my actions panel for a moment, click on that frame num dynamic text field on the sage,
13:56and I can see that even though I specified to use the Vera Bold font, because I'm on Windows, I neglected to click on the full bold option.
14:04If you're on a Macintosh you don't need to select that, but on Windows I need to make sure
14:08that I select the full bold button if I'm applying my Vera Bold font.
14:14Now that I've made all those changes, I'm gonna go ahead and save my FLA, publish an updated SWF and then hide or minimize Flash
14:24and then open up the master.swf file in my site directory.
14:28When I do that, and I click on the next button, my text now updates to say frame style two of ten, for example.
14:36So again, as I continue to click on the next slide show button, not only do my image
14:41and the descriptive text update, but my frame num text does as well.
14:46So it is now giving me correct updated information about which slide the viewer is currently looking at,
14:52and it does that when I both go forward and backward in the slide show.
14:58So there you have it.
14:59There you have the completed frames module that utilizes quite a bit of action script to not only load the slides
15:06in the slide show dynamically using the myMCL movie clip loader object that's in the master.fla file, but it also loads, again, dynamically,
15:15as well as styles, dynamically, some descriptive text about each slide as well as which slide the viewer's currently looking at.
15:22Now only that, but the slide show itself is intelligent in that as it gets to the last frame in the slide show, it knows that it's on the last frame
15:31so when the viewer clicks on it, it then goes back to the very beginning.
15:35The same holds true, but in reverse, for going backwards in the slide show as well.
15:41So you've done quite a bit in the slide show.
15:43You should be proud, obviously, of what you've done.
15:45You've accomplished quite a bit here inside of the frame module.
15:48Now, as you've seen thus far, you've done quite a lot of loading of external information, both external images as well as external text.
15:57In the next chapter, you're going to learn how to create a preloader that shows the downloading or preloading progress of your images
16:04or anything else that you use your myMCL movie clip loader class to download.
16:09So if a viewer comes to your website and they have a slow to moderate internet connection, as they're waiting for your imagery to download,
16:17or your SWF content, or whatever else you're using that movie clip loader class to download, it will display a preloading progress bar
16:24so they can see how that downloading progress is occurring.
16:27You're gonna complete that in the next chapter.
16:30For now, however go ahead and close your preview window and return back to Flash.
Collapse this transcript
8. Building a Preloader
Previewing what you're building
00:00>> In this chapter, you're going to learn how to build and add a simple preloader to your LA Eyeworks site.
00:08Now to give you a better idea of exactly what it is that you're going to be constructing in this chapter, for those of you who have access
00:15to the exercise files, open up the LA Eyeworks directory on your desktop and in there you'll notice there's another directory called Competed Site.
00:24If you open up the completed site directory, scroll until you locate the master.fla file, and open that in Flash 8.
00:33Then with that completed master.fla file open, choose control, text movie.
00:39Make sure that you have your bandwidth profiler turned on by choosing view, bandwidth profiler and give yourself some room
00:46to view what's going on here at the top left of the bandwidth profiler.
00:50I'm gonna do that by dragging the bottom portion of my preview window around a little bit so that I can still see the navigation bar
00:57at the top, but yet move it down as far as I can, like so.
01:03Then choose view, download settings, 56k.
01:08We're going to preview how this site is going to download on a 56k modem.
01:14Once you've selected that, then choose simulate download to, again, simulate how this website would be downloaded over a 56k modem.
01:23As you can see, it's downloading the sharedlib.swf file as we constructed earlier on in this title.
01:29When it finishes downloading the shared lib file, it'll download the splash, and again you can see that preloader appear there.
01:35But then click on the frames option from the navigation bar at the top and you can see the preloader that we're going to build in this chapter appear
01:44as the viewer navigates through the slides in the slide show which you just built in the last chapter.
01:50Click on the next slide button and you'll see that preloader appear again.
01:54We're going to build this preloader and hook it in to the myMCL movie clip loader object that exists in your master.fla file.
02:02So that each time the myMCL movie clip loader object is used to load in any kind of content, be it SWF, JPG, PNG, or GIF,
02:11it shows a preloader to show the downloading progress of that content.
02:16In this case, because our slide show utilizes the myMCL movie clip loader object, every time the viewer then uses that object,
02:24in this case to load the slides in the slideshow, it's going to show and then utilize that preloader.
02:30So each time the viewer navigates through the slideshow that preloader is going to appear and show the downloading progress of that image.
02:38That's what you're going to build in this chapter.
02:40Before you continue on to the next exercise, however, make sure that you close your preview window,
02:45and it may benefit you to also close the bandwidth profiler as well, and then if you opened up the completed master.fla file,
02:53go ahead and close that so you're just left with the master.fla file for the site that you're currently constructing.
03:00You're gonna start here in the master.fla file that you've been working in, in the next exercise.
Collapse this transcript
Getting started
00:01>> For those of you that do have access to the exercise files, one thing I would like to show you before we continue
00:07on much further is the completed preloader that I've provided for you.
00:11Hide or minimize Flash for a moment and navigate in to your site directory in the LA Eyeworks directory on your desktop.
00:19In there, you'll notice there's an FLA file called preloader.fla.
00:23Go ahead and open that FLA in Flash 8.
00:28In there, you'll see a graphic of a pair of glasses. With that graphic select, if you look in your Properties Inspector,
00:35you'll notice that it's actually a movie clip called mcGlassesAnim.
00:40Additionally, it has also been given an instance name of preloader.
00:44If you double click on that movie clip symbol to open it up,
00:47you'll notice that there's actually some shape tweens going on inside of this movie clip symbol.
00:52If you scroll your play head forward, you'll see the animation that appears as the content is being downloaded.
01:00If you'll scroll to your right in your timeline, you'll notice that the animation ends in frame 100, and that's not an accident.
01:08As our content is being downloaded, we're going to be using our movie clip loader class to monitor the downloading progress.
01:16More specifically, we're gonna be monitoring that download progress in terms of percentage.
01:21Zero being it hasn't been downloaded at all, 100 percent meaning that it's been completely downloaded.
01:27We're then going to be telling our preloader animation to move to the appropriate frame number
01:32that matches the percent of the content that's been downloaded.
01:36In other words, if our content is half way downloaded, we're gonna be telling our preloader animation here to move to frame 50.
01:4350 being 50 percent.
01:45When it's all the way downloaded, our play head will move here to frame 100.
01:50So essentially, we're just going to be using action script to find out what percentage of the content has been downloaded up to that point
01:58and then simply telling our play head inside the preloader, therefore, which frame it should move to.
02:04So as the content's being downloaded, this play head will be moving forward, thereby showing this download, or progress bar animation.
02:12For those of you that don't have access to the exercise files, inside of Flash 8, create a new, blank FLA and save it as preloader.fla.
02:21Save it into your site directory where the rest of your site content is saved at up until this point, then on the stage,
02:27create a movie clip symbol, give that movie clip symbol an instance name of "preloader", and then inside that movie clip symbol, create an animation,
02:37whichever kind of animations you'd like, that takes 100 frames.
02:42At the beginning, in an actions layer, on the very first key frame, add an action that is just simply stop,
02:50so that this animation doesn't automatically start playing.
02:53You only want the play head to start moving when the content is downloading and you tell that play head with action script to actually move.
03:01But if you don't add that stop action there, it'll start playing automatically.
03:05So that's all you need, essentially, is just a 100 frame long animation, it can be whatever you want it to be, inside of a movie clip symbol,
03:12and on the stage that movie clip symbol has an instance name of preloader.
03:16Now what we need to do, for those of you that do have access to the exercise files, or for those of you that don't have access
03:22to the exercise files, and have built your preloader.fla file yourself, is we need to publish a SWF file from this FLA.
03:30So choose file, publish to publish a SWF.
03:35Then go ahead and close this FLA file, in this case I'm not gonna save any changes since I have not made any changes to this FLA,
03:42and then make sure that you're back in master.fla that's in your site directory in the LA Eyeworks directory on your desktop.
03:50There, select the very first key frame in the "A" layer and open up your actions panel.
03:57Earlier, this is where you wrote your myMCL movie clip loader object,
04:01and it's in here where you're gonna write the additional action script that's gonna make that preloader actually work.
04:07You're gonna start doing that in the next exercise.
Collapse this transcript
Working with onLoadProgress
00:01>> As you've seen before some action script objects such as the LoadVars object or the movie clip loader object have event handlers that allow you
00:11to listen to what that object is broadcasting and then have other things occur based on those listeners.
00:17For example earlier you created the LoadVars object and you utilized the on load event handler
00:24to do certain things when that content has been completely downloaded.
00:29What we're going to need to use another event handler for the movie clip loader class that's going to allow us to build the preloader.
00:37When you're working and building a preloader and you want to show the downloading progress of content you need to construct a way
00:43that enables you to loop through a series of actions. The reason why is
00:47because essentially what your downloading progress preloader is doing is continually asking how much of the content has been downloaded.
00:55It's almost like the annoying kid in the back seat on a long trip "Are we there yet Dad?
00:59Are we there yet?"
01:00Your preloader is doing exactly the same thing, over and over again you want it to continually ask, how much of the content has been downloaded?
01:07And each time it asks it gets back new and updated information, it can then use that information to then show and update the progress bar so that
01:17as the content is being downloaded the progress bar is also updated to show an updated version of the downloading progress of your content.
01:26Now in years past when you would want to construct a preloader inside of Flash you would have to come up with a way to loop through a series
01:33of actions, one of the old school methods of doing that would be to create a couple of key frames inside your time line.
01:39On one key frame you would have your action script that would ask how much of the content has been downloaded then the play head would move
01:46to the next key frame where you would have an action that said go back to the last key frame and replay that again so your time line
01:54and your play head more specifically would be constantly moving back and forth between two frames and every time it would hit
02:00that first key frame it would say how much of the content has been downloaded.
02:05Now as Flash or action script more specifically got more advanced there came to be better methods of looping through a series of actions.
02:14There are a few other ways of looping through those actions, one is called the one inter-frame clip event which loops through a series of actions
02:22at the same rate that you'd have the frame rate of your movie set at, the frame rate of our movie it set at twenty one frames per second,
02:29an on inter-frame clip event will perform a series of actions twenty-one times per second.
02:36The advantage of an on inter-frame clip event is that it's fairly easy for you to set up and utilize.
02:43The disadvantage of it is that it doesn't give you any control over how often it loops through a series of actions.
02:50Another way of creating a way to loop through a series of actions is something called a set interval function.
02:56Set interval allows you to also again loop through a series of actions, the disadvantage of it is that it takes a little bit extra work for you to set
03:05up and create. It's also a little bit extra work for you to manage, you have to make sure you clear it correctly
03:11and there's a few other issues involved with working with it. The advantage of working with the set interval function on the other hand is
03:17that it gives you precise control over how often a series of actions are looped through.
03:23You can tell it to loop through actions every millisecond,
03:26you can tell it to loop through actions every ten minutes, you have precise control over how it works.
03:32Now before the movie clip loader class came along and Flash MX 2004 and action script 2.0 you would be forced to use either the
03:40on inter-frame event handler or set interval to be able to loop through those series of actions to enable you to create your preloader.
03:48However now that the movie clip loader class exists there's an event handler in the movie clip loader class called on load progress.
03:57On load progress is an event handler that gets triggered every time your movie clip loader downloads a little bit of data,
04:05so as the movie clip loader object in this case your movie clip loader object is called myMCL every time that object is downloading content
04:15from something it's continually re-triggering the on load progress event handler. What that means is essentially it's a perfect place for you
04:23to write your preloader actions script because the event handler function and all the actions that you put within it are going
04:30to constantly be repeated every time your movie clip loader class is downloading data.
04:34So in the first part of this exercise that is exactly what you're going to do, you are going to create on load progress event handler.
04:41Before we continue with that though make sure that you're still in master.fla that you have the first key frame in your layer A selected
04:48and that you have your actions panel open. At the top of the actions panel is where you have you actions movie clip loader script, we're going
04:56to add this within the MCL and end MCL comment lines, in there click after the action my MCL dot add listener and press enter
05:06or return a few times to create a couple of line breaks.
05:10Now when you're dealing with event handlers for the movie clip loader class you don't assign those event handlers
05:16to the movie clip loader class object itself, in other words unlike what you've seen with the LoadVars class when you're dealing
05:23with adding event handler such as the on load event handler which is assigned to your LoadVars object myLV you do not do
05:31that with the movie clip loader class, instead they get assigned to the listener object that you've assigned
05:37to the movie clip loader class, in this case that's called my listener.
05:42So in the new empty break you've created type My Listener dot On Load Progress, again this is attached to a function just
05:54like the event handlers are for the LoadVars object for example so type space equals space, function, open parentheses, end parentheses, space,
06:06open curly brace, a couple of line breaks, and close curly brace.
06:10Now again the fantastic thing about on load progress event handler is that any actions you place within this function will get automatically executed
06:19over and over again as the movie clip object loader is being used to download data every time just a little bit of data is downloading it's going
06:27to execute this on load progress event handler again, so in essence it loops through those actions over and over.
06:34Now as the movie clip loader object myMCL is used to go and get and download content it's going to be broadcasting information
06:43to the listener object, now the listener object which we've assigned our on load progress event handler to is going to be receiving that content.
06:52In terms of the on load progress event handler it's going to be receiving three bits of information that we're going
06:58to want to pick up on when we're creating our preloader.
07:02The first thing which isn't really important for how we're constructing this particular preloader is
07:06which content its downloading, what is it getting?
07:10Is it getting SWF file?
07:11What's the name of that SWF file?
07:13And so forth, the target movie clip in other words.
07:16The second bit of information that it's going to be receiving that has passed through the movie clip loader object is how many bytes has been loaded?
07:24That's a parameter that we're going to be entering to the on load progress function called loaded bytes.
07:30Another one, which again is a necessary piece of information that's being received from the movie clip loader class is how many bytes there are total
07:38for the content that it's loading. The loaded bytes and the total bytes are two necessary pieces of information to create your preloader.
07:47You need to know how much of the content has been downloaded and how much content is there total to be able to build anything like a preloader.
07:55Luckily all that content and data is being passed from myMCL Movie clip loader object to our listener then broadcast it to our
08:03on load progress event handler, what this means is again because its being passed as perimeters we need to specify here in the
08:11on load progress function in between the open and closed parentheses.
08:15So after My Listener dot on load progress function open parentheses, click between the open and closed parentheses and lets enter
08:24in those function perimeters, type Target, under score, MC, which as I mentioned we didn't need but we still have to specify here regardless
08:34and then strict type that to the movie clip data type because again its going
08:38to be receiving the instance name of a movie clip that content is being loaded into.
08:43Type colon, movie clip, then type comma, space, loaded, bytes, all one word with a capital B in bytes
08:54and that perimeter is going to be a number so type colon number.
09:00Then type comma, space, total, bytes, all one word with a capital B in bytes
09:06and that is also a number so strict type it to the number data type as well.
09:10Now that we've specified those perimeters in the on load progress event handlers for our movie clip loader object we can utilize those perimeters
09:19which again are essentially just like variables in our action script within the on load progress function.
09:24So within the on load progress function here, whenever we want to find out how many bytes have been downloaded so far,
09:32we can simply just type in loaded bytes, the same holds true for total bytes.
09:37O after the open curly brace, after the on load progress function, but before the close curly brace to end that function,
09:44click in the empty line break that you created and let's write an action that utilizes both the loaded bytes number and the total bytes number
09:52to find out what percentage of the content has been downloaded up to this point.
09:57We're gonna also store that number inside a variable so that we can use it later.
10:02Type var, space, preloadPercent, all one word with a capital P in Percent, this is gonna be a number obviously,
10:12so let's strict type it to the number data type, space, equals, space and then to find out the percentage,
10:19what we do is we divide how many bytes have been downloaded up to that point by how many bytes there are total
10:26and then we take that number and multiply it by 100.
10:30That's gonna give us the percentage of the content that's been downloaded up to that point.
10:34So type loaded bytes, forward slash for divide, total bytes, space, asterisks, space, 100, semicolon to end the action.
10:50So Flash is gonna take the loaded bytes up to that point, divide them by how many bytes there are total, and then multiply that by 100.
10:58Now we're gonna be utilizing this number here to be able to tell our preloader exactly which frame it's supposed to go to.
11:05Remember, our preloader goes from frame one to frame 100, and we wanna be able to tell that preloader which frame it should go to.
11:13Well, when Flash is executing this calculation here and finding out the loaded bytes divided by total bytes multiplied by 100,
11:21it can come up with an uneven number, for example 10.3542.
11:27Remember, we're utilizing that number to tell our preloader animation which frame it should move to.
11:32We have no frame called 10.3542, so what we wanna do is we wanna tell Flash to round out that number to an even number.
11:41Before loaded bytes, click there and type Math with a capital M, dot round, then type an open parenthesis, click after total bytes,
11:53but before the asterisks, and then type a closed parenthesis.
11:57What Math.round does, is it takes whatever's inside of the open and close parenthesis, and once it has that number it rounds out into an even number,
12:06so I it came up with 10.3542, it would round it to be 10.
12:11Then it's going to take that even number and multiply it by 100.
12:15So now, thanks to Math.round, we're gonna end up with an even number here inside of our pre-load percent variable.
12:23Now that we know the percentage of the content that's been downloaded up to that point,
12:27we can then tell our preloader to move to the appropriate frame.
12:31However, you might be saying to yourself, well where is the preloader?
12:35When we looked at the FLA, but where is it?
12:38How do I tell it what to do?
12:39Can I say preloader.swf go to such and such frame?
12:42Well we haven't yet loaded the preloader.swf file.
12:46In just a little bit, we're going to take the preloader.swf file and load it into a level.
12:52We're going to actually load it into level 50.
12:55Why level 50?
12:56We're going to have it load above everything else.
12:58That way, all the rest of our content that makes up our LA Eyeworks website is going to load beneath it,
13:05that way our preloader will always be visible whenever we need it, because it's above everything else.
13:11So even though you haven't yet written the action to load the preloader.swf into level 50, you're going to refer to it as being in level 50 right now.
13:19And then in just a minute we'll go and add that action script to load preloader into level 50.
13:25Click at the end of the action that you just wrote, after the asterisks, 100, semicolon.
13:30Press return, or enter, to create a new line break and then type underscore, level, 50.
13:36That's going to target our preloader.
13:38If you remember, the preloader movie clip inside of there that contains the animation that makes up our preloader is in a movie clip symbol
13:46with the instance name of preloader, so type dot, preloader.
13:51Then we want the play head of that movie clip to go to and stop on a certain frame, so we say dot gotoAndStop,
14:00all one word with a capital A in "And" and a capital S in "Stop".
14:05Well then, where do we want the play head in the preloader movie clip symbol to go to and stop at?
14:11Well, whatever this preload percent number is.
14:14If it's downloaded 25 percent of the content, then move the preloader play head to frame 25.
14:20So after gotoAndStop, type open parenthesis, preloadPercent, making sure you have the spelling and capitalization correct,
14:29and then type a close parenthesis and a semicolon to end that action.
14:34Now again, keep in mind that all the actions within the onload progress function, which you have two actions so far, are going to be repeated
14:41and performed over and over again as the movie clip loader object is downloading content.
14:47So each time you use the movie clip loader object to download content, such as in the frames module slide show,
14:53it is going to be constantly re-executing the actions in here until the content has been completely downloaded,
14:59in which case it won't perform the actions in here any more.
15:03In the next exercise, we're going to load our preloader into level 50 and we're also going to write a few more actions that tells that preloader
15:11when it's okay to be shown as it's downloading content, and when it should hide itself after the content's been downloaded.
15:18You don't want the preloader to just stay there on the stage, visible, you want it to hide itself.
15:23You're gonna do that as well as load the preloader in, in the next exercise.
15:27Of course, before you continue, to make sure that your house and computer doesn't get struck by a lightening bolt and you lose all your information,
15:34make sure that you save the changes to your FLA file.
Collapse this transcript
Showing and hiding the preloader
00:00>> Now that you've written the action script that actually tells the preloader animation which frame to go to and it gets that number based
00:08on the percentage of the content that's been downloaded up to that point, thanks to the on load progress event handler,
00:16you should write the action script to also load the preloader into the correct level.
00:21We're going to do that here in master.fla in the very first key frame, which is where you've been writing your movie clip loader content.
00:29Inside of the first key frame in layer "A", scroll down in your actions panel until you see the comment 'trigger the MCL to load these assets.'
00:39Underneath that you should already have an action that loads trigger.swf in to level five.
00:44At the very beginning here of master.fla, we also wanna load in our preloader.swf file as well,
00:51so that we can utilize that preloader and display it throughout the rest of our movies.
00:56So click after the myMCL dot load clip trigger dot SWF action, press return or enter once to create a new line break,
01:04and then type myMCL dot load clip open parenthesis quote preloader dot SWF end quote comma space 50,
01:17as in the number of the level that we wanna load it in to.
01:20Then type a closed parenthesis and a semicolon to end that action.
01:25So now preloader.swf is loading into level 50.
01:28If you'd like, you can test what you've done so far by saving the changes that you've done to master.fla and choosing control, test movie.
01:38When you do that it might also be beneficial to turn on the bandwidth profiler and again, under view,
01:45make sure that your download settings are still set to 56k and then giving your preview window a little bit more room, especially the top left portion
01:54of the bandwidth profiler and then choosing view, simulate download.
02:01You see the sharedlib.swf file download first.
02:04The reason why, by the way, you don't see the preloader actually functioning as the sharedlib.swf file is downloading,
02:11is because it's not using the movie clip loader class that we created to download the shared lib file.
02:16When the frame module appears, if you click on the next slide button, you should see the preloader actually animate across,
02:23and in this case, I'm not seeing that same effect happen.
02:26So I'm gonna close the preview window, go back to master.fla, in the first key frame of layer A and take a look again at my action script.
02:35And looking really quickly at my action script, I can see what I left out is
02:38in the action var preload percent number math dot round loaded bytes divided by total bytes multiplied by 100 is that when Flash is going
02:48to perform this math here, it's actually treating these as separate values.
02:52So what I want to do to ensure that Flash treats all this content as one number, that it's then inserting into the preloader percent variable,
03:00is enclose all of this also in another set of parentheses.
03:05So after math dot round and before that other parenthesis click there and type another open parenthesis and then after 100,
03:15but before the semicolon, click there and type a close parenthesis.
03:18What was happening before was that Flash was taking a calculation that wasn't quite finished and putting it inside
03:25of the preloader percent variable, then when I was trying to tell my preloader to then move to that number,
03:31because the number hadn't been fully calculated yet, it couldn't do anything.
03:35By enclosing this entire calculation in it's own set of parentheses, what this essentially tells Flash is to take the loaded bytes divided
03:44by the total bytes, do that calculation first, then once it has that number multiply that by 100 and once it's all done that,
03:52round that out and then make sure that that's in the preload percent variable.
03:57Now if you save the changes to your FLA file and then test your movie, when you then choose view, simulate download
04:07and wait for your sharedlib.swf file to preload, when the frames slide show image loads, you can see it actually perform that preloader animation.
04:18So if I click on the next slide in the slide show, you'll see that preload animation perform again.
04:23Now of course the problem is, is that the preloader stay visible on top of the rest of my content, again, because it's loaded into level 50,
04:31even after its finished showing the preloading progress of that downloading content.
04:37To remedy that, what' I'm going to do is utilize another event handler to turn off the visibility of that preloader once the content
04:45that has been downloaded using that movie clip loader object has been completely downloaded.
04:51To do that, close your preview window and then return back to the first key frame in the A layer, in master.fla.
04:59Locate the closed curly brace that ends the onload progress function and click after that closed curly brace, then press return
05:07or enter a few times to create a couple of empty line breaks.
05:10Then type my listener dot onload complete.
05:17Onload complete is another event handler that is associated with the movie clip loader class.
05:22This event handler is executed when the content that has been downloaded
05:27with the movie clip loader class has been completely downloaded, as its name implies, onload complete.
05:33Again, just like onload progress, I need to assign it to a function.
05:36So type space equals space function, and then I also need to specify the parameters that are being passed to the onload complete event handler
05:46by typing open parenthesis target underscore MC colon, and since the target underscore MC parameter is being passed the name of a movie clip,
05:58I'm going to assign it to the movie clip data type by typing movie clip, like so,
06:03and then type close parenthesis space open curly brace two line breaks and then a close curly brace.
06:11Then in between the open and close curly braces for the onload complete function, I'm going to specify what I want to happen
06:18when the movie clip loader content has been completely downloaded.
06:22Well, once the content has been completely downloaded, what do I want the preloader to do?
06:28Well, I want it to hide itself.
06:29I want it to go away so that the viewer doesn't see it there, sitting on top of the rest of the content on the stage.
06:35To do that simply type underscore level 50 dot underscore visible, which is the property of a symbol or in this case of a level,
06:47space equals space false semicolon to end that action.
06:51By setting the visible property of content to false, that makes it invisible.
06:56So the actions that you've just written essentially tell our preloader to hide itself when the content that is being downloaded
07:03with the move clip loader object has been completely downloaded.
07:06Well now that you've told it to hide itself, you also need to tell the preloader when it should show itself.
07:13Currently, the way it's set up, is that it would be visible the first time it's shown, but then after the content has been completely downloaded,
07:19it would hide itself and it would never show itself again.
07:23Just like you told the preloader when to hide itself, you also need to tell it when to show itself.
07:27So after the open curly brace that beings the onload progress function click after that open curly brace
07:35and press return or enter to create a new line break.
07:38It's within the onload progress function that you're going to write the action that tells that preloader to show itself so that
07:45as content is being downloaded it tells that preloader to make itself visible.
07:50So now type underscore level 50 dot underscore visible space equals space true semicolon.
08:01So now if you save the changes you've made to this FLA file, and then test your movie, and then again, I'm gonna give my preview window a little bit
08:09of extra room so I can see what's going on in the top left portion of the bandwidth profiler, like so, make sure under view, download, settings,
08:19that I still have my 56k modem selected, and then choose simulate download and wait for my sharedlib.swf to be completely downloaded.
08:27Notice how I don't see my preloader graphic appear at all.
08:31Then once sharedlib.swf has been completely downloaded, it's gonna show the downloading progress of that first slide in the slide show,
08:38and then once it's finished downloading that first slide in the slide show, and the movie clip loader is no longer in use, it hides that preloader.
08:46Then when I click on the next button to load the next slide in the slide show, it activates the movie clip loader object again,
08:52which says hey preloader, show yourself and start showing the downloading progress of the content, like so.
08:59And then once that content's been completely downloaded, then it hides the preloader again.
09:05So there you have a fully functional and working preloader.
09:09In the next few exercises, which are completely optional, I'm gonna be showing how to add a little bit of extra information to your preloader
09:16so instead of just seeing a progress bar, there's gonna be some information that appears both above and beneath the preloader
09:23to give the viewer a little bit of additional feedback as to how much content is being downloaded and how much longer they have to wait.
09:30Before you continue on, however, feel free to close your preview window.
Collapse this transcript
Adding more information to the preloader (optional)
00:01>> Now that you have learned how to create a preloader and add it to your project,
00:04let's take a look now at how to add a little bit extra information to your preloader so that as the viewer is navigating through your site and seeing
00:12your preloader, they are getting a little bit more detailed information as to how the content that they are downloading is proceeding.
00:20To do that, we first need to go back and open the preloader.fla file, so minimize Flash,
00:26go back into your site folder and double click on the preloader.fla file.
00:31Now we are going to have this extra bit of information be displayed in two text fields so we are going to need
00:38to create two text fields, one on top of the preloader graphic and one below.
00:43The text field at the top is going to display what percentage of the downloading content has been downloaded up to that point
00:50and the text field underneath it is going to display basically the same thing, but in terms of kilobytes.
00:56It is going to say so many kilobytes have been downloaded out of so many kilobytes total, so again, the first step is to create a couple
01:04of text fields to display that information, so inside your preloader.fla file, first select your Text tool
01:12and then in your properties inspector you need to specify how you want that text to be displayed.
01:18Make sure that the text type is set to dynamic text and then you need to choose a font face, in this case because we want the preloader to be
01:26as small as possible in terms of file size let's just use a device font so that we are not embedding anymore font information
01:34into the preloader SWF file, so from the font pull down menu click and choose underscore Sans then go ahead and choose a text color
01:43of something just straightforward like black, on this case, I want to make sure that I don't have any full bold
01:48or full italic selected, so I am going to make sure that's unchecked.
01:51I am going to also make sure that the line type is set to single line and not multi-line, this is just going to be one line of text.
02:01Then above my preloader graphic, I am going to click to create a dynamic text field, once I have created that text field,
02:07I am going to de-select it by either hitting the Escape key on my keyboard or selecting another tool in my Tool box.
02:14Now that that dynamic text field is still selected, down in my Properties Inspector, I can see that it has set itself automatically to input text.
02:23I want to make sure after I have created that text field that it is set to the settings that I want, in this case, dynamic text.
02:31I also don't need that dynamic text field to be selectable and I don't need it to be rendered as HTML either.
02:37I am also going to change the font size to be something a little smaller, say 9 point, and I am going to just make sure that the rest
02:45of the settings are where I want them to be and they are in this case.
02:49The other thing I need to do is give it an instance name.
02:52If I am going to tell that particular text field to be populated with text, it needs a name so that I can target it with my action script,
03:00so again with that text field still selected, in the Properties Inspector I am going to click in the instance name field and give it an instance name
03:08of 'Preloadinfo1' and then I am just going to press Tab or Enter to have it accept that name.
03:17Now I want to create another text field just like it, but down below my preloader graphic so again with my Text tool still selected,
03:24I am going to click down here toward the bottom, then I am going to press Escape to get out of that text editing mode.
03:31And then go down to my Properties Inspector and verify my options, they should still be set to what I set up last time for the previous text field,
03:39the only thing I need to modify in this case is to give it a new instance name.
03:44So again, with that new text field still selected, click down here in the instance name field in the Properties Inspector
03:51and give it an instance name of 'Preloadinfo2', so now I have two text fields that are going to display information about the preload in progress.
04:03I want to make sure that they are aligned properly so that they look good, so to do that select your Selection tool,
04:10select both of those dynamic text fields, and open up your align panel.
04:15The keyboard shortcut to do that on Windows is Control "K" or Command "K" on the Macintosh.
04:22In the align panel, I want to make sure that those two text fields are aligned horizontally with each other,
04:28so first making sure that the two stage button is not depressed I am going to click
04:33on the align horizontal center button to align those both with each other.
04:38Then I want to make sure also that those two text fields are aligned horizontally in the center of the stage,
04:44so this time I am going to select the two stage button and then again click
04:49on the align horizontal center button to align those both in the center of the stage.
04:54Vertically, they look like they are positioned pretty well so I am going to leave them where they are currently and I am going to close my align panel
05:01by again pressing Control "K" or Command "K" on the Macintosh.
05:05Now I am not exactly sure how wide the text that is going to be displayed in those text fields is going to be.
05:12I am not exactly sure because if the information that is going to be inserted into those text fields dynamically,
05:18how much horizontal space those text fields are going to need to display that information.
05:24So what I am going to do, as you have seen before, is that a little bit of action script
05:28that dynamically sizes those text fields horizontally to fit the amount of space that is needed.
05:35To do that, go ahead and create a new layer inside of your preloader.fla rename that new layer to be titled, as you have seen before again,
05:44A for Actions and then select the first key frame in that actions layer and open up your actions panel.
05:52Then click inside of the script pane within the actions panel and click in the insert a target path button.
06:00You should see the two text fields that you have just created Preloadinfo1 and Preloadinfo2.
06:05Go ahead and select Preloadinfo1 and it should automatically assign the path this dot preloadinfo1 for you up here in this field.
06:14If you see that, just go ahead and click Ok and it will automatically insert the path to that text field and the name inside of your script pane.
06:22Now what we wanted to do is have that text field auto sized to automatically expand to fit whatever is inside of it,
06:30but have the content be aligned in the center of that text field so that both the left hand side of the text field
06:36and the right hand side dynamically resize out or in as needed.
06:41To do that, just type dot auto size space equals space quote center, end quote semicolon to end that action.
06:52You want to do the exact same thing, but for the second text field Preloadinfo2, an easy way of course to do that would just be to select
07:00that first action right click or control click on it and choose copy, click at the end of that action, press return or enter to create a new line break
07:10and then right click or control click on that new line break and choose paste.
07:15Then all you need to do is change that Preloadinfo1 to Preloadinfo2, so there you have two text fields inside of the preloader
07:22that are automatically set up to receive some dynamic information.
07:26As you are going to see in just a minute, the text that is going to be inserted in there is going to show more information
07:32about the downloading progress of whatever is downloading at that point.
07:35First, you need to make sure that you save the changes that you have made to the preloader.fla and then publish a new SWF file, so choose file,
07:44publish, then you can go ahead and close the preloader.fla, you won't be needing it again in this movie and then go back to the master.fla file.
07:54Inside the master.fla file is where the action script is written that controls that preloader, so inside of master.fla make sure
08:03that you have the first key frame in the actions layer selected and that you have your actions panel open.
08:10Toward the top of your actions panel, you should see the mylistener dot on load progress function.
08:16It is here that it is actually showing as the content is being downloaded the preloader work is showing that animation that preloader animation occur
08:26and it is within this on load progress function that you are going to write the code that is going
08:31to show inside those text fields a bit more information about the downloading progress.
08:37Once you have found your on load progress function, in there you will see a line of code
08:42that says underscored level 50 dot preloader dot go to and stop preloader percent.
08:48Click at the end of that action and then press return or enter once to create a new line.
08:53Now the first thing I am going to do is to insert a little bit of text into that topmost text field that shows what percent has been downloaded so far.
09:04Again, you are already tracking that number, that percent.
09:07As you can see, there is a variable that you created earlier that says var preloader percent
09:12and then it does a little bit of calculations to arrive at that percent.
09:16So all you are going to be doing is reusing that variable and taking the text that is being stored in that variable
09:23and inserting it into a text field with a little string.
09:26So to do that type underscore level 50, which again is where the preloader is being loaded into which is also where our text fields are,
09:36dot preloadinfo1, which is the instance name of that topmost text field inside of that preloader, then type dot text to insert some text
09:47in there space equals space preload percent, preload percent is of course that variable that is storing what percent of the content
09:59that has been downloaded up to that point and then after that you want to add a little bit of string,
10:05so instead of the viewer just seeing a number inside that text field they will see a number as well as percent loaded
10:13so they have a better idea of what that number is supposed to represent.
10:16So after preload percent, type space plus space quote space percent space loaded and then type in end quote and a semicolon to end that action.
10:32So what is being inserted into that topmost text field is a little bit of text and that text that is being inserted in there is the percent
10:40of the movie that has been downloaded up to that point and then after that is a little bit of text that says percent loaded.
10:47Now in the bottom most text field you are going to display the raw numbers, you are going to show how many kilobytes have been downloaded up to
10:54that point and how many kilobytes there are total, so if the viewer wants even more detailed information about what has been downloaded
11:02and how much there is total, they can view it just by looking at that text field.
11:07So after that action you just created, press return or enter to create a new line break and then again type underscore level 50 dot preloadinfo2,
11:18which is that bottom most text field in the preloader, dot text space equals space and then now you want
11:27to display how many kilobytes have been downloaded up to that point, well you are already tracking how many bytes have been downloaded,
11:36as you can see, if you look up in the on load progress function there is a parameter in there that is being passed
11:42from the movie clip loader called loaded bytes that loaded bytes parameter is tracking how many bytes have been loaded up to that point.
11:51So type "loaded bytes" when Flash goes to run this code, it is going to insert how many bytes have been loaded up to that point.
11:59Now we want to display how many kilobytes have been downloaded up to that point.
12:04To do that, you need to divide that number by thousand so after loaded bytes type a forward slash one thousand
12:13to divide how many bytes have been loaded up to that point by thousand which gives you how many kilobytes have been loaded up to that point.
12:20Now some of you may be saying, "Wait a second, there is 1024 bytes in a kilobyte so why are we dividing it by a thousand?"
12:28When Flash deals with data transmission, content being downloaded over the internet as we are dealing with here in our preloader,
12:35it actually treats one kilobyte as a thousand bytes.
12:40When you are dealing with files that are being stored on someone's hard drive, then it treats one kilobyte as 1024 bytes,
12:49but again in this case because it is being transmitted, Flash treats that as 1000 bytes per kilobyte.
12:56Now when Flash does this math, it takes how many bytes have been loaded up to that point and divides it
13:01by 1000, it is not always going to yield a whole number.
13:04It may come up with a number like 12.3337, now obviously the viewer does not need such detailed information so let's round that number out.
13:14To do that, it is actually quite easy, click before loaded bytes and type math dot round
13:22and then an open parenthesis click after the 1000 and type in closed parenthesis.
13:28What that does is it tells Flash to round math dot round the value that is inside of the parenthesis so Flash is going
13:36to perform this calculation loaded bytes divided by 1000 and then it is going to round that number out to a whole number for us.
13:43Now again, that text that number is going to be displayed inside of the preloadinfo2 text field inside of our preloader.
13:51If we just left it as it is now, the viewer would only see a number, but they would have no idea what that number represents,
13:57so after that type space plus space quote space K loaded, as in kilobytes loaded, and then type space forward slash space end quote space plus space,
14:17and now we want to display how many kilobytes there are total, so the first thing it displays is how many kilobytes have been loaded
14:23and then after that it is going to display how many kilobytes there are total so the viewer has a little better idea
14:29as to how much has been downloaded and how much there is total, to get that value you do it very similarly to what you just did
14:37with loaded bytes except now you are going to be working with the value total bytes, so after the plus sign that you just created,
14:43type total bytes forward slash a thousand, again you want to round that number off as well so before total bytes,
14:54type math dot round open parenthesis and then click after the total bytes forward slash a thousand and then close parenthesis.
15:03Then you want to display a little string of text after that that says K total so type space plus space quote space taking that space
15:14after that number K total end quote semicolon to end that action.
15:21So there you have the two lines of code needed to insert some text into the two text fields that you added inside of the preloader.fla file.
15:30Inside of the topmost text field, which you gave an instance name of preloadinfo1 too it is going to display what percentage
15:37of the content has been downloaded up to that point as well as the string of text percent loaded
15:43so that the viewer knows what that number is supposed to represent.
15:46In the text field below it, which you gave the instance name of preloadinfo2 too it is going to display how many kilobytes have been loaded
15:54up to that point and then the text K loaded forward slash and then how many kilobytes there are total, after that is displayed,
16:02a bit of text that says K total so the viewer knows exactly what is going on.
16:07Now, go ahead and save the changes you have made to master.fla and test your movie.
16:15You should see the first slot and the slide show appear but to actually view our preloader
16:20and see it actually downloading the content working we need to first choose a modem speed at which to test it at, as you have seen before,
16:28so from the preview window choose view download settings and choose a modem speed to test, I am going to leave it set to 56K then I am going to turn
16:38on the bandwidth profiler by choosing view bandwidth profiler so I can get a little bit more information as to the downloading progress of my content.
16:47I need to see more of what is going on in the downloading so I am going to give as much room as possible to my preview window by dragging the ends
16:56of it down a little bit so that I can see more of what is going on here, like so, and then I want to simulate the download
17:04so I can see my preloader actually work, to do that choose view, simulate download, you can see that shared lib file is being downloaded
17:16and you can see the downloading progress here and you can see the preloader work just fine.
17:22Now you saw it happen pretty quickly it showed the preloader animation occur, but then above and below that it showed some text
17:29that gave you more precise information as to how that downloading was occurring.
17:34If I click to go to the next slide, you will see the preloader appear again and again look to the top and the bottom of that preloader animation
17:41to see the bit of extra text that you have added in this movie.
17:45You can see it shows the percentage loaded at the top and at the bottom it showing how many kilobytes have been loaded
17:51up to that point and how many kilobytes there are total.
17:56So that is how you can create a preloader that gives more detailed information to the viewer so that they have a better idea
18:03of how many kilobytes are being downloaded to the movie, what percentage that is equated to,
18:09and how many kilobytes have been loaded up to that point total.
18:13That way, the viewer has a much better idea as to how long they have to wait and what is exactly going
18:19on inside of the content that they are waiting to download.
18:22As you can see, it did not require a whole lot more information, all we essentially had to do was to add a couple of text fields to have
18:29that text be displayed in and then a few lines of actions inside of the master.fla file inside of the on load progress event handler so that
18:38as the content is being downloaded, and the on load progress event handler is being executed, as that content is being downloaded,
18:46it continually updates the text inside of the text field for us.
Collapse this transcript
9. Building a Form
Previewing what you're building
00:00>> In this chapter, you're going to construct a simple feedback form that will allow the viewer to fill out a form and then send you feedback.
00:09To get a better idea of exactly what it is that you're going to be building in this chapter,
00:13open up the sample website at www dot Lynda dot com forward slash intflash8 forward slash laeyeworks.
00:23When that website loads, click on the Contact Us option from the top Menu bar.
00:29This is going to load the Contact Us form where the viewer can enter in their name, email address and comments.
00:35One of the neat things about constructing forms inside of Flash is that unlike most forms in html,
00:40you can't specify specific type faces, sizes, styling and so forth.
00:46Here inside of Flash 8, however, if I click inside the name filed and I type in my name, notice how it's in a specific font,
00:54we're using Bitstream Vera Sans Bold, it's at a specific size that I created and a specific color.
01:01So Flash gives you a lot of control over the styling and presentation of the form.
01:06If I fill information in each of the fields and then click on the submit button at the bottom of the form field,
01:22it's gonna open up this extra window, which of course I don't need at this point, but it says "Thank you for taking the time to give us your comments,
01:28"Shane Rubenshide, we look forward to seeing you in one of our stores soon."
01:32The thank you message that this form gives me actually is customized so that it enters in the name that I entered in in the name field.
01:40So it feels like it's a little bit more friendly, in terms of being customized, for your specific visitor.
01:46Now if I go back to the contact us form, by simply selecting another selection and then going back there again,
01:53say for example the viewer is entering this information into their form, but maybe they forget to enter information into each field,
02:09when they click on the submit button, it's gonna say "Oops, it appears that you didn't fill out the form completely.
02:14Please go back and make sure you enter the correct information in all fields."
02:18And it gives them the ability to click on the back button to go back and fill out the form again.
02:24So the Contact Us form that you're going to construct in this chapter not only allows the viewer to leave feedback for you,
02:30but it also is somewhat intelligent in that it is going to do a little bit of detection to make sure
02:35that the viewer is filling out each of the fields in the form.
02:38Additionally, this form is constructed using some components,
02:42so inside of Flash 8 you're gonna utilize a few different components to construct this form.
02:47Now we could construct this form using just sample input text field, but in this case, we're gonna get a little bit extra added functionality
02:55by using components instead of just input text fields.
02:59One of those pieces of added functionality would be if the viewer is entering in the comments here, let me just speed this along,
03:07select all those comments, copy it and then just go in here and continue to paste all those comments in to speed it up,
03:15when a viewer fills enough information in one of the fields, such as the comment field here, automatically scroll bars will appear
03:22on the right hand side to allow the viewer to easily scroll through all of that content.
03:26If I was just using input text fields, for example, I would not get that added scroll bar functionality which the component provides me.
03:34So in this chapter you're gonna be learning how to build a simple feedback form that also has some detection scripts built into it
03:40to make sure that the viewer enters information in each field.
03:43You'll also write some action script to stylize this form, allowing you to specify the font, font size, font color and font styling for the text
03:52that appears in the form as the viewer types in the fields, as well as utilizing a few components to create the various form elements.
04:00Before you continue, make sure that you close your browser window and then open up the LA Eyeworks directory on your desktop and the site directory.
04:08It's in this folder where you're gonna continue in the next exercise.
Collapse this transcript
Setting up pt. 1
00:01>> For those of you that have access to the exercise files, I have created a starter fla to get you going.
00:07Inside the site directory, you will notice that there is an fla called contact.fla.
00:13For those of you that do not have access to the exercise files, go ahead and create
00:17and save into the site directory here a new blank fla called contact.fla.
00:23Again, for those of you that do have access to the exercise files, open up that contact.fla file inside of Flash 8.
00:31Inside of here, you will notice there are already a few pre-provided elements.
00:35On the stage, there is a movie clip symbol that is called MC Contact Form.
00:40Inside of there is just a simple light blue square and on the left hand side there are a few text elements these are just static text fields
00:49that say name, E-mail address, and comments.
00:52These are simply just textual labels for where our form elements will go, so that the viewers, as they are entering their information
00:59in the form fields knows what they are supposed to be typing in those fields.
01:03Additionally, at the top of the stage, there is a static text block that says, 'Contact Us'.
01:10Additionally, there are also some labels defined inside the time line, there is a key frame on frame 10 with the frame label 'Error'
01:18and there is a key frame on frame 20 with the frame label 'Correct'.
01:21There is some provided action script on both key frames 1, 10, and 20, which you will get to see a little bit later.
01:28Also, and lastly, on frame 10, in a separate layer called 'Messages' there is a bit of text in the stage that says, 'Oops,
01:36it appeared that you did not fill the form out completely.
01:38Please go back and make sure you entered the correct information in all the fields'.
01:42That is the error message as you can see by the label that has been also attached to the same point in the time line that the viewer will see
01:49if they did not enter in information in each of the form fields.
01:53On frame 20 that is marked as 'Correct', there is a dynamic text field that is currently empty which you will then populate with content later.
02:01For now, just go ahead and keep your play head back on frame 1.
02:05Now as you have seen quite a few times before, the first thing we need since we are obviously going to be using some text inside
02:11of the construction of this feedback form is to bring in our linked shared fonts that we created in the shared lib library.
02:18To do that, choose File Import, open external library, navigate to your site directory and double click on the FLA shared lib.
02:31This is going to open up the shared library panel.
02:33However, the construction of this feedback form only requires two fonts, Vera Bold and Vera Bold oblique.
02:40So in this shared library panel select those two fonts, Vera Bold and Vera Bold oblique,
02:46and drag them into the contact.fla library panel just by clicking and dragging over.
02:52Once you have done that, go ahead and close the shared lib library panel.
02:56Next, let us use some of those shared fonts and apply those to the texts that we have so far in our sample file.
03:02Select the 'Contact Us' text by clicking on the text block once that is at the top of the stage and in the properties inspector from the font pull
03:11down menu choose the shared font Vera Bold, again the shared fonts have the asterixes at the end of the name.
03:19If you are on Windows, also make sure that you click on the full bold button
03:23in the Properties Inspector to apply the bold styling to that block of text.
03:27Next, let's also assign some of the shared fonts to the text named E-mail address and comments.
03:33That text is inside of this movie clip so on the stage, double click on that movie clip symbol instance to open it up,
03:41then make sure that you have all three of the static text fields selected, then again in the properties inspector,
03:47from the font pull down menu, choose the shared font Vera Bold oblique.
03:53If you are on Windows, make sure that you click the full bold and full italic buttons.
03:58Now that you have assigned your shared fonts to some of the text blocks in your provided contact.fla file,
04:05let's start actually creating the various form fields that the viewer can start entering their information into.
04:10As I mentioned previously, you are going to use a few components, a text input and text area component for the construction of this form.
04:20Open up your component's panel by choosing Window Components.
04:26Again, the components panel will differ depending upon if you are using Flash Basic 8 or Flash Professional 8.
04:32In both versions of Flash, however, you have access to this user interface component section.
04:38From there, scroll down until you locate the component text input.
04:42Before you drag the text input component out onto the stage, however, let's create a new layer specifically for those components.
04:50Still inside the movie clip called MC contact form create a new layer, rename that new layer to be titled form fields
05:00and then with that new layer selected drag the text input component from the component panel out onto the stage and position it
05:10so that it is to the right of the text that says name.
05:13You might need to use your arrow keys on your keyboard to align it just where you want it.
05:18Then you can use your Free Transform tool to make that component field a little wider; I am going to move my components panel off
05:25to the right a little bit and then I'm going to drag on that horizontal slider to the right to expand the width of that component field,
05:33and I'm going to drag it so that its about like so, then first make sure that you have your Selection tool selected and on windows while holding
05:41down your Ctrl and Shift key or Option and Shift on the Mackintosh, click and drag that text input component down so that it is next
05:50to the text E-mail address, once it is next to that text, let go of your mouse button and then let go of your keyboard buttons
05:58to copy that text input component down to the next area.
06:03Lastly, we need a big field for where the viewer can enter their comments.
06:08Inside of the components panel again, right above text input is another component called text area, drag that text area component
06:17from the components panel out onto the stage and then position it so that the top left of the component is aligned
06:24on the left hand side along with the other two components already there.
06:27Then with your Free Transform tool selected go ahead and drag on the bottom right corner
06:33of that text area component down toward the right to increase its size.
06:41Like so. Then with your Selection tool selected, you may need to make some minor adjustments depending upon your operating system
06:48in exactly how you drag those components out onto your stage and where you place them you might need to make some minor adjustments
06:54to either the fields or the text on the left hand side so that they are all aligned appropriately with one another.
07:01I am going to move my components field up just a little bit and my E-mail address text as well as comments down just a little bit.
07:12Next up, now they are a little better aligned with one another.
07:15Now because I'm going to be targeting each one of these fields separate from one another with an action script,
07:20I want to make sure just like when I'm using any other symbol that I give each of them their own unique instance name.
07:27Click on the text input component that comes after the name text and then in the Properties Inspector, click in the instance name field
07:35and give it a name of 'UserName' all one word with a capital N in name.
07:41Now again, just like with variables, these instance names that you are assigning to these form fields can be anything that you like,
07:48just make sure that you do not put any spaces in the name or any special characters in the name either.
07:53Then click on the next form field down, this one next to the text E-mail address
07:58and then in the Properties Inspector give it an instance name of 'UserEmail'.
08:05Lastly, click on the comments field and give it an instance name of 'UserComments', again all one word with a capital C in comments.
08:15Also, now that you have finished copying the components that you are going to be using in the construction
08:19of this feedback form you can also go ahead and close that components panel.
08:24Lastly, after the viewer finishes entering their information in this form, they are going to need to click on something to actually send these results
08:32or submit the form to a CGI script on the web surfer to be processed and then done with whatever you choose.
08:38In most cases, it simply E-mails those form results to you or posts them to a database,
08:43so we need a button down here beneath the form that the viewer can click on.
08:47Let's place that button in a separate layer so again still inside your MC contact form movie clip symbol instance, create a new layer
08:57and rename that layer to be titled 'Submit', then inside of your library is an already created movie clip symbol for you called MC.Submit,
09:09go ahead and take that and drag it out onto your stage, position it down to the bottom right of your form elements like so,
09:18that yellow box that you see, by the way, is what is inside the BG layer and that is again just simply a light blue box.
09:26Its outline has been enabled so that it does not blend in with the background so that you can actually see where the edges of that image is.
09:34I am going to position my MC Submit movie clip symbol just down beneath the bottom right of it like so, then you can again use your keyboard
09:42to nudge it around until you get it in exactly the place you want it.
09:46Later you will be targeting that submit button movie clip instance with some action script, so before you leave here you want to make sure
09:53that you give that movie clip symbol instance an instance name.
09:57With that movie clip symbol selected on the stage, in your properties inspector click in the instance name field
10:04and give it an instance name of 'SubmitBtn' with a capital B in button.
10:10So while we are certainly not done with the construction of this form yet,
10:14that is the basic structure of how this feedback form is going to be set up.
10:18You have two fields where the viewers can enter in their name and E-mail address
10:22and a third larger text area field where the viewers can leave their comments.
10:26When they are finished filling out this form, the viewer can then click on the Submit button to then submit those results.
10:33Now we turn back to scene 1 by clicking its button above the time line and then click once on the MC contact form movie clip symbol instance
10:43that holds all of that information you were just working with.
10:46Again, because we are going to be using action script to talk to not only the form fields inside of the feedback form, but the submit button as well,
10:55we also want to make sure that we give this movie clip symbol instance its own unique instance name.
11:00With that symbol instance selected, inside of the properties inspector, click in the instance name field and give it an instance name
11:08of 'ContactForm' all one word with a capital F in form.
11:14Now when we want to refer to content inside of that we simply say, 'ContactForm dot' and then whichever element we have named inside
11:23of that movie clip symbol instance that we want to talk to.
11:26So now if I take what I have done so far, save the changes I have made to this fla, and just test my movie by choosing Ctrl Enter or command return,
11:36for now I am going to close my band with a profile, I have to give my viewing space a little more room,
11:41I can see that I have the beginnings of my feedback form.
11:45If I click in the name field, I can now type my name.
11:48Notice how the text I type inside of the form fields is aliased text meaning that it is not smoothed out,
12:05it does not have any smooth edges which is called anti-aliased.
12:08It is set to be a pixel size that I did not define and it is just plain black text.
12:14In later exercises in this chapter, you are going to be learning how to write action script to define the styling and displaying of the text
12:21that appears inside of the form fields themselves, but again as you can see, you have the great beginnings of a form.
12:28We are off to a great start, but there is still some more action script installing that we need to perform before we can call it finished.
12:34Before you can continue on to the next exercise though, go ahead and close your preview window and make sure again
12:40that you have saved your changes to contact.fla.
Collapse this transcript
Setting up pt. 2
00:01>>Now that you have gotten the basics of the form set up, in this exercise,
00:05you are going to write the action script that does the simple form validation.
00:09That is a fancy a word, basically that means to make sure that when the viewer is entering information in each
00:15of the fields that they enter information in all of the fields.
00:19If they only enter information in only one or two of the three fields, and they click on the submit button, we are going to write a little bit
00:26of action script that says, well since they did not finish filling up the form, send them to the error message.
00:32The error message informs them that they did not fill out the form completely and allows them to go back and fill it out again.
00:39However, our form validation is also going to say, "Hey, they did fill out all the fields correctly," if they did, and in if that is the case,
00:47when they click on the submit button, send them to the correct message, which will then display a message for them telling them that they filled
00:54out the form correctly and that the results have been sent.
00:57Before we get in and start writing that action script, however, let's make sure that our error and correct messages are set up correctly.
01:06Move your play head to frame ten in your contact.fla file and then click on the error message once on the stage to select it.
01:14As you can see, if you look in the properties inspector, it is just using the device font underscore Sans.
01:19Let's change that so that it is using the shared font Vera Bold.
01:23So with that text field selected on the stage, in the Properties Inspector, click on the font pull down menu and choose the shared font Vera Bold.
01:33If you are on Windows, you also need to make sure that you click on the full bold button in the properties inspector as well.
01:39We want the word "Al"' at the very end of that text block to be italicized.
01:45To do that, double click on the text field to edit it, double click on the word "All" to select it, and then in the Properties Inspector,
01:53click on the full italic button to italicize just that one word, and then select your selection tool to exit out of type editing mode.
02:03Next, let's also specify that the correct message also uses the shared font Vera Bold.
02:09To do that, move your play head to frame 20, click once on the multi-lined dynamic text field on the stage to select it,
02:17and then in the properties inspector, click on the font pull down menu and choose the shared font Vera Bold.
02:25On Windows, make sure that you click the full bold button also in the Properties Inspector.
02:31As you might also notice, again in the Properties Inspector, that dynamic text field has already been given an instance name of "Correct Message"
02:40that way when we want to place text inside of that dynamic text field, which we will do later,
02:45we can simply refer to it by its name "Correct Message" Msg.
02:49As a matter-of-fact, if you select key frame 20 in layer A and open up your actions panel,
02:56you will notice that some action script has already been written in there for you.
03:00Let's take a second to review it and for those of you that do not have access to the exercise files now would be a good time to select frame 20
03:08in your A layer, add a key frame there, and then copy down the action script that you see printed here.
03:14Essentially, what is going on in frame 20 is that there is a Stop action, so when the play head moves to that frame, the play head stops there,
03:21and then, if you remember again, that text field on the stage is called Correct Message.
03:26Its auto size property has been set to center so that that text field will automatically resize out from the left and the right
03:33and then some text has been told to be displayed inside of there that says, "Thank you for taking the time to give us your comments"
03:40and then after that you can see that it is appending a variable name called "Visitor Name".
03:46We are going to create that variable "Visitor Name" later and then after that it has entered in some more text.
03:53One of the things in here that may look different than what you have seen before is this back slash n. That is called an escape sequence
04:01and what that does when you add a back slash n inside of a string, flash does not actually print that.
04:08In other words, you won't see when we go to view this text as it is displayed in the dynamic text field on the stage,
04:15you won't see forward slash n you will just simply see a line break that is what escape sequences do.
04:21If you were to search the flash help documentation for an escape sequence, you would find a list of the various escape sequences that you can use,
04:29in this case, again the back slash n inserts a line break there, so it would say, "Thank you for taking the time to give us your comments"
04:37and then if I typed my name Shane Riebenschied in the name field, it would say, Shane Riebenschied.
04:43And there would be a line break and on the next line it would say, "We look forward to seeing you in one of our stores soon".
04:51So that pre-provided action script here on key frame 20 in layer A, simply auto sizes that text field
04:58and then places a "Thank you" message inside of that text field itself.
05:02Now that you have defined the fonts that the error and correct messages are going to be using let's go ahead and go back to the first key frame
05:10in layer A, and as you can see, inside the actions panel, there is already,
05:14as with some other chapters, some prebuilt code for this particular chapter.
05:19Again, for those of you that don't have access to the exercise files, you may want to pause the movie at certain times
05:25and copy down the action script that you see written here.
05:28As you can see, there is some action script that defines what should happen when the viewer interacts with the submit button that has some pre-created
05:36on rollover, on rollout, and on release action script, in this case the on release for that submit button is empty, which you will fill in later
05:45and then there are some simple comment lines to comment out that action script.
05:50In the next exercise, you are going to start working with some of this pre-provided action script as well as writing some of your own.
05:57Before you continue on to the next exercise, of course make sure that you save the changes to contact.fla.
Collapse this transcript
Performing simple form validation
00:01>> When setting up this simple form validation, let's first start by un-commenting the commented out action script
00:08in the first key frame of layer A in your contact.fla file.
00:13To do that, toward the top of your actions panel, select the comment line prebook code for chapter 8
00:20as well as the forward slash asterisk that comes after it.
00:24Once you have selected those, go ahead and delete them.
00:28Deleting them will un-comment out the action script underneath it and will color code them meaning that this action script is now active, however,
00:36just to keep things cleaned up in the actions panel here, scroll down to the bottom, select the two comment lines, asterisk forward slash as well
00:45as the comment line underneath that, and delete those two lines.
00:51Again, the action script that you have just commented out does a few different things.
00:55These are all things that you have seen before, which is why they were pre-provided for you.
00:59The first line simply changes the auto size property of the button labeled text field
01:05in the Submit button movie clip symbol in the contact form to be center.
01:11For your reference, if I hide or minimize my actions panel for a moment, open up the contact form movie clip symbol on the stage,
01:19and then double click on that Submit button on the stage as well inside of there, on the stage is a dynamic text field called Button Label.
01:29The actions back on scene 1 on key frame 1 simply sets this dynamic text field to be auto sized from the center,
01:36so as I use action script to insert text inside that text field, it will expand out to the left and to the right automatically for me.
01:44Back on scene 1, again in the first key frame in layer A that is what that one action does.
01:51The second action inserts some text into that dynamic text field called Submit.
01:57Now some of you might be wondering why don't you just create a button with the text written in there submit.
02:03Why are you trying to be all fancy and do it with action script?
02:06The reason why is because in this case we are trying to optimize our Flash movie by building this one button once,
02:13which in this case is actually just a movie clip symbol that we are behaving as a button called MC submit,
02:19and we are using that as not only our Submit button but as our Back button here on the error page as well,
02:25that is the same movie clip instance called MC submit.
02:29Then it just has a dynamic text field inside of it that we use action script to put text inside of,
02:36so that way instead of having two separate symbols, one for our Submit button and one for our Back button. We can use one symbol as many times
02:44as we would like and then just use action script to modify not only the functionality of, where it should go when the viewer clicks on it
02:52for example, but as well what text should be displayed inside of that dynamic text field so it can be our Submit button,
02:58it can be our Back button, it can be a Clear Form button for example, it can serve multiple purposes,
03:04and by doing that, we lower the overall file size of our Flash movie.
03:08So back in key frame 1 in layer A in the actions panel that is what those two actions do, one makes sure that that text field is auto sized
03:18from the center and the other one puts the string of text Submit inside of that text field.
03:24If you scroll down a little bit in the actions panel, you will notice that for the on roll over state of that Submit button,
03:31it simply tells that movie clip symbol to go to frame 2.
03:34When they roll their mouse off of it, it simply tells that movie clip symbol to go back to frame 1, so in actuality,
03:40all that action script does so far is inside of that movie clip symbol when the viewer moves their mouse
03:46over that movie clip symbol, it tells the play head here to go to frame 2.
03:51In frame 2, it is just the graphic behind that text changes to a different color and then when they move their mouse off of it,
03:58the action script tells this play head to go back to frame 1, so essentially you have created a button effect where it interacts
04:05with the user moving their mouse over it and then back off it again, but you have done that with an action script instead.
04:12Again, back in scene 1, in the first key frame of layer A, in the actions panel that is what these set of actions here do,
04:20it just moves the play head inside that button movie clip symbol to frame 2 or to frame 1.
04:26Scrolling down a little further, however, you have an empty on release function for that button and it is here where we are going
04:33to write the action script that does that little form validation.
04:36It is going to check when the viewer clicks on the Submit button whether or not they filled out the form correctly.
04:42If the viewer has filled out each of the fields in the form, when the viewer clicks on the Submit button,
04:48it is going to send our play head to the correct message.
04:51However, if our form validation script finds that the viewer has not entered information in all of the form fields,
04:58it is going to send the play head here to the error message.
05:01Now since we want to find out what is going on with the form elements when the viewer clicks on the Submit button, we are going to utilize to do
05:10that an 'If' conditional statement, 'If this is happening, do this, otherwise do something else.'
05:18So click in the empty line break provided for you in the on release function and then type
05:24if space open parenthesis close parenthesis space open curly brace a couple of line breaks and a closed curly brace.
05:34So that is the skeleton of our 'If' statement.
05:37Then click in the open and close parentheses after 'If' and it is here where we are going
05:41to write the conditional 'What should be true for something to occur'.
05:45Now let's just start by seeing if the viewer has typed information inside of the name field.
05:51If you remember, you gave that component that is where the viewer will type in their name an instance name of 'User Name'.
05:59So we if we want to find out if the viewer has entered information in that,
06:03we simply tell Flash first where that component named 'User Name' resides at,
06:09if you remember that text area component resides inside of the movie clip on the contact.fla stage.
06:17The name of the movie clip that holds all of that form you gave an instance name of 'ContactForm2' again all one word with a capital F in form.
06:28Then the name of that form element that you want to see if the viewer entered text into you gave an instance name of 'UserName'
06:36so after ContactForm type dot UserName, all one word with a capital N in name.
06:44Then if you want to find out if the user has entered text into that or not type.text.
06:50What our 'If' statement is going to be doing is seeing if the viewer has entered information in there or not.
06:56So what we want to find out if the text inside the UserName field is empty that means that the viewer has not entered information inside of that field
07:05so after dot text type space equals equals space quote quote.
07:13Now quote quote means no text basically there is nothing there, so we are finding out if the text inside of that UserName field
07:21in the contact form movie clip symbol on the stage is exactly equal to nothing, meaning the viewer has not entered information in that field.
07:31Now again, there are more than just one fields for the viewer to enter information into.
07:36There is also UserName and UserComments.
07:40So how can we have our 'If' statement check multiple things?
07:44Do we have to write three "If' conditional statements to check each one of those elements?
07:49And in actuality, luckily, thankfully, you don't have to.
07:52We want our 'If' statement to essentially ask if this is true or this is true or this is true.
08:01The things that we are checking to see if they are true or not is if the viewer has not entered any information in the fields.
08:08If the viewer has not entered information in every field, then we are going to send them to the error message.
08:14So after your equals equals space quote quote, type another space and then two pipe symbols.
08:22Pipe is the backslash key, but you hold down your Shift key along with it.
08:27On your keyboard, if you are on Windows, it should be below your backspace key.
08:31On Macintosh, it should be below your Delete key.
08:35So hold down your Shift key and press that backslash key twice to give the pipe symbol.
08:40Now in Flash, those two pipes have the fancy name called a logical or operator and essentially if you are just thinking
08:47about this, as stating it in plain English, that just means or.
08:51If there is no text inside the UserName field or if, and we are going to continue writing it alone.
08:59After that, we want to find out if no text has been entered in the UserEmail field either
09:04so type ContactForm dot UserEmail dot text space equals equals space quote quote.
09:14So right now it says, if there is no text in the UserName field or if there is no text in the UserEmail field,
09:21and then we need another or if there is no text in the UserComment field.
09:26So after quote quote again type space pipe pipe space ContactForm dot UserComments dot text space equals equals space quote quote.
09:43So what that if conditional statement says is if there is no text in the UserName field or if there is no text
09:51in the UserEmail field or if there is no text in the UserComments field.
09:57If any of those things happened, if there is no text in any of those three fields,
10:02then that means that the viewer has not fully entered information in all of our form elements.
10:09In that case, we need to send them to our error message, so after the open curly brace that marks the beginning of our 'If' statement
10:17and before the closed curly brace that marks the end, click in that empty line break to send them to the error message, we simply type go to
10:25and stop open parenthesis quote, because we are sending them to a frame that has a label on it, error end quote end parenthesis semicolon.
10:39So if the viewer has not entered information in each of the three field elements send the viewer to the error message.
10:47However, if this 'If' conditional statement turns out to be not true, meaning that they have entered information in each of the form elements,
10:56then we can go ahead and send them to the correct message.
11:00So after the closed curly brace that marks the end of the 'If' statement, click there, make sure that you don't click after the closed curly brace
11:08that marks the end of the on release function but instead the end of the 'If' statement.
11:12Click after that and type space else space open curly brace two line breaks and a closed curly brace.
11:21So if they have not entered information in every field, show them the error message; otherwise, show them the correct message, so in between the open
11:31and closed brackets for the 'Else' statement, click in that empty line break and type go to
11:38and stop open parenthesis quote correct end quote end parenthesis semicolon.
11:46So there you have in just a few lines simple form validation.
11:51It just simply checks to make sure that the viewer has entered information in every field and obviously
11:56if you are equating the more complex form instead of Flash and you did not have
12:00to have every form element field B required you just would not include them here in this list.
12:07However, because our form requires that all three of these form element fields be filled out, we are checking to see if text does not exist
12:15in every of those fields and if there is not text in all of the fields then that means they get the error message.
12:22Otherwise, they get the correct message.
12:25Let's go ahead and test what we have done so far, save the changes that you have made to contact.fla and because we are not yet utilizing any sort
12:34of action script that resides in master.fla we can preview contact dot SWF by itself, so just choose Control Enter or Command Return.
12:44Then inside the name field, and I must admit the form is looking a lot better, click inside that name field and type in your name,
12:50you can type in something in the E-mail address field if you would like, but don't enter anything in the comments field and click submit.
13:03When you do that, you will notice you get the error message, 'Oops, it appears that you did not fill out the form completely.
13:08Please go back and make sure you enter the correct information in all fields.'
13:12When you click on the Back button, it takes you back to the form again.
13:15Now, if I don't fill out anything in the form and click Submit, of course, I still get the error message.
13:21So we know that the error handling is working correctly.
13:24I am going to click on the back button again and this time in the name field I am going to type my name, I am going to type my E-mail address
13:32in the E-mail address field, and I am also going to type something in the comment field.
13:39When I click on the Submit button this time, I get the Thank you message because I have entered information in all three of the form fields.
13:48It says, 'Thank you for taking the time to give us your comments undefined.
13:52We look forward to seeing you in one of our stores soon.'
13:55Now it says 'undefined' because we have not yet written the action script that tells Flash to take what the viewer has entered in the name field
14:02and place it here inside of this message, but we will do that later.
14:07However, as you can see the form validation is working perfectly.
14:11When the viewer has not entered information in each of the three form fields, it sends them to the error message.
14:17However, if they have entered information in each of the fields when the viewer clicks the Submit button, they see the Thank you message.
14:24So the form validation is, in fact, working correctly.
14:28In the next exercise, I am going to show you how to write a load vars object that instead of loading variable value pairs
14:35from a separate text file, as you have been using the load vars object up until this point, instead of doing that I am going to show you how
14:42to use load vars to take what the viewer will have entered in each of the fields in this form, gather them all up together,
14:50and send them to a CGI where they can be processed by that CGI.
14:54Now I cannot actually show you how you can integrate this with an actual live CGI on a web server because of how many variations there are
15:01between how web servers work, how the various CGIs work, and so forth, but I will show you again how to take the results from this form
15:09when the viewer has entered in all their information and used the load vars class to gather them all up into a bundle
15:16and then send them to a mock CGI that could then process them.
15:20You are going to learn how to do all that in the next exercise.
Collapse this transcript
Using LoadVars to send the form results
00:01>> The first step in the process of creating a LoadVars object that's going
00:06to handle all the information that the viewer entered in your form.
00:09Collecting it all together and then sending it to a CGI is to create the LoadVars object that's going
00:15to act as the container to hold all that information.
00:19Making sure that you are still in frame one, in layer A, in the contact.fla file.
00:25Scroll to the top of your actions panel and click in one of the provided empty line breaks, between the stop action and the comment line.
00:34In this case for me that's line number 3.
00:36And again let's create a new LoadVars object that is going to create a container for the form results.
00:43Type var space gather form and let's strict type this to the LoadVars datatype.
00:51So type colon LoadVars space equals space new space Load Vars, open parenthesis, close parenthesis, semi colon.
01:04So we now have a new LoadVars object that we give the name gather form 2 that's going to act as a container.
01:12Now just like when we use LoadVars to load verbals from a separate text file into it and then when we want to refer to the verbals inside
01:21of the LoadVars object we would as in this case, just say gather form dot my verbal name, for example.
01:29Just like we do that we can also take content and put it inside of this LoadVars object.
01:36So if I wanted to I could place something inside of this load vars object by simply writing gather form dot my content.
01:44And then I can place content within that.
01:47That is the exact kind of thing you are going to do here.
01:50You are going to write the action script to do just that inside of a function.
01:54The reason why you are writing it inside of a function is so that you can trigger the actions
01:59that place the content within this LoadVars object at a certain time.
02:03That time would be of course when the viewer fills the feed back form in and after they have entered all their information in correctly when they click
02:11on that submit button and the form processing script says that everything is okay, its going to then execute the function
02:19which places the content within the LoadVars object.
02:22So after the LoadVars object action you just wrote, press return or enter a few times on your keyboard.
02:29Then write function space sendForm.
02:33A one word with capital F in form.
02:36And then open parenthesis, close parenthesis, space open curly brace, two line breaks and a close curly brace.
02:44Inside of the sendForm function is where we are going to take the text that the viewer enters in the form fields.
02:51Assign them to variables and then insert those variables into the gather form LoadVars object.
02:59Then once all that's been finished, we will then send that LoadVars object, all the variables inside of it to the CGI to be processed.
03:07Now again as I mentioned in the previous exercise, different CGIs on different web servers perform different ways.
03:15But in many cases with CGIs, especially form processing result CGIs they need to know
03:22which email address they are supposed to email the form results to.
03:27Now you should look in the help documentation of your particular CGI or probably a better idea would be to call the support
03:35for your internet service provider that manages that CGI script and tell them, describe to them, what it is that you are trying to accomplish.
03:43Regardless, along with the CGI should come some help documentation that you should try to read through.
03:49In there it should tell you that when you are creating a form, what variable you should use to specify
03:55which email address the form results should be sent to.
03:59Now again that differs, depending upon your web server, your ISP and the CGI script itself that you are using.
04:06In this case I am going to simulate that by using a variable called email underscore 2.
04:12And again this information should be provided to you by the CGI, or your ISP or better yet, the help documentation that comes with the CGI.
04:22So the first action I am going to write is going to insert a variable into the gather form LoadVars object.
04:30So I am going to type gatherform dot email underscore 2.
04:37And again this is one of those things you cannot make up on your own as the CGI script, depending upon various factors, is expecting to receive.
04:47The CGI script will be looking to receive certain variable names that it will associate with certain things.
04:53In this case my mock CGI is expecting to receive a variable called email2.
04:58Its expecting that to be associated with the email address that I want these form results to be sent to.
05:05So what I am going to place inside of that variable is of course the email address that I want my form results to be emailed to.
05:12So I am going to type space equals space quote, and then as a place holder for now I am going
05:18to write in, your at email dot com, end quote and a semi colon.
05:26Now of course if you were doing this yourself or for a client you would actually write down the email address
05:31within the quotes that you want the form results to be sent to.
05:35And again depending up on the CGI you use you might need to change the name of this variable from email2
05:42to whatever variable the CGI itself is expecting to receive.
05:46Next I am also going to create another variable inside the gatherform LoadVars object that is going
05:52to hold whatever the viewer enters in, in the username field.
05:56So after the action adjust route, I am going to click there, press return or enter to create a new line
06:02and then again type gather form dot visitor underscore name space equal space and then again what
06:12that does is it creates a variable called visitor name which again you would want to check with your CGI to see what variable it is expecting
06:20for the form field for which the viewer is entering in their name, but in our sample script here we are just going to say
06:26that the CGI is expecting a variable called visitor name we are taking that variable, inserting into the gather form LoadVars object
06:35and inside of that variable we want to place whatever the viewer has entered in our form in the name field.
06:44Again the location for that name field is contact form dot username.
06:52That is the instance name that we gave that field and that is the instance name of the movie click that is holding that field.
06:59Now we don't want to put that field in there.
07:01We want to put the text that the viewer has typed in that field.
07:05So after username type dot t-e-x-t, text and then type a semicolon to end that action.
07:12So what that action does, which you just wrote is that it creates a new variable called Visitor underscore name in a gather form LoadVars object
07:21and inside of that variable it places the text that the viewer has entered in the username field in the form and that field in the form is inside
07:31of a movie clip symbol instance with the name contact form.
07:35You are going to want to repeat this process, of course with a few minor changes for the other two fields in the form.
07:42So click after the action you just wrote press return or enter again
07:47and type gather form dot visitor underscore email space equal space contact form dot user email dot text semicolon.
08:03So again this creates a variable called visitor email in the gather form LoadVars object and inside of that variable it's placing the text
08:12that the viewer has entered in the form field that you called user email and that field is inside the contact form movie clip symbol instance.
08:21The last one is visitor comments.
08:23So after the action you just wrote press return or enter to add another line break
08:29and type gather form dot visitor underscore comments space equal space contact form dot user comments dot text semicolon.
08:43So what that send form function does is that it creates a new variable called email form
08:49in the gather form LoadVars object and in there it enters a string of text.
08:54The string of text is the email address we want these form results after the CGI processes them,
09:01this is the email address we want those form results to be sent to.
09:05And then the next three actions simply create new variables inside of that same gather forms LoadVars object and in each one
09:13of those variables it places the text that the viewer has entered in the three form elements inside of our feedback form.
09:21Now lastly all we have left to write is the action that tells our gather form LoadVars object to actually send all
09:29of these results to the appropriate CGI to be processed.
09:33So after the last action you just wrote, user comments dot text after that semi colon and press return
09:41or enter a few times to create a couple line breaks.
09:45Then type gather form dot send.
09:50Send just like gather form dot load for example as you've seen using load
09:56for your other LoadVars object, sends these results to a particular location.
10:02So just like LoadVars can be used to load data it can also be used to send data.
10:08And that's what this send command here does.
10:10After that type in open parenthesis and notice how in the code hinting pop-up window it tells us we need to specify a URL.
10:18The URL is not where we are loading information from, obviously because this is send.
10:23This is the URL of the CGI script relative to where this SWF file itself is that we are going to be sending this data to.
10:32Now here is another occasion when you would need to refer to the help documentation of the CGI to the help documentation
10:39of your internet service provider itself or you can simply call up technical support for your internet service provider
10:45and ask them what is the URL to the CGI script to process forms.
10:50In this case for our sample we are going to type in quote, forward slash, CGI dash sys, as in CGI system, forward slash and then the name
11:03of the CGI script that is going to process these form results.
11:06In this case I am going to enter in a common one called form mail dot pl for pearl script and then type in end quote.
11:14Again you would need to check with your internet service provide or the help documentation to get the exact name and location of where
11:21that script is and what its name is that will be processing these form results.
11:26A common location for CGI scripts to be stored at is a place called the CGI bin.
11:32So just simply ask your internet service provider, what it is that you are supposed to be entering in here.
11:37Now depending up on the CGI script that is being used to process the form results,
11:43the script may send results from the server back to the browser again.
11:47And usually that's just some kind of confirmation like a thank you message and so forth.
11:52Now as you can see in the code hinting, it is next asking up what the window will be.
11:57The window is, when the CGI script sends back that thank you message or sends back those results, where should it display those results.
12:05The most common thing in this case to enter in and what the default is with how Flash treats it is
12:10to type comma space, quote, underscore blank, end quote.
12:17Which means that those results will be sent back to a blank window.
12:20Now if you had another frame in your html page that you wanted those results to get sent back to,
12:25you could specify the name of that frame in between the quotes.
12:28In this case lets just leave it set to the default, underscore blank.
12:32The next thing again you can see in the code hinting pop up is the method.
12:37Now the method is either post or get.
12:39And again you should refer to the help documentation for the CGI or your ISP to find out which you should get.
12:47Now the get method is an older one, so more than like the method you should specify is post.
12:53So after underscore, blank, end quote, type comma, space, quote and then in all caps POST, end quote.
13:03Then, type a close parenthesis and a semicolon to end this action.
13:08Again there is lots of different sorts of variables in the action script here that you will need to check with the help documentation for the CGI
13:16or your ISP themsees to make sure that you get the variable names correct.
13:20Not only the variable names but the location of where the CGI is that will process those results.
13:26What the method is that the result should be sent to the CGI in post or get, as well as whether or not you want to load the results
13:33from the CGI script in a blank window in a separate frame, and so forth.
13:38Now since this script is actually getting quite large, let's go and add some comment lines here to better define it inside of our actions panel.
13:46To make my life a little easier, I'm going to select one of the other long comment lines that I already see here in the actions panel.
13:53Copy it. And I am going to click before my action var gather form.
13:59I'm going to click at the beginning of that action.
14:02Press return or enter once to create a line break and then select that empty line break above that action and paste my comment line.
14:10Then I am going to select the comment in between the less than and greater than symbols and I'm going to change it to read, sendForm LoadVars.
14:19Then I am going to select that comment line, copy it, scroll down to the last closed curly brace that ends the send form function,
14:31click after that closed curly brace, press return or enter to create an empty line break and then paste that comment there.
14:39Then I'm simply going to click before the word send in that pasted comment and type a forward slash to mark the end of that comment.
14:46The last thing that I should specify so that I can actually utilize this sendForm function is where this sendForm function will be executed from.
14:57Now remember what the sendForm function does, is it takes everything that the viewer has entered in our feedback form and sends it
15:04to the appropriate CGI script on the server to actually be processed.
15:08So I only want this send form function to be executed after it is confirmed that the viewer information in each of the form fields.
15:19Now so that I get my spelling and capitalization correct, while I am here I am going to select the sendForm function name including the open
15:27and close parenthesis after it and I am going to copy that.
15:31Then the place that I want have this send form function to be executed from is from within my If statement which I wrote earlier that confirms
15:40that the viewer has correctly entered information in all of the fields.
15:44Inside of the actions panel if you scroll down to the on release function you'll see there where it says else go to and stop correct.
15:53That part of our If statement is where it has been verified that the viewer has correctly entered information in each three of the form fields.
16:02So after Else, open curly brace, click there, press return or enter to create an empty line break and then paste the function name that you have
16:11in your computer's clipboard and then simply add a semi colon after that function call to end that action.
16:18So what happens is that when the viewer enters information in each of the fields and they click
16:23on the submit button, it performs the form validation script.
16:26It basically checks to make sure that the viewer has entered something in each three of the text fields.
16:32If they have not it displays the error message for them.
16:36If they have meaning, they have entered information in each three of the form fields, its not only going to display the correct message for them
16:44but its going to execute the send form function which will then take everything they entered in each there of those fields,
16:52put them inside of variables in the gather form LoadVars object and take all that object, everything inside of it,
17:01and send it to a CGI script to then be processed and emailed to the email address that you specified.
17:08Again there are all sorts of variables that you have to deal with when working with CGI scripts, the various ones that are out there,
17:15including the various types of web servers that are available for use as well.
17:19So make sure you verify a lot of variable names as well as the location and name of the CGI script as well as the variable name that applies
17:27to which email address that form result should be sent to and whether
17:31or not it should be even be using the post or get method to send those form results.
17:36So there is quite a lot for you to check in to but this is the basics of how to take your form results and send them to a CGI scrip to be processed.
17:45Now that you have hooked the form up so they can actually interface with the CGI script,
17:50the last step is to actually style the form so it looks better.
17:54Currently the text that is being displayed inside of the three form field is Alias text, means that it has jagged edges around the outside
18:02and doesn't look so hot and secondly its not styled the way we want it to.
18:06It's not using font we want, nor is it using the font size or color that we want.
18:11In the next exercise you are going to learn how to stylize the form elements so they look how you want them to look.
18:18Before we continue on to the last movie however, make sure that you save the changes to this FLA file.
Collapse this transcript
Defining tab order (optional)
00:01>> Up until this point you have a simple form that even does a little bit of simple form validation.
00:06If I test the form as it is right now, And I click inside the name field and I enter my name.
00:14When I press the tab key on the keyboard.
00:17Notice how it automatically goes to and selects the next field in sequence.
00:22In this case it is email address.
00:24You can tell which field is selected because not only do you have the blinking insertion icon there
00:29but also there is a green halo around the outside.
00:32If I press tab key again it will go to the next field in sequence.
00:37Now I didn't tell Flash which field it should go to in sequence as the viewer presses the tab key on their keyboard to advance to the next field.
00:46Flash did that for me automatically.
00:48And it does do that in the order that I created the fields.
00:51Because I created the name field first and then the email address field and then comments field, as the viewer presses the tab key on the keyboard
01:00that is the same order that it will advance through the fields as the viewers pressing the tab key.
01:06Now Flash also gives you the ability to change the order at which the fields are selected as the viewer presses the tab key.
01:13It's an action call tab index.
01:16I'm going to show you how to use the tab index action to change the order at which fields are selected
01:22as the viewer presses the tab key on their keyboard.
01:25Now why you would want to do something like that on a form that is so small as is this Contact Us form is probably not so evident.
01:34But after I show you how to use the tab index action, I'm going to show you another, better use of how to go about applying that particular action.
01:43Go ahead and close your preview window if you have it open and you should still be contact.fla.
01:49First make sure that the first key frame in your A layer is selected and then open your actions panel.
01:56Scroll to the top of the actions panel and click on line three in this case or whichever line comes after your stop action.
02:06The first thing you should do is specify which field is the first item in the tab index.
02:11In other words which is the first field the user is going to be interacting with.
02:15To do that select the Insert a Target path button at the top of the actions panel.
02:20Expand the contact form the movie clip symbol.
02:23And then scroll down until you locate username.
02:27That is where the viewer is typing in their name and that is the first field in the form.
02:32Select that and click ok.
02:34Flash will automatically insert the name to that field and the path to it in your actions panel for you.
02:40Then type dot tab Index with a capital I in Index.
02:46Then type space equals space one semicolon.
02:51That's it.
02:51You have just defined the Username text field as the field that is the first item in sequence.
02:58Then as you can imagine just press return or enter and define the next item in the sequence.
03:05Now as I showed you by default, the email field, where the viewer can specify their email address is automatically the field
03:12that is selected next when the viewer presses their tab key when they are entering their username.
03:18That is something that Flash did for us automatically.
03:21Let's however specify that instead of the username field being selected next.
03:27Let's choose that the comment field is actually the one that should be selected next instead.
03:32Click on the Insert a Target Path icon again.
03:35Expand the contact form movie clip symbol.
03:38And locate user comments, select that and then click ok.
03:44Now type dot tab Index making sure to have the capital I in Index space equals space 2 semicolon.
03:54So we're overwriting what Flash did for us by default and instead of having the user email field selected next in sequence,
04:03we are instead changing that just so you can see how the tab index action works and we are overriding that the in specifying that the comments field
04:11which is the bottom most field is actually the one that's selected next.
04:15Lastly let's specify that the user email field is set to Tab Index 3.
04:20So again press return or enter to create a line break, click on the Insert a Target Path icon.
04:27Expand the contact form movie clip symbol and choose user email and click ok.
04:32They type dot Tab Index space equals space 3 semicolon.
04:38Go ahead and test your movie now to see what changes those actions have brought.
04:43So I am going to click in the Name field which is set to Tab Index 1, then I'm going to type my name.
04:49Now I am going to press my tab key.
04:51Now before, before we added any Tab Index actions as you saw Flash automatically selected for us the next field in sequence, email address.
05:00But the Tab Index actions that you have just written overwrite that default behavior.
05:05So that now you are specifying that the comments field, the last big field down here actually comes next.
05:12So when you press the tab key, notice how now that is the next field that is selected in sequence.
05:18If I enter in a comment here and then press my tab key again, now email address is selected.
05:23Because again that's how you specified the Tab Index sequence should occur.
05:27First is name, then comments and then email address last.
05:32So tab index gives you really great control over how to specify as the viewer is pressing their tab key to advance to the next field in sequence.
05:42How that process occurs.
05:44Now again I mentioned that it is not really evident why you would want to use something like that in a form that is so small like this one
05:51and moreover when it was already working properly to begin with.
05:55We changed it so that its not really working the way optimally you would want it to work.
06:00Just so you could see how the action itself worked.
06:02I am going to show you however an instant in which the Tab index action would be greatly helpful.
06:09When I close this preview window and feel free to follow along if you'd like, and I am going create a new fla.
06:15I'm going to go ahead, minimize this and give myself a little more room to work with here.
06:21And then I'm going to open up my components panel again by choosing window, Components.
06:31In the Components panel I am going to make sure that I have the users interface components maximized.
06:35And I am going to locate the text input component and then I'm going to drag out a few instances of that component.
06:43So I'm going to drag this one out here and I'm going to drag out about 10 total.
06:47Just kind of randomly position them here in this stage.
06:51That's 5, 6, 7, 8 9, 10.
06:57Then I am going to go ahead and position them.
06:59Now I don't necessarily want them to be positioned in the same order that I dragged them out on to the stage.
07:06So I'm going to go ahead and position them side by side here.
07:13About like so.
07:15So they are in two columns.
07:19And you don't have to be precise, because you can use your align panel later, to make sure that they are all aligned properly with each other.
07:34Like so. Now what we have here represents a more complex form.
07:40If you are creating a form inside of Flash to take more information from the viewer.
07:44For example may be they are purchasing something from your store that you have built inside your Flash and they have to fill out their first name,
07:51their last name, their credit card numbers, their mailing address, their shipping address and so forth.
07:56You are going have lots of different fields in the form for the viewer to provide that information to you.
08:02So it is not uncommon for you to have multiple fields that make up your form.
08:07In this case we have 10 fields for our form and when I drag the text input component out on to the stage I didn't make sure to position them
08:16in the same order that I wanted the tab index to occur.
08:19In other words I didn't check make sure to they were positioned in the order that I wanted the viewer
08:25to be able select those fields as they press the tab key on their keyboard.
08:31If I test my movie as it is so far and click inside one of those fields, if I press the tab key on my keyboard, notice how it jumps down here
08:40to this field in the second row in the second column.
08:44If I press my tab key again you can see that it jumps to a completely different field so on and so forth.
08:50In this case, because this is a more complex form I would want to go in there and specify the precise order that I want the fields to be selected
09:00in as the viewer presses the tab key on their keyboard.
09:02And this is a great use of the Tab Index Action.
09:07Optimally, what I would like to happen, is that when the user clicks on the first field and enters their information,
09:13when they press the tab key on the keyboard it goes down to the next item in that same column.
09:20So let's take look at using the Tab Index Action to better define the tab order of how the viewer is going to tabbing through these fields.
09:29The first thing that you need is to be able to give each of these fields an instance name to be able to tell Flash
09:35which field is first and second and third and so forth.
09:38Each field has to have a name.
09:40So go ahead and close your preview window and let's start by assigning names to these various fields.
09:46Go ahead and click on the very top left field.
09:49And then in the Property Inspector click in the instance name field and call this simply My Field with a capital F in Field 1.
09:59Then I am going to click on the next field down and type My Field 2 and I am going to keep doing
10:07that until I get all the way to the bottom right which should be My Field 10.
10:11Now to make it a little more streamlined with naming these fields, I am going to select the Instance Name of the properties inspector
10:18and copy it using my keyboard Control C on Windows or Command C on the Macintosh.
10:24Then I am going to click on the next field down, click in the Instance name field name in the properties inspector
10:30and simply choose command V or Control V to paste that in.
10:34And then change that 2 to a 3.
10:37I'm going to continue doing that all the way down to My Field 10.
10:41So there is My Field 4, My Field 5, 9 and then lastly 10.
10:54So now each of those fields has its own unique name and I have labeled them in the same order that I want the tab index to be defined in.
11:02My Field 1, My Field 2, and so forth.
11:04So now we need to write the Tab Index Actions that specifies that those fields should go in the order that we've set.
11:11To do that I am going to create a new layer and I am going to rename this new layer to be title A for action.
11:16And again we're always keeping our actions that are in the time line in their own layer.
11:20I am going to select the first key frame and in the A layer and open up the Actions panel.
11:26I am going to also close my components panel as I don't need that anymore either.
11:31And then I am going to click inside the scripts pane in the actions panel, and then I am going to insert a target path
11:38by clicking the Insert a Target Path button, and I am going to choose the first field, My Field 1.
11:43And then click ok.
11:46As you've seen before after that I am going to type Tab Index, making sure I get the capital I in index, space equals space 1 semicolon.
11:56Now what I need to do is repeat that for the remaining nine fields for all ten fields inside of my forms.
12:04So I am going to select that action, copy it, click at the end, press return or enter to create a new line break,
12:12paste and change My Field 1 to be My Field 2 and change it to be order number 2.
12:18I am going to repeat that process for the remaining fields.
12:26So now you've targeted each field in your form and you've specified the tab index.
12:35Now when you test your movie and you click on the first field in the form, when you press your tab key, it should advance down to the next field
12:43in sequence and it should go all the way down that column and then when it gets
12:47to the end it should jump up to the next column and work its way down again.
12:51So let's test and see it works ok.
12:53I press tab and it goes down, down, down, down now it should go back up and it does until it goes to the end.
12:59When it gets to the end, I press tab and it goes back to the beginning again.
13:03So there is a really great example of how a tab index can really benefit both you, your viewer and the usability of more complex forms.
Collapse this transcript
Styling the form
00:01>>When wanting to style components as you are about to do, there are quite a few ways to go about doing it.
00:07So keep in mind as you follow through the steps that I'm about to work through, that this is simply one to go about doing it.
00:14Components can also be skinned, which means you can change the graphics that the components use
00:19as they are displayed and as the viewer interacts with them.
00:22Now skinning is quite an involved topic that is best if saved for a completely separate title.
00:28However what I am going to show you in the next few exercises is using something called the underscore global dot style declaration,
00:36which basically is a fancy name that means that is going to allow you to change a few simple elements about how the content inside
00:44of these text fields, inside of these components also are going to appear.
00:50Inside of the first key frame in contact dot fla, in the actions panel, locate the comment end sendForm load vars.
01:00Which you were working with in the last exercise.
01:03Click at the end of that comment line and press return or enter a few times to create some empty line breaks beneath it.
01:10Let's first write an underscore global dot style declaration to set how the text that appears inside of the form elements
01:19in those components that make up the form to be a specific font.
01:23To do that simply type underscore global dot Style dot set style again all one word, the capital S in style, open parenthesis,
01:36and then the name of the style that we want so set is called the font family.
01:42So type quote fontFamily all one word with a capital F in Family, end quote, comma, space and the fontFamily or the font that we want to choose
01:55to be displayed as the font that's used as when the viewer types inside of those form elements is quote Bitstream Vera Sans,
02:06which of course we have been using through out this title.
02:08Now if you are on the Macintosh, type Bitstream Vera Sans bold, like so.
02:15If you are in Windows, just leave it Vera Sans and then type in end quote.
02:22Then type a close parenthesis and a semicolon to end that action.
02:26So if you are on a Macintosh it would read Bitstreams Vers Sans Bold end quote, end parenthesis, semi colon.
02:33On Windows you would type just as you see here, Bitstream Vera Sans, end quote, close parenthesis, semi colon.
02:41Now only if you are on Windows, do this following step: Go ahead and create an extra line break and type underscore global dot style dot set Style
02:53as you did before, open parenthesis, fontWeight, a one word with capital W in weight, end quote, comma space,
03:04quote bold, end quote, close parenthesis, semi colon.
03:11Now again that goes back to how Windows and Macintosh operating systems treat both dealing with fonts as well
03:18as font variations, such as bold, italics and so forth.
03:22Windows users have to specify that the font weight itself for the fontFamily chosen is bold.
03:29Macintosh users can refer directly to the font Bitstream Vera Sans bold, so therefore don't have to complete this extra step.
03:36Now if you see the changes that those two actions have made to your file, go ahead and save the changes you've made to this FLA
03:44and test your movie by choosing control enter or command return.
03:50Now when I click inside the name field and type in something, notice how it is now in a bold font using Bitstream Vera Sans.
04:00Now it still looks a little bit off and there are a few things that I still want to do to look a little bit better.
04:06But now as you can see those actions are taking effect.
04:10The font is now the correct font that you chose, Bitstream Vera Sans, and on windows it is using the bold font weight,
04:17whereas in the Macintosh it's using Bitstream Vera Sans Bold itself.
04:22Go ahead and close your preview window and then go back into your actions panel.
04:26Now even though you wrote an action that specifies the name of one of your shared fonts, Bitstream Vera Sans,
04:33Flash is actually not embedding the outlines for the font.
04:37Nor is it using the outlines to display that font.
04:41Even though again it is a shared font.
04:43You need to add one more action to have Flash utilize the actual outlines for your shared fonts, so that the text that is displayed
04:51in those text files is actually anti-aliased and looks good.
04:55So click after the last action you just wrote.
04:59Press return or enter to create a new line break and then type, underscore global dot Style dot set style open parenthesis, quote embedFonts,
05:14again one word with capital F in fonts, end quote, comma space true, end parenthesis, semi colon to end the action.
05:25That means that is going to embed the font outlines, even though it is referring to the actual shared fonts
05:31so again don't worry you are not adding to the file size yet.
05:34It's going to refer to those font outlines for the shared fonts for the text that the viewer is entering inside the text fields.
05:41So now after just making that one change, if you save your FLA file again and test your movie, when you click inside of one of the form fields
05:50and start typing, you can clearly see a difference now.
05:53Notice how the text is all nice and smooth, because it is anti-aliased.
05:58You are actually using the font outlines for the font to be displayed in.
06:02So therefore it is now in nice anti-aliased font.
06:06Next let's use that underscore global dot style declaration to also set not only the font size but also the color as well.
06:14Close your preview window and return back to contact dot fla and click after that action that you just wrote.
06:22Then press return or enter to create a new line break and again type underscore global dot style dot set style open parenthesis, quote fontSize,
06:34a one word with capital S in size, end quote, comma space, 12 as in 12 pixels, end parenthesis, semi colon to end the action.
06:46Last let's specify the color that the text is going to be displayed in as well.
06:51So create a new line break and type underscore global dot style dot set style open parenthesis, quote color, end quote, comma space.
07:04And then when you are specifying the color here in the actions script you want to specify the hexadecimal value.
07:10The hexadecimal value is a six digit value and you can easily get that if you would like by clicking on one of the color swatches in your tool box,
07:18such as the fill color and hovering over the color you want.
07:21Say may be you the color to be a dark blue purplish color like this.
07:26As you can see up here in this little box, the hexadecimal value for that particular color is 3300ff.
07:35That six digit value is the hexadecimal value.
07:38And when you are writing that in an action script you simply precede it by 0X.
07:43So you would write 0X3300ff.
07:48Back inside of my actions panel and this time I am going to use a different color.
07:53So I am going to type 0X and the hexadecimal value of the color I want which is 3f7fbe.
08:01Then I am going to type a close parenthesis and a semi colon to end that action.
08:10Then let's see what effect those changes have.
08:13So save your FLA and test your movie.
08:16When I click inside of that name field and now I type my name, notice that it is in the exact font color
08:22that I picked, the font size, the font itself and so forth.
08:27So I can continue to add all these elements here inside of these form fields and it's exactly how I specified it.
08:34It looks great.
08:34Now when I click on the submit button down at the bottom, it is going to submit those form elements and it tells me 'Thank you for taking the time
08:45to leave your comments, Shane Rebenschield' and again I have the black so it's opening up by browser window,
08:49'We look forward to seeing you in one of our stores soon.'
08:52So the form elements have then been sent to the cgi to be processed and then emailed to the email address I specified.
08:58Lastly as you probably saw, when you previewed your movie, if I preview it again, notice how the submit button itself is not nicely anti-aliased.
09:07Let's go ahead and fix that now as a last sort of housekeeping measure.
09:10I am going to close my preview window and hide my actions panel for a moment.
09:16And then on the stage I am going to double click on the contact form movie clip symbol to open it up.
09:21And then I am going to double click on the submit button movie clip symbol there to open it up.
09:27On the stage is that dynamic text field.
09:30Go ahead and click on that once to select it and then in the properties inspector from the font pull down menu choose the font Vera Bold.
09:40On Windows, make sure that you click the full bold button, and then I am going to want to set this down actually to one point size smaller.
09:48I think 11 pixels may be a little bit better.
09:50And then I am going to save the changes I have made to this FLA once more and then test my movie.
09:57When I do, you can see that it says the submit button which I can see is aligned a little high, that's fine, I am going to go in
10:02and select that text field and move it down a couple of pixels.
10:07Test my movie again.
10:09There is my submit button now, and it's in the exact font that I want as well as being nicely anti-aliased.
10:15So there you have your complete contact form.
10:18It not only does some simple form validation, by checking to make sure the viewer is entered their name in each of their text fields,
10:25but it also allows you to specify exactly which font, color, size and so forth that is being displayed in each
10:33of these fields as the viewer is entering information into them.
10:36And once the viewer has entered information in to each of these fields, depending upon if they have entered information in each field,
10:44they will display the appropriate Thank you or error message.
10:48And then if they have entered information in each field when they click on the submit button, it's going to take all that information,
10:55package it all up into a load vars object and send it to a cgi script to be processed and then emailed to whichever email address you specify.
11:04So you've covered quite a bit of information in this chapter.
11:07And I hope you can see based on that how flexible working with forms is inside of Flash.
11:12It gives you a lot of control of not only how they work but how they are presented as well.
11:17So there you have the finished feedback form.
11:19Go ahead and close the preview window when you are finished marveling at it,
11:23save the changes again to contact dot fla, and go ahead and close that FLA file.
11:29You won't be needing access to it right now.
11:31Now that you have completed the last module in the LAR worksite, you have built it the About Us module,
11:38built the Frames module, you've built the Feedback form module.
11:42In the next chapter you are going to learn how to build the main navigation menu,
11:46that allows the viewer to switch back and forth between all of these sections.
11:51In the next chapter is really where you start to see all of these content come together into a cohesive site.
Collapse this transcript
10. Building the Main Menu
Previewing what you're building
00:01>> In this chapter you're going to learn how to build the main navigation bar that the viewer is going to use to navigate through the entire site.
00:09And again, as I mentioned in a previous chapter, this is sort of where you start to see everything come together, because the navigation bar is used
00:17to allow the viewer to load in all the other sections that you've been working on throughout the rest of this title.
00:22This is where you start to see all the elements be pulled in to comprise your complete finished site.
00:29To give you a better idea of what you're gonna be working on before you get started, open up your preferred web browser and navigate
00:35to www dot Lynda dot com forward slash int flash eight forward slash laiworks.
00:46When you navigate to that URL, you'll see the navigation bar appear in the top.
00:50It animates in with a simple mask wipe.
00:53So a mask animates across our navigation bar, just to give it a little extra visual effect.
00:59Then when you hover your mouse over one of the navigation options, notice how the color changes.
01:04You're going to be doing that using action script.
01:08Then when you select one of those options, that option, much like the submenu options in your about us module, then becomes disabled,
01:16and the viewer can't click on it or do anything to it.
01:19Additionally, it stays locked in that same rollover color, that green.
01:23Then when you select another one of the options from your navigation bar, the option that was disabled is now re-enabled,
01:30and again the option that they clicked on is now disabled.
01:33So there's quite a few things going on inside the navigation bar.
01:37Not only do the options change when you roll your mouse over and off, but they also become disabled when you click on an option,
01:43as well as the other options becoming re-enabled when the viewer selects one of those options.
01:48Additionally of course, when you click on one of the navigation bar options, it actually loads the content for that section,
01:54which is what it was meant to do in the first place.
01:57So there's quite a few things going inside the navigation bar, and that's what you're gonna construct inside of this chapter.
02:03Before you continue on to the next exercise however, when you're finished viewing this navigation bar, go ahead and close your browser window
02:10and return to your site directory in the laiworks directory on your desktop.
02:15It's here where you're going to start the next exercise.
Collapse this transcript
Setting up
00:01>>Speaker: For those of you that have access to the exercise files to both save you some time as well as save you from repeating action script
00:09that you already know, I have created a starter file for you to build the navigation bar.
00:15Inside of your side directory you will notice there is as FLA called main underscore dot fla.
00:21Go ahead and open that FLA up inside of Flash 8.
00:25If you scroll towards the top of a stage and you take your play head and scrub it back and forth,
00:30you will see that white animation that I was referring to earlier.
00:34Again, if you look in your layers, you can see that it is a simple shape tween,
00:39and that shape tween is masking your navigation bar including the options inside of it.
00:45So as that wipe, that mask moves across and animates, it thereby reveals the options of the navigation bar.
00:53Now as you have seen thus far at the beginning of working on each new module you are going to want to first make a link
00:59to the shared font that you are going to be using in this exercise.
01:03To do that choose File, Import, Open External Library, navigate to your site directory, and double click the file Shared lib dot fla.
01:14When that shared lib library panel opens select the shared font Vera Bold Oblique, there is just one font that we have been using in the construction
01:23of this main menu and take that Vera Bold Oblique shared font and drag it into the library of your main menu dot fla file.
01:31Then close that shared lib library panel.
01:34Next let's assign that shared font to our main menu options.
01:39The layer that contains main menu options, is in a locked layer that is being masked called Menu options.
01:47Go ahead and unlock that layer first and make sure that your play head is all the way at the very end of the time line.
01:54Then on the stage click once on the About Us options.
01:58If you look in the Properties Inspector you will notice that there is an instance of a movie clip symbol called MC About us.
02:04Additionally you will notice that it also has an instance name of MM underscore about us.
02:11All of these main menu options already have instance names applied to them.
02:15Again to both save you time as well as to prevent you from repeating things that you already know.
02:20It's good to keep that in mind though, so that as you begin to write the action script that changes how those options interact
02:27and how they look you know which instance names those particular actions have.
02:32Next double clip on that movie clip symbol instance to open it up and then click once on the dynamic text field inside there.
02:41You will also notice that that dynamic text field already has an instance name of text label.
02:47As you will also see in just a minute every other dynamic text field inside of the other options also have the exact same instance name, text label.
02:56As you will see later when you are writing the action script that's going to help to streamline the process of writing a function to change the color
03:03in interactivity of each of those options because they all have the same name.
03:07But for now what we want to do is change which font that option is using.
03:12With that dynamic text field still selected, from the Font pull down menu select your shared font Vera Bold Oblique.
03:21If you are on Windows, make sure that you click the full bold and full italic buttons as well.
03:27Now you just need to repeat that same process for the remaining three main menu options.
03:32So go back to scene 1, double click on the frames movie clip symbol there on the stage, select a dynamic text field on the stage
03:41and from the font pull down menu again choose the shared font Vera Bold Oblique.
03:47On Windows again make sure that you have the full bold and full italic buttons depressed.
03:52Then I am going to go back to scene 1, do the same thing for the locations option making sure again
03:58on Windows to select the full bold and full italics buttons.
04:02And then lastly for the Contact Us option.
04:07When you are finished linking the shared fonts for the main menu options return back to scene 1 and make sure
04:18that you save the changes that you have applied to this fla file.
04:22In the next exercise you are going to start writing the action script that allows those options to be modified when the viewer interacts with them.
04:29So as the viewer rolls the mouse over and then off those main menu options,
04:34you are going to write some action script to modify how those options appear.
Collapse this transcript
Scripting onRollOver, onRollOut, and onRelease
00:01>> Now that you have linked a F font to your main menu options, the next step it to write some action script.
00:08What you are first going to start writing is a few variables that are going to hold color information,
00:14that you will apply to your main menu options as the viewer interacts with them.
00:19So go ahead and select the last key frame in layer A and open up your actions panel.
00:25As you can see when you open the actions panel for those of you who that have access to the exercise files,
00:31I have already included some action script here for you.
00:34Again that was for a few different reasons, to both save you some time as well as prevent you
00:39from writing action script that you are already familiar with.
00:43As a quick review you can see there is a simple stop action so that when the play head gets
00:48to the last frame it stops there instead of going back to the beginning and playing again.
00:53There is also a function called reactivate buttons, and its sole purpose in life, as you'll see a little bit later is to re-enable our menu options.
01:02It just targets each of our objects, About Us, Contact Us, Frames, locations and so forth and sets the enable property
01:10of those movie clip symbol instances back to true again.
01:13So when we want our main menu options to be reactivated we can simply execute this function.
01:20It's doing a few other things down here inside this function as well, which we'll go back and look at later.
01:26If you scroll down some more inside your actions panel you will notice there are some rollover and rollout actions for your options About Us,
01:36Frames, Locations and so forth already all defined for you.
01:41Now the About Us option which you will be working with in this chapter the rollover and rollout actions is as yet undefined.
01:49There's nothing going on inside those functions.
01:51You are going to learn how to write the action scripts within the on rollover and on rollout functions of the About Us option,
01:58but the other options have already been completed for you.
02:01Again because once you know how to do it one time the others are exactly the same.
02:06So the first step here is to create some variables that is going to hold hexadecimals color values for you
02:13so you can then apply those color values to your main menu options at various points.
02:18Scroll to the top of your actions panel and then click after the action in line number 2 which is mm underscore logo dot enable equals false.
02:28Click at the end of that action and press return or enter a few times to create a couple empty line breaks.
02:34It's here where we're going to create a few comment lines to better separate in our actions panel the functionality that we are about to write.
02:42To save myself a little bit of time, I'm going to select the comment line that is down beneath it in the actions panel and copy that.
02:50Then I'm going to click on line 4, one of the empty lines I just created and paste the comment line.
02:56Then I am simply going to change the text comment in there to read 'define option colors' then I am going to select that comment line, copy it,
03:13click at the end of that comment line, press return or enter a couple times and then paste that copied comment line.
03:21In the pasted copied comment I am going to click before the word define and then type a forward slash to end that comment.
03:27Next let's quickly create a few variables to hold our hexadecimal color information.
03:32So click in the empty line break between the two comment lines that you've just written and type var space overColor, all one word with a capital C
03:42in color, this is going to hold a number, so let's strict type into the number datatype by typing colon number, space equals space,
03:52and then the number which is going to be the hexadecimal value of the color that we are adding to this overColor variable.
03:59Type 0X7DPC6P and then add a semicolon to end that action.
04:10Then press return or enter again and type var outColor colon number space equal space,
04:210X and then 000000 which is black, and then semicolon to end that action.
04:30So what you've just done, is that you have just store two hexadecimal color values in two variables, one called ovreColor,
04:36which we will utilize then the viewer rolls the mouse over one of our options and outColor which we will utilize
04:43when the viewer rolls their mouse out or off of an option.
04:46As you can see the outColor is the default color that the options currently are, which is black.
04:52The overColor is a different color completely.
04:55Now that you've defined the over and the out colors and stored those numbers inside of a few variables, you are going to create a function
05:01with parameters that you are going to utilize as the viewer rolls the mouse over and then off of our main menu options.
05:09So after that outColor action that you just wrote, press return or enter two times to create a few empty line breaks.
05:17Then create your function by typing function space change Option Color.
05:26With a capital O in option and a capital C in color.
05:30Make sure of course that you spell everything correctly.
05:34Then type in an open parenthesis and then we are going to pass a few parameters to this function.
05:39One parameter is which movie clip symbol we are going to apply the contents of this function to.
05:45So we are going to have a parameter that is going to receive the name of the main menu option we are applying this to.
05:51So type myOption, a one word with a capital O in option and that is going to be the instance name of a movie clip.
06:00So strict type this to the data type of movie clip, by typing color movie clip.
06:07The other parameter we are going to be passing to this function is the color that we want that movie clip instance to be changed to.
06:15So type comma space, myColor all one word with a capital C in color.
06:21This is going to be a number so strict type it to the number data type by typing colon, number.
06:27Then type a close parenthesis, a space and open curly brace a couple of line breaks close curly brace.
06:35Then click in the line break in between the open and closed curly braces of that function and type, my Option dot text label,
06:45which if you remember is the instance name of the text field inside of each one of the main menu options.
06:51Dot text color which is a property of a text field, space equals space, my color, semicolon to end the action.
07:02So as you can see here we are utilizing the My Option parameter, which again is one that we are going to be passing to our function
07:09that my option parameter, is going to be the instance name of a movie clip that we are targeting.
07:15Then the dot text label, text label is the instance name of each dynamic text field inside of the main menu options.
07:23Then what we are doing is resetting the text color property of that dynamic text field
07:28to be whatever the my color parameter is that we are also passing to this function.
07:33So when we want to utilize this function to change the color of an option, when the viewer for example, rolls the mouse over one of our options,
07:41we simply execute this change option color function and then in parenthesis we pass to it the instance name of the movie clip symbol that we are going
07:50to be targeting as well as which color we want that option to be changed to, overColor or outColor.
07:56And all that does is it sets the hexadecimal value of the text field called text label inside of that option.
08:04Let's take a look at how to do that now.
08:06Scroll down in your actions panel a little bit until you locate the mm underscore About Us dot on roll over function.
08:16This comes after a comment line that says About Us option.
08:20Then click in the empty line break in between the open and close parenthesis after the about un on roll over function
08:28and type the function name, change Option Color, again making sure that you spell things correctly as well as have your capitalization correct.
08:39Then type and open parenthesis, and then type 'this'.
08:44Remember that this keyword is situational.
08:47When you use the keyword 'this' inside of a function that is being attached to a timeline or a movie clip symbol instance such as mm underscore
08:56About Us, the 'this' keyword simply references that movie clip symbol or timeline.
09:02So when I use the keyword 'this' as a parameter then I am passing to my change option color option, it's not passing the word 'this' to it,
09:12it's passing the name of the name of the timeline or symbol that I am currently inside of.
09:17Mm underscore about us.
09:19So again when I execute my change option color function and I pass the 'this' parameter to it, it is actually passing mm underscore about us.
09:30Again because I am inside of a function that is attached to that particular movie clip symbol.
09:36Then type comma space overColor, which is the variable name that is holding the hexadecimal value that we want our options
09:46to be displayed as when the viewer rolls their mouse over it.
09:50Then type a close parenthesis and a semi colon to end that action.
09:55Now when the viewer rolls their mouse off of our action we want it to do something very similar, except we don't want it to display the overColor,
10:03we want the main menu options to be displayed as the outColor.
10:07So select that action that you just wrote inside the About Us on roll over function, copy it, then click in the mm underscore about us on roll
10:19out function, click in the empty line break within that function and paste the action that you just copied.
10:25The only thing that you need to change here is that instead of overColor you want it to be outColor.
10:31This is why we created the action that actually changes the color of our main menu option.
10:37That's why we put it inside of a function.
10:39That way as you can see, when we want to modify the color of our options when the viewer interacts with those options,
10:46all we have to do is write this one line that simply targets the function, tells that function which movie clip symbol instance we are targeting,
10:55and then we simply tell it after that what is the variable name that is holding the hexadecimal color value that we want to change that option to.
11:04It makes it much easier for us to go and add this functionality to our main menu if we do it this way.
11:10You can test what you have done so far by saving your changes that you've made to your main menu FLA and testing your movie.
11:19When the main menu wipes and reveals itself when you move your mouse over About Us and off it again you can see that it is changing colors.
11:27So you know that that's working perfectly.
11:29Now the action script that you've just written to get this About Us option to work the way it does, because it's the same for the other options
11:37in the main menu, I have already, for those of you that have access to the exercise files,
11:42applied those same actions to the other options to save you some time.
11:46So as you roll over those actions and interact with them, you'll notice they will all perform the same way.
11:51And again the same action that you've just added to the About Us option, is the same actions that you will have added to the other options as well.
12:00Once you've finished previewing what you have just written, go ahead and close that window and return to the last key frame
12:06of your layer A in main menu dot fla with your actions panel open.
12:12In the actions panel if you scroll down a little bit from where you were last writing your actions, and till you locate the mm underscore
12:19about us dot onrelease function, again you will already notice that there is a little bit action script written there for you.
12:26The first thing that you'll notice is a function called reactivate buttons.
12:30As I mentioned previously, if you scroll up in your actions panel, you'll see that reactivate buttons function.
12:37All that that function does is it currently sets the enable property of all of the main menu options movie clip symbols to be enabled.
12:44All that that does that it currently sets the enable property of all the movie clip symbols option to be true.
12:51That means that when the viewer clicks on one of the button options it's going to execute this reactivate buttons function
12:58and then all of the main menu options will be re-enabled.
13:01At this point you may be saying to yourself: re-enabled?
13:04When were the disabled?
13:06And again if you scroll down to your about us dot onrelease function you'll notice that one of the actions in there is 'this dot enabled equals false'.
13:16Meaning disable the option that the viewer just clicked on.
13:20This action is added to the About Us on release function so that means that when the viewer clicks on the About Us option,
13:26it simply sets the enable property of itself to be False.
13:31So when the viewer clicks on a main menu option the first thing it does, is it executes this fun