Creating a Portfolio Web Site Using Flash CS4 Professional

Creating a Portfolio Web Site Using Flash CS4 Professional

with Paul Trani

 


Flash and ActionScript are ideal for creating flexible, easily updatable web sites that are both unique in design and small in file size. In Creating a Portfolio Web Site Using Flash CS4 Professional, Adobe Certified Instructor Paul Trani shows how to exploit Flash to create a web site that showcases work to clients and prospective employers. Find out how to add dynamic navigation, animation, and video to a page, and how to load, sort and display XML that enables portfolio content to be updated without opening Flash. This course is designed to take your existing tweening skills and gotoAndPlay code and walk away with a fully functional Flash site. Exercise files accompany the course.
Topics include:
  • Optimizing and publishing a Flash web site
  • Designing a professional photo or video portfolio
  • Adding button interactivity
  • Adding functionality to portfolio thumbnails
  • Displaying content with XML
  • Adding audio to portfolio presentations

show more

author
Paul Trani
subject
Web, Web Design, Projects
software
Flash Professional CS4
level
Intermediate
duration
4h 4m
released
Feb 17, 2010

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(Music playing)
00:04Hello! My name is Paul Trani and welcome to Creating a Portfolio Website with Flash CS4 Professional.
00:10Now, are you interested in creating a website to show off your work?
00:14Then this course is for you.
00:16I am going to be really walking you through all of the ins and outs of how to
00:19create a robust, flexible portfolio website in Flash from the ground up.
00:24I will show you how to incorporate good web design principles, how to create a
00:28user-friendly site, including dynamic navigation, eye-catching transitions,
00:35multiple content sections, sound to bring your site to life, and of course, I
00:41will show you how to display an unlimited number of images, complete with
00:45supporting text and links.
00:47Or, what if you want to show off some of your video or film work? No problem,
00:52because you will also see how to create a video portfolio.
00:55I will even include some of my bonus sites that you can take and modify to your liking.
01:01Now, let's get started Creating a Portfolio Website in Flash CS4 Professional.
Collapse this transcript
Using the exercise files
00:00If you are a premium member of the lynda.com Online Training Library, or if you
00:04are watching this tutorial on a disk, you have access to all of the exercise
00:08files used throughout this title.
00:10So I am going to open up this Exercise Files folder, and as you can see, all the
00:14Chapter content is in here, as well as the Final site.
00:17I have included some Bonus Sites, and even some various Assets that you will
00:21need throughout this title.
00:23Now, if you are a monthly or annual subscriber to lynda.com, you actually don't
00:27have access to the exercise files, but you can always follow along with your own files.
00:32So let's get started.
Collapse this transcript
1. Getting Started
Understanding web design
00:00I would like to start off by giving you a good understanding of web design.
00:04First of all, what is web design?
00:06Well, it's all about creating visual content, placed on a web server and served
00:11through the Internet to somebody's web browser.
00:14So we need to keep in mind the context as in which this content is being shown.
00:19And I am not just talking about websites. This could be banners. This could be
00:22interactive presentations.
00:23It could be anything.
00:24The principles of web design carry across all those different types.
00:28But why a portfolio website?
00:30Well, it's all about convenience.
00:32Being able to give somebody my URL and having them check out my work is the best
00:36way to pretty much get my work in front of them.
00:38And it's a great way, not only through my portfolio to show my design skills,
00:42but through the website itself, it enables me to show off my web design skills as well.
00:47But really where you want to start is with the goal of your website.
00:51So if you are making a portfolio website, what's your goal?
00:54In this case, and probably in your's, potentially, is to get a job.
01:00So I want to keep that in mind as I make decisions about my website.
01:05And I want to develop all content around this goal of getting a job.
01:09Now, the website checklist are things I want to keep in mind as I start to design.
01:13I want to make sure that, of course, my site is available and accessible.
01:16So do I have a URL?
01:18Do I have website hosting set up?
01:20I want to make sure my site is easy to use.
01:23Does it fit on the user's screen?
01:25Are links clearly identified?
01:27Is it browser compatible?
01:28Does it download quickly?
01:30Are users able to see the content quickly?
01:32Does it deliver the information expected?
01:35Are links clearly defined?
01:37Are buttons clearly defined on what they do?
01:39And, of course, is this appropriate for the audience?
01:42If I am after a creative job, I want to make sure that my website might be as
01:46creative as possible in order for me to get that particular job or just geared
01:49toward that audience.
01:51And, of course, I want to make sure my site is owner-friendly.
01:53So is it easy to update?
01:55That's probably the most important thing, easy to use, easy to update.
01:58But I want to keep all of these goals in mind, my personal goals as getting a job
02:03and then the user's goal, which is going to be finding out content about you.
02:07You want to keep these two things in mind as you design.
02:10And what you come up with will be based on those goals.
02:14So in this case, as you can see, there is an image in the background. This could
02:17be a portfolio piece to show off my work.
02:20I can clearly see that there's a hierarchy of information.
02:23I know I am on John Doe's website.
02:25I can see that the copy is clearly legible, easy to read, and there
02:29is navigation as well.
02:30If this is for a, say, creative job, I can get more creative with the
02:35navigation or the content.
02:37It's all centered around what I am trying to do, in the design of the site as
02:40well as making sure it's usable for the end user.
Collapse this transcript
Creating a Flash file
00:00I would like to start off by giving you an overview of Flash CS4 Professional.
00:05Obviously, I have it open right now.
00:07You can see, from this start up panel, I can go ahead and Create a New File.
00:12So that's the first thing I want to do is Create a New Flash File (ActionScript 3.0).
00:16If I select that, a new Untitled file opens up.
00:21It's just a document that just has a white background right here.
00:26And what I am going to do is I am going to go ahead and save this.
00:29So I am going to go to File>Save and I am going to save it to my Desktop, in my
00:36Exercise Files folder, Chapter01, and I am going to save it in 02 final.
00:44So I am going to change this title from Untitled-1 to index, because when you
00:49are making your website, the root file, the main file of your website, is going
00:54to be called index, and that's what I am calling it here.
00:57This is going to be more or less like my homepage.
01:00It's going to be index.fla, and I am going to go ahead and select Save.
01:04Now I have it saved correctly and now I am ready to do some work.
01:07So there is plenty of panels around here, and your setup might be different from
01:11mine, so what I would like for you to do is go to Window, down to Workspace, and
01:18change your Workspace to something else, change it to Classic.
01:22If I change it to Classic, you can see how all the panels adjust.
01:25I have the Tools panel on left side. I have the Timeline at the top. I have the
01:29Properties panel on the right side.
01:33The only other panel that I know I am going to use a lot is the Library panel.
01:37So if I go to Window, down to Library, it will open up that Library panel.
01:42In fact, it was nested right here.
01:44But I can go ahead and select that tab and pull that panel out.
01:48Now I can position this wherever I want, but I can also nest it over here in
01:52the Properties panel.
01:53And that's what I want to do, nest it clear down here at the bottom, so the
01:57Library panel is just beneath the Properties panel.
02:00And I can go ahead and close that panel if I want to see more of the properties.
02:03But in general, this is set up the way I want to set up my document.
02:07And sure enough, if I twirl that Library panel down, I can change the
02:11Properties for this document.
02:14So this white stage area, well, I can easily change that to a medium blue if I want to.
02:21I could even change the Size of this document.
02:23I am going to click Edit, and I can adjust the Dimensions.
02:27So since this is for a web page, I want to make sure it fits a web browser perfectly.
02:32Now, the smallest common denominator for a monitor is going to be 1024x768.
02:39So 1024x768 would be the size, but I have to subtract some to account for the
02:45browser scrollbars and buttons.
02:48So I will just make this 1000 pixels wide, and instead of it being 768, I want
02:55to take off and make that about 700, make it a little smaller to account for the buttons.
02:59But sure enough, I can control the dimensions, I can hit select, and then we
03:02will go ahead and change it, and I can see that this is ready to go, and I can
03:06go ahead and Save this file.
03:08And sure enough, I can go ahead and use any of these tools to create what I need
03:12to, but in general, that's the short of creating your very first Flash File.
Collapse this transcript
Importing a design from Photoshop
00:00One of the great things about Flash is that you can import content in from other
00:04programs that you might be more familiar with.
00:07So if you are familiar with Illustrator or Fireworks, even Photoshop, you can
00:11import that content and still maintain the integrity of the design.
00:16For instance, I have Photoshop open, and I want to import all of this
00:19content from this Photoshop file into Flash, but I first want to explore
00:24some of this content.
00:25In the Layers panel, you can see that there's this image layer and I can turn that off.
00:29You can see that's the large image in the background.
00:32There's a content folder.
00:34I can twirl that down and you can see that it contains text layers in here.
00:40And if I turn those on and off, you can see that this is the navigation.
00:45I then have this Logo folder that holds the logo, and then I have this
00:50background folder, and I will turn that on and off.
00:53That provides the texture and some additional text for this file.
00:57So if I zoom out, you can see there's some additional text out here.
01:02If I just select this content folder, so what I want to happen for this design
01:07is I want this content to rotate around and then display, say, the Portfolio
01:13section or the About section or the Video section.
01:16It's all going to be like twirling and rotating to reveal the
01:20appropriate section.
01:21So that's what I want it to do, and those extra items are all in the background folder.
01:28All right. I am not going to do anything tricky. All I am going to do is Save, and I am
01:33going to make sure it's saved in the Exercise Files folder/Assets/design, and
01:41that's the Design.psd.
01:43That's where this file is being saved, so I know where to get it from when I go into Flash.
01:50So with my index.fla opened, what I want to do is I want to go to File >
01:56Import > Import to Stage.
02:01From there, I can dig into the Exercise Files folder/Assets/design, and select
02:07that PSD, and click Import.
02:11I love how Flash gives me this wizard for importing files, so I can click on all
02:17of these various layers and I can decide what I want to import.
02:21Say, for instance, I don't need to import this black background, so I will just uncheck that.
02:26For the image layer, I can make sure that gets imported.
02:30And then I have this content folder.
02:32Well, I can import that content folder, but I can import it as a movie clip, so
02:38I am given multiple options over here on the right-hand side.
02:42I am going to create a movie clip for this layer.
02:44So when in doubt, make it a movie clip, because it's going to give you more flexibility.
02:49But what a movie clip is, it's just a container for any content you want.
02:54So I can animate movie clips. I can add interactivity to them. I can do lots
02:57of things with them.
02:59So when in doubt, just make it a movie clip and it will give you lots of flexibility.
03:03And within this content movie clip, there's going to be additional items.
03:07So I can select this Portfolio layer, which is a text layer, and I can make it Editable text.
03:13And I might want to make this a movie clip as well.
03:16So that's what I want to do for each one of these text items, make it a text
03:20layer, and then make it a movie clip.
03:23In general, there's going to be a text field that exists inside of this movie clip.
03:28The Logo folder, if I twirl that down, you can see that it contains many
03:34different items as well, but for this Logo folder, I want to create a movie clip
03:37for it, and I want to make sure this text is Editable as well, just in case I
03:43misspelled something or whatever the case may be.
03:46I could even import Vector objects, so I am going to select this Cross, so
03:52these are the different crossbars that make up the Cross.
03:55I can import it as Editable paths and layer styles.
03:59So in general, if it says import is Editable, you probably want to do that.
04:04Our last area is this background.
04:07Again, I am inside of this content movie clip. Here are some additional text
04:12items, and I want to import as Editable text.
04:15Again, if I misspelled something or if I decide I need to change it, I can
04:19go ahead and do that.
04:20Here's my gradient, so this is the big gradient. I can just go ahead and leave
04:24that as is, but be aware that it is in the background folder. All right.
04:29Everything is looking great and it's ready to be imported.
04:32Last thing I want to do is to review this bottom area.
04:34I want to Convert all the layers to Flash layers, and place those layers at
04:39their original position.
04:41I am not going to worry about the stage size, because I already have that set up.
04:43Go ahead and select OK, and it will import the design.
04:49Now, I can use this Navigator to change my viewable area, say down to 25%, and I
04:57can see that here's all of my content.
05:01Quite frankly, I do need to move this into position.
05:04I can select this content and I can move it around.
05:09In general, everything has been placed at its original position.
05:13And instead of using this Navigator, I can go ahead and use Command+Plus to
05:17zoom in and Minus to zoom out, but in general, I want to start to align this up in my stage area.
05:23Now, I can kind of eyeball it and see if I can get it close, or I can go to
05:27Window, down to the Align panel, and I can go ahead and align it to the stage.
05:32So Align panel, I am going to make sure this is depressed.
05:36I pressed that down and it's going to Align Vertical to the stage and then I want
05:41to go ahead and Align Horizontal to the stage.
05:44So you see it shift a little bit, and in general, that's what the Align panel does.
05:49So it's looking good. I have that stuff positioned appropriately.
05:52Take a look at the Timeline panel.
05:54Sure enough, it imported those layers appropriately.
05:56Turn off that content layer and you can see the image layer, there it is.
06:02I can turn that on and off.
06:03If I select this content layer and I look at my Properties panel, you can see
06:08that it is a movie clip, it came in as a movie clip, and it's an instance of the content.
06:13And I can double-click on it and start to take a look at all the different items
06:17within this movie clip.
06:19I can see that this About button is an instance of the movie clip, and if I
06:23double-click on it, I can see that there's the text and I can go ahead and edit it.
06:27All right.
06:29Notice how deep I am, and I want you to be aware of these breadcrumbs, because I
06:34am actually inside of the About movie clip.
06:37Well, to get back out, to edit anything else in the previous movie clip, I
06:42would click content.
06:43Now I can adjust anything else I may need to adjust.
06:47And then I can go out, again, to Scene 1, otherwise known as your stage, to work on the stage.
06:54But in general, that's how it works. If I want to edit a movie clip, it's just a
06:58matter of double-clicking on it and then you will be inside of that movie clip.
07:01In this case, I am inside of content_mc. All right.
07:05There's another way to do that as well.
07:07There's all this content that I have imported. If I open up my Library panel,
07:11you can see, here's my Library folder and here's all of my content that I have imported.
07:17So again, I can just double-click on this movie clip and then edit content in here as well.
07:23And again, just be aware of where you are. Always click on Scene 1 to go back,
07:28but in general, you can see that you can easily import any design from other
07:33programs, such as Illustrator or Fireworks or Photoshop.
07:37You can import them. It maintains the integrity of the design, so you can then
07:41start animating or adding interactivity, if you want to, in Flash.
Collapse this transcript
Optimizing the design
00:00As you start to import graphics into Flash, it's important to be aware that the
00:04more graphics you import, the larger your file size is going to be, and the larger
00:09your file size is, the longer it's going to take to download, and the longer it
00:14takes for your users to see your content.
00:17So you want your file size to be as small as possible.
00:20And what I want to do is I want to take this design down to be about of 10th
00:26of its current size.
00:27So what you're going to want to do is explore what got imported and how you can optimize it.
00:33First off, there is just this extra layer, just hanging out down here. He doesn't
00:36add any file size, but I'm just going to perform some clean up by selecting that
00:41layer and hitting the delete button. All right.
00:44Next up, I do have this image.
00:45Well, quite frankly, I do need that image, so I'll just leave it there for now.
00:49Let me go into my content movie clip, and as I double-click into that, I can see
00:55that I have these text items.
00:59These are movie clips and then there's texts inside of them, so they're fine.
01:03This I imported as text, so that's looking pretty good, but if I zoom out, I can see
01:09that there's this really large image, and this is probably my biggest issue, is
01:15this big background.
01:18So I have this gradient, vertical, and horizontal, as wells as this gradient
01:22burst, and then this pattern in there.
01:24So what I want to do, instead of this being a really large file, I want to make
01:29this in vector format, because if it's a vector, it's going to be a lot smaller.
01:34But first, let's explore the file size of this file, so this is an index.fla
01:40file, the .fla file is the working file.
01:43But what I want to do is I want to go to Control and I want to do a Test Movie,
01:48which you will do this a lot in Flash.
01:50If you go to Test Movie, what actually happens is it creates an SWF file, small
02:00web format file, so Flash does a good job of making your files small, but in
02:06general, this is the file that would go on the Web.
02:08You're probably wondering "How small is this SWF file?"
02:12Well, if I go to View, and I select Bandwidth Profiler, you can see that I'm
02:18given this graph right here.
02:21So this animation is only one frame long, but I can see, down here at the bottom
02:25of this panel, it says that it's about 1400KB, about one-and-a-half megabytes, so
02:32which is pretty darn large.
02:34So I'm going to take this one-and-a- half megabytes and crunch it down.
02:37So I want to close that file, and again, this is probably my biggest offender if
02:41you will, and what I want to do is recreate some of these elements.
02:45So I'm just going to create a new layer. With this new layer, I'm going to
02:48select the rectangle tool, and what I want to initially select is the Fill
02:54color, and instead of it being a solid color, it's going to be this burst,
02:58this radial burst, like that.
03:01Okay, so when I draw the circle, I am going to draw it from this upper corner, in
03:08fact, I'll scale that out a little bit and maybe zoom out and touch more, but
03:14I'm just going to go ahead and draw this radial burst, like that.
03:18There is my radial burst. I can select this item, and what I want to do is I
03:25want to modify it, Color.
03:28So I'm going to expand out this panel, and I'm basically going to the Color panel.
03:33You can always get to it through Window, going down to Color.
03:36But in general, this fades to white. The center points a white, when really, I
03:40want the center point to be, not necessarily black, but I want it to be
03:45transparent, just like that.
03:47So there's my gradient.
03:49It's looking pretty good. In fact, I can even call this layer just by
03:53double-clicking in it. I can call it gradient, and that's now a vector item.
03:58But I'm still creating different parts here.
04:00So I'm going to create a new layer, and this time, I want to duplicate this
04:04gradient bar, so I'll zoom in a touch, and I'm going to select the Rectangle
04:09tool again, and instead of using the burst, I'm going to use this linear
04:14gradient, and I'll just click and drag, like that.
04:19So if I select the Selection tool, you can see that I can start to align
04:24this appropriately.
04:25But it's going the wrong direction, so the first thing I'm going to do is
04:28I'm going to fix the color. I'm going to have it fade to black, and I'm going
04:32to make fades to transparent, and then what I want to do is I need to adjust the angle.
04:39One easy way to do that is just to use the Paint Bucket tool, because if I click
04:43and drag with the Paint Bucket tool, it starts to manipulate -
04:46let me just change this color for you -
04:49it starts to manipulate the angle of your linear burst, so let me just
04:55change that to Red. There we go.
04:57You can start to see it work, but in general, I can go ahead and make sure this
05:02is fading the right direction and sort of the right degree.
05:06So using your Paint Bucket tool, you can add that gradient, and again, I just
05:09changed it to red, so I can see it, but I can easily change that back to black,
05:13just like that, and there is my gradient.
05:17Now, I need to create the same gradient right here, okay, vertically.
05:21Well, anytime you find yourself doing something twice, think about converting it
05:25to a movie clip, and I'm going to show you how to make something a movie clip.
05:29Right now, I'm going to open up the Library panel, and with this gradient
05:34selected, I'm just going to click and drag it right into the Library.
05:39Once I drag something into the Library, in essence, what I'm doing is I'm
05:43converting it to a symbol, and I want to call this symbol 'gradient,' and I'm
05:51going to keep it as a movie clip,
05:52but I can some other things as well.
05:54I'm going to just keep it as movie clip, select OK.
05:59And sure enough, if I select it, and look at my Properties panel,
06:02it says that it's an instance of the gradient, but there it is.
06:06It's in my Library now, and what I can do from here is I can drag out another
06:11instance of that gradient, and I can use my Free Transform tool, third one from
06:20the top, to rotate that around like so and line it up.
06:27So when you find yourself doing something more than once, think about
06:30converting it into a symbol and having multiple instances on your stage,
06:36because what this means is that Flash is only storing one version of it, and
06:41then it just duplicates it.
06:42So it makes your file size smaller when you use symbols, and really, you need to get
06:47in the habit of making things symbols.
06:50So, I'm going to go ahead and select this, and these are also gradients, but
06:54this is the layer, so these are my linear gradients.
06:58Let me just turn off these two layers, because you can see I still have this
07:04pattern, and this is where things get a little tricky, because how am I suppose
07:09to recreate this pattern? Am I suppose to draw little squares? Well, no.
07:13It is a pattern, so I want to use a pattern to cover that entire area.
07:19So I'm going to zoom in a touch. I'm going to add another new layer and this is going to be
07:26my pattern, and I'm going to go to File, and I'm going to Import the pattern.
07:32So I'm going to Import to the Library a pattern.
07:39So this is just a really simple file.
07:41It's really small. It's just a PNG, so it's a file with transparency that just
07:46has four little dots in it, but this could be whatever type of pattern you want.
07:50It could be anything.
07:51In general, I want to take this and import this pattern into my library, and I'm
07:58going to go ahead and Import this, everything set to the defaults, select OK.
08:05So I have it imported. There is my pattern PNG, and now what I can do, if I
08:11minimize that Color panel and expand this out some, and zoom out, because what
08:16I want to do is want to draw another rectangle.
08:20And instead of using these Fills, what I want to use is that imported pattern,
08:26and if I twirl this open, just so you can see where it is,
08:30it's actually clear down in here, and it's called Bitmap 5.
08:34It's actually this one right here. It's that graphic, so I'm just going to go ahead
08:38and select that file, and with that pattern selected, I can go ahead and draw
08:45with the Rectangle tool, and it recreates that pattern.
08:49So let me go ahead and turn off this gradient layer. Again, all this stuff was imported,
08:56but you know what? I don't need this layer anymore, so I can select that layer I
09:00was trying to recreate, hit delete, and twirl up some of these things. Actually, let me make
09:10sure everything is showing appropriately.
09:11You can see that there's the pattern, and I've recreated the look of that pattern.
09:17So let me go ahead and do a Control> Test Movie, just so we can check the file
09:24size, and sure enough, we're actually down to 4KB for this file, so we've
09:32drastically decreased the file size, and if I turn that on, you can see my
09:37image is actually still in there.
09:39So let me just turn that on, because this is ultimately the look I want.
09:43Let's go to Test Movie.
09:44You can see with that image back there, I have a file that's 100KB, quite a bit
09:51smaller than the original file, all by sort of recreating elements that were
09:56imported, which you might have to do on occasion, depending on what you import.
10:01But again, it can all be done in Flash, and if you're given the choice,
10:05recreate it in a vector format, and it's really going to make your files
10:10smaller and provide for a better user experience.
Collapse this transcript
2. Creating a Unique Web Experience
Dynamically loading an image
00:00One thing you might want to consider when optimizing your site is determining
00:04what information is important and needs to be seen immediately, and then what
00:08information can be loaded later.
00:10Take, for instance, this design. What I want the user to see, initially, is, of
00:16course, JOHN DOE, the text, as well as the navigation, but the background can be loaded later.
00:22So really, I don't want this background to be part of the Flash file.
00:27So what I am going to do is I am just going to turn off that content layer.
00:31I am going to select that graphic, and I am just going to delete it.
00:34So I am going to replace that graphic with a UILoader component that's going to
00:41dynamically load an image.
00:42So the first thing I need to do is go out and find my image.
00:47So I am going to go to Exercise Files/ Assets/design/and I'm going to
00:51select this images folder, and I am just
00:54going to Copy all of these images, but most importantly, I need this first
00:59image, background1.jpg.
01:01So I am going to be aware of this filename, and I am going to put it in the
01:05Chapter02/01 begin folder, paste everything in there, and again, that's the
01:12image I want to load in.
01:13So, let me go back into Flash and I am going to use a component.
01:18So I am going to go to Window> Components, and what Components are are assets
01:24that I can use where most of the code is written for me.
01:29So they basically extend the functionality of my Flash file, without me
01:34having to write code.
01:36So this UILoader component is one of them, because it will load in images, or SWF
01:42files, or Bitmaps, or JPEGs.
01:44If I want, all I have to do is drag it right onto your stage to add it.
01:51So I'm going to close the COMPONENTS panel, and I might want to put it in the upper
01:56corner, right there, all right.
01:57So next thing I need to do is define its properties, so I am going to go to the
02:03PROPERTIES panel and what I need to do is just go ahead and open up the
02:09COMPONENT INSPECTOR panel to view the different components options that I have
02:15available for this UILoader.
02:17So with it selected, I can take a look at my COMPONENT INSPECTOR panel.
02:21I want to autoLoad.
02:23I want to scale the Content.
02:25Well, do I really want to scale the content?
02:27No, I wanted to load in at its actual size.
02:31So I am going to change scaleContent to false.
02:34Next thing I need to do is type in the source. Remember that we did put an
02:40images folder in the same folder as this fla, and in this images folder is the
02:47background1.jpg. That's where the file is.
02:50Of course, we want to make it visible, but in general, that's all I need to do.
02:54So now when I go to Control>Test Movie, it loads in that background, and now my
03:01file size in only 15K.
03:04So if I just turn on this content layer, you can see, if I go to Control>Test
03:09Movie, that I do get the full experience.
03:12Now the file that was 100K is only 20K now, so this content is going to load
03:19pretty much in a split second for most users.
03:23But it's all about keeping the user in mind and making sure they can see
03:26content, and get to content right away, without having to wait.
03:30And all this is done using the UILoader component, and pointing to the specific
03:35image that you want to load in.
Collapse this transcript
Loading random images
00:01One thing you will always want to consider is how to keep your site fresh
00:03and visitors returning.
00:05One easy way to do this is by loading in different content for each visit.
00:10And that's what I want to do, in this case.
00:12I want to load in a different background each time the page is refreshed.
00:17Okay, and I really want to pick from a pool of about 10 backgrounds I
00:20already have set up.
00:22So let's go ahead and take a look at how this is currently set up.
00:27The background is being loaded in, using this UILoader component.
00:32So if I go to Window down to Component Inspector, you can see that the source
00:38says that it's pulling from images/Bkgd1.jpg.
00:42Well, it's not realistic from you to come in here and change this every 15
00:45minutes and then republish the file.
00:48But I could, I guess, do that, but what you're probably thinking,
00:50"There should be an easier way," and there is.
00:52And this way is done in ActionScript.
00:56Okay, so I'm going to use Flash's programming language to change this number here.
01:03I'm going to pick a random number from 1-10, and then replace that number.
01:08Okay, so just close that panel.
01:11First thing you need to do, if you're going to write ActionScript, is put
01:14ActionScript in a layer, and create a new layer just by clicking this Page icon, and call AS.
01:23And all of your ActionScript should really go on one frame in your Timeline,
01:28preferably in your main Timeline, just right here.
01:30That's where I want to keep all of my code.
01:33So with that frame selected, I'm going to Window, down to Actions, and that will
01:37open up the Actions panel. All right.
01:41First off, notice that there is this panel off to the side.
01:44I could use some of that content, but I'm going to do is I'm going to type in,
01:47right in this area, I'm going to write my ActionScript to right in here.
01:51And what I want you to get used to doing is start just typing in, in Plain
01:55English what you want to do.
01:57And in this case, what I want to do is I want to LOAD A RANDOM BACKGROUND (FROM 1 TO 10).
02:07That's basically what I want to do.
02:08So just in Plain English, type in what you want to do.
02:12And if you highlight that line, what you can do is tell Flash to ignore this
02:17line by selecting Apply line comment.
02:22That will enable Flash to just ignore that line, and then move on down to what
02:25you wanted to render out.
02:28So in this case, what I want to do is I need to create a Random number.
02:32And this Random number is really going to go in a container called a variable.
02:37So I'm going to create this var randomNumber, and what's going in this
02:44container is a number,
02:46so I need to tell Flash to expect a Number.
02:51So again, think of a variable as just an empty box that you can put anything
02:55into, and in this case, I am telling Flash that it's going to contain a number,
02:59and sure enough, that's going to be equal to whatever number you want it to
03:03contain, but I want it to be a Random Number.
03:06So first thing you might want to consider is just typing in 'random.'
03:10And notice that it's a keyword, and if it changes colors, it means that it's a
03:16keyword, and you really explore what it really does.
03:20So I'm going to go ahead and View Help, just by right clicking on that word, and
03:25it will open up Flash's Help, and it tells me what random is.
03:29Now if I scroll up near the top, notice that it's part of the Math Class.
03:34And the Math Class has many methods, one of them being the random method, but
03:41you can do so many different things.
03:43So again, if I select that, it's just going to tell me that it's going to pick a
03:46random number between 0 and 1.
03:48It's not going to be a whole number.
03:49It's going to be like 0.3258, something like that.
03:53But it does generate a random number, and that's what I want.
03:57So I want to use Math.random.
04:00So let me just minimize that, go back in Flash and type in Math, because
04:07again, it's part of the Math Class.
04:09It's this random method, and then just like it showed me in help, I need to have
04:14open and close parentheses.
04:16Now, this will return a random number, and it puts it in this container.
04:21All right!
04:22Now for testing purposes, what you're going to want to do is use a trace statement.
04:28And all this does is helps me check what's inside of random number.
04:34Just for my purposes, the end-user will never see any sort of trace statement,
04:38but it really helps me figure out sort of how my code is working.
04:41So I'm going to go to Control and Test Movie, and we're going to see what
04:46happens with the trace statement when I add that in.
04:49What happens with the trace statement is it prints out what was in that trace
04:54statement, and this is what that random number is .63 yada, yada.
05:01So let's just do a Test Movie, and I'll show you that it does generate
05:03a different number.
05:05So it is picking your random number each time.
05:06It's working great.
05:07But this is really random, and isn't really useful for my specific case.
05:11So I need to do some more things with it.
05:12In fact, I need it to pick from a number, say, between 1 and 10, Okay?
05:16So what I can do is say, "Hey, Math.random? I need to multiply you by 10."
05:24Now if I run it, it's going to pick a number between 1 and 10.
05:28So I'm just going to hit Command+Enter, or Ctrl+Enter if you're on a PC, and you
05:34can see, in the Output Panel, it's showing me that it is actually picking a random
05:40number between 1 and 10.
05:41But I still have an issue, because I don't have my image named this.
05:45I just have one background, two background, three background, or background
05:50three, but I don't have their whole numbers,
05:54so I need to round this to a whole number.
05:57And again, this - if I check out the Math Class again, I can see what else I can do.
06:05For instance, I can round down, maybe using floor, or I can even, Returns the
06:11ceiling, I can round up using ceil, so that's what I want to do. I want to round up.
06:18So 1.5 will actually become 2. 2.9 will actually become 3, and so on.
06:24So Math.ceil, and then within those parentheses, it will go ahead and round up
06:34anything that's in there.
06:35Let's check this out now, Test Movie.
06:38Finally, a whole number, and I'll just hit Command+Enter a couple more times, and
06:44you can see it's generating a whole number.
06:46Finally, something pretty useful.
06:49So now that it's returning a whole number between 1 and 10, let's make sure I
06:53have my images in place.
06:55Because here is my images, Background 1 through 10.
06:58Great, they are all set up.
07:00I need to be aware of how this is named, because now I need to use this random number.
07:08So another line and what I'm going to do now is I'm going to pin my code, and
07:15what pinning your code does is it just always keeps it up.
07:19So if I actually click off in the Timeline anywhere, in some other location,
07:24my code disappears,
07:25But if you're always writing code in one place, what you want to do is bring up
07:32that code and hit this little push-pin, Pin active script, because I always want
07:37this to be up, regardless of what I am clicking on.
07:40In this case, I want to click on the UILoader component, because I want to kind
07:43of compare what that component is doing with my code.
07:48So UILoader component selected. I'm going to go to Window>Component Inspector.
07:53Here is my Component Inspector panel, source, images/Bkgd1.jpg. All right.
07:59I need to write this in ActionScript, and the first thing I need to do is I need
08:04to give that UILoader an instance name.
08:07I need to give it a specific name, so I can reference it in my ActionScript.
08:11Just close that, select my UILoader component.
08:14Right up in here, I want to type 'bkgdImage.'
08:19This is known as an instance name.
08:21It's just a specific name.
08:23And what I encourage you to do is just do Command+C, just to copy it, because
08:27I'm going to use that in my ActionScript, Command+V, bkgdImage.
08:33So now that UILoader has a specific name. I can reference it.
08:37I can change its source to "images/Bkgd1.jpg," just like that.
08:47All right.
08:48So it's doing an exactly the same thing as this Component Inspector panel is doing.
08:53What I want to do is I want to replace this number with a random number.
08:57So in order to do that, I am just going to make sure this is text, and then I
09:03want to add this random number, so I'll, again, Copy, Paste.
09:09I encourage you to copy and paste, just to eliminate any sort of mistypes or typos.
09:14But now what's going on is it's going to look in the images folder for a
09:18background, whatever random number we pick .jpg. All right.
09:23Everything is looking good, and one thing you can do is, in your Actions panel,
09:29you can check the syntax.
09:30So I can go ahead and hit that checkbox.
09:33And say this script contains no errors.
09:34That's great, but I really won't know if it's working until I do a Test Movie.
09:39Sure enough, there it is, looks like a different background to me, and it's bkgd6.jpg.
09:44And I can do a Command+Enter, or Ctrl+Enter if you're on a PC, and you can see a
09:50different background 8, background 5 loading in, so each time the user visits
09:55the site, it's going to go ahead and pull up a different image, which works out
09:59great, a great way to keep your site fresh, and hopefully, visitors returning.
10:04It really does a good job of just really appealing to your portfolio as well,
10:09seeing as you can have sort of an unlimited, virtually unlimited number of
10:13images as your background that you can pull from, and again, the fact that your
10:17site is fresh just really enhances the experience for the user.
Collapse this transcript
3. Adding Navigation
Creating menu buttons
00:01One of the fundamental things you'll want to do in Flash is create a button
00:05and eventually add interactivity to it, and that's what I want to do with this project.
00:09I want to have each one of these items a button, as well as this John Doe be a button.
00:16This is going to be my home button and this is the one I'm going to start with.
00:20What I want to happen is I'm first going to give everything a Drop Shadow, just
00:25to set it off from the background.
00:27Then I want it to highlight red when you move your cursor over that particular item.
00:34Next, the down state when you click down on it, I want it to highlight white,
00:39give it this white glow as well.
00:41So that's what I want to do for the buttons is add a Drop Shadow, a roll over
00:45red color, and a click white color to each one of these,
00:49but the first thing I need to do is make it a button.
00:53So that's what I want to do.
00:56In my Timeline, in the content movie clip, I'm just going to double-click.
01:00What I want to do is I want to take this text and convert it to a button.
01:05Currently, it's about three different things all grouped together, and that's
01:11what you might need to do in some cases is break something apart in order to
01:16control it a little more.
01:17So Modify, go down to Break Apart and you can break apart that cross from the
01:25text, because I just want this text here to be the home button. All right.
01:30With these two items selected, what I can do is just click and drag it right
01:35into the Library and then I get the Convert to Symbol dialog box.
01:39I can go ahead and give it a Name.
01:41I will call this home button.
01:42I'm going to make sure the Type is a Button and then select OK.
01:48Notice in the Library panel, here is my home button and sure enough, it has an
01:52icon that looks like a button as well. All right.
01:56I want to edit this button now.
01:57So I'm going to double-click on it and now I'm in Symbol Editing mode for this button.
02:04Notice the Timeline.
02:06I have an Up, Over, Down and Hit state, and what I want to do is I want to modify
02:11this text for each state.
02:13So I'm going to start with the Up state.
02:14I'm going to select that text.
02:16In the Properties panel, I'm going to show how you can give something a glow.
02:21So down here, near the bottom, I'm going to click this Add Filter button and I'm
02:26going to give this a Glow.
02:28By default, it gives it a fairly nice red glow but again, I just want to make
02:32this black just to kind of set it off from the background. All right.
02:37So that's the initial state, the Up state, sort of the untouched state.
02:41The next it is the Over state.
02:43This is going to be the touched state.
02:45For the Over state, what I want to do is I want to Insert a KeyFrame.
02:49So when I Insert a KeyFrame, it actually gives me a keyframe and allows me to
02:53modify the contents in here at this point in time, or at this state, in this case.
03:00So John Doe, instead of it having this black glow, I can go ahead and change the
03:04Color to red and change the Strength to, say, 200%.
03:09I can adjust the Blur radius and different things as well, but I really want it
03:13to pop when you rollover or when your cursor touches this item.
03:18So typical state, Over state turns red.
03:21I'm going to insert another KeyFrame and instead of this being red, I'm going
03:26to change it to white.
03:28So it's going to have this white pop when you click on it, so the Down state.
03:33Lastly, I'm going to Insert a KeyFrame for the Hit area and what the Hit area
03:39is is just a larger area and I'm going to select just pink, for instance, this hot pink.
03:44I'm going to draw a box.
03:46I picked hot pink because you're never going to see what's in this Hit frame.
03:51All it does is it extends out the size of this button.
03:55So if you have small text, or you just need a bigger Hit area, you can draw
03:59whatever you want in here and that will be your active area for your button. All right.
04:04So far, so good!
04:06Let's just do a Control > Test Movie. There we are, and when I roll over it, it turns red.
04:12If I click on it, it gives it that white glow and it's working pretty well.
04:17Notice that when I will roll over even close to it, I'm going to hit that Hit area.
04:22So out here, this is my Hit area.
04:25It activates the button.
04:27So that's looking pretty good.
04:29It even has that nice black glow as well.
04:32So I want to apply this same method, I want to convert all three of these into
04:36buttons and I want to give each one these same settings, so the same effects. Okay.
04:43Since these effects are working out so well for me, I actually want to save them.
04:47So with John Doe selected in the Properties panel, down here in Filters, what I
04:52can do is Save Presets.
04:55Notice I already have some saved here, but I could just do a Save As and I'll
04:59call this one, say, 'Black Glow.'
05:03The Over state is nice red.
05:04I'd say it looks pretty good.
05:07Properties panel, Save As 'Red Glow.'
05:11Down state, there is my white.
05:14Save As 'White Glow,' just like that.
05:18So you can have as many as you want and really, you can build up a nice library
05:23of effects to use anytime you start a project.
05:27In this case, I'd want to do the same thing for the About button.
05:32Currently, it's not a button.
05:33So don't forget that you have to drag it into the Library to make it a button.
05:37I'll call this about button, select OK.
05:40Double-click that button to enter symbol editing mode and what I can do is start
05:47inserting keyframes and I can start giving this effects.
05:51So you can see the process is going to go much faster now that I have Filters Presets.
05:57So for this Up state, I can select the Black Glow, Over it's going to be a Red,
06:03Down is going to be the White.
06:08You don't have to put anything in the Hit area,
06:11so you can always skip that step, if you'd like.
06:14But really, for each button that you need to create, you do have to drag it into
06:19the Library, 'video button.'
06:22It's a Button Type, double-click it and, again, it's just the matter of inserting
06:27keyframes and then adding those effects.
06:32So Black Glow, the Red is the Over state.
06:39Now, note that if I ever change this White Glow, it's not going to change
06:44it across the board.
06:45They're not really linked together.
06:47So just keep that in mind for the Down state that it is going to be that White
06:50Glow, just like that.
06:53So again, this is probably the fastest way to make buttons too is just by
06:58dragging it right into your Library and then calling it.
07:02Of course, it helps to have some consistency.
07:06Each one's named, say, portfolio button, video button.
07:10So double-click it and Insert KeyFrames.
07:15Again, anytime you have a keyframe, you can change that content and it won't
07:20affect it in other places.
07:22So for the Up state, Black Glow, Over, Red and the Down state is going to have the White.
07:34So I really just used one effect and I kept modifying it and then I just saved
07:39it as Presets, but I encourage you to really explore this list because there is
07:43Drop Shadows, Blurs, some Gradient Glows you can add.
07:47You can even adjust the color of items.
07:49It's really helpful when you need to modify the look of an item, just like I did
07:54here with my buttons.
07:56It works out great.
07:57So with all four of these set up, let's do a Control > Test Movie, roll over the
08:03About, turns red, turns red, turns red.
08:06Everything is looking really good.
08:08When I select them, they turn White as well.
08:12So now my site set up.
08:13I have my buttons created, and now I can go ahead and add functionality to them.
Collapse this transcript
Adding functionality to buttons
00:01Once you have the buttons created, the next thing you want to do is add
00:04functionality to them,
00:05in other words, make them do something.
00:08That's what I want to do here is I want to make these four buttons work.
00:13The first place you need to start is to give them a specific name, an instance name.
00:20So I'm going to double-click on this content movie clip to enter inside of it
00:25and notice here are my buttons.
00:27I want to go through and give each one an instance name, starting with this one
00:32right here, the John Doe.
00:34It is the home button.
00:35So in the Properties panel, I'm going to give it an Instance Name of home_btn.
00:41Don't use any special characters or any spaces.
00:44It should really just be one word _btn.
00:48About is going to follow the same pattern, btn, video_btn and portfolio.
01:01So really be mindful of what you're calling each button because that's probably
01:06where the most errors happen is with instance names. Okay.
01:11So I'm going to start off with this home button.
01:15So I'm going to remember home_btn.
01:18But let's be aware that we are actually inside of the content movie clip.
01:23So I need to click back out on Scene 1, because on my main Timeline, all my
01:31ActionScript is going to be in this frame.
01:34So what I need to do is I need to give the content movie clip an Instance Name.
01:39So with the content movie clip selected, I'm going to go ahead and type in
01:44'content_mc,' just like that. All right.
01:49Now select that first frame in your ActionScript actions AS layer and go to Window
01:57and open up your Actions panel.
01:59Here is mine, loading in the random background.
02:03The first thing I want to do when I open up my Actions panel, since I always
02:07want this code to appear, I want to pin my code.
02:11So it's just pressing this pushpin.
02:13Now the code always stays up, regardless of what I click on.
02:18Next thing I want to do is just add a couple of lines.
02:22Two forward slashes will enable me to add a comment.
02:26What I want to do is just go ahead and type in plain English what's going to happen.
02:31So in this case, I want to Listen For The Click Of The Buttons.
02:37These are going to be for all the buttons.
02:40Now, the first button I'm going to deal with is going to be the home button.
02:43Let's remember that it's inside of the content movie clip. So content_mc.
02:49That's my Instance Name.
02:50Inside of there, so I need to separate that with a period, is the home_btn.
02:56I'm going to hit period again.
03:00What I need to do is I need to listen for the click of the home button.
03:03So I need to add an event listener.
03:06Again, I love the code hinting I get in here, because as soon as it highlights
03:11right here, I can go ahead and hit Return and it adds it.
03:14I am also given additional hints that can be pretty convoluted, but they are in
03:20there, because it is asking me for what type of listener I'm listening for.
03:25Well, I'm listening for the MouseEvent.CLICK to be more specific.
03:32The great thing about how setting up listeners works is I can not only listen
03:37for a click, but I can also listen for many, many different things and you can
03:41peruse this at your leisure,
03:43but, you know, whether it's MOUSE_OVER or MOUSE_OUT, MOUSE_WHEEL, whatever it may be, it's
03:48all available right in here.
03:50So, in this case, it's just going to be the CLICK that I'm listening for.
03:54I'm going to add a comma and it's going to go ahead and listen for some sort of
03:58Function is what it's going ask for next.
04:01I'm just going to type in 'homeClick.' All right.
04:06So homeClick is going to be a function that fires off when this button is clicked.
04:14So I need to create this function.
04:16As you start typing ActionScript, notice you'll quickly run out of space.
04:21Well, you can always minimize this panel off to the side, just by clicking that
04:25arrow, and now you have more room. All right.
04:28Now again, I want to create a function called homeClick.
04:31So just below that, function homeClick. It's going to accept a MouseEvent and
04:41it's going to be void.
04:43as in it's not going to return anything.
04:46But in general, this is the structure for a function.
04:50Anything within these curly braces is going to execute when this function is
04:55being called and this function is being called when you click on the button.
05:01Now, I can go ahead and add whatever I want to add to this when it gets clicked on.
05:05And what I'm going to do now is just add a trace statement.
05:08Again, this is just for testing purposes to make sure everything is
05:10working, homeClick.
05:13Go ahead and listen for and just print out in the Output panel, this word
05:19homeClick, just so I know that it's working for testing purposes. All right.
05:23It's looking pretty good and anytime you type a lot of code, feel free to hit
05:27this little Check Syntax button and it'll tell you that it contains no errors.
05:34Let's go ahead and test the movie.
05:36Now, here is my home button.
05:38So if I click on it, I can see that it says, I will move this out of the way,
05:42it says 'homeClick,' right there,
05:44so it's working out perfect and, of course, if I hit it multiple times,
05:48that's working great.
05:49We're doing quite well.
05:51In fact, I want to go ahead and do the same thing for the other buttons.
05:55So I'm just going to condense this down.
05:58You can have line breaks all you want.
06:01If you want to condense it down, you can go ahead and remove the spaces if you want,
06:04but in order to make the others, it's going to follow the same format.
06:08So I want to just go ahead and Select All of this and then Copy it and then I'm
06:15just going to paste it right below.
06:16So I'm going to do the About button next.
06:18So for content_mc inside of content, that movie clip is going to be an about_btn.
06:24Of course, it has an EventListener. I am listening for the click.
06:29Well, I don't want it to fire off this function up here.
06:32I want to create a new function called aboutClick.
06:36aboutClick is going to be right here.
06:39Then it's going to trace out aboutClick, just like that.
06:43Two event listeners written for two buttons, and again, it's the same process of
06:50just copying and then pasting and then changing,
06:55so video_btn, videoClick.
07:00It's going to call this function, called videoClick.
07:04Oh, see? I almost mistyped right here.
07:07Be really careful that you don't mistype, of course.
07:10What you can always do is do a Copy and then Paste, literally, which is usually
07:15what I like to do, because it eliminates, or helps eliminate, errors, videoClick.
07:21One last time, for the portfolio_btn. I'll just keep that short and call it
07:35'portClick,' but I want to be aware that that's what this function needs to be
07:40called, just like that, and then portClick. All right.
07:46I want to be aware that these instance names exist inside of the content movie
07:52clip, but let's just go ahead and Check the Syntax. Great!
07:57Doesn't contain any errors, but let's go ahead and test this. Do our true test
08:02by clicking on, sure enough, our home button, then on the about button, works great,
08:08video button works great, and then, of course, the portClick as well.
08:14So again, if I just close this and go back to my code, what you're going to want
08:20to do is just write event listeners and that's all you need to do in order to
08:24make a button work, for the most part.
08:27The great thing about event listeners is you can listen for pretty much
08:32anything, whether it's the clicking or rolling over or something, or
08:35potentially, even, say, listening for a video to complete, or until it's done
08:40playing, or a graphic to load.
08:42It's all done with event listeners.
08:45So as soon as you get comfortable with writing event listeners, you'll be able
08:49to do so much with them.
08:51Now, that the buttons are set up, I'm ready to make them navigate to
08:54their particular section.
Collapse this transcript
Adding navigation
00:01Once the ActionScript structure of a basic button is in place, I can now
00:05navigate to this section selected, because currently what's going on, if I go to
00:11Control>Test Movie, all I have are these various trace statements that are
00:17being shown in the Output panel.
00:19But what I want to happen is I want to actually navigate to the video section
00:24when I click on the Video button and likewise for all the other buttons.
00:29So let's take a look at the code.
00:31I'm going to go to the AS layer.
00:33I'm going to select that first frame.
00:35I'm going to go Window and open up the Actions panel and the first thing I'm
00:39going to do is I'm going to pin the code, because, again, I don't want it to move
00:43if I click on something else.
00:45I want it to always stay up and available.
00:48But as you can see, when you click on the home button, all I get is the trace
00:52statement and same for the about button and the video button.
00:58Now, I'm just going to go ahead and start with the Video button and what you can
01:01do is click in this gray bar.
01:04You can just retract the Actions panel, so it's out of the way.
01:08I am going to Command+Minus to zoom out.
01:12I want to move this content movie clip this direction, and I want to change the
01:19X and Y position of this content and see. It starts out.
01:24Again, I'm going to do an Undo Move.
01:27It's going to start here and then I want it to end up right here.
01:32So let's go ahead and reference the X and Y position.
01:37So in the Properties panel, with the content movie clip selected, I can see
01:42that the Position and Size, the X is -920. In fact, I'll just round that to 920
01:48and then the Y is about 530, maybe I want to make it about 520 or let's go 540,
01:55have it move up a little bit just so we can make sure we get that Portfolio button down there.
02:02That's a pretty good position, -920 by -550 for the Y position and that's what I
02:07want to move the content_mc to.
02:10So I'm going to open up my Actions panel that was currently nested.
02:14And I'm going to go to the video button and when it's clicked on, it's going to
02:19fire off this function and then just below the trace statement, you can type in
02:24'content_mc' and then change, after I type that period, I can change the property
02:31of this movie clip and I want to change the x position.
02:35Okay, so this is going to be horizontally that it's going to move.
02:38So change the x position equal to -920, just like it shows right over here.
02:46The y position, -550.
02:49New line, content_mc.y equals, again, don't forget the -550, just like that.
02:58So again, I'm going to click on this gray bar just to nest the Actions panel into
03:03that one bar and I'm going to go ahead and move this back into position.
03:07Now, I could kind of eyeball this, but what I'd like to do is use the Align panel.
03:13So I'm going to go to Window > Align and make sure this button is depressed, the
03:19To-stage button, and I want to center vertically and horizontally to make sure
03:23that is in its exact position.
03:25Now, this is the starting point.
03:27So the John Doe button,
03:30it's the home button, and when you click on his name, I want to reset the position
03:35of the content_mc, back to this location, which is -600 x -752.
03:43So I'm going to remember those numbers because when I click on the home button,
03:49I want to adjust the x and y position of content_mc.
03:53Again, x position is going to be equal to -600 and content_mc's y position is
04:02going to be equal to -752.
04:06Now, I'm just going to round that to a whole number, -752, and with the home
04:12button set up and the video button set up, it should work just fine.
04:18So I'm just going to go ahead and check syntax by clicking that check box and
04:23this script contains no errors.
04:25Now, let's go ahead and do the Control > Test Movie.
04:28I'll move this into place and now when I click on video, it pops, changes the x
04:35and y position, when I click on that video_btn and then for the home button,
04:39bam, snaps back into place.
04:42So it's working quite well, and quite frankly, I can set up the other two now.
04:47So let's close this and go back into my code and I can start to add some of the
04:53code for the other buttons.
04:55So let's go ahead and minimize this Actions panel and what I want to do now is
05:01bring in the about section.
05:04Now the About section is actually going to rotate.
05:07So I need to do just kind of minimize, scoot this out of the way.
05:11I want to expand out this panel and I just want to be able to see the
05:17Transform panel, because what I need to do is I need to change the rotation of this content_mc.
05:24And what I can do is is I can just go ahead and click and drag and I can
05:29see that rotate around.
05:31Now, you can use the Transform panel to, obviously, transform anything.
05:36I could even use, in my Tools panel, the Free Transform tool, in case I just kind
05:41of want to adjust it this way.
05:44But I think when you're dealing with code it's better to do it numerically, so
05:47that's why I'm going to use the Transform panel, just to rotate it a -90 degrees, just like that.
05:54So I'll just position it into place.
05:56Use my arrow keys to fine-tune it like that.
06:02That's a pretty good position. All right.
06:04It's a -90 degrees is the rotation.
06:06The x and y position, and I'll just round this up,
06:10is going to be -250 and a positive 1430, just like that. All right.
06:17I'm going to remember those numbers and the 90 degrees when I open up my Actions panel
06:23and again, this is for the about button.
06:26Make sure you're inside of this aboutClick function.
06:29So just before this closing curly brace, you can type in content_mc, move its x
06:37position to -250, its y position 1430, _mc rotation, well, I will just start to type in 'rotate.'
06:52Oh! Rotation, there it is. I can select it,
06:54hit return, and then make that equal to -90 degrees.
07:00Now, there is an issue, because I'm dealing with rotation at this point and
07:04these other two are not rotating.
07:07In fact, I need to make sure the rotation gets set back to zero for these other two.
07:13So I'm just going to go ahead and copy this.
07:16I'm going to select it and copy that line of code and paste it right into the home
07:22button's function and I'm going to make sure the rotation gets set back to 0.
07:28Same thing for the video button, paste that in there, set the rotation back to 0.
07:33All right. It's looking pretty good so far.
07:37In fact, I'm just going to go ahead and do the Portfolio button now as well.
07:41So let's see what that looks like.
07:44Portfolio button actually shifts over and is really going to be on the same
07:50y-axis, but the x axis is going to change.
07:55So I'm just going to position that accordingly, maybe use my arrow keys to
07:59fine tune it. In the Properties panel, maybe make it -1000 and then this is going to be 1450.
08:09All right. So I'm going to open up my Actions panel for the Portfolio button and again, I
08:16can just copy all of the x and y rotation from a previous function and paste it
08:22in and start changing some of these numbers.
08:25As for the Portfolio button, it's going to move to the left -1000 and then the y
08:33is going to be 1450 and let's be aware that the rotation is still -90 degrees, so -90.
08:42All right. Everything seems to be looking pretty good, but you never know until you test it.
08:48So I'll do a Control > Test Movie.
08:51And as you can see, I didn't move it back to its original place when I finished
08:59getting all my coordinates.
09:00So I can go ahead and fix that just by typing in 0 here.
09:04Change the Align panel.
09:06Change the Align horizontal center and the vertical center to reset it back to
09:11its original position.
09:13Now, Control > Test Movie.
09:16It's in its original position.
09:17I'm going to go ahead and click About. I can see that it rotates and then moves the
09:22x and y position, and go to Video and I can even go to Portfolio.
09:28So it's looking pretty good so far.
09:30I can select any one of these and I can even reset back to the beginning, just
09:35like that, by clicking John Doe.
09:37So notice that as I select the button, it changes the properties for the content
09:42movie clip to reveal that section.
Collapse this transcript
Creating transitions
00:01Flash does many things really well, but probably at the top of the list is its
00:05ability to animate, which is what I want to do with this site.
00:08I want to create some smooth transitions from one section to the next.
00:12Because currently what happens is if I click on a section, it's just a
00:16straight cut from where this navigation was, to the About section, and really I want it to animate.
00:23And what's great about Flash is I can build some Tweens, so it does all the in between frames.
00:30I don't have to move something frame by frame. I can just tell Flash, "Move it
00:34from point A to point B." And that's what I want to do, going from section to
00:38section, move it from point A to point B, just build out the Tween.
00:43So let's take a look at what I currently have, because in the Timeline I have my
00:49AS layer. I can select that first frame.
00:52And what I want to do is go to Window and open up the Actions panel.
00:57And if I scroll down, I see that I have all of my EventListeners that listen for
01:05a Click and then fire off this homeClick function, and then it just pops
01:10directly to this position, for instance, and rotates it as well.
01:14So I want to really, ultimately replace these with some nice Tweens.
01:20So I am just going to move to the very top and just hit Return a couple of
01:24times, become I want to do a Tween, and I will just type in Tween.
01:27So this is the keyword you need to remember.
01:30It's a keyword in Flash, and you can select it, do a right-click, and then
01:34View the Help for Tween.
01:37Here is Flash's Help on the Tween class.
01:41It tells me what it does.
01:43Well, it lets you use ActionScript to move, resize, and fade movie clips by
01:49specifying a property of the target movie clip and then animate it over a number
01:54of frames or seconds.
01:56So here's the code.
01:58I love it that they have given me some code as an example, but this is the code I need.
02:04There's some further notes in here, saying that there's some parameters that I need to modify.
02:09So I am going to just take this code, right- click, copy it, and then go back into Flash.
02:16Right here at the top, I am going to go ahead and paste this code.
02:21And now let me just explain what's going on, because these first two lines,
02:26these are import statements.
02:28In general, this just TELLS FLASH TO IMPORT THE APPROPRIATE CODE to make this Tween work.
02:37So these two line tells Flash to import the appropriate code, and here is the Tween.
02:44So what this does is there is a variable called myTween, and what I want to do
02:50is I want to move the content movie clip when that button is selected.
02:56So the first thing I need to do is just cut this and move it to the correct spot.
03:03So let's start with the about button.
03:06Inside of this aboutClick function, instead of it just popping directly to the
03:11x position, I want to add the Tween, so I am going to paste this Tween right in here.
03:16All right. I am just going to go ahead and type in 'Animate,' because that's what this is going to do.
03:23I want to animate the xTween, so I am going to change this variable to myxTween.
03:30And I need to define the Object to move content_mc.
03:33I am going to change the x position.
03:37It's going to do this with elasticity, so it's going to be kind of like a rubber
03:41band. I can control this as well.
03:45And then I am given some numbers down here.
03:47And if you are ever curious as to what a parameter is, you can always put your
03:51cursor in there and then select Show code hint, and then that will tell you.
03:56Well, this is the begin point.
03:59Where do I want it to start from?
04:01I don't have an exact number I want to put in here, but wherever the content_mc
04:06is, wherever its x position is is where I want it to start.
04:10So I am doing content_mc.x.
04:14And where I want it to end up is this point right here, -250.
04:20So I can take this, Command+C, copy it, paste it right in here.
04:27And this is going to happen. What is this last number?
04:30Well it's the duration.
04:32It's going to happen over the course of seconds, because this true means use seconds.
04:38Or I can say, "You now what? Animate it over the course of one second." All right.
04:44There's myxTween variable, and I can go ahead and just Delete that property to
04:51change the position of the x, because now that I have this Tween, it's going to
04:54do all the work for me.
04:55So Control > Test Movie. I have just changed one property for the About section,
05:00so only one thing is going to move.
05:01If I click on it, did you see that bounce? Click on it again.
05:05It does that crazy bounce.
05:08I can do it multiple times, and I really only have one property that's being animated.
05:14So let me just expand this out a little more so I can see this long line, but I
05:19want to do the same thing for these other two properties.
05:22So it's just a matter of copying this, Command+C, Command+V and changing
05:27what you need to change.
05:28So I am going to change the yTween, move the content movie clip,
05:31its why position, from wherever it currently is to this point right here.
05:38So again, I want to Command+C to copy that, Command+V, put that right in there,
05:43over the course of 1 second. All right.
05:46Let's Copy this one again and let's do the rotation.
05:50myrotate, rotate the content_mc, rotation.
05:57Its current rotation position to -90 over the course of 1 second.
06:08Now that those are written, I can Delete that, and you did see the Elastic.
06:12You saw how it worked like a rubber band.
06:14Well, I am not particularly fond of that effect. I will just change this to Regular.
06:19It's going to be a Regular easing, so it's going to be really smooth.
06:26And what easeOut means is when it reaches its resting point, it's going to
06:30slow down gradually. All right.
06:32It's looking pretty good.
06:33Now I am going to go ahead and Test my Movie, click on the About section, and
06:38that animates into place. Beautiful!
06:41Let's try it again, see it move into place.
06:44So I want to do the same thing for all the others, so I need to do this three more times.
06:52So let's expand out this panel some more.
06:54So what I want to do is I want to copy all this code, Command+C, for the Home
07:01button inside of this function, so just before that closing curly brace, I just
07:07want to start replacing those numbers.
07:08So Command+C, or Ctrl+C if you are on a PC. I can start replacing these
07:16numbers, just like that.
07:21And don't forget to remove those first three lines, so we just have our Tweens
07:27in there, and that's looking pretty good. All right.
07:29Let's Copy this again.
07:33For the video button, make sure you get the minus, or the negative, 920 x position,
07:41y position, and then the rotation is just going to be 0.
07:48And lastly, this Portfolio section -1000, 1450, and -90, just like that.
08:03And remember, if you forget what these numbers are, just put your cursor
08:06in there and then click Show code hint and it will tell you, "Oh, this is
08:11the finished position."
08:12So keep that in mind.
08:14I will Delete these three lines.
08:16Everything is looking pretty good.
08:19In fact, I can go ahead and check syntax.
08:22It says the script contains no errors. That's great,
08:24but is everything going to line up and animate to the correct position?
08:28Well, let's check it out and see.
08:30Control > Test Movie. Click the About section, works great.
08:36My Home button, it animates back into place, my Video button does a pop, which I
08:43need to fix, and then I have my Portfolio section, which animates up.
08:47So there is some weirdness that goes on.
08:50In fact, it looks like I still need to do -- aha, this is what you might
08:55run into, is that it pops directly there, and it's because I did not remove this code.
09:01So I just need to Delete that and then everything should be fine.
09:05So for the most part, everything is looking pretty good.
09:08Control > Test Movie.
09:12And looks like I need to fix a couple of things, because this 'o' is getting
09:16cut off, and I want to point this out, because if you don't have items
09:20positioned on whole pixels, on whole numbers, then you might get this weird
09:24sort of cutting effect.
09:26So I want to go back in and make sure the position, the initial position of
09:30my content_mc is on a whole number, and that will alleviate this sort of cut right here,
09:36but I am really getting into the point where I am fine tuning this.
09:39If I click on About, yeah, it rotates into place.
09:42This 'o' is getting cut off right there, so I might need to move its y
09:47position down some, so it fits in there fully.
09:50In fact, if I click on Portfolio, that looks a little more appropriate.
09:55Maybe I can scoot it over a little bit, and then if I click back here on the
10:00Home button, it navigates back into place.
10:03And as you can see, it navigates back into the center position, and it is on
10:07whole pixels, so that's why you don't see that being cut off.
10:10So be aware of that.
10:11And what I am going to do is I am going to fix those two things:
10:13the About section, where it's sitting a little high, and then this Video, how
10:18that gets cut off a little bit.
10:20And I am going to minimize that Actions panel.
10:22I am going to select this content_mc, and if I look in the Properties panel,
10:27Position and Size, -599.15.
10:31Well, you know what?
10:32Let's just round that up to 600.
10:35In fact, this y position, 751.95.
10:38Let's just make it 750.
10:39We will start to get things sort of lined up just right, and that's kind of what
10:44happens even if you start to sort of scroll things back and forth, they get a
10:47little funky, but feel free to just type in exactly what you need.
10:52And if I zoom in, Command+Plus, you can definitely see that everything is okay,
10:57so it's that positioning that's getting things a little weird. All right.
11:02Let's go back into the Timeline panel.
11:03I am going to select that first frame in the Actions layer, and I am going to
11:07look at the About button, and its y position, it was sitting a little high, so it's 1430.
11:13So to move it down I need to add to this number, so I might want to make that 1450.
11:20In fact, I can even compare that with the Portfolio section, because the
11:25Portfolio section is on the same y position, and that does say 1450.
11:31So it's much more appropriate now, and I am going to go ahead and do a Test
11:34Movie, see the Video isn't getting cut off, that I can see the About section is
11:41in a better position, the same as the Portfolio section.
11:45And everything is positioned appropriately.
11:47I can even scoot this in a touch if I want to.
11:49But this really allows you to give you a sort of full control over the
11:53positioning of items, as well as just the animating of them, which just really
11:57adds just another dimension to your website.
Collapse this transcript
Simplifying code
00:00Now that you have seen the basics of ActionScript, I am going to show you how
00:04you can simplify your code, which is going to cut down on errors and make
00:07your code more flexible.
00:09So I am going to go to this AS layer, select that first frame, and go to
00:14Window, and Actions.
00:17And the first thing I am going to do is pin my code by pressing that
00:19little Push-Pin icon.
00:21As you can see, as I scroll down, I am repeating many, many lines of code,
00:27this all looks the same. This looks the same, and it's pretty lengthy, and
00:31all that really changes from one function to the next is this parameter, ok, and
00:41this one, and then this one.
00:44So what I want to do is create one major function that's going to accept these
00:50parameters and then move the content movie clip accordingly.
00:54So I am going to create that function right up here, above of
00:56the EventListeners.
00:58I am just going to go ahead and type in 'function,' and this function is going to
01:02be called moveContent, because the goal of this function is to move content.
01:07This function is going to accept these parameters: the x position, the y
01:12position, and then the rotation.
01:14So I need to type that right in here, theX, add a colon, and it's going to
01:22accept a number, so type in Number.
01:25As soon as that is highlighted, you can hit Enter.
01:29It's going to accept theXPosition, and theYPosition.
01:36That's also going to be a Number, and it's going to accept theRotation, which is
01:44also going to be a Number. All right.
01:48All within those parentheses.
01:49It's not going to return anything, so as always, I am just going to type 'void,'
01:53open curly brace and then a closing curly brace.
01:57So here is my function.
01:58Anything in here is going to execute when this function is being called.
02:02And what I want to do is I am just going to set up some trace statements.
02:06So trace is just some testing statements for me, so I can see that certain
02:11things are showing up.
02:13I can put whatever I want in here.
02:14I really want this letter X to appear, followed by the position that it
02:19receives, so theXPosition.
02:20So I am going to do Command+C, just to copy that, paste that right in there.
02:26In the Output panel, it's going to show me X and then whatever number gets
02:30passed into this function.
02:31I am going to copy this, paste it a couple of more times, because all I need to
02:36do is modify theYPosition.
02:39Again, theYPostion is going to be displayed in the Output panel as well.
02:44And then lastly is theRotation, and again, I need to use this, theRotation.
02:54So my function is set up.
02:56It's going to accept these three parameters, and then it's just going to show
03:00the trace statements in my Output panel, just for testing purposes.
03:05But what I need to do now is I need to call this moveContent function, and I am
03:09going to call it when I click on the homeClick.
03:12So just below this trace statement, I am just going to type in 'moveContent,' and I
03:20am going to pass three parameters into that moveContent function.
03:26Those three parameters, again, are these three.
03:29So I can take this 600, drop it right in there, add a comma, take this
03:36parameter, drop it right in there as theYPosition, and then lastly, is
03:41theRotation, so I need to take theRotation, which just happens to be 0, and I
03:47will drop that right in there.
03:48All right, looking pretty good.
03:50It's going to pass these parameters into this function.
03:53It's going to show me in the Output window.
03:55And what I can do now is move this content, these three Tweens, and I can just
04:04select them all and move them right up into that function right there.
04:08I want to pass these parameters into this moveContent function, and I want these
04:14numbers to appear right here.
04:19What I am going to do is I am just going to take this, theXPosition, and I am
04:23going to copy it and paste it right here.
04:26I am going to take theYPosition, because that's going to be its final
04:31YPosition, and then theRotation, I am going to take that and copy it and paste it right in there.
04:37All right. So you can see I have basically eliminated three lines of code from this
04:41function and put them up in this moveContent function.
04:44What I am going to see is everything is going to look the same, but my trace
04:48statements will appear in the Output panel.
04:51So I am going to do a Control>Test Movie, and if I go to the About section,
04:58everything looks good.
04:59I am working with the Home button, so if I click on it, it rotates back into
05:05position, just as I expected.
05:08And the Output panel, if I can show you what that prints out, it gives me what's
05:14in that trace statement, this X, the Y, and then the Rotation.
05:17So I will open that up. Sure enough, this stuff matches up.
05:20So it's working really well, but you are really not seeing the true power of it yet.
05:24I mean, you are probably thinking, "Geez, it did this five minutes ago."
05:28Well, let's start eliminating some of this code, because I want to do the same
05:32thing for these other functions when these other buttons are clicked on.
05:36So for the aboutClick, I want to do the same thing.
05:39It's the same function, this moveContent, moveContent, and in there, it's going
05:45to accept these three parameters.
05:46So I am just going to drop in these numbers, just like that, click and drag them
05:53over, select them, drag them on over.
05:56You can do it how ever you want, but I am just doing a click and drag.
05:59Make sure you have commas separating each one.
06:03So that's looking pretty good, and this is the fun part, because I get to delete
06:07those three lines of code, and I get to simplify everything.
06:10I will even delete that comment.
06:12So you can see my code getting smaller and smaller.
06:17And the nice thing is is this will alleviate any errors, because there could be
06:20some error right in here.
06:22Well, since that's not going to exist anymore, since these are all parameters
06:27that are being passed into the moveContent function, it doesn't matter that some
06:34things might be misspelled, because the less typing, the less lines of code,
06:40probably the less errors there will be.
06:42So it's looking pretty good so far.
06:43The last one I am going to do is the Portfolio button.
06:46moveContent, these three, and lastly, this rotation, drop that right in here,
07:01and eliminate those three lines of code. All right.
07:05So definitely everything is condensed down, and if I have these parameters
07:09correct, I am going to make sure I have my commas separating each.
07:12Notice that I have three parameters for this moveContent function, for each one,
07:17that then gets passed into here, and then these Tweens get used.
07:21So this is going to work out quite well.
07:24Let's just go ahead and test it out.
07:27Clock on the About section, works like a charm.
07:34Video section, works great.
07:36Portfolio section, works great.
07:39And then I can click back on John Doe.
07:41And again, the great thing is is this is really flexible, because if I want
07:45to go in here and change some of this, say, for instance, I want to change
07:48this, instead of having a Regular smooth transition, I can change that to
07:53something else, like Bounce.
07:54I don't have to change it in 12 different places. I can just change it in three
07:58different places and then it will affect all the transitions, and I can see that
08:04there's this sort of jarring bounce that happens with all of these.
08:09I don't particularly like it, but again, the nice thing is I can roll it back to
08:15what it was, no problem, because I just need to change it in these three places.
08:21That's the power of making one function and then just passing in the parameter,
08:26the one item you want to change, and then using it wherever you want to use it.
08:30So the more you can simplify your code this way, the better off you will be, the
08:34more flexible your code will be, and the less errors you will have.
Collapse this transcript
4. Creating Sections
Creating web site sections
00:00Now I would like to get into creating content for these various sections,
00:05because as you will notice, nothing is in this area.
00:08But I want to go ahead and create the content, and what I have used to create
00:12this content is Photoshop.
00:15So in the Assets folder, in the design folder, you will see three PSD files that
00:23all pertain to the various sections.
00:25So I am going to go ahead and open those up with Photoshop.
00:30And here are my three sections, already designed out, I will just start with the About section.
00:37Now, I notice that there is this text layer, I want to import that text layer,
00:42and I want to import just this simple Blog button that just contains this shape
00:47right here, and then also contains this text here.
00:51So that's my About section. I want to import it, and I will start with that one first.
00:57Again, I am just going to Save this file, nothing tricky going on there.
01:01But what I want to do is, in Flash, I don't want to import the content
01:06directly into this FLA file. I want to create a new FLA file, a new Flash
01:14file, and import that design,
01:17because when the user clicks on this button, I then want to load in that SWF separately.
01:25So if I divide up the content this way, it just makes it more manageable and
01:30just easier to work with.
01:31So I am going to create a new file, File>New.
01:35It's going to be a new Flash File (ActionScript3.0), select OK, so these are
01:42my default settings.
01:44But all I need to do is first Save this file, and I will go ahead and save it
01:55into Chapter 04, and I will call this 'about.fla.' All right. Here I am.
02:04If I click on Timeline, you can see that there is nothing in this file, and now
02:09I can go ahead and Import to Stage the PSD file.
02:17And Assets/design/Section_About.psd, select Import, and I get this wizard,
02:26which is nice, because I want to control how each layer is being imported,
02:30starting with this top one.
02:32This Text layer, well, I want to import it as Editable text.
02:36This Blog button, I do want to create a movie clip for this layer, and if I
02:42twirl that down, I want to make sure this text is editable and that this is just
02:47a Flattened bitmap image.
02:49So in general, this is just going to be one movie clip.
02:54I don't need to import the background, because the background is already
02:58going to exist in the index file that this file gets loaded up into, so I
03:05will just uncheck that.
03:08Down here at the bottom, I want to place everything in its original position,
03:12convert layers to Flash layers, and then I want to set the stage size to the
03:17size of the Photoshop canvas. Select OK.
03:21The content gets imported, and I can just change the color of the stage, the background.
03:31You can see, there's my text.
03:34Reads great, and I can always change anything I want in here now, because this
03:39is editable text, and then here's my button, that is of course known as the Blog button.
03:44So that is set up.
03:46I will just Save this file.
03:49And now I want to go ahead and open up the next file, the Portfolio section.
03:57Portfolio section has more going on.
04:00In fact, if I turn off these layers, just to show you this Thumbnail layer,
04:04notice that it's going to contain multiple thumbnails.
04:08When you click on a thumbnail, a larger image is going to load, and so will more
04:14text pertaining to this image.
04:16So that's how this Portfolio section is going to work.
04:19So I have done all the design work in Photoshop.
04:22It's looking really good. I will just Save the file.
04:25I am going to go into Flash. Just like I did for this About section, I am going
04:29to create a New File, and I am going to Save this file as portfolio.fla.
04:41Now I am going to File>Import> Import to Stage, this portfolio.psd file.
04:50Select Import, and again, I get similar settings.
04:54I want to make sure my text is going to be editable, in case I need to change it later.
05:00This main image, I will just leave as a Flattened bitmap image.
05:04This thumbnail, I will leave as a Flattened bitmap image.
05:07And the background, again, I don't want to import it because that background is
05:11already in my index.fla file that this gets loaded into.
05:17And then just make sure you set the stage size to the same size as the Photoshop Canvas.
05:21Select OK, and there it is.
05:24Everything gets positioned accordingly, and I can see some text down here as well.
05:30Again, I can always change that background color to see anything else that I
05:35might not see initially.
05:37I will go ahead and Save this file.
05:39Last section is going to be the Video section.
05:42Again, this is in the same design folder.
05:46I have these thumbnails. As you can see, I am turning them on and off, and then
05:52here is my VideoPlayer folder that contains this video frame, and then just this
05:58little Cross element, the design element.
06:00So this is good to go.
06:01I will just make sure it's saved.
06:03I will go back into Flash and create my New file, and I am going to Save this
06:10file in the same folder, and I am going to call this video.fla.
06:13I am going to import this file as well, video.psd.
06:22So again, I am using this PSD file and I am going to control its import settings.
06:29The VideoPlayer, I am going to go ahead and just create a movie clip for that layer.
06:33This vidThumb1, well, I want to create a movie clip for it, vidThumb2, create a
06:39movie clip for it as well.
06:41Lastly, uncheck that background, and down here, I want to make sure both of
06:46these are checked as well, so the stage size changes.
06:51Sometimes you will run into this.
06:53It says one or more library items already exist in the document.
06:57I don't want to replace any existing items, but what's happening is these two
07:04files have the same name, and they kind of want to overwrite one another.
07:08So in general, Don't replace existing items, if you ever get that warning,
07:13select OK, and it looks like everything is in place. This is great.
07:18So this section is set up, and I can Save it as well.
07:24So those are my multiple sections all set up as a separate file in Flash, and
07:31when I select the appropriate button, that's when I want to load in the
07:36appropriate section, and that, obviously, would be my next step.
Collapse this transcript
Dynamically loading sections
00:00Now, I currently have four different Flash files created:
00:05the main Flash file and then these different sections.
00:10And what I want to happen is I want to, when you click on a button, to load that
00:15particular section in.
00:18But I am not going to load in the FLA, because this is the working file, I need
00:22to load in its SWF file, its Small Web Format file.
00:27Now, I am just going to open up my about.fla, and in order to make an SWF, I can
00:32do it a number of ways, but the easiest way is just to go down to Control > Test
00:37Movie, because each time you test a movie, it creates an SWF file.
00:43So this is already generated, and I can also see what it looks like, so this is
00:47what I should expect when it gets loaded into the index file.
00:51Same thing for the portfolio.fla, portfolio file in that folder, if I do a Test
00:57Movie, it will generate that portfolio.swf.
01:03And then the video.fla, if I do Control > Test Movie, it will create this video.swf.
01:10Now, just be mindful that the stage background color is irrelevant, because
01:16it's going to be actually transparent, and it will actually show whatever's in
01:22the index.fla file.
01:24So this content is going to appear on top of whatever is in this index.fla.
01:31But again, I went ahead and I basically published out three different SWF files.
01:36If I go back to my Desktop, you can see that these SWF files were generated, and
01:41I need to make sure that they are in the same location as this index.fla.
01:46So they are in the correct location and now I can open up the index.fla file.
01:52So what I want to do now is I want the sections to load in when you select
01:59the appropriate button.
02:00So I am going to go to the AS layer, select that first frame.
02:04I am going to go to Window, down to Actions, and I can open up my Actions panel,
02:11and here is all of my code.
02:13So the first thing I am going to do is just pin my code by clicking that little
02:17Push-Pin icon, move this into place, and now I can see what I want to happen.
02:25So at this point in time for, say for instance, the About button, when you click
02:31on the About button, I want to load in, and I will just type this in here, as I
02:36comment, Load in the about.swf file.
02:41And how I am going to do this is I am going to use the UILoader component.
02:47So I am going to just minimize the Actions panel, and what I am going to do is
02:54I am going to go ahead and create a New layer, and I am just going to call this mainLoader.
03:03This is all my main content for that section. This is my mainLoader.
03:07It's going to go right in here.
03:08I am going to go to Window, down to Components, and I am going to go ahead and
03:16open up the User Interface components.
03:18Now these components, I encourage you to explore all of them, but they provide
03:22additional functionality to your Flash website.
03:25So whatever you want to use, check it out and see if you can just maybe use one
03:30of these items as opposed to creating your own.
03:32Now, I don't want to write multiple lines of code to load in my SWF file. What I
03:37want to use is of course this you UILoader.
03:39I am just going to drag that onto the Stage, and I will close that Components
03:45panel, and I will go ahead and, I will just put him up here as well, upper left hand corner.
03:53And with this UILoader selected, I am going to go to Window and open up the
03:57Component Inspector.
04:00I just want to show that I need to make sure this is set up appropriately,
04:04because I don't want to scale the content down to this size.
04:08I want to change the scaleContent to false.
04:12I don't want to load in anything into this UILoader initially.
04:17Only when you click that About button, do I want to determine what the source file is.
04:24But what I need to do is I need to give this UILoader a specific name,
04:29because remember, if I turn off this layer, notice there's that UILoader in the background.
04:34Well, I need to give this one a specific name.
04:37So I will just call this sectionLoader.
04:44Type that in the Properties panel.
04:46And I am going to remember this.
04:46In fact, I am going to do Ctrl+C to copy it, and I am going to open up my
04:51Actions panel, go back to where that comment is and I am going to Paste in sectionLoader.
04:59So for sectionLoader, set the source equal to about.swf.
05:06And again, I need to make sure this about.swf is in that same folder, and it
05:12definitely is. About is right there, and it will get loaded in when you click
05:18on the About button.
05:21In theory, this should work.
05:23Let's go ahead and test it.
05:26If I click About, that content comes up.
05:29So it's working perfect.
05:31It's exactly what I want.
05:33I am going to go ahead and do that for the other sections.
05:37If I was to do this for the other sections, I would have to repeat this line
05:41of code for each one, and I really want to use the power of this moveContent function.
05:50So currently, this moveContent function, what it does is it sets theX,
05:53theYPosition and then theRotation as well, when really I want to do something a
05:58little more advanced.
06:00What I want to do is I want to add another parameter, down here on the end, theSection.
06:06theSection is actually going to be a string.
06:11A string is just text.
06:13It's going to now accept text as opposed to a number, this last parameter is
06:18going to accept text.
06:20So for this About button, this is the text I want to pass in into my
06:28moveContent function.
06:30So just after the X, Y Position, and theRotation, I want to add a comma and I am
06:36just going to move this right up in here. All right!
06:38There is my string that gets passed into that function, and it's now known as theSection.
06:48But what I also need to do is I need to move this sectionLoader property as
06:53well, and I need to move it right up into that moveContent function.
06:58So let's just scroll down.
06:59Notice I dragged it up, and I want you to just be aware of where this last curly
07:04brace is, because it needs to be below sort of bookmarking this function.
07:09It needs to start with a curly brace and then end with a curly brace, and now
07:15I can go ahead and just tab that in, sectionLoader.source is now equal to theSection.
07:21So I will just Copy that and Paste that right in here.
07:28So that's looking pretty good.
07:29I have moved that up.
07:32And let me just even remove that comment, and do a Test Movie.
07:39And it does break, and that's what this is doing.
07:42And I am glad this came up, because it gives me a chance to show you the error.
07:48So right in here, I can see that it tells me exactly what line the error is
07:54happening, and it says, You know what? Hey, there is an incorrect number of
07:59arguments," also known as parameters.
08:01There is an incorrect number of arguments.
08:03It's expecting 4, but there's 3.
08:07And what's great about the Compiler Error panel is, what I can do is I can
08:13just double-click on that error and it takes me right to that line of code that's broken.
08:19So the reason it broke is because it's looking for four parameters, but these
08:26other buttons, there is only three.
08:27So it's saying, "Hey, I am expecting four and you gave me three."
08:30Only in one case do I have four.
08:32So what I need to do, and the great thing about this is it gives me the
08:36opportunity, to load in the other sections.
08:39So let's start with this video button, add a comma, and then in quotes, I want
08:45to type in "video.swf."
08:49Down here at the bottom, for the portfolio button, add a comma, type in "portfolio.swf."
08:58portfolio.swf, the video. swf, and then the about.swf.
09:02Now, if I can reference this error again, remember, I have to put 4 arguments in
09:08there, and for the home section, I don't need to load any other content.
09:13So I can just add a comma, and then I could just type in null.
09:16Null is just a word meaning nothing.
09:19It says, "Hey, you know what? I am just a filler, don't break the code.
09:23I don't need to be anything, so don't worry about me," is what it's saying.
09:25So everything seems to look good, and I can go ahead and check my syntax.
09:31And sure enough, it clears out my Compiler Errors.
09:35It says my script contains no errors.
09:37I am getting pretty hopeful now.
09:39Let's do a Test Movie.
09:40Here is my SWF file.
09:43If I click About, that's great.
09:46It loads in the About content.
09:47Let's click Video. My Video content gets loaded in.
09:51If I click Portfolio, there is my Portfolio content.
09:56So it's all looking really good.
09:59For the most part, this is all squared away, and again, what I am doing is I am
10:05creating these SWF files and then they all get loaded into this main file.
10:12And the reason I want to set my site up this way is because it doesn't force the
10:17user to wait for all this content to download in order for them to see your
10:23site, but you are only loading in the content that they are interested in.
10:27So if they click on the Portfolio button, that's when they get the Portfolio
10:32information, all that content.
10:34So at the end of the day what it means is your initial size of your website is
10:40going to be pretty small.
10:42So it's only going to be like 25K.
10:44And then when they select their individual sections, that's when it will load in
10:48that appropriate content.
10:50So this is a really smart way to set up a site, and it's also very flexible,
10:54because now if I need to edit any of the portfolio content, I can jump right to that file.
10:59I don't have to worry about messing with any of the other files.
11:02So it's really flexible that way, and it's really user-friendly as well.
Collapse this transcript
Linking to web sites and email addresses
00:00Loading in SWF Content is fairly easy using the UILoader component,
00:05but what if you want to link to content on other sites?
00:08Well, this can be done a number of ways.
00:11And I need to do it in this about.fla file.
00:15So if I open that up, you can see that I've text in here, and quite frankly,
00:21you're probably going to have some text that you want to link out to a place on the Web.
00:27Say, for instance, if I just select this word, 'Adobe,' and I want this to link to
00:32Adobe systems site, I can select that word and in the Properties panel, down
00:37right under Options, twirl that down, if it's not already open and in the Link
00:43field, you can go ahead and type in http://www.adobe.com.
00:51Now if I want to open up a new browser window, I can select _blank.
00:57That way it keeps them on my site, but also serves up the information that
01:01they're after on Adobe's site.
01:03So that's done and that word is still highlighted.
01:06And probably what you're going to want to do is make it look different, so it
01:09looks like a link, so it stands out more.
01:12Currently, most of my buttons are red and that's kind of my signature color for this site.
01:16I'll change the color of that to red as well.
01:19Well, what about email addresses?
01:22Well, right down here, I have an email address.
01:25And I want this link to link to john@johndoe.com.
01:29So I am going to select that text and in the same area under Options in the Link
01:35field, I can type in mailto: john@johndoe.com.
01:44Just like in HTML you do it the same way.
01:47It's pretty simple, just hit Return.
01:49I won't worry about the Target at all, but that's set up and the last thing I need
01:54to do for that is change the color to red. All right.
01:57It's looking good so far, so let me just do Ctrl+Test Movie and if I click on
02:04Adobe, it opens up Adobe's site. Great!
02:09Close that. You see email.
02:12If I click on that email link, it will open up my default email client with that
02:19email address in the To field and I can type whatever I want, since they'll be
02:25emailing John@johndoe.
02:27It's done that easily and I'll close that.
02:31Well, what about your own sort of standalone button?
02:35What if it's not text in a sentence?
02:37Well, I need to do that a little bit differently, because I need to set this up
02:40as a button, give it an instance name and then do a navigate to the URL.
02:47So I'm going to close that SWF and I'm going to open up the Timeline panel and
02:54I'm going to select New layer.
02:55I'm going to change this layer name to AS, because my ActionScript is going to go here.
03:02Now the first thing I need to do is select this item and currently, it just says
03:09it's an instance of a Blog button, but it's really just a Movie Clip.
03:12Well, to be honest, I want to make this actually a button.
03:18Okay, so I'm just going to go ahead and do a Modify.
03:23I'm going to do a Convert to Symbol.
03:25It's the equivalent of just dragging it into my Library, but I'm going to do a
03:29Convert to Symbol and then, I can type in 'blog' and I'm going to make sure this
03:36is a Button, and select OK. All right.
03:40So this is now a Button.
03:42So just to confirm in my Properties panel, it says that it's a button and I need to
03:46give it an instance name, blog_btn, just like that.
03:50I want to remember this name, so I'm just going to do a Command+C to copy it,
03:55copy that instance name.
03:56Now I'm going to go to that layer I have created.
03:59I'm going to select that first frame.
04:01I'm going to go to Window and open up my Actions panel.
04:04Now right in here, this is where I'm going to write my code.
04:07So just a comment, Link to website, I'm going to paste in blog_btn and I'm going
04:16to add an EventListener, just like I've done in the past, MouseEvent, I'm going
04:23to listen for the CLICK and then it's asking me for another parameter, which I'm
04:29going to put in visitSite.
04:33So that's the name of the function that is going to be called when they click on this button.
04:39So visitSite. All right.
04:41Now I need to make this function, function visitSite, and it's going to accept
04:49a MouseEvent and then I'll just type in void, because it's not going to return to anything.
04:57But this is the basic structure for any function and it's looking good so far.
05:01But right in here, within these two curly braces, this is where I want to put a
05:07URL request and then a navigate to URL.
05:10So I need to create a variable called req or request.
05:15It could be called anything you want it to be called.
05:18Just remember the name and I want this to be a URLRequest.
05:23So I'm creating a variable
05:25that is a URLRequest and it's a new URLRequest.
05:34And you know it's correct, because it will change colors usually to that blue
05:38and then you can go ahead and type in your URL.
05:46That's this blog so - all right.
05:48There we have it, a new URLRequest I've just created.
05:53So within this container called req, exists this URL.
06:00Now I can use that wherever I want,
06:02but really the only place I need to use it, currently, is in the
06:05navigateToURL function.
06:11So I'm going to create this call to this function, called navigateToURL, and I'm
06:15just going to say req for request.
06:18So that's my variable and then I can do a comma and if you want, you can also
06:23type in _blank within quotes and that will open up a new web page.
06:30So let me just get rid of this last line.
06:33So that's how it's done,
06:34to sort of create a container that's going to contain that URL and then just
06:39put that variable into the navigateToURL function call is what it is, and then
06:45make sure it opens up in a new window.
06:47Now let's do a Ctrl+Test Movie.
06:50These buttons I know it'll work, these links, but let's check this one out.
06:54Click Visit Blog and sure enough, it opens up my personal blog in your default browser.
07:02So, it works out great.
07:03Pretty simple to do for the most parts.
07:06And really, it's again, all back to EventListeners and then just adding a
07:12navigateToURL that passes in that certain URL Request.
07:17And that's really how you link to a content that exists outside of your site.
Collapse this transcript
5. Creating a Portfolio
Setting up a portfolio
00:00The first thing you want to do when creating a portfolio is to figure out the
00:04design and how it will function.
00:06Then you can focus on the best way to execute it.
00:08So I'm going to go to the Portfolio section.
00:10And as you can see, there is a large image in the center and then supporting
00:15text just beneath it.
00:16There is also the thumbnails, the small images below that as well, and when you
00:23select a thumbnail, it will load in the upper area and so will that text.
00:29So that's what I want to do, but I want to be smart about how I develop this,
00:33because I want all of these images to be outside of the SWF file, because if
00:40they are embedded, then this file is going to be really large.
00:43So what I want to do is make sure,all of these images are outside of the SWF
00:48and then they get loaded in.
00:49So what I'm going to do is I'm going to have a UILoader component that's
00:53going to load in the large image and then write some code to load in the small images.
00:58All right.
01:00So the first thing I need to do is identify the images I want to use.
01:04So I'm going into these Exercise Files/Assets, into the design folder,
01:10into portfolio and I'm going to take a look at the large folder and the thumbs folder.
01:17And these are the images I want to use.
01:20I have large JPEGs in here, and then thumbs that match up perfectly in the thumbs folder.
01:27So all I need to do is copy those folders and put them in the current folder I'm working in.
01:3405/01 begin and I'm going to create a new folder called portfolio.
01:45And I'm going to paste both of those folders in there. All right.
01:47I'm going to start with the UILoader component.
01:50That's going to load in this basketball.jpg.
01:53So I'm going to go to my portfolio.fla file and here is my large image that I
02:00want to replace, so I'm just going to delete that image and what I want to do is
02:05replace it with a component.
02:08So Window>Components and I want to select the UILoader component and just drag
02:15it right on to the stage.
02:17Now I can go ahead and resize it.
02:21So I'm going to just zoom out by holding down the Command+Minus to zoom out and
02:27now I can start to scale this out.
02:30So what I've done there is I've hit the Q key.
02:32If you hit Q, that will select your Free Transform tool, allowing you to scale
02:41and adjust the size of this item.
02:44Another way to do it is just to use, of course, your Properties panel.
02:48So the height I want to be about 400 pixels and then the width can be wider.
02:54But I definitely don't want my UILoader component to be too large, as far as
02:59the height, because it does say portfolio here at the top.
03:03So I'll just kind of position it right there and then make sure this text, if I
03:08select my Selection tool, and this text is underneath that UILoader component.
03:14And I'll just use my arrow keys to fine tune it.
03:17So, it looks good so far.
03:19Here is my UILoader component, and what I want to do is I want to load in
03:24that basketball.jpg.
03:25So I'm going to go to Window down to Component Inspector and in the source
03:29panel, I'm going to type in portfolio, because inside of that portfolio is a
03:36large folder and inside of there is the basketball.jpg, just like that.
03:44I have mapped it directly to that source.
03:47And I do want to scale the content and that's why I like the UILoader component,
03:51because regardless of the size of your portfolio piece, it will always scale it
03:56down so it fits within this area.
03:59I made it extra wide in case, I have sort of more of a panoramic image,
04:03but that should do the trick.
04:05In fact, I'll just do a Test Movie, and yup, just like I expected, the image
04:10loads in and everything is looking great.
04:13Okay, so the next thing I want to tackle are these thumbnails.
04:16So I'm going to create an all thumb thumbnails movie clip and inside of that movie
04:23clip, I want to start loading in the different little thumbnails.
04:26I'm only going to do two right now, but in general, that's what I want to pull off.
04:31I'm going to close that SWF file, close that Component Inspector and
04:38Command+Plus will allow you to zoom in.
04:40So I really want to focus in on this.
04:45And this is going to be my all thumbs movie clip.
04:48So I'm just going to click and drag that into the Library, and I'm going to call
04:51this allThumbnails, because it's going to contain all of the thumbnails.
04:57And I'm just going to make it a Movie Clip for the Type and select OK.
05:03And I'll even give it an instance name, allThumbnails, which I will use in a second.
05:12Now what I'm going to do is I'm going to double-click on this, and this large
05:16graphic, you know what? I don't need it.
05:18In fact, I'm going to load in all these images.
05:20So I'm just going to delete that altogether.
05:23Now let's go back to Scene 1, and now what this serves as is a positioning item
05:30for all of my thumbnails.
05:31So wherever I move this is where all my thumbnails will appear.
05:35Okay, now I can go ahead and write some code that will pull in a thumbnail.
05:42So I'm going to take a look at my Timeline panel.
05:44I do see this layer 1, which I just don't need. I'll hit the Trash can to
05:48throw it away and create a new layer at the top and I'll just call it AS, for ActionScript.
05:54I'm going to select that first frame and I'm going to go Window down to Actions. All right.
06:01I am going to pin my code.
06:03I want you to get in the habit of pinning your code, so it doesn't move,
06:06regardless of what you have selected.
06:08And now, I can go ahead and type in what I need to type in, because I want to go
06:12ahead and create a new Loader from the Loader Class.
06:16So, in fact, I'll type in a comment, LOAD THE THUMBNAILS. All right.
06:24That's just a comment for me,
06:27so I know what I'm going to do. var, I am going to create a variable or a box,
06:31if you will, called thumbLoader. It's of the type, Loader.
06:40It's using the Loader class.
06:42So it's basically creating an instance of this Loader class.
06:48So there is functionality in here that I can use now.
06:52I'll show you what I mean in a second, because with the thumbLoader, I want to
06:59go ahead and load in the request. So new URLRequest.
07:08That turns blue. That's a good sign, because I'm typing that correctly, portfolio
07:13and inside of that portfolio folder is the thumbs folder and then, in there is
07:19the basketball.jpg, the small version.
07:23End that quote. Close that with a parenthesis and I need to close it with another
07:31parenthesis and then end with a semicolon.
07:34So anytime I have an open parenthesis, I need to close it down as well.
07:38So always make sure these match up.
07:40That's a common error is sometimes you won't have, say, both of them at the end.
07:45So that's what it's going to load in and what I'm going to type next is
07:50thumbLoader.contentLoaderInfo. I'm going to add an EventListener.
07:57It's going to listen for an Event COMPLETE.
08:07So once that image has been fully loaded in, fire off this function
08:12called thumbLoaded.
08:17Just like that, I'll create the function, thumbLoaded Event, and just be
08:28mindful that this word needs to match up with this word, but that's the type
08:33of method that we're using.
08:37And then void, open curly brace, closing curly brace and now I can go ahead and
08:44type in what I need to type in.
08:45So I'm going to go ahead and add the thumbnail to the allThumbnails instance.
08:55So remember how I named that earlier? If I just minimize this by clinking in
09:00that gray bar, right down here this little dot if I select it allThumbnails,
09:05that's what I'm referencing.
09:06So I'll open up my Actions panel because for the allThumbnails, I want to addChild.
09:16So I'm adding a Child and all that means is I'm just going to go ahead and
09:20attach this thumbLoader content, whatever it is,
09:25in fact, I'll just copy that word and I'm going to paste it right in here.
09:30It's going to add whatever content this has to the allThumbnails, so right where that dot is.
09:38So let me go ahead and do a Test Movie. I can see,sure enough, there is the
09:44little thumbnail. It loads in the correct spot and everything is looking great.
09:48And I'm just going to do a little clean up now.
09:50I have plenty of spaces in here, some line breaks, I'll just go ahead and
09:54condense this down, because this loads in one thumbnail.
09:58And in essence, what I've created is my own UILoader component.
10:02So it's definitely really cool and this is actually more flexible as well,
10:07because I can control different properties of it.
10:09But if you want to load in another one, what you can do is copy that code, paste
10:15it just below and you might call this one thumbLoader2.
10:20So thumbLoader2, I'm going to change that name everywhere, thumbLoaded2.
10:24So I just went in and changed the name of that function as well.
10:31And for thumbLoader2, I want to load in another image, cafebuena.
10:37That's another image in this folder right here.
10:42So it's going to place it right on top of my basketball image.
10:47So I really don't want that.
10:49What I want to do instead is thumbLoader change it's x position = 100.
10:58So move it over 100 pixels, so it's not on top of this one.
11:03That's all I need to do.
11:04I can check the syntax and it says all the code looks good, and let's do a Test Movie.
11:12And as you can see, I don't see it right now.
11:15So there is obviously a problem and since it didn't throw an error, I know it's
11:21an issue with one of my instance names.
11:24And what's happening is I've change this to thumbLoader in most places,
11:30except for right here.
11:31So right here, thumbLoader2 is where you need to add it.
11:35And I point that out because if Flash doesn't throw an error, it's probably an
11:39issue with your instance names.
11:41So if I change that to thumbLoader2, I do a Test Movie, I can see cafebuena
11:48loads in, basketball loads in right there.
11:50So they are both loading in and it looks pretty good and even right here, these
11:56are kind of changing places, but I can go ahead and type in 2 there and I will
12:03run this one more time, just by hitting Command+Return, I can see that they are
12:08in their appropriate places.
12:09So again, all this content is now external from the Flash file, making this
12:14initial file size really small and then you'll see the content start to load in.
12:19Now I can start to add many different thumbnails down here if I want to, but all
12:24that content is external.
12:25It makes my initial file size small and it just serves up content faster to
12:29the user.
Collapse this transcript
Adding functionality to thumbnails
00:00Once you have your buttons in place, you can begin to work on what happens when
00:04these buttons are selected, or when these thumbnails are select.
00:09So when you click on a Cafe buena thumbnail, I want to load that image into this
00:15large area, and then replace the text to down here.
00:19So I am going to jump into my portfolio.fla, and
00:23I am going to select that ActionScript, that first frame there, and I am going to go
00:29to Window and open up my Actions panel, and I am going to pin my code by
00:34pressing that button there.
00:36So here I have my code, which loads in that Thumbnail image for the
00:42basketball.jpg and the cafebuena.jpg.
00:46What I need to do is add another EventListener in here and I need to add an
00:54EventListener that listens for the click,
00:56But I need to do that once this thumbnail loader is created.
01:01So I actually need to make it right inside of this thumbloaded function.
01:07So right in here, I'll just hit Return a couple of times, just before that
01:11closing curly brace, I need to add an EventListener.
01:14So thumbLoader.addEventListener. If it highlights for you, you can hit Enter and
01:25it will add it, keep you from typing that whole word there.
01:29You can type in MouseEvent, because I am going to listen for MouseEvent,
01:33specifically the CLICK method.
01:37So when it's clicked on, it's going to fire off this function
01:40called LoadMainImage.
01:44There is my function call for LoadMainImage. Now I need to create that function,
01:49LoadMainImage and I am going to be loading this image multiple times.
01:59So I am going to need to do the same thing down here, so what I think I am going
02:03to call this is LoadMainImage1, because there is going to be multiple functions.
02:09So, LoadMainImage1 event colon, MouseEvent is what it's expecting.
02:18So I need to make sure these two words match up, and this function is going to
02:24be void. Just so you know what void means, sometimes you'll have say an
02:29add function that passes out may be two numbers that were added together, so it
02:34might pass back out that number.
02:36Void means it's not going to pass any content, or any text, or any code outside of the function.
02:42It's all just kind of happen inside of it.
02:45Open curly brace, close curly brace and within this LoadMainImage1, this
02:51is where I want to add code, just to do what I want it to, when this button is clicked.
02:56So I need to reference this large UILoader component. It's pretty large, so in
03:06my PROPERTIES panel, what I'll call it is largeUILoader.
03:10I just need to remember this instance name. In fact, I'll do a Command+C to copy it.
03:19I am going to go back into my code, and paste largeUILoader that instance name.
03:26I am going to change its source= portfolio/large/basketball.jpg, just like that,
03:41semicolon at the end.
03:43Now I can go ahead and use this EventListener for thumbLoader2, so I am going to
03:51copy these four lines, the EventListener and also the function.
04:00I am going to paste it down inside of this thumbLoaded2.
04:06So addEventListener, Mouse Click.
04:08It's going to give me an error if I don't change this function here, because I
04:13want to have a LoadMainImage2 function.
04:16So this is the call to this function, so I need to change it here as well.
04:21Then I want to load in a different image when this button is selected, and this
04:26is the cafebuena.jpg image, just like that.
04:31Notice as you start to nest functions within functions, things get a little
04:35crazy. In fact, you could have things indented more than once, and it's not a
04:40big deal to have multiple spaces before or after Lines,
04:44but what you can always do is click this Auto Format button, right next to
04:49Check syntax button.
04:51If I click that button, it's going to line everything up accordingly.
04:55So everything looks cleaned up, it kind of formats everything nice and neat, and
05:01just makes it little easier to read, so now I know what's inside of this
05:04function, for instance.
05:05I am going to go ahead and test this movie. All right.
05:11Everything looks as expected, but let me come down here and click on Cafe buena,
05:17and I don't get anything, but I do get a Flash for this.
05:21So I am going to take a look at that Cafe buena, and right in here, since it
05:26didn't throw an error and it wasn't working, well I need to check the instance
05:31name, so I need to change that to thumbLoader2.
05:32Now I am going to do a Control > Test Movie. If I click the cafe buena,
05:38it changes, so be aware of your instance names. If I click back, that changes as well.
05:44First thing I noticed is I don't have the little hand cursor. Quite frankly, I
05:49need to use that hand cursor.
05:52I need to have this movie clip work like a button, so I need to activate that hand.
06:00So what I am going to do is create a new line, and for the allThumbnails, I'm
06:07going to change this movie clip.
06:09It's buttonmode=true.
06:13So now it's going to work like a button.
06:15It's going to give me the hand that I need, so I know that those thumbnails are clickable.
06:19I can take this and I can copy it and use it wherever I want, for any movie clip,
06:24but I am just going to go ahead and test this movie.
06:28As I roll over either one of these, I can see that I get the hand and now users
06:33know that these are clickable, and it will load in the correct information. All right.
06:38Now what I need to do next is I need to change this content down here as well.
06:42So right now this is just a Static Text. I need to change that, so I am going to
06:46select this text field and then in the PROPERTIES panel,
06:50I want to change this from Static Text to Dynamic Text.
06:54So Dynamic Text means it's going to change at some point in time, and when I
06:59select that, I get the opportunity to give it an instance name.
07:03So I'm just going to call it something simple like selectedTitle, because that's
07:11going to be whatever was selected is going to appear right in there.
07:14And then for this text field right here, I am going to change that to Dynamic
07:18Text, and I am going to change this to selectedDescription, so that's going
07:25to be a description.
07:26I am going to minimize that LIBRARY panel, and just to show you what also you
07:31need to do, because down in here for the various PARAGRAPH options what I need
07:38to do is I need to change the Behavior. Instead of it being Single Line, I might
07:43need this to be MultiLine.
07:43So if you have a lot of text, I need to make sure it wraps to the next line.
07:50I'll even expand that out more, but notice you also have the ability to make
07:54the text Selectable. If you want you can turn that on or off, or you can even
07:59Render text as HTML.
08:02Because I could have HTML text in here, so I can make a word bold if I want to.
08:07But in general, that's looking pretty good, and notice what it does visually.
08:10It gives me these dotted lines for these text fields, an indication that they are
08:14Dynamic Text fields.
08:16But I needed to keep in mind selected title and selected disk are the instance
08:21names, and for this first image I can go ahead and when that image is selected,
08:27go ahead and change the selectedTitle, its text property=whatever I want that
08:35text to be, and I'll just type in Basketball.
08:40And for the selected Description, change its text property to
08:47Basketballdescription, whatever you want that to be.
08:52So for the sake of time, I'll just do that.
08:56I want to do the exact same thing for the other buttons, so I am going to Copy
09:00these two lines and paste them right in here.
09:03Of course, I am going to change the text to Cafe -
09:09There we are, something like that. Keep it simple, and we are
09:19looking pretty good.
09:20So again, I might want to click Auto format and Check syntax tells me
09:26everything looks good, and then I'll click Test Movie, so I can change these
09:31default values right in here.
09:34But notice that when I click on Cafe buena. it changes those two text fields,
09:40It also changes it back to say whatever the Basketball description is.
09:44It works both ways. So, sure enough, the site is set up and it's ready to go.
09:49I can add multiple thumbnails if I want to, and they'll all follow the same format.
09:56But it's really just a matter of adding an additional EventListener that
10:01listens for a CLICK that then changes various properties of elements that
10:06already exist on your stage.
Collapse this transcript
Allowing for unlimited thumbnails
00:00So here is my portfolio as it stands right now.
00:03I have two thumbnails and what I'm going to want to do is I'm going to start to
00:07add more thumbnails on down the line, until they actually go off the screen, and
00:12then I want to add a scroll pane component, so I can scroll those images.
00:18What this allows for is an unlimited number of images for your portfolio.
00:22So I'm going to go into the code, this first frame of the AS layer, and I'm
00:27going to go to Window>Actions, and right in here, you can see that I have the
00:34current two thumbnails.
00:35All I'm going to do is just paste in code for a total of ten images.
00:41I'll just review how these change from thumbnail to thumbnail.
00:45As you can see, thumbLoader2 moves over 100 pixels.
00:52So this thumbLoader3, I had to create.
00:55Again, give it an instance name, and it moves over 200 pixels.
01:00So it's not on top of the previous one.
01:03Not only that, I've changed the thumbnail image, the large image, and then the
01:08content that goes in the text fields.
01:11So that's what happens for each one.
01:12It's a matter of changing the instance name, the JPEGs, and then the functions as well.
01:19So that's kind of how it goes on down the line, and make sure you just change
01:23the instance names from one to the next.
01:26So I'm going to run this, just so you can see all of the various images.
01:29There they all are.
01:31You can tell that, actually, it does start to run off.
01:34If I expand that out,
01:36you can see this street trends image, which the user just wouldn't be able to get to,
01:41not unless I add a way to scroll to it, but otherwise, all of these are working just fine.
01:48So I'm going to go ahead and add a UIScrollBar Component.
01:52So let me close that Actions panel, but before I do, I'll just pin the code to it.
01:59It does stay up when I open it back up.
02:01What I want to do is go to Window, down to Components.
02:06In my Components panel, I want to select this ScrollPane component.
02:11So I'm just going to scroll down the page, and click and drag this on to my stage.
02:16Now I can close that panel.
02:18From here, what I can do is I can start to resize it.
02:21In fact, I can use the Free Transform tool.
02:25I'll double click on that center point, just to move it to the upper left-hand corner,
02:29so I can scale it out appropriately. I can go ahead and scale that out and do
02:34a Command+Minus to zoom out some, and I can start to position this in its appropriate place.
02:40I could even use my arrow keys to adjust it, but in general, it's going to just
02:44exist at the base of this page, kind of like that.
02:47That looks pretty good.
02:49For the most part, it's set up.
02:52What I need to do is I need to give it an instance name, so I can reference it
02:56in my Actionscript.
02:58So with this component selected in the Properties panel, I am going to give it
03:02an Instance Name of myScrollPane.
03:06All right, myScrollPane. So I'm going to go ahead and do a Command+C to copy that.
03:11Now let me go into my Actions.
03:16That's that first frame, and what I want to do is I want to go ahead and attach
03:22all of these thumbnails to myScrollPane.
03:26So at the very top of your code, just paste in myScrollPane, so that's the
03:31instance name, and I want to set the source equal to allThumbnails.
03:38So all the thumbnails that are in there, just copy that and paste it.
03:42That's what's going to go in the source for the myScrollPane.
03:44So, it's going to go ahead and attach appropriately.
03:48So let's do a Control>Test Movie, and what I'm going to do is I'm going to
03:54right-click and I'm going to do a Show All, because my screen size is a little
03:59small, and I can start to just scrunch that down.
04:03The scroll pane is actually there, but you don't really see it working,
04:09because what you'd need to do is you need to update the scroll pane as each
04:14image gets loaded in.
04:15So I want to do that, now I want to update it.
04:18So myScrollPane, when it loads in this thumbnail, I want to update my scroll pane.
04:30So it's as simple as myScrollPane.update, just like that.
04:34Now I'm going to copy this line of code, Command+C, because I want to update it
04:40as they get placed in here.
04:42So I'm going to update it after it's placed in at that position.
04:46This third one, it's going to update.
04:49So again, it's just a matter of adding this line of code for each one of these
04:55functions, right after if it's placed on the stage.
04:59The ScrollPane Component will actually reference the size of these thumbnails,
05:04and adjust its scrollbar accordingly.
05:07So paste that last one in, and we are looking pretty good.
05:11So let's do a Control>Test Movie.
05:15I do need to kind of scrunch this down some and I need to Show All, just to
05:20get it our viewable area,
05:22but you can see that I do have a scrollbar and I can easily scroll from left to right.
05:26Now notice it also added this vertical scrollbar.
05:29Well, that's easy to fix as well, because I can just close this SWF file.
05:34And I could probably write some code to do that, but the easiest way to do that
05:38is just to select your component, go to window and open up Component Inspector.
05:46And right in here, I can adjust the horizontal and even the
05:51verticalScrollPolicy, because I don't want it to automatically add that
05:57scrollbar. I always want it to be off.
05:59So I'm going to change that verticalScrollPolicy.
06:02Never show me that vertical scrollbar.
06:04I'll go ahead and do a Test Movie.
06:08Scrunch this down, just so we can see this really fast.
06:13Show All, and the vertical scrollbar is gone, but the horizontal one is still there.
06:19It works like a charm, because now I can click on each of these and I can
06:22finally get down to this last image, and this is really built for unlimited images.
06:26So the more I add to my code, the more I can scroll, but in general, this is
06:31really flexible and it's suited to fit whatever size portfolio you might have.
Collapse this transcript
6. Making a Flexible Portfolio
Benefits of using XML
00:14I'd like to give you an overview of the benefits of using XML,
00:19but first off, I would like to talk about what XML is.
00:23Well, it stands for eXtensible Markup Language, which just means that it's very
00:28flexible and really easy to read and use.
00:31In fact, there is many different technologies that can create and
00:35understand this XML format.
00:38So whether you're using PHP or a database, those different technologies can read
00:43and write XML file formats and XML content.
00:47But what it is is basically structured information that you define, and that's
00:52what makes it flexible.
00:53I can define what it contains, and what the different tags are.
00:59It's usually contained in a text document, as you can see by that icon, but in
01:03general, it is tag-based, like HTML.
01:06So if you're familiar with HTML, XML should be even easier to understand.
01:12But what are the differences?
01:13Well, HTML has predefined tags.
01:16So you can see in this example, there can be a heading 1 tag in HTML.
01:21That's a predefined tag like <b> for bold, any of that sort of thing, say the
01:26title is again, predefined, and what it does is it defines how the data is being displayed.
01:32So it has to deal with the visual display of the content.
01:37Well, XML is more flexible in that, because the tags aren't predefined.
01:40You define your own.
01:41So whether I want to have a tag that says <firstName> and another one that says
01:45<lastName> I can do that.
01:47I own have these tags are written, what they say and what the content inside
01:52of them say as well.
01:53So it was basically designed to carry this data not necessarily to display the data.
01:58So it really does separate the content from the visual aspect of your content.
02:05It plays really nice with Flash.
02:07So XML content can easily be displayed in Flash.
02:11It really does separate that content from the design, and it really allows your
02:16content to be external outside of your Flash file.
02:19So updating your site is a cinch, because all I need to do is open up that XML
02:24file in a simple text editor and edit it.
02:28So, what can XML be used for?
02:30Well, you can define the data, so it could contain News updates, maybe Schedules,
02:35Personnel Information, or even Portfolio content, but since you define the data
02:40you can determine what's in it, and how it's being used.
02:43The great thing is it's separate from the Flash file.
02:46So I would like to take a look at an XML file right now.
02:51In the Exercise Files folder, in the Assets folder, in the design folder, clear
02:56down in here in the portfolio folder, here is a portfolio.xml file, because
03:02that's what this XML file contains, all the portfolio information.
03:07So I'm just going to open that up in a simple text editor.
03:10I'm using TextEdit.
03:11You can use whatever you want, Dreamweaver.
03:13It's really up to you, but in general, this is the structure of this XML file.
03:18It does define it as an XML file, and then I have this tag that contains all of
03:24this portfolio information.
03:27Again, I've created this tag that says <portfolio>.
03:30I start with it, and I finish with it.
03:32Within this portfolio tag, exists this other information, and this is just a simple comment.
03:38It's actually an HTML comment, but I've just defined that this is Image 1, which
03:43contains the title of this image.
03:45It gives a description of the image.
03:47It gives the path for the largeImage, and then a path for the thumbnail image
03:54for this image, and it works out really well.
03:57But I do want to focus on the description, because notice how this does say
04:01CDATA and that means character data.
04:04So anything that I want to put within these two brackets will not mess up my
04:09code, because there are some cases where if I put a real interesting character,
04:13whatever that might be, it might tend to say, break the code.
04:17And if it'll ever breaks your code, then wrap it in CDATA, just like that, and
04:22close with those two brackets, because what's going on even for this description
04:27is I have these quotes.
04:28I want to make sure that this line doesn't break anything.
04:31So just wrap it in CDATA. But other than that, I've defined the tags, I've
04:35defined the content within those tags, and now this is ready to go.
04:39So I can close that, and I won't worry about saving it.
04:42But all my content is right in here, and it's going to be external from my Flash files.
04:47So if I need to update my portfolio, all I need to do is update that XML, and my
04:52website is pretty much automatically updated.
Collapse this transcript
Loading XML content
00:00Loading XML content into Flash isn't quite as easy as, say, loading in a JPEG,
00:05but knowing that the XML content can contain anything you want makes it totally
00:10worth it and very powerful.
00:12So in the Assets folderm in the design folderm if you look in this portfolio
00:17folder, you'll find this XML file.
00:20So this is what I want to copy and use in my Flash file.
00:26So I'll just copy it over to the appropriate place, into my portfolio folder,
00:31I will paste it right in there and this is the file I want to load in.
00:35So I'm just going to open up my portfolio.fla file.
00:39As I open it up and know that if I close this Actions panel, I'm actually right
00:44here on this first frame of the AS layer.
00:47So Window>Actions, I'll open this back up and you can see all this code written
00:52to load in all of the various thumbnails.
00:55But right at the top, if I just hit Return a couple of times, I can make room
01:00for loading in the XML.
01:02So I'm going to start off just by writing a comment, just going to type in XML
01:07and this is going to load in XML is what I want to do.
01:12And the first thing I need to do is create a variable and this is going to be
01:16the XMLURLLoader variable.
01:21It's a URLLoader and I'm going to create a new one.
01:25The URLLoader is great for loading in text content such as XML or TXT file, any
01:33sort of text content, I want to use the URLLoader.
01:36So I've instantiated, or made a new URLLoader, called XMLURLLoader.
01:43So I encourage you to just always copy and then paste to use any instance name
01:48you might have typed in.
01:49What I need do to now
01:51is go ahead and load in that specific file that I just placed in
01:56the portfolio folder.
01:57So I'm going to create a new URLRequest right in here, just like that code
02:01hinting tells me, and I'm going to do an open parenthesis and open quotes and
02:08type in 'portfolio.' This is going to be the URL, of course, portfolio.xml.
02:14That's what I want to load in.
02:16So I'm going to close that quote and close the parentheses.
02:19And remember there's two parentheses here so I need to add another one right there.
02:24So make sure you do that.
02:25That's looking good.
02:27Now once the XML is loaded, I want to just trace out some of that data, but I do
02:32need to create a Listener.
02:33So I'm just going to do a Command+V because the XMLURLLoader is what I want to
02:38use and I want to add an EventListener for it.
02:42And it's going to be an Event and I am going to listen for the COMPLETE.
02:47Once it's completed loading then I want to create a function called processXML.
02:52So I've just kind of made up the name of this function, but I do have to remember
02:57it because, just below that, I need to create the function to processXML.
03:03It's going to go ahead and be an event: Event.
03:08It's going to be the method so I need to make sure these two words match up, right
03:12now it's looking good and then open curly brace, close curly brace.
03:17So once this XML has been completed loading in, it's going to fire off this
03:22function and all I'm going to do is trace and I'm going to trace out the
03:26XMLURLLoader and I'm going to get the data from it, because since I'm using this
03:33URLLoader class, it enables these various functions to be available.
03:40And what I'm accessing here is this data property.
03:43So it's going to take this XML and put all the information from that XML into
03:48this data property and all I'm doing is tracing it out.
03:51So I'm going to check syntax.
03:53It does tell me that it doesn't contain any errors.
03:56So I'm feeling pretty good about this.
03:58I'll go to Test Movie and this is what I currently have, but if I look in my
04:03Output panel, I can see all of that XML content.
04:07All of it is in the XML file and now it's in Flash and available and ready to use.
04:14So really, if I go back to my Actions panel, you can see that through these
04:18lines of code, I'm able to load in an XML file.
04:20And of course, the next steps would be to access and start using all of this
04:24content, but now that my content is separate from my Flash file, it makes this
04:29really powerful when updating my portfolio.
Collapse this transcript
Sorting XML content
00:00Once the XML is loaded in Flash, you can start to sort through the content to
00:04determine what you want to use.
00:06So as you can see, it's really currently just a big dump of the XML, verbatim
00:12everything that's in the XML file.
00:15I want to start sorting through these individual items to start accessing their content.
00:21So I'm going to go to the Timeline to that very first frame in the AS layer and
00:25I am going to go to window to open up my Actions panel.
00:28Notice at the top, here is why I load in the XML, defines what file it is and
00:34once it's completed loading, it traces out all of the data.
00:39Okay, so that's where that big dump of data comes from.
00:42It comes from this.
00:43But what I want to do is start tracing out the individual items.
00:48So before this closing curly brace, I want to create a new variable.
00:52In fact, I am just going to delete this information because I'm going to create
00:57a new variable and it's going to be called theXMLData and it's going to be an
01:03XML file and it's going to be equal to new XML.
01:08And then within these parentheses is that data.
01:12So that's why I just deleted the trace statement.
01:15So what I want to do is take all of the content in here and put it right in this
01:21variable called theXMLData.
01:22Now that all the data is in there, I can start tracing out some of it.
01:27So I am just going to type in 'trace (length,' because the first thing I want to
01:32get is the length of this XML.
01:37So the length, colon, and that's in quotes and I can add Plus and I can start to
01:42type in theXMLData and I want to actually get the title.length.
01:49Length is a property available to the XML class.
01:53So again, that's why I've created this new XML, because I can start accessing
01:58things like the length.
01:59So that's what's going to be displayed when I run this code.
02:02It's going to trace out the length, but I am going to type in a couple
02:04more things in here.
02:05I am going to type in another trace statement and instead of the length, I am
02:09going to get the title, the actual title, and I am going to go ahead and use this
02:15information right here.
02:17So I am just going to copy it and paste it right here.
02:21So what's happening right now is it's going to get the title information but
02:25what node in the lineup of the title am I going to get?
02:29So am I going to get the first item, the last item? Because they're all numbered.
02:33There's about 12 titles in there, because there's 12 different portfolio pieces.
02:38So what I need to do is I need to type in title and I need to reference a number.
02:42So I am going to do brackets and within those brackets, I'm just going to type zero.
02:48Now that's going to get the title of the very first item, starting at zero,
02:53and make sure I close that parentheses, just like that, and I want to do the same thing.
02:58In fact, I am going to copy this, Command+C, Command+V and I am going to start
03:02getting more of the information.
03:04So Description and theXMLData I am going to change title to Description, just like that.
03:13So it's going to get the description of the very first item.
03:16Again, I am going to paste in that code again, and I am going to get the large image.
03:21That's going to be the large image name, and instead of the title or
03:25description, it's going to be largeImage.
03:28And lastly, I am going to go ahead and do the thumbnail and I am going to change
03:34this title to thumbImage.
03:37Now I need to make sure these various items exist within the XML.
03:43These are the various tags that I've defined, but these do match up and what I am
03:48going to do is I am just going to go ahead and run this code.
03:50First off, I'll do the check syntax and it does say it contains some errors.
03:55So I am going to go ahead and take a look at some of that, and for this
04:00one, theXMLData.title.length, it's giving me an error, and it's probably
04:06that semicolon there.
04:08So I am just going to go ahead and hit Check Syntax and then that gets rid of the error.
04:13So it's looking good now. Let's do a Test Movie. It runs.
04:17I am just going to just close this because I want to close my Actions panel as
04:22well and peek into the Output panel.
04:25So notice that it does get the length, so it says that there's 12 items and then
04:31it gets the very first information of the very first node, which is actually
04:35Node 0, but it gets the title of it.
04:38It gets the description.
04:40It gets the large image path and the thumbnail.
04:43So it doesn't show me any of the various tags.
04:46It just shows me the content within the tags, and as you can tell, this
04:51information here is much more useful for me.
04:54So what I want to do is I want to get the other data as well.
04:57So I am going to open up the Actions panel.
04:59Now what I want to do is I am going to create a loop because I want to loop
05:02through all of this and I want to show all of the content for all of the various nodes.
05:08So for these trace statements, I am going to type in a for. I am going to create
05:13a for loop and I am going to make i equal to a number.
05:17It's going to be a Number and that's going to be equal to zero.
05:20It's going to start at the zero node and it's going to loop through this data.
05:26And then I am going to type in i. As long as i is less than the total length of
05:35this XML information, then keep on running through the code.
05:39So I am just going to copy this code and paste it up here.
05:42So this code is really going to execute multiple times.
05:46So this is where we do a comparison to see if i is less than the total length
05:50of this information.
05:52And lastly, I need to type i and then do Plus, Plus.
05:56So what that does is it adds one each time this code is executed.
06:03But I need to make sure I finish writing this code because I need to do an open
06:07curly brace and then a closing curly brace.
06:10And I encourage you to, each time you add these curly braces, you write a
06:14function or anything, go ahead and check this Autoformat button and it will go
06:20ahead and nest all of those trace statements.
06:22Now I can see what's in the for loop.
06:24So it's going to run through all of this information, starting at zero.
06:27It's going to do it for the length of the array and each time it loops through,
06:31it's just going to go ahead and add 1 to i.
06:34Now I don't want it to keep sort of printing out in the Output panel the item
06:38that's in the first position.
06:41I want it to change each time.
06:43So I am going to replace these zeros with an i, because what i is is it becomes
06:48zero the first time through, then it adds one.
06:51Then it becomes 1 the second time through and then becomes 2 the third time
06:55through, and it does that 12 times.
06:57So if I just reset this back to i and I check my syntax, it does say that it
07:02doesn't have any errors and I am going to do a Test Movie.
07:07Close that SWF file.
07:08I am going to close my Actions panel and as I look at this information, I can
07:12see that all of the data is in there, none of the tags, but just the raw
07:17information that I want to take and use in my Flash file is all there and quite
07:21frankly, it's ready to be used.
07:22So through the code I have just written, I am able to access this information
07:26and then the next step, obviously, would be to use it in my Flash file.
Collapse this transcript
Displaying XML content
00:00Now once you can trace out XML content in Flash, the next thing you're going to
00:04want to do is to put this data into containers to be accessed when needed, and
00:10probably the most flexible container is going to be an array.
00:13But as you'll notice, here are all of my different items being traced out.
00:17I have the title, the Description, large image, thumbnail and what I want to
00:22do is to put all of these in a large container, so all of the titles will go in an array.
00:29And what an array is
00:30is kind of like if I had a big moving truck and this truck is filled with
00:34boxes, well, each box would be an item and in this box could contain any type of
00:41item I want it to contain.
00:42In this case, it's going to be a truck full of titles, and each title contains
00:47some specific information.
00:49So that's what I want to make.
00:50I am going to my Timeline panel. I'm going to go to this first frame here and
00:53I'm going to go to Window and open up the Actions panel and right at here, at the
00:57very top, I'm just going to go ahead and type in Array.
01:01Now notice it is a keyword, so I can select it and I can View the Help on it.
01:07So here I can read more about arrays, but notice there are some examples
01:12right down in here.
01:13So to make an array, I would create a new variable and give that variable a name
01:20and then go ahead and create the array and I can have certain values in that
01:23array, certain boxes if you will.
01:25But I'm going to go ahead and just copy this first line here as a starting place.
01:29All right. I can paste this code in and I don't want this to be a oneArray, but again, I
01:35want this to hold the titleArray.
01:39Okay that's the name of this moving truck, titleArray is an array and here's
01:44where I access the array class and I'm just going to clear out this information,
01:50because I want to put content in it later.
01:53So I am going to do the same thing for the other items in our XML, such as the
01:58largeImageArray and again, this is going to be the same, so I'm just going to go
02:04ahead and copy this.
02:06Command+C, Command+V just like that, var thumbnailImageArray, and notice that I
02:16actually do have two colons there, so I will remove those and I'll start to put
02:21this in that more of a readable order because I want to have my descriptionArray
02:28right underneath my titleArray and then there we are. All right.
02:32So this does follow sort of the same format that I have down here, sort of the
02:36title, Description, large image and then the thumbnail.
02:40But now that I have these arrays created, I want to push content into them.
02:44So I want to load it up with information.
02:47Now I can go back to my Help and you'll notice that arrays do a lot of different
02:51things from popping, from pushing.
02:54You can read each one, but it adds elements to the array is what push does.
02:59So that's what I want to do is I want to push information into it, so it's like
03:02loading up the truck. All right.
03:04And the information I want to push is all of this information in here.
03:08So it's going to include the title, Description, large image and thumbnail.
03:13So what I'm going to go ahead and do is let's go ahead and type in titleArray
03:20and push and within those two parenthesis, I'm just going to take this data and
03:27I'm going to put it right in there. All right.
03:29So that looks good.
03:30I will, in fact, delete that, descriptionArray, push content into it as well and
03:37it's going to be this information right here.
03:40Drag that on in there.
03:42Next up is, of course, the largeImageArray, push content into it, drag that on in there.
03:51and start to eliminate these trace elements and last one I need to do is,
03:57I've gotta make sure this is right, thumbnailImageArray.
04:02That's a very long word, so I'm just going to go ahead and copy it and paste it right here.
04:08thumbnailImageArray push data into it as well and it's going to be this
04:11data, just like that.
04:13So with that setup, it's going to push all of this information into these arrays and
04:19notice how it gets loaded up as it actually comes through here and I've this for
04:23loop, so it loops through it for the length of the array.
04:26It starts pushing the title in for each title and all the descriptions go in
04:30this array and all the images and than all the thumb images go in their
04:34specific arrays as well.
04:35So now that the information is in there, I'm going to show you how I can use it.
04:40So if I scroll down further, you can see that there's this thumbLoader, and
04:45what this thumbLoader does is it loads in the first image, the first thumbnail
04:50into this thumbLoader.
04:52So what I want to do is I want to start using some of that information down in here.
04:56So that very first image, well, you know what I want to do is I want to change its source.
05:02I want to change it from this hard coded link to that image to what's in the XML.
05:08So I'm just going to go ahead and type in 'largeImageArray' and I'm going to go
05:14ahead and do an open bracket, close bracket and then I'm going to type a number in here.
05:20So whatever item in the array that I want to put in here, I can go ahead and
05:25just type that in there.
05:26So if I want to access the very first largeImage, I can just type 0 in there. All right.
05:32Next up, I am going to do the same thing for this title.
05:36It's not going to be Basketball any more. It's going to be titleArray and again,
05:40open close brackets, and then within those two brackets I'm just going to go ahead and type 0.
05:45Lastly, again, this is all hard coded and I want it to come from the XML, so I'll
05:49delete it and I can type in 'descriptionArray' open bracket, close bracket, zero.
05:58Make sure we get that spelling right, descriptionArray, make sure all the stuff
06:02matches up and these are the items I'm going to get.
06:05So it's looking pretty darn good and notice initially, what was in there was of
06:10course all about Basketball and I'm leaving this the way it is just to show you
06:15that this information that's getting loaded in is going to be different than
06:19what the image displays.
06:21So I'm going to do Control>Test Movie and I'm going to run it and for
06:28Basketball, if I click on that and maybe I click on one of these other ones, but
06:33you can see, if I click on this basketball image it changes the text to Our
06:38Future Generations and then also it gives the description right down here and
06:43then displays that large image.
06:45So it's working out quite well.
06:47It's changing that information and it's all based on the XML.
06:49So this is really working for me.
06:51In fact, I can go through and do the same thing. In fact, if I just copy
06:55these three lines, right-click Copy, I could do the same thing for this next thumbnail.
07:03Paste that in and then the only change I need to make is change that from 0 to 1, just like that.
07:10So now when I run it, you can see that when I select this cafe buena image, it's
07:17actually going to be the Basketball image.
07:19So you can see how things are changing. They're no longer what they were, but
07:24it's actually referencing XML content.
07:27Notice that the thumbnail images don't sync up with the large images. Not to
07:31worry. I'm going to sync this up later.
Collapse this transcript
Using XML to create thumbnails
00:00So, currently what's going on with this file is that all of my thumbnails are
00:06all hardcoded in the ActionScript.
00:09So, with this first frame selected, you can see that I opened up my Actions
00:13panel and I'm going to pin my code and I'll even close that as well.
00:18If I scroll down, you can see all of these thumbnails are hardcoded with their
00:22information and quite frankly, I don't want this. I want it to all come from the XML.
00:28Okay. So, I'm going to do that and I'm going to really start with this first thumbnail
00:34as they shell, if you will, to create all my thumbnails, because not only am I
00:38going to pull all of the content from the XML, but I am going to end up deleting
00:43all of these other functions. All right!
00:44So the first thing I'm going to do is I'm going to create this new function and
00:49this function is going to be called loadThumbnail.
00:53Right now, I'm just putting a call in to the loadThumbnail that I'm just about to make,
00:57but know that that loadThumbnail function is going to be called once all of the
01:01data gets loaded in.
01:03So once all the data is available, I'm going to call this
01:05loadThumbnail function. Okay.
01:08So right down in here, I'm going to use this first thumbnail as my template, so
01:13I'm going to make a function called loadThumbnail and I'm going to do an open
01:21curly brace and I'm going to put everything inside of this function right here. Okay.
01:26Again, anytime you make a function or you add curly braces, go ahead and select
01:31this Auto format button and it will format everything so I can see all the
01:36content inside of the loadThumbnail. Okay.
01:39So you can see that this is hardcoded and I really want to get rid of all of this stuff.
01:44So I'm just going to go ahead and delete that.
01:47In place of that, what I want to use is the content from the Array, more
01:53specifically, the thumbnailImageArray.
01:55So I'm going to copy that name and scroll back down.
02:02Right here in the URLRequest, that's where I'm going to paste it.
02:06Now, I'm not going to reference the whole array, but I just need to get that first image.
02:11So, between two brackets, I'm going to put a zero and that's going to get the
02:15first thumbnail image, just like that.
02:18So that's looking pretty good.
02:20This is going to be called and it's going to go ahead and display that first thumbnail.
02:24Everything else is going to work as normal.
02:26I'm going to do a Test Movie and there is my image.
02:30So this is a different image.
02:31In fact, these two match up.
02:33But the point is this image is coming from the XML. Everything else is hardcoded.
02:37So now what I'm going to do, I'm going to get rid of all of these thumbnail
02:40images and replace them with content from the XML. All right!
02:46So, what I want to do is I'm just going to go ahead and delete all of
02:51these other functions.
02:52This is the fun part.
02:53I like that I'm removing lots of lines of the code, looks like I'm at 207, delete that.
02:59Now I'm down to 54.
03:01In fact, if I start eliminating some of these lines, you can see that I'm now
03:05down to 45 lines of code.
03:07But now I need to start adding some additional lines.
03:11So right up here at the top, this is where I have my variables for my arrays and
03:15I want to create a new variable.
03:16So I'm going to create a variable and this variable is going to be called imageNum.
03:22It's going to store a number and I'm going to make it equal to zero.
03:26So that's its starting point.
03:28imageNum is going to be equal to zero.
03:30So I'm going to take this number and I'm going to copy it and inside of my
03:34loadThumbnail function right here, I'm going to go ahead and paste imageNum. All right!
03:39So that will just put zero in there, initially, since I have this set to zero,
03:43but I want to run this function multiple times and I actually want to add to
03:48imageNum each time the function is run.
03:50So right down here, before that closing curly brace, I'm going to go ahead
03:54and type in imageNum++.
03:58So what that does is I'll write a comment in here, add to imageNum each time it's run.
04:05So it adds 1 to it. All right!
04:08It's going to add to imageNum and then I want to call the function.
04:12I'm going to call the function loadThumbnail. That's right.
04:16I'm calling the same function that this is currently in.
04:19It's going to call that many times.
04:21In fact, it's going to call it indefinitely.
04:23So, there will be some errors here, but the short of it is that it's going to go
04:28ahead and load up this image.
04:29In fact, at this point, what I want to do is I want to make sure that this is working.
04:33So, right inside this function, I'm going to add a trace and inside of this
04:38trace, I'm just going to say imageNum.
04:41That's what I want to trace out is the image number. All right.
04:45Notice up here there's this other trace statement in here where it's outputting
04:48the length 12 times.
04:51I really don't need that, so I'll come up here to this trace line and I'll just
04:54eliminate that line of code to that trace statement, so I just have this one.
04:59So, that's all I'm really going to see.
05:01I shouldn't see any of the thumbnails, other than that one.
05:03I'm going to run it.
05:06Sure enough, there's my one thumbnail and I'm going to close this, but if you
05:09can take a look at this, I can see and I'll close my Actions panel, 2, 3, 4
05:14clear up till 12, and then I start running into these errors, because it keeps
05:18on running that function even though there's only 12 images.
05:21So I'm going to take care of this now.
05:22I'm going to go back to my Actions panel and I only want to run this
05:26loadThumbnail 12 times for the length of the array.
05:29So I need to create a new variable right up here at the top.
05:32I'm going to type in var totalImages:Number.
05:38So it's going to store a number.
05:40So right down in here, for the totalImages, it's going to be the length of the
05:44array, which I can find right here.
05:46So, just after the data gets loaded in, I'm going to go ahead and type in var
05:51and make sure I type in totalImages.
05:53I'm going to make that equal to theXMLData.title.length.
05:58In fact, I will take that and I'll move that right in there.
06:01I'm going to make sure this ends with a semicolon and I need to make sure I
06:05use totalImages as I copy that and paste it. It's going to be still used right in there,
06:11but I can also use this totalImages down further as well.
06:15So right down in here, again, I want this loadThumbnail to be only run for the
06:19length of the array.
06:20So, I need to create an if statement.
06:23imageNum is less than totalImages and let's just make sure we have that
06:29name right, totalImages, capital 'I.'
06:32Close parentheses, open curly brace, and then close curly brace.
06:36Again, anytime you add curly braces, click this Auto format button and it should
06:42be only running 12 times.
06:45So I'm going to go ahead and run this code, Control>Test Movie.
06:49It's only being run once and I'll show you why, because right up here at the
06:54top, this is equal to zero and this var means that it's only going to keep this
07:00variable within this function.
07:02So I actually need to remove that var right there.
07:05I did that to point out that any time you make a var, it's only going to be
07:09available within that area.
07:11If you make a var or variable sort of at the root of this Actions panel, it's
07:16available everywhere.
07:17So now if I run this, you can see that it runs the length of the array, but I
07:25still only see one image, so I'm going to take care of that right now.
07:30So right down in here, the images are being loaded in, but they're not being
07:34positioned appropriately.
07:36So, that's my next step, is to position them appropriately.
07:40So just before that Event.COMPLETE, what I want to do is I want to go ahead and position this.
07:47thumbLoader.x, make it equal to 100, not 100 pixels, but I want to multiply it.
07:55I want to have the first one maybe 100.
07:57Maybe the second one is 200.
07:59Maybe the third one is 300.
08:01So I need to start multiplying.
08:02So the asterisk is a multiplication and I can type in imageNum, just like that.
08:09So, everything is looking good. I'll do a Control>Test Movie, and sure enough, it
08:14runs. I can see all of my various thumbnails right down here and they're set up.
08:20So, the next step would be adding some additional functionality to these,
08:23because when you select them, it opens up the first image, but I can take
08:27care of that later.
08:28The point is all of this data that you see right now is all external from the
08:32Flash file, all coming from the XML and I don't have to open up Flash if I want
08:37to update my site, I can just edit the XML.
Collapse this transcript
Displaying content with thumbnails
00:01I'm now going to display the appropriate content from the thumbnails and I
00:04want to make everything XML-driven, because currently how this is set up is
00:10this image is hardcoded in the Flash file, so is this text, as well as the description.
00:16So I want to take care of that first.
00:19Also notice, as I come down here over these thumbnails, I need to implement the
00:25hand cursor, just so users know that these are buttons.
00:28So I need to make these movie clips work like buttons.
00:32Now, if I do select one of these or any one of these, notice how it displays
00:39content from this very first image.
00:42So, I need to make sure all this information is being pulled from the correct
00:47XML and it's not hardcoded, because believe it or not, this information, as you
00:52click, is all hardcoded, pointing to that first image and its related text. Let me close that.
00:58I'm going to go into my portfolio file.
01:02The first thing I'm going to do is I'm going to make sure this UILoader does not
01:07reference that basketball image.
01:09So I'm going to go to Window, down to Component Inspector, and right in here,
01:14this is what I mean by hardcoded. I would have to actually open up Flash and
01:18type in a new name, if I wanted to change this.
01:21That's what's meant by hardcoded, but just, all I need to do is get rid of that
01:25and that's no longer an issue now, because I don't want it to display anything
01:30when you first go to the Portfolio section.
01:33Next thing I need to do is delete the text in these text fields, right here and right here.
01:40I do want to make sure that this text, in the Properties panel, that the Behavior
01:46is Multiline, because since I'm going to be loading in XML, I could have
01:52multiple lines of XML content.
01:54So I want to make sure this is set to Multiline.
01:57So, another thing I need to do is make sure this button is pressed as well.
02:03So I want to render text as HTML. All right!
02:07So that's looking pretty good.
02:08Those two have been cleared out, as well as the image, and of course, that
02:15information doesn't show up.
02:17Okay, now I'm going to go ahead and fix this issue.
02:20Those movie clips, well, I want them to look like buttons or at least act like buttons.
02:24So, I'm going to select the first frame in the AS layer and I'm going to go to
02:29Window, down to Actions to open up my Actions panel and I'm going to pin my
02:34code, just so it doesn't move if I select something else. All right.
02:39So right in here, in this loadThumbnail function, this loadThumbnail function
02:45gets called many, many times, each time where the thumbnail that gets loaded in.
02:49What I want to do is I want to make my all thumbnails act like a button.
02:57That's as easy as typing allThumbnails.buttonMode, capital M, = true.
03:04So, I'm saying, "Hey, you know what?
03:05I know you're a movie clip, but work like a button."
03:07So, give me the hand cursor and everything should be okay.
03:11So I'll do a Test Movie.
03:12Now when I roll over these, sure enough, I get that hand and it's looking good,
03:17but I still have this issue of all of these thumbnails displaying wrong content.
03:23So let's take a look at that.
03:25Right in my loadThumbnail function, right down in here, when you click on the
03:30image, this is the hardcoded part.
03:33So it's pointing to the array, but it's taking the very first element and displaying it.
03:38So, this stuff has to go.
03:41So what I want to do is I want to create some variables, and I'm going to create
03:44some variables right in here.
03:47So not inside of the Event.COMPLETE, EventListener or anything, but I want to
03:52write this code just above that and they are going to be variables.
03:56So these variables are going to hold the specific array information.
04:01So var thisLargeImage is going to be a String, and it's going to be equal to the
04:09largeImageArray, and then I do my two brackets.
04:14Since this is an array, I'm going to do these two brackets, and just like I'm
04:19getting the thumbnail image array, the appropriate image number, I want to do
04:23the same thing right here.
04:24So it's just a matter of copying that line and pasting it right in here.
04:29I also want you to confirm that this LargeImageArray is spelled correctly, so up
04:33at the top of the code, largeImageArray is right there.
04:37So I want to do the same thing for the titleArray.
04:39So I'll just copy that, scroll down and create another variable.
04:45This title is also a String and it's going to be equal to, and I'm just going to
04:51paste in what I just copied, titleArray.
04:54I want to do my brackets and within my brackets, I'm going to copy and paste in imageNum.
05:01Next up, I have, at the very top, if I scroll up to the top, descriptionArray.
05:05So I'm going to copy that again, scroll back down and type in thisDescription,
05:15and it's a String, and it's going to be equal to, add descriptionArray, my
05:19brackets, and then that image number as I copy and paste it.
05:25So this actually stores the appropriate info for the thumbnail, regardless of
05:35what number thumbnail it is.
05:37So these variables store that information. Now, I need to use these variables.
05:43So thisLargeImage, I'm going to copy that, and where I want to put it is right
05:47down in here, for the source of the largeUILoader.
05:51So right in there, I'm going to go ahead and paste thisLargeImage.
05:57Same thing for the title. I'll just do a Command+C and for the selected title,
06:02I'm going to make the text equal to thisTitle.
06:05Same thing for the description. I'm going to copy that variable and paste it for
06:10the text property for the selected description. All right!
06:15Test the movie.
06:16So, I'll just go ahead and click on one of these and it displays the appropriate image.
06:24So it's working great now.
06:26All of this content is coming from the XML.
06:29There are a couple issues, it looks like.
06:31If you take, for instance, this description right here, notice that there is
06:35some HTML in there, some HTML code.
06:38I point that out, because you can have HTML code in your XML file, some
06:44basic HTML 1.1 code.
06:47So links, making a word Bold, things like that, but it's really appropriate
06:52for this because you might make a website design have an image of it in the center area.
06:57You want to give the user the ability to click out to that specific website.
07:01So I need to render this HTML in Flash.
07:05So I'm going to close this file, and again, I'm going to just minimize that
07:10Actions panel by clicking that gray bar and I'm going to select this text box,
07:14because I want to point out that I need to make sure this is set to Render text as HTML.
07:21I'm going to open up my Actions panel again.
07:24The last thing I need to do is type in htmlText.
07:30It changes colors, confirms that it's typed correctly, and now Flash will render
07:36out this text as HTML text.
07:39So let's run this, Test Movie.
07:41Now if I go into this take flight image, I can see the HTML code is gone
07:48and it gives me a link.
07:50So I have a hand cursor, and if I click on it, it's going to take me out to
07:54that specific site.
07:55So again, all of this content is coming from the XML.
07:59I can easily add to the XML, all I want to remove from it, edit any of this text.
08:04It's all XML-driven.
08:05I no longer have to open up Flash to update my site.
08:09Everything is external, really making my site flexible.
Collapse this transcript
7. Creating a Video Portfolio
Creating and importing video
00:00Video is one of the most compelling assets you can add to your site and Flash
00:04makes it easy to create and import video.
00:07So that's what I am going to do.
00:09I have my video.fla file open, and I want to replace this image with a video.
00:15So I am going to double-click on this movie clip, and I am going to select just
00:19this image and I am just going to make note of the size.
00:23The Size is about 500 pixels wide.
00:27So I want to keep that in mind when I import my video, because I want it
00:30be about that wide.
00:32So I am going to delete that image.
00:34And I am going to go to File> Import and I am going to Import Video.
00:39So you are greeted by this Import Video dialog box.
00:43It asks you where your file is.
00:45I'll click Browse and I will browse to it, because in my Assets folder, in the
00:49video folder, there's this newport QuickTime movie that I want to import.
00:55So I am going to select Open and it does tell me that this QuickTime movie
01:00doesn't seem to be supported by the Flash player.
01:04So it's going to launch, or ask me to launch, the Adobe Media Encoder so I can go
01:09ahead and convert that video to an FLV file or F4V.
01:13So I'll select OK, and right down here at the bottom, I can click Launch
01:18Adobe Media Encoder.
01:20Now the Adobe Media Encoder does come with Flash.
01:23It is technically a separate program, but I like how you are able to convert
01:28videos into the Flash format and you can convert as many as you want.
01:33You to list them all in here.
01:35But notice how it already references my QuickTime movie.
01:38It tells me the Format, but I want to jump in here to the Preset.
01:42So if I twirl that down,
01:44you can see that I get all these different options to select and quite frankly,
01:49I am just going to select FLV - Same As Source.
01:52Well, what is FLV - Same As Source?
01:55Well, I can click on this link right here and it will open up the Export Settings for me.
02:00At this point, I can review what it is.
02:02It gives me a summary, saying it's actually pretty large and also does include audio.
02:08Well I can modify these settings if I want.
02:11So it's just a matter of going to that specific tab, such as Video, and right in
02:15here, I can Resize the video.
02:17So again, I want to resize it to about 500 pixels.
02:20I want to make it 500 pixels wide.
02:23Now it's going to fit that space better.
02:25And I can control some of the other options as well, but everything looks good
02:29now. I just wanted to adjust the size and I can select OK. All right.
02:34If I scroll down to this Output File area, and I click on this link, this tells
02:41me where it's going to be exported to.
02:43Now what I want to do is I want to out it in the same area as my portfolio.fla
02:48inside of a video folder there.
02:50So I am going to click New Folder and the name of the folder is going to be video.
02:58In this video folder, I am going to put that newport.flv file in there.
03:02So I will just click Save.
03:04And now it needs to be rendered.
03:06Rendering it means the Adobe Media Encoder needs to make all of these frames
03:10at this certain size.
03:12So it says that it's waiting to be rendered and all I need to do is click
03:17Start Queue and if I had more videos in there, it obviously would render out all of them,
03:24but in this case, I am just rendering one and it is actually done.
03:27So I will close the Adobe Media Encoder.
03:29I will go back to Flash and it does say,
03:31"Hey! You know what? After you are done with the Adobe Media Encoder, make sure
03:34you switch back to Flash and click the Browse button to locate the file you just created."
03:40So I am clicking on the Browse button and I am going into where I created that
03:45file, which is in the video folder. There is the newport.flv file.
03:50I will select Open, and I want to make sure it Loads in this external video with
03:56the playback component.
03:57So most of the time, you are going to want to use this option and I will show
04:01you what that looks like, because if I click Continue, this is the playback
04:06component right here.
04:08This playback component comes with this skin, which I have full control over.
04:13So if I open up this dropdown menu, I can select, say, a different skin.
04:18So this is the skin over the video, showing all of the buttons.
04:23Well that's quite a bit, but I can start to select sort of all of these
04:26different options and really, maybe I want to go with the SkinOverPlayMute option,
04:34which just gives me these two buttons, and I can even change the color to fit my
04:39design, which is red.
04:41So after that's done, you can click Continue, and then it does say,
04:46"Hey! You know what? Keep in mind that you need to upload this video when you are done
04:50with your website, because it's going to reference this external file.
04:54So make sure this FLV travels with your website if you happen to upload it.
04:59So now it loads in that video using FLV playback component.
05:04I could move it into position.
05:06Now the next thing I want to do is take a look at some of the properties for
05:11this FLV playback component.
05:14So in the Properties panel, notice that it does say it's an Instance of the FLVPlayback.
05:18Well I can click this icon right here and that just opens up the
05:22Component Inspector panel.
05:25Now if I expand this out, notice that I can change the color and change some of
05:29the other settings that I got earlier.
05:31But what I don't want to happen is I don't want this video to play automatically
05:35when they click on this section.
05:38In fact, I want to change the autoPlay to false.
05:41So that's all I want to do here.
05:42The color and everything else looks good.
05:44So I can close that panel down and now I am going to go to Control>Test Movie. There is my video.
05:52It loads up, but it doesn't auto play, not till I click on that button.
05:56(Video Playing)
06:00I hear the audio.
06:01I can pause the audio and still watch the video.
06:06And it all looks pretty good.
06:08So I would say this is looking really good for what I want to do.
06:11But let's take a look at this within context of our site.
06:15I was working in the video.fla file.
06:18But what I want to do is open up this index.fla.
06:22So if you recall, this is my main site.
06:25This is the file that loads in all the other SWF files.
06:30So I am going to do Control>Test Movie.
06:34Now I am going to go ahead and click on Video to go to the video section.
06:38You can see my video.swf file loads up and I can play this video.
06:43(Video Playing)
06:46Let's check out what happens if I play this video and then navigate to another
06:51section before this video is done playing.
06:54(Video Playing)
07:04So you probably noticed that the audio continued to play and this is obviously
07:09going to be an issue, seeing as you have navigated away from that page, we
07:13want that audio to end.
07:15So regardless of the section you go to, we want to make sure all the audio has been stopped.
07:21So that's what I want to do next is in this index.fla file, I am going to go to
07:26the Timeline and I am going to go to this first frame here, in the AS layer and
07:31I am going to open up the Actions panel.
07:34Now currently what I have in here are all of my various function calls that
07:39calls this function, that navigates to that particular section. All right.
07:44So within this function, I want to stop all audio, but what I need to do first
07:50is I need to create an import.
07:52So right up here at the top, in my current list of import settings, I am going
07:57to go ahead and import something else.
07:59I am just going to type, import flash.media and
08:05I'm going to import the SoundMixer. There it is.
08:08If it highlights you can hit Enter, and we'll select it, and what this does is
08:12it tells Flash to go get all the code for SoundMixer because I want to use one
08:18of the functions associated with SoundMixer.
08:22Now that it's imported all of that code, right down in here in this
08:26moveContent function, and after these trace statements, I am going to type in
08:31SoundMixer.stopAll.
08:34You can see that it highlights it right down here.
08:37I can select that, do an open and close parentheses, end with a semicolon and this
08:43will stop all audio.
08:44So anytime you navigate to another section, it's going to kill any audio that
08:48was in that previous section.
08:50So let's go ahead and test this out.
08:55Video section, I am going to play this video, and then I am going to click
08:59on the About button.
09:00Now the audio is going to stop playing when I click on the About section.
09:04(Video Playing)
09:10The audio stops and now it's working appropriately.
09:13So again, that's an issue you might run into when you start loading in audio or
09:18loading in video is it might continue to play.
09:21You can use the SoundMixer.stopAll, and it will kill any sound that's going on,
09:27but otherwise this is set up.
09:29Flash makes it easy to take your current video and convert it to Flash video
09:33format as well as applying a certain skin with certain buttons to it and
09:40control how it gets integrated with your site, being able to stop the audio
09:45using the SoundMixer.
Collapse this transcript
Adding a Full Screen button
00:00One of the nicest features that Flash has for video is the ability to make your
00:04video go full screen.
00:06But this is a two-part process.
00:08I am going to start with first step, which is going to be adding a full screen button.
00:12So it's going to be changing this Skin.
00:15So I am going to select this movie clip. It's the VideoPlayer copy movie clip,
00:20and I am going to double-click on it, and I am going to locate just this
00:23FLVPlayBack Component.
00:25So in my PROPERTIES panel, it says FLVPlayback. I can go ahead and select the
00:31COMPONENT INSPECTOR panel.
00:33This gives me different settings to change this FLVPlayback Component, and the
00:38one I want to focus on is the Skin.
00:40So right here, this is the current one I have selected, SkinOverPlayedMute,
00:46lists out all the buttons, and I can just click on that name, and it opens up
00:50the Select Skin dialog box, and gives me the opportunity to change it.
00:55So this is quite a list of Skins that I can choose from.
00:59There's a quite a few in here, and really, I just want to focus on the ones that say Full.
01:04So this means Full Screen, some of them also say Full Screen, literally, but
01:08these are all the ones that have the Full Button.
01:12So I am just going to go ahead and select one of these.
01:16In fact, I will just Select the SkinOverPlayFullscreen. I am going to keep it simple.
01:21The Play button, Fullscreen Button, this is the one I am going to focus on, I
01:25am going to select OK.
01:27Now if I close my COMPONENT INSPECTOR panel, you can see that this is now
01:31my Full-screen button.
01:33Okay, I am going to go ahead and run this now.
01:34I am going to do a Test Movie.
01:38There's my video. Now I can play it, plays great, my Full-screen button.
01:44If I click on it, actually nothing happens, because I need to do something to
01:49the HTML, because really it's the HTML page that's going to make this video go full screen.
01:56So I need to do into the Publish Settings, and Publish out an HTML page that has
02:01the appropriate code.
02:02So I am going to close this video.swf, and if you recall, this SWF file is
02:09sitting right here, but technically, it gets loaded into this index.swf.
02:14So this is really my main file, and this file is going to publish out both the
02:19SWF and the HTML page.
02:23So I am going to double-click on that, and in this index.fla, here is where I
02:28want to go to File, and I want to go down to my Publish Settings.
02:31Okay, with that selected, notice that I have Flash and HTML checked.
02:37It's going to publish out both of those files, and I'm also given tabs up at the top.
02:42So I am going to select the HTML tab, and notice how it gives me the ability to
02:49change the template, and this is what I want to focus on right here.
02:52I can publish it to different template, but what I want to do is I want to
02:55publish for Flash only, and go ahead and allow for the Full-screen function.
03:01So this will create an HTML page with the Full-screen function already embedded.
03:06I am going to go-ahead select OK, and now I am going to go to File, and I
03:12am going to go down to Publish Preview, and I am going to Publish Preview
03:16the default HTML page.
03:18So I am going to select that.
03:19It shows me the SWF sitting right on an HTML page.
03:25So I am going to go to Video. There is my video. I can go to my different
03:29sections, About. If I go back to Video, notice that I have my Full-screen button, so
03:36let me play it, and then I am going to go Full Screen, and then I am going to
03:40close it and pause it.
03:41(Video playing)
03:52So notice how it went Full-screen.
03:54It gave me the option to hit the Escape key to escape out of Full-screen mode,
03:58but it was done pretty easily, for the most part I just need to make sure I
04:01select a skin with that button in it, and then I need to Add up my Publish
04:05Settings, and then I am good to go.
04:07It provides a great user experience for the end-user, and really shows off all
04:12of your video content quite well.
Collapse this transcript
Creating custom video controls
00:00Flash is very flexible, allowing you to not only at the video controls you want,
00:05but to also customize the look of the controls you add.
00:09So let's take a look at where this is at, currently.
00:11I'm going to double-click on this movie clip, because inside of this movie clip
00:15the Video Player copy movie clip, there is this FLVPlayback COMPONENT.
00:20In my PROPERTIES panel, with it selected, I can open up the COMPONENT INSPECTOR.
00:26So this is where I have been changing the Skin and each time I change the Skin
00:30and Publish out the file, it does generate one of these files.
00:35So just be aware that that does happen. You do need these files if you're using
00:40the SkinOverPlayFullscreen.swf file, for instance.
00:45So quite frankly, I don't need either one of these. In fact, I will just go ahead
00:49and throw them away,
00:50because what I am going to do is I am going to click on the Skin, on the
00:54Magnifying Glass, and I'm not going to use any one of these Skins.
00:58But feel free to peruse them. They might interest you because there's a fair
01:03amount of variety in each one.
01:05I'm just going to select None, because I want to integrate my own buttons.
01:09So with no Skin selected, I am going to select OK, and I am going to close the
01:14COMPONENT INSPECTOR, and as you can tell, the Skin is gone.
01:17Now, I am going to go to Window and open up my COMPONENTS panel,
01:21because in my COMPONENTS panel, under the Video section, there's a huge list of
01:27buttons that I can add.
01:29So now I can add buttons on a case-by-case basis.
01:32So the first thing I am going to do is I am going to create a new layer and I'm
01:35just going to call it video controls.
01:38Now with that layer selected, I can start to drag out the buttons I want to use,
01:43say, for instance, this PlayPauseButton.
01:45The SeekBar I like a lot. I'll just drag that on, and the FullScreenButton is
01:52pretty nice, so I will just put that right down there.
01:54So notice how I can kind of position them in the place that I want, and I can
01:58do a Test Movie, and notice, without adding any code whatsoever, I can go ahead
02:04and use these buttons.
02:06(Video playing)
02:11I can scrub, I can even go full screen. This button would work as well, once I
02:15publish the HTML file.
02:18But in general, everything works out great. I didn't have to add a line of code.
02:22That's very effective,
02:24but notice that I can even zoom in on these buttons and customize them further.
02:29So if I just double-click on this PlayPauseButton, notice how it shows me all of
02:35the states of these buttons.
02:36So the over state, when you rollover the button, the down state is when you click on
02:41it and then the inactive state.
02:44But notice if I just start double- clicking on this, I can really dig down to the
02:48specific elements that make up this button, and notice they're all movie clips.
02:52So I'm already about four levels deep into this, and I have this area selected,
02:59and I can change the color if I want to.
03:02So I'll just change it to red, for instance, and it changes it that way.
03:06I'll click back out to VideoPlayer copy. Notice how it changes this button, as
03:11well as this one, because they share the same background.
03:14So you really have a lot of control when it comes to customizing your buttons,
03:19and what you could end up with is, potentially, another file, so I am going to go
03:24to File Open, and in the Assets folder, in design, I have this
03:30CustomVideoControls.fla. What you could end up with is a file like this.
03:35Since you have spent all that time customizing your buttons, you could save a
03:39separate file and then just use this content.
03:42So right in here, there is those three buttons, and all I am going to do is copy this content.
03:49I am going to go back to my Video.fla, and I will delete them here, but even
03:56though I deleted them on the stage, if I open up my LIBRARY panel, notice they
04:01technically still exist.
04:02So when I go to paste in these other controls, it's asking me "Hey, do you
04:08want to replace the ones that are already in there, or do you not want to replace them?"
04:12Well, I want to replace the ones that are currently in my library, select OK.
04:16Let me zoom out just by hitting Command+Minus, and I can move these buttons
04:21right into place, kind of like that.
04:23But notice how they do have this new look to them, and I can go to Control > Test
04:28Movie, and let's see if these buttons work.
04:32(Video playing)
04:34Yup! they work like a charm.
04:35I can scrub, and again, I can go full screen as soon as I Publish out the
04:39appropriate HTML page.
04:41So notice that Flash really gives you a lot of flexibility in adding the
04:45specific video buttons you want to add,
04:47as well as customizing their look.
Collapse this transcript
Adding functionality to video thumbnails
00:00Now what if you want have a video portfolio?
00:03Well, it's going to be set up in a similar fashion as an image portfolio would be set up,
00:08in that you are going to have thumbnails that serve as buttons that then change
00:13content in the main area.
00:15So that's how this is set up.
00:17I have these thumbnails on the side, and I want them to play the appropriate
00:21video right in here.
00:23So first thing I am going to do is make sure these are buttons.
00:28Currently, they are just movie clips.
00:30So I am just going to click and drag this movie clip into the LIBRARY, and I
00:34convert it to a Symbol, and I am just going to call this vid button.
00:40I am going to make sure it says Button as the Type, select OK.
00:44Same thing for this second thumbnail, vid button, and this is vid button 2. I am
00:49going to make sure the Type is button, select OK, and now they are buttons,
00:55but now I have to give them specific names.
00:59I am going to refer to these names in the ActionScript.
01:02So let me just go ahead and minimize that LIBRARY panel, because
01:05with this first button selected, I am going to go the PROPERTIES panel, and for
01:09the Instance Name, I am going to type in vid1_btn.
01:15So that's the first button's Instance Name.
01:18Second button is going to follow the same format, vid2_btn, just like that.
01:24And now I am going to go ahead and make this first button work.
01:30So vid1 button, in fact, I am going to do a Command+C to copy that. All right.
01:36I do have this empty LAYER down here, so I will just delete that by hitting that
01:40trashcan, and I want to make a new LAYER at the top, and I am just going to call
01:45AS, for ActionScript.
01:47I am going to select that first frame. I am going to open up my Actions panel,
01:53and the first thing I am going to do is just Pin my code by selecting that Push Pin.
01:59Now my code will always stay up, regardless of what I have selected. All right.
02:02So I am going to type in a comment, and I am going to Listen for the buttons to
02:08be clicked on, and then I am going to do something.
02:13If I do a Command+V, there is my vid1_btn.
02:17I need to add an EventListener for this button.
02:22So again, as soon as it highlights, you can hit Return, and it will add it.
02:26Now I can add the Type.
02:28The Type, well, it's going to be MouseEvent.CLICK, so I am listening for the
02:34click of this button, and I am going to add a comma.
02:38So once this is clicked on, I need to go ahead and reference a function.
02:43So the function I am going to make is going to be playvid), parenthesis to close
02:49it, semicolon, and now I can go ahead and create my function, playvid.
02:56It is going to accept a MouseEvent.
02:59And I can kind of tab through, I am just using my arrow keys to select
03:03MouseEvent, and this is the structure for a basic function.
03:08Within these two curly braces, is what it is going to execute when you
03:11click on this button.
03:14So what I need to do is when you click on the button, I want to change the
03:19Source of this video.
03:22Okay, but notice this video is actually inside of a movie clip, so I have just
03:26minimized this ACTIONS panel just by clicking on that gray bar, kind of move it
03:30down out of the way, so I can select this movie clip.
03:35So in order to target this movie clip, I need to give this movie clip an Instance Name.
03:40I am just going to call it myVideoPlayer.
03:45myVideoPlayer, so I am going to do a Command+C to copy that.
03:49I am going to paste it right in my code.
03:52MyVideoPlayer., well, I am just referencing the movie clip, I am not - if I
03:57minimize this again, I am not pointing to that FLV component yet.
04:02So I need to double-click to enter inside of that movie clip.
04:05And I need to select that FLV.
04:08So now I need to give this FLV component an Instance Name as well.
04:13So myFLV, technically, it is the FLV playback component, but I do want to
04:19remember this, in fact, I will copy it, Command+C. Go back to my ACTIONS panel.
04:24I will open that up and then paste it right in there.
04:27So myVideoPlayer.myFLV. I am targeting the right thing. Now, I need to change its Source.
04:33So I will do a period and type in Source and I am going to make it equal to
04:38the appropriate video. All right.
04:40Well, where is that video?
04:42Well let us take a look.
04:43If I go out to my video folder, I can see that this newport.flv is what I want to target.
04:50So again, I am right here. I want to go into the video folder and target that
04:54newport.flv, so let me go back and right within these Quotes, video/newport.flv. All right.
05:03I need to do one more thing, because I want to make sure it plays as well, I can
05:08change the Source, but I am not telling it to play yet.
05:11Well, I am just going to copy this and paste it below, because not only am I
05:16changing the Source, I am also going to tell it to play.
05:22Now, I am going to go ahead and test this, Control>Test Movie, so when I
05:27click on this thumbnail, it's going to change the Source of this file and
05:31then it's going to play it.
05:32(Movie Playing)
05:37Great, works like a charm. In fact, I want to do the same thing for
05:41this thumbnail as well,
05:43but the first thing I need to do is I need to make sure that video exists.
05:47So I am going to go to my Assets folder, into video, and I am going to take this
05:52tahoe.flv, and I am just going to right- click, and Copy it, and I am going to go
05:58ahead and put it in the appropriate folder, right where the newport.flv file is.
06:05So again, it's in the same location, so I can go back into Flash, and I want to
06:10do the same thing for vid2_btn.
06:12So it's really just a matter of copying all this code, Command+C, and
06:17then pasting it below.
06:19Now, I can start changing the Instance Name to vid2_btn, and playvid2, which
06:26calls this function, playvid2, and now I can change the Source to tahoe. It's that easy.
06:33It's just copying that code and pasting it again for the second thumbnail, and
06:38now when I click the second one,
06:39(Video playing)
06:45it plays that video.
06:46I can come back to this first one and play it.
06:48(Video Playing)
06:52So from here, I can add as many thumbnails as I want for however many videos I
06:56have, so you could really start to build out your portfolio.
06:59But again, Flash makes it easy.
07:01It's just a matter of adding EventListeners, just like you would, any
07:05other button.
Collapse this transcript
8. Adding Audio
Adding audio to buttons
00:00Audio is a great way to bring your site to life and add confirmation on tasks,
00:05such as adding rollover and click sounds on buttons and that's what I'd like to
00:10do this main menu is add some audio confirmation.
00:14So when you roll over any one of these, you are going to hear like a highlight
00:17sound and when you click on it, you are going to hear like a button click sound.
00:22So the first thing I need to do is go to File and import my sound.
00:27I am just going to import to my library and in the sound folder, which happens
00:33to be in the Assets folder, go to sound and what I want to do is I want to add
00:39the rollover.mp3 and the clickSwoosh.mp3,
00:45but notice I can actually import all sorts of different sound formats.
00:51So just take a look at this list if you ever want to determine what sound can be imported.
00:56Of course, MP3 is really popular, so that's what I'm using.
01:00Okay, Import to Library and if I minimize the Properties panel, right in there,
01:07you'll see the clickSwoosh and you'll see that rollover.mp3. All right.
01:12I want to add it to all these buttons including this Home button.
01:16So I am going to first double-click to enter inside of the content movie clip
01:21and then I am going to double-click again to enter into this Home button.
01:26So notice right up here at the top in the timeline, I have my various Over,
01:31Down and Hit states.
01:33So what I need to do is I need to create a new layer by clicking the New layer
01:37button and I am just going to type in Sound.
01:40So this is where I want to add my audio and I want to add my audio right in this Over frame.
01:46So what I need to do is I need to right click and I need to insert a keyframe.
01:51So at this point in the state of the button, I want to add that audio track.
01:56Okay, so with that frame selected, I am going to open up the Properties panel
02:00and right underneath Sound, you might need to twirl it down if you don't see it,
02:05I can select the name.
02:06So here it is going to list out all of the audio tracks that I have imported.
02:10Now since this is the Over state, I am going to select rollover.mp3.
02:16Now I am just going to confirm that the Sync is Event.
02:19I can also use Start.
02:21The last thing you want to use is Stream because Stream will not play the audio
02:25track for you, in this particular case.
02:27So I am just going to leave that on Event.
02:30That's looking pretty good.
02:32Maybe for the Down state, I will do the same thing.
02:35I am going to insert a keyframe and on that keyframe,
02:38If I go over to Properties, I can select clickSwoosh, because that is going to
02:43be on the Down state.
02:44It is kind of a click sound with a slight swoosh since this interface turns. All right.
02:51Sync is set to Event and we are looking pretty good. All right.
02:56With that done, I am going to go to Control>Test Movie and if I click on it, you
03:03can hear the sound and when I roll over it, you can hear it activates.
03:07So let me rollover it again.
03:08So you could hear those two sounds.
03:15Now you can play with the volume if you want to as well.
03:17It is just a fine balance as far as getting the sound that you want.
03:21But luckily, if you ever want to edit any of this audio, you can always come in
03:25here and with that frame selected where the audio is,
03:28you can always select this Pencil icon, which allows you to edit the sound envelope.
03:34So here you can raise or lower the volume of that particular sound.
03:38So, all right it is looking good so far.
03:41So, what I want to do is I want to really add those same sounds to other buttons.
03:46So all I am going to do is just go ahead and select those three frames and
03:51right-click and Copy Frames.
03:55Now if go back to the content movie clip, I can double-click on the About movie
03:59clip and it's the same process of adding a layer called Sound and then right in
04:05here, I can go ahead and Paste Frames, just like that.
04:11So I am just going to repeat this process by going into that particular button,
04:16creating a new layer, selecting all of those frames and pasting them in.
04:22And the last one, I am going to double- click on portfolio, create a new layer,
04:29select all those frames.
04:31Notice when I paste it in, it is actually going to change the name of that layer as well.
04:35Paste Frames, it changes it to sound.
04:38I like how it does that.
04:39Let's go to Control>Test Movie.
04:41Again, I am just going to be quiet for a second and so you can listen to these
04:46various button sounds.
04:48(Button sounds)
05:06Looks like everything is working. This does get hung up a little bit and I am going
05:10to talk about that later how to kind of take care of the little transitions
05:13that might get stuck.
05:14But in general, you can hear all the audio and I can get as elaborate as I want
05:19with the audio, but I like how I am able to integrate audio into the user
05:24experience to give the users confirmation as to what they are doing.
Collapse this transcript
Adding audio to dynamically created buttons
00:00One issue you might run into is how to add sound to buttons that are created
00:05with ActionScript and that's what's going on here with this portfolio, because
00:10I want to add just some click sounds when the user clicks on any one of these portfolio items.
00:17So that's what I want to do.
00:18I am going to close this SWF and I am going to go to the Timeline.
00:22So within this portfolio.fla, I need to open up that ActionScript layer,
00:29this very first frame.
00:31I am going to go to Window>Actions.
00:33So here's where all my code is written and right down here when you click on
00:39any one of the images, it's going to fire off this function. This is where I
00:43need to add my audio,
00:46but I am going to start off at the very top.
00:48Right up here at the top, I am just going to do two forward slashes so I can add
00:52a comment and I am just going to type in SOUND.
00:56This is where my sound item is going to go.
00:59It's going to be a variable, so var clickSound is what I am going to make.
01:04I'm telling Flash that it's a sound and here's where I create a new sound
01:13from the Sound class. All right.
01:16So here's where I create this variable called clickSound from this Sound class.
01:22But there's nothing in it yet.
01:24I actually need to do a URL request and I need to go out and grab that sound and
01:30then put it inside of this variable.
01:32So what I am going to do is I am going to go out to my desktop into my Assets
01:38folder. I am going to click on sound and this is the file that I want to play.
01:42So I am going to copy this click.mp3 and I am going to move it into the folder
01:48that I am working in.
01:50So I am actually going to create a new folder just so I can keep everything
01:53organized and I am going to call this sound.
01:56And in this folder, that's where I am going to paste that click.mp3.
02:00So again, this is the portfolio.fla that I'm working in.
02:04So If I go back to it, for new sound what I need to do is I need to type in new
02:09URLRequest, an open parenthesis, open quote, sound, forward slash, click.
02:17So it's in the sound folder, click.mp3 is what I am after.
02:22I need to close that quote and close that parenthesis, so make sure you have two
02:26down here at the end.
02:28But in essence, what's happening is it's taking and grabbing that mp3 and putting
02:32it right in this variable.
02:34So I am actually going to copy this variable, scroll down to where I want to use
02:39it, right inside of this function.
02:41So about Line 52 right now, I want to paste in that clickSound variable.
02:47All I need to do is type in a period and type Play and open and close
02:53parentheses. End it with a semicolon. All right.
02:57So that's all I need to do, but let's go ahead and test this out.
03:01Now as I click on these buttons, you should hear a click sound. Great!
03:12It works like a charm, works great and what's happening is I've made this sound
03:18variable that grabs this click.mp3.
03:22So I do need to remember to make sure I always have this click.mp3 in this sound
03:28folder in relation to where the SWF file is.
03:32So if I upload this site to a web server, I need to make sure this mp3 travels with it.
03:37But it's pretty easy to implement, took me two lines of code and works great.
Collapse this transcript
9. Completing the Web Site
Applying professional transitions
00:00So as you are developing but before you complete your site, you want to give
00:05your site a quick review just to see how everything is functioning, and
00:09currently, it seems to be functioning pretty well.
00:12I can click on the About section and what I do see is this content actually
00:17comes up before the transition finishes.
00:20Not only that, if I click on video, it does get stuck sometimes.
00:25And what's going on there is Flash is trying to do too much at once.
00:30It's trying to move this big background and then it's trying to load in this video.
00:34So I really want to have an orderly process for these transitions.
00:40So really, when the transition completes or the tween completes, that's when I
00:45want the content to load in. All right.
00:49So I have the index.fla file open and I am going to select that first frame
00:55there in the AS layer.
00:56I am going to open up my Actions panel and I am going to move this up a touch,
01:00and pin my code down there at the bottom, just by pressing that Pushpin.
01:04Now I can go ahead and take a look at this, because what's going on in is I have
01:10three tweens that are making this move and rotate, and I want these tweens to
01:15happen and then even finish before it loads into that particular section.
01:21So I need to go ahead and implement a complete of the tween.
01:24So that's what I need to listen for.
01:27It's all about creating a new EventListener.
01:30I have my rotate tween.
01:32I am just going to copy that, Command+C, Command+V, because I want to listen for
01:37this tween variable.
01:39And I am going to add an EventListener to it.
01:41And what I am going to listen for is a TweenEvent, and I am going to listen for
01:47the MOTION_FINISH, so you can see all these various things, I can listen for.
01:53I want to listen for the MOTION_FINISH.
01:56Select that, comma, and I can go ahead and type in donePlaying.
02:01That's going to be the function name that I am about to create.
02:05Okay, so the first thing I do before I even get into that function is I am going
02:09to make reference to this.
02:10I have this TweenEvent.
02:12Now this is actually a class that I need, so there is code that I need in
02:18order to make this work.
02:20So if I scroll up to the top, notice that I have imported tween, I have
02:25imported some easing, some other things, but I haven't imported that particular TweenEvent.
02:31So I am going to type in import fl. transitions and I am going to type in TweenEvent.
02:42So I am telling Flash to go get all this code to make this MOTION_FINISH work.
02:48Now that that's done, I can create this donePlaying function.
02:52So function donePlaying, TweenEvent, the basic structure of a function, just like that.
03:07Now I need to just move this sectionLoader.source right into this function.
03:13So I should have two curly braces down here. In fact, I'll remove that line.
03:17And again, what you are going to want to do anytime you add a function or add
03:21these curly braces is select the Autoformat button and it will line everything up.
03:25All right.
03:26It's looking pretty good.
03:28So when the rotation finishes, it's going to go ahead and fire off this
03:34donePlaying function.
03:35Let's do a Test Movie.
03:40So if I click About, not until this rest into place, do I see this content.
03:47But let's take a look at the issue it brings up, because if I click
03:51another section, such as Video, that About content stays up until that
03:59Video content loads.
04:01So I need to remove content for a short period of time during this transition.
04:08So right up here in the same moveContent function below these trace statements,
04:13I need to go ahead and have a sectionLoader.source and I am going to make this
04:20equal to absolutely nothing.
04:22So I'll just type a null.
04:25So this, all this is doing is kicking out anything that's in the sectionLoader,
04:32until the transition is done and then it will load in the appropriate content.
04:37So I am going to go to Control>Test Movie, in the About section, just like
04:42that, content loads in, if I click Video, this content should disappear, and
04:50sure enough, it does.
04:51So everything is working out pretty well.
04:54This content loads in when the transition has finished.
04:58Notice it will also happen for the portfolio section.
05:02So again, establishing an order of priority for these transitions is really
05:07going to help the performance of your Flash website.
05:10And what I want to do next is even add some other transitions that are really
05:14going to bring my site to life.
05:16For instance, if I just replay this from the start, I'll just do a Test Movie,
05:22let's take a look at the background.
05:25It just kind of appears.
05:26In fact, I see this flash of blue and then all of a sudden I'm hit with this
05:29pretty striking image.
05:31So I definitely want a smoother transition, as opposed to feeling like the user
05:35is getting slapped in the face, I am going to give it a little fade in.
05:39Okay, so right up here at the top, at least near the top, this is where I am
05:44loading in the random background, from one to ten.
05:47And I am just going to remove some of those line breaks, kind of nest everything
05:51together, because what I want to do is I want to load in that random image and
05:55once that image is loaded in, I want to go ahead and do a tween, just kind of
06:01like I am doing down here.
06:03Okay, so again, it's going to be adding another EventListener.
06:06So you can see I'm really using EventListeners a lot here.
06:09I am going to type in background image and I am going to add an EventListener to
06:18this background, and I am going to listen for the Event.COMPLETE.
06:23So once the image is loaded in, once it's completed, I am going to type in
06:29fadeIn, because that's what I want to happen.
06:33So that's going to be my function name, fadeIn, capital E for Event, just like that.
06:43Typical structure for a function and that's looking pretty good.
06:46So I'll even type in a comment.
06:55That's what I want to happen right here.
06:56When it's loaded, go ahead and fadeIn the image.
06:59So now that I have this function in place, I can go ahead and use a tween.
07:06So I am going to use a similar tween to this.
07:10In fact, just to help me out, I am going to select this tween and I am going to
07:14copy it and paste it up here.
07:17Okay, so instead of myxTween, it's really going to be changing the Alpha.
07:23Alpha is the transparency of an item.
07:27So var myAlphaTween.
07:30Well, don't change the content_mc.
07:31Change the background mc.
07:33So I'll copy and paste that right in there, and alpha is the property I want to
07:39change, right down here, I don't want to refer to the position at all.
07:43In fact, I want to refer to a number.
07:45I am going to start at zero.
07:48Zero means it's not visible at all.
07:51So it's 100% transparent.
07:53I want to go from totally transparent to opaque, which is 1.
07:59Now I might want varying degrees of transparency.
08:03So if I want this at about 80% and I kind of do because the background is pretty
08:08bright, well, I'll put .8 in there and that's the equivalent of doing 80%.
08:13So that's looking pretty good.
08:15It is going to happen over the course of one second.
08:18So I am going to just click that gray bar to remove my Actions panel, nested up at the top.
08:26Another thing I want to do is I really don't want the background to be blue.
08:32What I need to do is just go ahead and change my Document properties.
08:35So I am going to Modify up to Documents and I am going to change the Background
08:41color because I always want this page to start on black.
08:45So black is selected. I am going to select OK.
08:48Now if I expand open the Actions panel, that image is going to fade in as soon
08:53as the image gets loaded.
08:55So let's try this out. Test Movie.
08:58It fades in nice and smooth.
09:00I really like that. In fact, let's do it one more time.
09:03I can see it fade in.
09:07Now not only do you want to review and prioritize how your content gets
09:10loaded, you can also, obviously, add some very nice transitions to
09:15other content you'd like, such as the images in the portfolio section or maybe
09:20fade in the About section.
09:22Either way, it really does add a nice professional look to your website.
Collapse this transcript
Creating a preloader
00:00One of the final things you're going to want to do with your site is make
00:04sure you're using preloaders where you need them.
00:06Well, what is a preloader?
00:08It's basically an indicator that tells the user what's going on.
00:12Usually, it's a percentage preloader that tells the user how much has been downloaded.
00:17So really you just want to review your content, determine the larger items, say,
00:22for instance, I am going to go into the portfolio section and just take a look at these images.
00:28Now I could actually put some pretty large images in here. Currently, these ones
00:32are fairly small, but as I add to my site, I could have some very large images.
00:37So that's where I'm going to use the portfolio.fla to add my preloader to.
00:42So I'm going to double-click on the portfolio.fla and I'm going to go that first
00:48frame in the AS layer.
00:50Then I am going to go to Window and open up the Actions panel.
00:53Now I'm going to go ahead and pin my code.
00:56So it doesn't move in case I select something else. I'll move this up.
01:02Now just to kind of review, I do have this very large loadThumbnail function and
01:08in this loadThumbnail function, it creates the thumbnails and then also has this
01:13EventListener that listens for the Click.
01:16So this is where I want to put my preloader when they click on the thumbnail.
01:21I then want to update a text field letting the user know that the image is being loaded.
01:29What I want to target is this largeUILoader.
01:32That's what I want to reference.
01:34So I'm just going to copy this name and add a comment, Add Preloader to images.
01:47largeUILoader, well, just like most things in this code, it's actually an
01:52EventListener so I'm going to add an EventListener and this EventListener is
02:01going to be a ProgressEvent.PROGRESS is going to be the specific method that I'm
02:10going to go ahead and listen for.
02:12So I'm going to select PROGRESS and as pieces of this image gets downloaded,
02:19the Progress is going to update and the Progress is really going to fire off a
02:25function, so I'll just type in largeImagePreloader as that function name.
02:33So as bits are downloaded, fire off this largeImagePreloader.
02:37So I'll copy that name, just beneath this EventListener, I'm going to go ahead
02:42and type in function largeImagePreloader.
02:47It's going to be an event: ProgressEvent, there it is.
02:53As soon as it highlights, you can hit Enter, but I need to make sure this and
02:57this matches up and then the typical structure of a function is what I'll add.
03:05Between these two curly braces is where I want to put my preloader.
03:10So maybe the one I want to try initially is a trace.
03:14So in this trace statement, just for my own testing purposes, I'm going to see how
03:18often this Progress is firing off.
03:21In fact, I'll just type in loading.
03:22I'm going to go ahead and select auto format just to make sure everything is
03:29lined up and everything within this function is going to fire off at the
03:32Progress of this JPEG that's being downloaded.
03:36So I went to Control>Test Movie, here are my images and in order to simulate
03:41download, what you need to do is go under View, and you should first check
03:47your Download Settings.
03:49Now I have mine set to 56K. I'm not really targeting 56K modems, but just to
03:55show you the progress, you probably want to test DSL.
03:59But as soon as you have the appropriate one checked, you can Simulate Download.
04:03So select that and let's give it a second.
04:06It might take a little longer since it's a 56K modem and that makes
04:11you appreciate DSL.
04:12But this is a good test, because it's slowly going to try to load in all of
04:17these thumbnails and there are all my images.
04:23So if I select any one of these, I click on it in my Output panel, you
04:28should see it loading.
04:29In fact, I'll just scoot this over a touch.
04:32Click, you can see loading.
04:33It gets fired off, actually many, many, many times.
04:37Now I am going to just go ahead and click in the Output panel.
04:39just to scroll through and show you that how many times it's being
04:43printed out, plenty of times.
04:45So let's go back to my code. I am going to go to Window>Actions and right in
04:51here, instead of my trace statement, I'm going to type in the code I need.
04:55So I want to create a variable called percent and it's going to be a Number.
05:02This number is going to be equal to the event.bytesLoaded, divided by
05:12the event.bytesTotal.
05:18Event.bytesLoaded is this event is basically what's called.
05:22So it's going to be that largeImage is what event is referring to.
05:25So it's going to take the bytesLoaded and divide it by the bytesTotal.
05:29It actually returns a very small integer, so what I need to do is I need to multiply it.
05:34In fact, since I want this to be a percentage, I'm going to wrap this in
05:38parentheses and from there, what I can do is within those parentheses I can
05:44multiply it by 100, because these will only return zero to one.
05:49This will give me more of a realistic percentage number, but it's not going to
05:52be a whole number either.
05:54If that's the case, what I need to do is type in Math.round.
05:59This will round this non-whole number up or down to the nearest whole number and
06:07put it within this percent variable.
06:10Now I can go ahead and use that percent and I could do another trace statement,
06:15but what I want to do is I want to put it inside of a text field.
06:19So I'm going to go ahead and select the Text tool and in the Timeline panel, move
06:25that out of the way, I'll expand this out a little bit.
06:30Underneath mainimage, I'm going to create a New layer and this is just going to
06:35be called preloader and now let me go ahead and turn off that mainimage.
06:40But basically where it was is where I want to go ahead and a text field.
06:45So there's my text field. I'm going to kind of adjust it accordingly and with
06:50that text field selected, I want to look in my Properties panel and make sure
06:54it's set to Dynamic Text.
06:56You also want to make sure that you have the Color that you want, the Size of
07:01the font that you want as well.
07:03Lastly, I need to give it an Instance name of percent_txt, because it is a text
07:11field and I will copy that name.
07:14Now I'm going to go back into my code and right within this function, I can paste
07:20percent_txt and I can type in text is equal to percent right here,
07:26That's what I want.
07:29And I don't want to just show those numbers. I want to add, within the quotes, a percentage sign.
07:35All right. Now that is looking pretty good.
07:37In fact, I'll just end with a semicolon.
07:40It's going to go ahead and give me the percentage and put that Percentage sign
07:44right next to it and I can go ahead and test this out.
07:48Now so you'll notice that this actually is misspelled, so I need to say percent. All right.
07:55That should take care of it.
07:56I'm going to a Test Movie.
07:57There are my images.
08:00Now it's not tracing out anything, because what I want to do is I actually want
08:04to see the text field in the center there.
08:06So I'm going to change my Download Settings to DSL and I am going to go to
08:11View>Simulate Download.
08:14So I'm going to select this and you're going to see the images load down here.
08:21With them loaded, I'm going to go ahead and select an image and you can see the
08:26percentage working, just like that.
08:31So it's fairly straightforward because it is an EventListener and we're getting
08:36used to EventListeners.
08:37It's just a matter of getting the bytesLoaded divided by the bytesTotal and
08:42making sure the bytesLoaded is multiplied as well.
08:45But I can go ahead and use this, I can copy it, I can paste it into any of the
08:49other sections for any other item I want to add a preloader to and it will
08:54work just fine.
Collapse this transcript
Publishing a web site
00:00The last step in creating a portfolio site is publishing it, which is a
00:04very exciting part of the process, because it's my chance to show the site to the world.
00:10So I actually want to start in this index.fla file.
00:13I'm going to open it up, in Flash of course, and I'm going to just go to
00:18the Publish Settings.
00:20So File>Publish Settings.
00:23In the Publish Settings dialog box, you can see that I have Flash checked, I have
00:27HTML checked and then I can also publish out to these different mediums.
00:31But again, this is a website, so I'm going to make sure these two are checked.
00:36Let's take a look at the details of each one of these.
00:39I'll leave the file name alone.
00:41I'm going to click on the Flash tab first.
00:43So just to review, this site does require the Flash 10 Player and now the Flash
00:4910 Player, most users have it, I think it's about 95%, if not more.
00:55So you definitely covered as far as the Flash Player version that they need.
00:59Now one thing I do want to point out is the Audio event.
01:03If your audio sounds degraded in any way, you might want to come in here and set
01:08the audio to something higher, so I'll keep it at MP3, but I might want to up to
01:14the Bit rate to as high as say CD-quality.
01:19Something like that would be a good idea to do. Other than that, I'm going to make
01:23sure Compress Movie is selected and everything else is looking good.
01:27Let me go over to the HTML tab and I can take a look at what I have available.
01:33the Template, I'm going to use Flash Only - Allow Full Screen, because I do have
01:38a Video section that has those Full Screen buttons.
01:42So I'm going to make sure that's selected.
01:45As for the rest of this, it's pretty typical. I want the quality to be high and
01:50really, for the most part, you don't need to change any of these values.
01:54So really, all you need to do from there is click the Publish button.
01:59What that generates, as I select OK and minimize Flash, it will create this
02:05HTML and this SWF file.
02:09So let's take a look at it.
02:10I'll just double-click on this HTML and it'll open up in a browser, my website.
02:17So here it is and I can go ahead and navigate through it and you pretty much can
02:23see what it's generated.
02:25Now it's loading up different content as well, this about.swf.
02:29So let me close my browser, because I just do want to point out that I have to
02:34make sure all of these files right here, including these folders, all need to be
02:40uploaded with my site.
02:43The only things that don't get uploaded are, of course, these files, these working
02:48files, the FLA files. So that's it.
02:51That's all you need to do.
02:52Once you have everything published, you can go ahead and share your site
02:55with the world.
Collapse this transcript
10. Bonus Sites
Reviewing the "corporate" Flash site
00:00Also in the Exercise Files folder is a BonusSites folder.
00:05So, there are two sites in here.
00:07I'm going to review the Corporate site and I'm just going to double-click on this index.fla.
00:12So, with this file open, I'm going to go to Window and open up the Actions panel
00:17and I'm going to make sure that this first frame is selected.
00:20I'm going to focus on the area that has been changed and if you take a look at
00:24this function, something has been changed in here.
00:27I'm curious as to whether you know which direction this content is moving.
00:32Well if you'd guess x, you'd be right because it is going to move horizontally, so
00:36back-and-forth this content is going to move.
00:39So, let's go ahead and take a look at it. Notice that this moveContent only
00:42accepts two parameters.
00:44This first one being a number and then either null for the home information or
00:49an swf file, depending of the section.
00:51So, I'm going to go to Control>Test Movie and as I roll over each one, you do see
00:57a little bit of a distortion going on, so just an added effect.
01:01But I can go ahead and click on Video.
01:05That's going to shift, again, horizontally and I can play that video.
01:12I can click on the About section that will shift again horizontally. We are just
01:15moving back-and-forth, displays the content, just some different options for you
01:19and then I can click Portfolio and then it will load in the Portfolio.
01:23In this case, the Portfolio scrollbar is vertical, so this scroll pane has been
01:29adjusted and if I select an image, it will load in.
01:32So just some different options that you can do.
01:35Feel free to take this site and learn from it and modify all you want.
Collapse this transcript
Reviewing the "artistic" Flash site
00:00In the Exercise Files folder, there's a BonusSites folder and in there is also an Artistic site.
00:07I'm going to just double- click on this index.fla.
00:09So, if you'll notice one this screen here, look at all these
00:13UILoader components.
00:15Well, if you could imagine, different images are being loaded into every
00:19single one of these.
00:20And again, all those images are external.
00:22There is another little interesting thing that's going on in here.
00:25If I select that first frame, go to Window, down to Actions, I can open up this code.
00:30All right. It might seem like a lot, but let's take a look at this loadContent function,
00:37because not only is it adjusting the Position for each the X and Y, but it's
00:43also going to scale the context,
00:45its X and Y Scale, and that's being used right in here.
00:50So, I'm going to close that and let's take a look at what this looks like.
00:54I'm going to go Control>Test Movie, content loads in, I'll click on Video,
01:03scales up and then the videos load and I can play them.
01:09Now I can even jump to the About section, just by clicking there. It'll shift to
01:14the About and you can see that content and then even Portfolio.
01:19So, look at how this content has scaled down, allowing for a lot of room for
01:24all of these images.
01:25So, just some other options that you can do with the same code that I've
01:30covered, just using it in a different way and modifying different properties.
Collapse this transcript
Conclusion
Goodbye
00:00Thank you so much for watching.
00:01I hope you've enjoyed everything that you seen and hopefully I'll see your
00:05work online some time.
00:06So, feel free to send me any website that you might have created based on
00:10what you've learned.
Collapse this transcript


