- Flash Guide 2006
- Welcome to the New Flash Reference Guide
- Flash Design Guide
- Introduction To Flash
- Working with the Authoring Tool
- Working with Templates
- FreeHand for the Power User
- Creating Animation with Fireworks
- Creating Animation in Flash
- Animating Text
- Working With Layers and Keyframes
- Working With Tweens
- Quickly Add Keyframes to Tweens
- Using Animation Paths
- Using Flash's Onion Skinning Tools
- Publishing Your Animation
- Preloading for Non-Programmers
- Drawing in Flash
- Using the Library
- Organizing Animations With Storyboards
- Working With Masks
- Making 2D Look 3D
- Working With Text
- Working With Input Text Fields
- Working With Dynamic Text
- Working with Text: Advanced Text Treatment With CSS
- Working With Text: Embedding Fonts
- Flash Interactive Developer Guide
- What is an Interactive Developer?
- Creating Flash Projects
- Using Form Applications
- Working with Form Components
- Setting up a Movie for Design and Animation
- Setting up a Movie for Programming
- Working with Components
- ActionScript Fundamentals
- Intro to Working With Arrays
- Understanding The Three Types of Arrays
- Control Data Stored in Arrays
- The Eolas Solution
- Intro to Flash Player 9
- Working with Strings
- Creating ActionScript Transitions
- Working with Boolean Objects in ActionScript
- Optimizing Delivery
- Working with Numbers in ActionScript
- Working with the Number Class
- Flash Professional 9 Preview
- Adobe Takes ActionScript Open Source
- Flash Rich Media Guide
- Pros and Cons of Flash 8 Video
- Using SMIL in Flash Video 8
- Stream an MP3 Audio File to Your Flash Movie
- Flash 8
- Introduction to Flash 8
- Advanced Text Rendering
- Using BitmapData Class in Your ActionScript
- The CacheAsBitmap Property
- Bitmap Rendering Improvements and Blend Modes
- Using The ExternalInterface Class
- Using Filters
- Downloading and Uploading Files with ActionScript
- Runtime Support for GIF and PNG Files
- Garbage Collection in Flash 8
- Using Enhanced Gradients
- Using Scale 9
- Stroke Enhancements in Flash 8
- Video Support in Flash 8
- How to Create a Slideshow
- Creating Dynamic Text in Flash
- Flash 3-D–Taking Flash to the Third Dimension!
- Object Collision Detection with Flash
- Create a Quiz With The Flash Quiz Template
- Working with Flash
- Uses for Flash
- Beyond Flash
- Flash Reference Guide
- Informit Articles and Sample Chapters
- Books
- Online Resources
- Blogs and Discussion
- Tools and Downloads
- Summary
- Flash MX Interface
- Welcome to Flash: the Designers' and Developers' Tool
- Using the Stage
- Panels, Panels Everywhere
- Using the Tools Pane
- Using the Property Inspector
- Using the Timeline Panel
- Using the Library
- Adding Interaction through the Actions Panel
- Integrating with Studio MX
- Saving and Publishing Flash Movies
- Informit Articles and Sample Chapters
- Books
- Online Resources
- Summary
- Drawing in Flash
- Shape Tools
- Applying Color
- Informit Articles and Sample Chapters
- Tools and Downloads
- Summary
- Flash Bitmaps
- Importing Bitmaps
- Exporting Bitmap Images
- Converting Bitmap Images to Vector Illustrations
- Informit Articles and Sample Chapters
- Online Resources
- Tools and Downloads
- Summary
- Flash Text and Text Fields
- Text Types
- Input Text
- Online Resources
- Tools and Downloads
- Summary
- Using the Library
- Library Organization
- Creating Instances
- Informit Articles and Sample Chapters
- Books
- Online Resources
- Summary
- Flash Animation
- Controlling Time
- Keyframe Animation
- Tweening
- Text Animation with Flash
- Informit Articles and Sample Chapters
- Books
- Online Resources
- Summary
- Flash Audio
- Using Audio in Flash
- Importing
- Linking to MP3
- Publishing Audio
- Streaming MP3 from the Flash Communication Server
- Informit Articles and Sample Chapters
- Online Resources
- Summary
- Video in Flash
- Video
- Flash Video
- Spark Codec
- Exporting Video
- Informit Articles and Sample Chapters
- Blog and Discussion
- Summary
- Flash Components
- Attaching Components to Movies
- Creating a Component
- Informit Articles and Sample Chapters
- Tools and Downloads
- Summary
- Exporting and Optimization
- Connecting Flash to the Internet
- Loading SWF Movies
- Sharing Fonts Between Movies
- Reusing Your ActionScripts
- Using Third-Party Tools
- Informit Articles and Sample Chapters
- Online Resources
- Tools and Downloads
- Summary
- Introduction to Design in Flash
- Introduction to Design
- Fundamental Design Concepts
- Breaking Up the Screen
- Branding
- Adding Forms to Movies
- Developing with ActionScript
- Introduction to Programming within Flash MX 2004
- Using ActionScript to Extend the Functionality of Flash
- ActionScript Fundamentals
- Using the Actions Panel
- Using the Reference Panel
- Rapidly Adding ActionScript with the Behaviors Panel
- Event Handling within ActionScript
- Timeline Events
- Triggering Events through User Interaction
- Flash MX 2004 Pro
- Summary
- Creating Interactive Movies
- Giving Users a Choice
- What it All Comes Down to
- Summary
- Testing your Flash Movies
- Naming Conventions
- Syntax Checker
- Testing your movies
- Summary
- Debugging
- Using the "Debugger"
- Reviewing ActionScript Error Codes
- Summary
- Using ActionScript to Control Your Movies
- Setting Up Your Movies for Interaction
- Making Movie Clips Behave Like Buttons
- Controlling Multiple Movie Clips
- Applying Different Types of Events to a Movie Clip
- Summary
- Using ActionScript to Control Text
- How ActionScript Can Control Text
- Using Cascading Style Sheets within Flash MX 2004 Dynamic Text Boxes
- Applying CSS formatting with ActionScript
- Where Do You Go Now?
- The Differences Between ActionScript 1 and ActionScript 2
- Working with Classes
- Which Version of the Flash Player should you use?
- What’s Next?
- Using Pre-Built Classes In Flash MX 2004
- Using a Class in ActionScript
- The List of Core Classes
- Flash Player-Specific Classes
- Summary
- Creating Your Own Classes
- Creating a Custom Class
- Working with External Data in Flash
- Why Use XML in Flash?
- Integrating Flash and XML
- Visual Elements
- Adding the ActionScript
- Future Shock
- Using Components
- Begin Using Components
- Building an Application with Components
- Gluing Components Together with ActionScript
- Summary
- Informit Articles and Sample Chapters
- Books and e-Books
- Online Resources
- Rich Internet Applications
- Introduction to Rich Internet Applications
- Why Use Flash for Building Application Solutions?
- Building Applications with Flash
- Getting Started
- Using Flash Variables
- Working with Parameters in the Object and Embed HTML Tags
- Linking data with Flashvars
- Getting Data Into Flash: Loading External SWF and JPG Files
- Why You Should Separate Your Files
- Loading Movies into Levels and Target Movie Clips
- Summary
- Loading SWF and JPG Images
- Working With XML: What is XML, and How Does it Relate to Flash?
- A Brief History of XML
- Why Structuring Your Data is Always a Good Thing
- How XML Came to Flash
- Summary
- Working with XML: Good XML vs. Bad XML
- Good Places to Start
- Writing Good XML
- XML Tools
- The Next Step - Using XML in your Flash Applications
- Working with XML: Loading XML into Flash
- Integrating Flash and XML
- Visual Elements
- ActionScript
- Future Shock
- Working with XML — Dynamically Building XML with .NET, ColdFusion, Java, and PHP
- ColdFusion
- .NET
- Java
- PHP
- Summary
- Working with XML — Web Services
- SOAP Support in Flash MX 2004
- Using Components to Bind Web Services into your Applications
- Summary
- Working with Data — Working with XML
- XML In Flash
- Writing XML In Flash
- Building Trees of Data with XML
- Working with Data: Pushing Data back to the Server with Load Vars
- Setting up the Database
- Writing the VB.NET Code
- Creating the Flash Movie
- Working with Data: Leveraging Persistent Connections
- Using XMLSocket Connections
- XMLSocket Server
- XMLSocket Security
- XMLSocket Class in Flash
- Creating a Pong Game with an XMLSocket Server
- Summary
- Flash Remoting
- What is Flash Remoting?
- Using Flash Remoting
- The Future of Flash Remoting
- Flash Remoting Links
- Working with Data: Macromedia Flex Presentation Server
- What Problem Does Flex Presentation Server Address?
- How does Flex work?
- Coding and Building Flex Applications
- Building Rich Internet Applications: Connecting Flash to a Database
- Using FlashVars
- Using LoadVars
- Loading XML
- Consuming a Web Service
- Live data connections with XMLSocket Connections
- Building Rich Internet Applications: Planning, Planning, Planning
- A Simple Plan
- Tools You Can Use
- Applying a Discipline
- Building Rich Internet Applications: Design Counts
- Do Not Be Afraid to Ask For Help
- What if You Do Not Have a Ben To Call
- Building Rich Internet Applications: Beyond the Movie Clip
- UI Components
- Data Components
- Media Components
- Manager Components
- Screen Components
- Building Rich Internet Applications: Using Macromedia Central
- What Central is All About
- Who is Using Central?
- Developing for Macromedia Central
- Next Steps You Need to Take
- Building Rich Internet Applications: Using Macromedia Flex
- Authoring with Flex
- Publishing with Flex
- Presenting the Solution: Delivering Flash Applications to the Web
- Flash's own Publishing Tools
- Using Dreamweaver
- Writing your Own HTML
- Presenting the Solution: Delivering Flash Over Non-PC Devices
- Using Macromedia's Flash Lite
- Programming for Flash Lite
- FlashCast
- Informit Articles and Sample Chapters
- Books and e-Books
- Flash for Designers: Rich Media Production
- Graphic Control in Flash
- Drawing in Flash
- Importing Vector Art
- Importing Raster
- Scripting Images
- Introduction to the Rich Media Production
- Using Video, Audio and Images in your Flash Movies
- Using SWF Flash Movies
- Using JPEG Images
- MP3 Sound Files
- Flash Video
- Using Components to Build Rich Media Solutions
- Using the Loader Component
- Using the Media Components
- Controlling Components with ActionScript
- Controlling the Loader Component
- Media Components
- Using Audio in Flash
- Linking to MP3
- ActionScript-Controlled Audio
- Volume Control
- Publishing Audio
- Summary
- Video in Flash
- Working with Video
- Controlling Video with Components
- Exporting Video
- Summary
- Choosing Which Version of Flash Communication Server to Use
- Server Requirements
- Installation
- Running Communication Server on Different OS Platforms
- Pitfalls to Watch for
- Summary
- Streaming Video
- Live Video
- Broadcast Video on Demand
- Flash Video Components
- The Communication Server MX Server Code for the VideoPlayBack Component
- Record Video with VideoRecord Communication Component
- Create A Video Conference
- Examining the VideoConferencing Component
- The Communication Server MX Server Code for the VideoConferencing Component
- Summary
- Using the Microphone and Camera Core Classes
- Microphone
- Camera
- Constructing Large Applications That Leverage Video and Audio
- Configuring the Server
- Creating the Movie
- Broadcasting
- Summary
- Informit Articles and Sample Chapters
- Books and e-Books
- Matthew's Predictions for 2006
- Matthew's Favorite Flash Books
- Matthew's Favorite Flash Web Resources
- Macromedia as Part of Adobe
- First Look: Flash Player 8
- First, the Facts
- What Macromedia Brings to the Table
- What Adobe Brings to the Table
- What the Two Companies Can Do for Each Other
- A Brief History of Flash
In this section of the guide, I’ll explain how to use ActionScript to both add content and change text styles dynamically.
Working With External Files
For this tutorial, you’ll need to begin working with external files, which are files that are used by Flash but not included in the Flash movie itself. By using external files, you can share the balance of your final movie over several files and better control the final size of the movie by only delivering the files you need when you need them. This is especially important when working with very large files.
For this tutorial, I’m using the following external files:
- Sample.html
- Sample.jpg
- Sample.gif
- Sample.png
- Sample.css
These files are files you can see on any Web site. This is an important distinction to make: Adobe is letting you use the same file types both in your Flash movie and on your Web site. For example, a typical image used on a Web page is a JPG with some HTML and CSS formatting. It can look like this:
Now, however, even if you use different text, styles, or image files—like GIF or PNG—on your site, you can use them in your Flash movies as well. This means your Web site and your Flash movies can pull and link to the same media repository, which is a huge time-saver.
You can download all of the files you need to follow along with this tutorial here. You’ll see that there are three graphic files in JPG, PNG, and GIF format—all of the same image, just sized differently. I will use these images later to demonstrate how image files can be easily swapped in and out. You’ll also see HTML and CSS files. The HTML file contains all of the content for your Flash movie. The HTML code has been formatted in XHMTL format, which is an XML derivative of HTML. The formatting is important as XHTML format is a grammatically strict code language. The HTML code looks like this:
<body> <headline>LOREUM IPSUM</headline> <subheadline>Ut rutrum velit mattis tortor. </subheadline> <biline>Lorum - Ipsum Ipsum </biline><mainBody>Sed sollicitudin pulvinar libero. Praesent ac diam eu ante tempus laoreet. <img align=’right’ src=’sample.gif’/>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque commodo. Vestibulum ac nunc a tortor consequat suscipit. Ut hendrerit. Phasellus ultricies lacus vel velit. Nunc sodales. Etiam libero. Aliquam mattis pretium nibh. Fusce ut risus eu nibh ullamcorper dictum. Fusce mollis consequat dui. Suspendisse in arcu ac nisi facilisis interdum. Aliquam quis tellus condimentum nunc viverra mollis. Vestibulum urna. Ut quis quam. In semper feugiat ipsum. Vivamus volutpat pellentesque magna. Nullam consequat est a lorem. Suspendisse vitae urna. Vivamus ornare accumsan purus. Mauris dapibus congue ligula. Aenean venenatis lectus semper nibh aliquam blandit. Vivamus ornare. Proin tempor. Vestibulum sem enim, ultricies eget, feugiat eu, convallis in, ipsum. Maecenas sem diam, mollis sit amet, posuere ac, volutpat vitae, lacus. Proin semper risus a urna. Nam nec lectus ut nisi semper varius. Suspendisse vulputate, tortor et cursus venenatis, lorem dolor suscipit felis, vitae mollis quam dolor at tellus. Nullam arcu. Donec pede nulla, tempus at, ultrices eu, sagittis ut, nibh. Morbi purus lectus, pretium eu, feugiat sed, cursus id, orci. Sed posuere turpis vitae nisl. Curabitur sit amet metus ut risus mattis placerat. Nunc varius, felis eu vestibulum fringilla, quam lectus dictum augue, ut ornare nibh elit vel neque. Sed nec urna ac ipsum imperdiet egestas. Sed elementum purus id velit. Pellentesque ultrices libero id neque. <A HREF="http://www.informit.com">Click here for more.</A> </mainBody> </body>
The HTML code itself will be formatted with a Cascading Style Sheet (CSS). The file named sample.css contains all of the CSS needed for this project. It looks like this:
headline { font-family: Times New Roman, Roman, serif; font-size: 16px; font-weight: bold; display: block; } subheadline { font-family: Arial,Helvetica,sans-serif; font-size: 13px; font-weight: bold; display: block; } mainBody { font-family: Arial,Helvetica,sans-serif; font-size: 10px; display: block; } biline { font-family: Arial,Helvetica,sans-serif; font-size: 11px; font-style: italic; display: inline; } A { font-family: Arial,Helvetica,sans-serif; color:cccccc; font-size: 10px; display: inline; text-decoration:underline; }
Pull all of these elements together and you have the Web page sample above. These elements can now be pulled into Flash dynamically.
Using ActionScript To Link Files Together
Let's start using Flash. Open Flash 8 or later and create a new file. Save this file and call it "sample.fla." You’ll want to save sample.fla in the same folder you have sample.html, sample.css, sample.jpg, sample.gif, and sample.png.
On the Stage add a Dynamic text field. Name the text field "content_txt." It should look something like this:
I have added a background color of dark blue.
Go to your Timeline and create a new layer and label it "scripts." This is where you’ll add the ActionScript that will dynamically link the content in the HTML, CSS, and images to your Flash movie.
Add the following ActionScript:
//the following code applies a CSS style sheet to the text field var myStyle:TextField.StyleSheet = new TextField.StyleSheet(); myStyle.load("sample.css"); content_txt.styleSheet = myStyle; content_txt.multiline= true; content_txt.wordWrap = true; content_txt.html = true; //The following code add the formated content var story:XML = new XML(); story.ignoreWhite = true; story.load("sample.html"); story.onLoad = function () { content_txt.htmlText = story; }
As you can see, there’s not a whole lot to this ActionScript. Essentially, you have two parts. The first part applies the CSS formatting to the dynamic text and the second applies the content that will show in the text.
When you’re done, you can test your Flash movie. It should look like this:
Adding a Scroll Bar Component
As you look at your new Flash movie with the externally linked content and formatting, you’ll notice that not all of the content appears on the screen. You can still get to the content, but it requires using the arrow keys. That’s not much fun and certainly not intuitive. A better way is to use the UIScrollBar Component.
From the Components panel, drag the UIScrollBar Component onto the text field on the Stage. Release your cursor and you’ll see that the UIScrollBar snaps into place on the right side of the text field. In addition, the UIScrollBar resizes itself to the same height as the text field. Test the movie. You’ll now see that you have an easy-to-use scroll bar along the left side of the movie.
Changing Files Outside of a Flash Movie
In the past, if you wanted to change something in your Flash movie such as the text, an image, or the style, you’d have to open the original Flash FLA file and then re-export it as a SWF file. This is fine if you have Flash, but if you’re just a content contributor it can be a real problem.
The ability to link to external files through Flash, however, makes it very easy for non-Flash users to update content in a Flash movie. Now, I can open up my HTML file and change the content in Dreamweaver or any other HTML editing tool.
As a content user, I can also change the image and its format. In this example, I’m going to change the format to PNG by editing the HTML to look like this:
<body> <headline>Vestibulum ac nunc!!</headline> <subheadline>Fusce ut risus eu nibh ullamcorper dictum. Fusce mollis consequat dui. </subheadline> <biline>Lorum - Ipsum Ipsum </biline><mainBody>Sed sollicitudin pulvinar libero. Praesent ac diam eu ante tempus laoreet. <img align=’right’ src=’sample.png’/>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque commodo. Vestibulum ac nunc a tortor consequat suscipit. Ut hendrerit. Phasellus ultricies lacus vel velit. Nunc sodales. Etiam libero. Aliquam mattis pretium nibh. Fusce ut risus eu nibh ullamcorper dictum. Fusce mollis consequat dui. Suspendisse in arcu ac nisi facilisis interdum. Aliquam quis tellus condimentum nunc viverra mollis. Vestibulum urna. Ut quis quam. In semper feugiat ipsum. Vivamus volutpat pellentesque magna. Nullam consequat est a lorem. Suspendisse vitae urna. Vivamus ornare accumsan purus. Mauris dapibus congue ligula. Aenean venenatis lectus semper nibh aliquam blandit. Vivamus ornare. Proin tempor. Vestibulum sem enim, ultricies eget, feugiat eu, convallis in, ipsum. Maecenas sem diam, mollis sit amet, posuere ac, volutpat vitae, lacus. Proin semper risus a urna. Nam nec lectus ut nisi semper varius. Suspendisse vulputate, tortor et cursus venenatis, lorem dolor suscipit felis, vitae mollis quam dolor at tellus. Nullam arcu. Donec pede nulla, tempus at, ultrices eu, sagittis ut, nibh. Morbi purus lectus, pretium eu, feugiat sed, cursus id, orci. Sed posuere turpis vitae nisl. Curabitur sit amet metus ut risus mattis placerat. Nunc varius, felis eu vestibulum fringilla, quam lectus dictum augue, ut ornare nibh elit vel neque. Sed nec urna ac ipsum imperdiet egestas. Sed elementum purus id velit. Pellentesque ultrices libero id neque. <A HREF="http://www.informit.com">Click here for more.</A> </mainBody> </body>
You can see that I have now changed the HTML. The change is subtle, only the image was modified, but I could have changed all of the text, added more images and more links.
Finally, CSS formatting can also be changed. In this example, I’ve modified the first two formats to this:
headline { font-family: Arial,Helvetica,sans-serif; font-size: 36px; font-weight: bold; display: block; } subheadline { font-family: Arial,Helvetica,sans-serif; font-size: 18px; font-weight: bold; display: block; }
The Flash movie has now dynamically changed without anyone having to open Flash and re-author the original file! Your new Flash movie should look like this:
Why Have Files In Two Or More Places?
You may be asking yourself, "Why have files in two places, such as on my Web site and in my Flash movie?" I can sum up the answer in one word: convergence. It used to be that Flash and Web and other content were all mutually exclusive. That really isn’t the case anymore. Content is spilling off the Web onto the desktop and everywhere else. You need to build your solutions so that your content can be re-used in many different ways, including Flash and other formats such as PDF, the Web, your Office files, and more.