- 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 would like to introduce you to ActionScript, a feature of Flash that has matured over the years, with a corresponding increase in complexity. This introduction highlights variables, objects, and methods, with an explanation on how to access externally shared scripts with the #include object. In the future, I intend to dig deeper into the technology to discuss more complex ActionScript features.
Variables
The foundation for any ActionScript you create is a variable. A variable is a name used to capture a set of values in ActionScript. The value can be today's date, the name of a game player, or the score of a game. The variable is limited only by what it can and can not capture. The information within the variable can then be used in other blocks of ActionScript.
The following code defines a very simple variable:
myNameIs = "Matthew";
A new variable, called myNameIs, now has a string value. This variable can be used at any time and the value will always be "Matthew " unless it is subsequently changed.
To see this in action, create a new movie and draw a text field on the stage using the text tool. Give the text field the name "txt." Open the Actions panel (press F9) and enter the following ActionScript:
myNameIs = "Matthew"; txt.text = myNameIs;
In this example, the variable is an alphanumeric string intended for use in a text field. While it is possible to define the text field using a string instead of a variable, that would be more limiting. It’s much more flexible to have the value generated from an expression. The second line of ActionScript in this example uses an expression to set the value of the text field to equal a variable.
Variables are very dynamic in nature. This is what makes them so useful. You can capture information on the fly and have it dynamically updated. The dynamic value of Flash can be demonstrated with a simple Flash movie.
- Open Flash. Do not worry about the size of the screen you are working with.
- On the stage use the Text tool and draw a dynamic text field. Name the text field "t".
- The timeline defaults to a single layer named "layer 1" with one frame. Select frame 1 of layer 1. Press F5 to add a second frame. Preview this movie. The animation loops through two frames.
- Open the Actions panel and enter the following ActionScript:
t.text = this._xmouse;
- The ActionScript has a variable called "t." The value of "t" is property _xmouse. This property tells you where the mouse is on the stage.
- Press CTRL+Enter and preview the movie again. As you move the cursor around the stage, the value in the text field changes. This is a dynamically updated variable value.
Objects
If variables are the communication tools that you use to talk to Flash, then objects are the main engines that expose the different tools you can use to build interactive elements. Each set of objects comes with a collection of methods and properties.
The four main groups of objects are:
- Core
- Movie
- Client/Server
- Authoring
The Core objects are basic objects such as math functions. With these you can generate random actions on the stage or calculate mathematical equations.
Flash is all about visual engagement. The Movie objects control what you see on the stage. In Movie objects you can control text fields, movie clips, graphics, mouse interaction, buttons, sound, and more.
The Client/Server objects enable you to connect with and receive content generated by databases. You can also connect to XML data sources.
Finally, the Authoring objects are specific to Flash authoring and not the Flash Player. These tools give you the power to extend Flash itself through component technology.
Methods
Each object has methods that allow you to control that object. Essentially, a method is a device that allows you to control and execute a specific request through ActionScript. Each and every object has methods. In the Actions panel, select the plus symbol to view any object. From within that object you can view all of the methods.
There are many different methods. An introductory example comes from the Date object. The Date object, as its name implies, controls the date. The methods within that object are what give you a value for a date.
- Create a new movie. Draw a text field on the stage and give it the name "t". You will use this text field to display the date.
- Open the Actions panel in Expert mode.
- You need to tell Flash that you are going to use the Date object. You do
that with the following ActionScript:
myDate = new Date();
- Here a variable, myDate, is used for the object new Date.
- Add the next line of ActionScript:
dateTextField = ((myDate.getMonth() + 1) + "/" + myDate.getDate() + "/" + myDate.getFullYear());
- At the beginning of the line is a variable called dateTextField followed by an expression. The expression uses three methods from the Date object: getMonth, getDate, and getFullYear. The getMonth method allows Flash to find out the number of the month you are in today; the getDate method finds which day of the month it is; and getFullYear tells you which year it is. The dateTextField variable now has the expression for today's date. This can be passed to a text field.
- After the last line of ActionScript, add the following line to pass variable
data to the text field:
t.text = dateTextField;
- Preview the movie and confirm that today’s date is displayed correctly.
Methods are a powerful way to extract useful information from the objects within ActionScript.
External ActionScript - #include Object
As an ActionScript programmer, you are going to start with small scripts and then they will grow as you become more confident in your skills. If you have an identical ActionScript required for two or more programs, you can re-use the ActionScript through the #include object.
The #include object allows you to point Flash to an external text file containing ActionScript. The file is dynamically loaded into Flash when a movie is run. The power of this tool is that you can re-use the same scripts in a limitless number of movie.
A simple example can show how you can use the same ActionScript to place content into multiple text fields.
- Create a new movie. The new movie will open with a default of one frame and one layer. Save the movie and name it include.fla. When you begin working with include files it is a good idea to keep the include in the same folder as the final SWF file. This is because it is easy to tell Flash where to find the include.
- With the Text tool, create a new dynamic text field on the stage. Name the text field "t." Later you are going to add ActionScript that will generate content for "t." Change the font size to 23, the type to Times New Roman, and the color to #993399.
- Open a text editor such as Windows Notepad. You are going to write the
ActionScript directly into the text editor. Enter the following
ActionScript:
t.text="Flash";
This script will look for a text field clip labeled "t" and dynamically add the words "Flash."
- Go back to Flash. Select frame 1 of layer 1, open the Actions panel, and enter the following line:
- #include "script.as"
- Preview your movie. You will see that the text field now populates dynamically from the commands in the include file.
- Now you can create a second Flash movie with a dynamic text field labeled "t." Give the new text field different properties (change the font, size, and color) and link the movie to the same include file. Preview and you will see the action from the new movie is the same. You are re-using content. You can repeat these steps re-using the file hundreds of times. Later, you can change the content of the include file and have those changes replicated immediately through all of your Flash movies.
The include object is relatively simple to use. However, its power in re-use is undeniable.
Summary
As you can see, we have covered a lot but still have long way to go with ActionScript. If you are a Java, C#, or JavaScript programmer, then you will have seen techniques that are common across your languages. The strength of ActionScript is that it is bedded deeply within industry-standard programming languages. You will be delighted to know that this is the tip of the iceberg. There is a lot more functionality to be discussed in future updates to the Flash Reference Guide.