Suggested courses to watch next:

Publishing Video with the Flash Platform (2h 12m)
Lisa Larson-Kelley


Create an Online Portfolio with WordPress (3h 13m)
Morten Rand-Hendriksen


Are you sure you want to delete this bookmark?

cancel

Bookmark this Tutorial

Name

Description

{0} characters left

Tags

Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading
cancel

bookmark this course

{0} characters left Separate tags with a space. Use quotes around multi-word tags. Suggested Tags:
loading

Error:

go to playlists »

Create new playlist

name:
description:
save cancel

You must be a lynda.com member to watch this video.

Every course in the lynda.com library contains free videos that let you assess the quality of our tutorials before you subscribe—just click on the blue links to watch them. Become a member to access all 98,648 instructional videos.

start free trial learn more

If you are already an active lynda.com member, please log in to access the lynda.com library.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Get access to all lynda.com videos

You are currently signed into your admin account, which doesn't let you view lynda.com videos. For full access to the lynda.com library, log in through iplogin.lynda.com, or sign in through your organization's portal. You may also request a user account by calling 1 1 (888) 335-9632 or emailing us at cs@lynda.com.

Access to lynda.com videos

Your organization has a limited access membership to the lynda.com library that allows access to only a specific, limited selection of courses.

You don't have access to this video.

You're logged in as an account administrator, but your membership is not active.

Contact a Training Solutions Advisor at 1 (888) 335-9632.

How to access this video.

If this course is one of your five classes, then your class currently isn't in session.

If you want to watch this video and it is not part of your class, upgrade your membership for unlimited access to the full library of 1,896 courses anytime, anywhere.

learn more upgrade

You can always watch the free content included in every course.

Questions? Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com.

You don't have access to this video.

You're logged in as an account administrator, but your membership is no longer active. You can still access reports and account information.

To reactivate your account, contact a Training Solutions Advisor at 1 1 (888) 335-9632.

Need help accessing this video?

You can't access this video from your master administrator account.

Call Customer Service at 1 1 (888) 335-9632 or email cs@lynda.com for help accessing this video.


site feedback

Thanks for signing up.

We’ll send you a confirmation email shortly.


By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

By signing up, you’ll receive about four emails per month, including

We’ll only use your email address to send you these mailings.

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked