What is Software? | What is Education? | What is Technology? | What is Research? | What is Wi-Fi? | What is Communication? | What is Customer Service?

Free SEO Tutorials & Help

Tutorials:   Adobe Flash   Adobe Photoshop   CorelDRAW   SEO  

Site Map

Website Development | Cable & Broadband Magazine | Solutions for Higher Education | Auction Anything Online

Adobe Flash Help & Tutorials

 Back to Topics

 

Using ActionScript: How to Use Script Assist mode in Flash

ActionScript: Use Script Assist mode

Examine the completed FLA file

Open the starter document

Add a script to a button by using Script Assist mode

Add frame scripts to the Timeline by using Script Assist mode

Add a frame script to the Title movie clip

Test the application

Summary

ActionScript: Use Script Assist mode

TOP

This tutorial guides you through using Script Assist mode in Macromedia Flash Basic 8 and Macromedia Flash Professional 8.


Script Assist mode prompts you to enter the elements of a script, and helps you to add simple interactivity to your SWF file (a compressed version of a Flash .fla file with the .swf extension) or application more easily. Script Assist mode is ideal for users who either aren't comfortable writing their own scripts, or who just appreciate the ease of use the tool provides.


Used in conjunction with the Actions panel, Script Assist mode prompts you to select options and enter parameters. For example, instead of writing your own script, you can select a language element from the Actions toolbox (or the Add (+) command on the toolbar), drag it onto the Script pane, and then use Script Assist mode to help you complete the script.


This tutorial guides you through the steps of using Script Assist mode to add interactivity to a Flash application. You will add ActionScript code to an object (a button) and to frames in the Timeline. This tutorial also demonstrates some best practices for adding scripts to your Flash document.


After examining the completed Flash application, you'll begin by opening a starter Flash document and end by testing the interactivity you've added to an application by using Script Assist mode. The tutorial should take approximately 20 minutes to complete.
 

Examine the completed FLA file

#TOP

As you examine the finished version of an application that you'll create, you'll also look at the Flash workspace.

In this section, you will complete the following tasks:

  • Open the authoring document

  • Review the completed FLA file

  • Close the completed FLA file

In subsequent sections you'll go through the steps to create the application yourself.


Open the authoring document


It's helpful to analyze the completed authoring document, which is a FLA file, to see how the author designed the application. You should examine what kinds of scripts were used to add interactivity, and understand what you are going to create.

The files for this tutorial are located in the Samples and Tutorials folder in the Flash installation folder. For many users, particularly in educational settings, this folder is read-only. Before proceeding with the tutorial, copy the entire Script Assist tutorial folder to the writable location of your choice.

On most computers, you will find the Script Assist tutorial folder in the following locations:

  • In Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Tutorial Assets\ActionScript\Script Assist.

  • On the Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/Tutorial Assets/ActionScript/Script Assist.

Copy the Script Assist folder to another location on your hard disk to which you have access. In the Script Assist folder, you will find a Flash file called scriptassist_complete.fla. Double-click the file to open it in Flash. You now see the completed tutorial file in the Flash authoring environment.

Review the completed FLA file

In the completed FLA file, you will see all the objects (buttons, movie clips, and graphics) that make up the sample application. The application, a Flash-based company information website, looks like this:

The completed FLA file

There are three movie clips in the application:

  • The Title movie clip, which displays the section titles of the site when the user clicks the corresponding navigation links (Home, About, Products, Contact).

  • The Menu and Menu tween movie clips, which display the primary navigation links (buttons) and together create an animation when the application is run.

The application has four buttons:

  • The About, Products, Contact, and Home buttons provide the navigation for the application.

In this tutorial you will add the ActionScript code to enable the buttons to navigate to the separate sections of the site.

Close the completed FLA file

To close the document, select File > Close.

If you prefer to keep the finished file open as a reference while working with the starter file, be careful not to edit it or save any changes to it.

 

Open the starter document

TOP

Now that you have seen the completed file, it is time to create your own Flash document. To get started, you'll open a starter file that contains the elements to which you will add ActionScript code using Script Assist mode.


To open the starter document:

  1. In Flash, select File > Open.

  2. Navigate to the following directory:

    • In Windows: Hard Disk\Program Files\Macromedia\Flash 8\Samples and Tutorials\Tutorial Assets\ActionScript\Script Assist

    • On the Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/Tutorial Assets/ActionScript/Script Assist

  3. Open the scriptassist_start.fla file.

 

Add a script to a button by using Script Assist mode

TOP

In this section you'll use Script Assist mode to add a script to the Home button. When the sample application is run and the Home button is clicked, the Home title appears in the Title movie clip.

NOTE This section demonstrates how you add scripts directly to objects. Although this approach can be convenient for adding interactivity to your Flash applications, you should follow best coding practices and add code to the Timeline rather than to individual objects. For more information, see Add frame scripts to the Timeline by using Script Assist mode.

  1. Click the Selection tool in the Tools panel.

  2. On the Timeline, select the "menu and button" layer.

    If the layer is locked, unlock it.

  3. In the upper-right corner of the Stage, select the Home button.

  4. In the Actions panel, you'll see the Script Assist button above the ActionScript editor.

    Click Script Assist to display Script Assist mode.

    With no functions selected, the Script Assist pane is blank.

    Initially, the Script Assist portion of the Actions panel is blank. Script Assist mode prompts you to select options and set parameters for the functions that you add to the selected button. The parameters are displayed when you add an ActionScript function.

    NOTE You may notice that when Script Assist mode is enabled, you cannot directly edit code in the ActionScript editor, because it is read-only. All interaction with the code in the editor is through Script Assist mode with one important exception: you can highlight functions in the ActionScript editor and delete them.

  5. To add a function to the button, click Add on the toolbar.

    Clicking the Add button displays all of the predefined ActionScript functions.

  6. From the Movie Clip Control option, select the on event handler.

    NOTE An alternative method of adding ActionScript functions is to browse for and then select them from the Actions toolbox. The Add button on the Actions panel toolbar and the Actions toolbox display the same categories of functions and you can add functions to the editor from both.

    Script Assist mode prompts you to set the function's parameters.

    The release event of the on event handler is selected by default.

    You'll use the release event to trigger the script action when the user clicks Home.

  7. Click Add again and then select the goto() function from the Global Functions > Timeline Control option.

    Adding the function that is triggered when the event occurs

    The goto() function is added as the action of the on event handler. In other words, when the Home button is pressed (the on handler) and released (the release event), the goto() action is executed.

    When the Home button is clicked, the movie clip should move to and stop at the Home frame of the Timeline. To do this, you use Script Assist mode to modify the default parameters of the goto() function.

  8. In the Script Assist panel, select the Go To and Stop option.

  9. Set the Type to Frame Label by selecting it from the Type pop-up menu.

  10. In the Frame text box, enter home.

    Modifying function parameters to complete the script

The changes you made with Script Assist mode are displayed in the ActionScript editor. You've just created a script without manually writing code in the ActionScript editor.

When you test the application, clicking the Home button will display the title "Home" in the Title movie clip, indicating that the Home frame is currently displayed.

Clicking the Home button displays "Home" in the Title movie clip.

You could repeat this process for the About, Products, and Contacts buttons. However, for these buttons you'll use an alternative and preferred method for creating scripts.

In each case, you want to display the related frames on the Timeline when each of the buttons are clicked; therefore, you will set the frame target of the gotoAndStop() function to the About, Products, and Contacts frames, as you've just done for the Home button.

 

Add frame scripts to the Timeline by using Script Assist mode

TOP

Rather than adding scripts to individual objects, and acting on objects directly but also dispersing code in many different places in your Flash document, place the scripts in a frame in the timeline instead. This section demonstrates how you add scripts to a timeline.

  1. On the main Timeline, select Frame 1 of the Actions layer.

  2. In the Actions panel toolbar, click Script Assist to display the Script Assist window.

  3. From the Actions toolbox, select ActionScript 2.0 Classes > Movie > Button > Events and locate the on(release) event handler.

    Double-click the on(release) event handler to insert it into the ActionScript editor.

    Using the Actions toolbox to insert functions into the script

    You'll notice that code placed on a timeline behaves differently than code placed on objects. In the previous example, you had to specify the target object for the on(release) event handler.This is because you're not adding the script directly to the object, but rather, you're referring to it from the code in the timeline. It also explicitly uses the function keyword to declare a function. You'll see how to use Script Assist mode to handle these in the following steps.

  4. Click in the Object text box.

    On the Actions panel toolbox, the Insert a Target Path button is enabled.

  5. Click the Insert a Target Path button to display the Insert Target Path dialog box.

    Selecting the target object from the Insert Target Path dialog box

  6. Select the About button (about_btn) from the tween_mc movie clip.

  7. Make sure that the Relative Path option is selected and then click OK.

    The target object (the Menu tween) is added.

    The path to the target object is added to the event handler.

You now need to add the goto() function, the action that occurs when the About button is clicked.

  1. Using the Actions toolbox or the Add button on the Actions panel toolbox, select Global Functions > Timeline Control and insert the goto function.

  2. In the Script Assist pane, select the Go To and Stop option.

  3. Set the Type to Frame Label by selecting it from the Type pop-up menu.

  4. In the Frame text box, enter about.

    The completed Timeline script

Repeat this process for the Products and Contacts buttons. In each case, when the buttons are clicked, you want to display the related frames on the Timeline; therefore, set the frame target of the gotoAndStop() function to the Products and Contacts frames as you did for the About button.

 

Add a frame script to the Title movie clip

TOP

The final step is to add a script to the last frame of the Title movie clip. This script is used to display the text "Home" in the Title movie clip when its animation has completed.

  1. From the Library panel, select the Title movie clip and its timeline is displayed.

    Selecting the Title movie clip timeline to add a script to the last frame

  2. With the Actions layer selected, select the last frame (14) on the Timeline.

  3. In the Actions panel, click Script Assist to display Script Assist mode.

  4. Using either the Actions toolbox or the Add button on the Actions panel toolbar, select Global Functions > Timeline Control and insert the stop() function.

  5. Next, using either the Actions toolbox or the Add button, select ActionScript 2.0 Classes > Movie > MovieClip > Methods > gotoAndStop.

    Modifying function parameters to complete the script

  6. In the Script Assist panel, select the gotoAndStop action on line 2.

  7. Click in the Object text box.

  8. Click the Insert Target Path button.

  9. In the Insert Target Path dialog box, click the _root object and click OK.

  10. In the Frame text box, enter home.

  11. Deselect the Expression checkbox.

    Now, when the Title movie clip reaches the last frame and the animation is complete, "Home" is displayed. This is the initial state of the application, after it loads and before the user clicks any of the buttons.

  12. Save your work.


All of the scripts needed to run the sample application are now complete and the application is ready to be tested.

 

Test the application

TOP

At any point during authoring, you can test how your application plays as a SWF file. Now that you've added scripts to the application with Script Assist mode, you can test the interactivity you've just added to it.

  1. Select File > Save to save your FLA file.

  2. Select Control > Test Movie.

  3. Click any of the buttons (About, Products, Contact, and Home) to test that those frames are loading and that the corresponding title is displayed in the Title movie clip.

  4. When you finish testing the application, close the SWF file by closing the test window.

You have now successfully added scripts to a button and both the main and Title movie clip timelines. You can use Script Assist mode in many ways as you work with ActionScript in your Flash documents.

 

Summary

TOP

Congratulations on using Script Assist mode to add scripts to objects and to the timeline. In just a few minutes, you learned how to accomplish the following tasks using Script Assist mode:

  • Display Script Assist mode in the Actions panel and insert predefined ActionScript functions.

  • Add a script to a button.

  • Add frame scripts to the main timeline.

  • Add a frame script to the last frame of a movie clip.

To learn more about ActionScript, take another lesson in the Basic ActionScript series.

 

Copyright ADOBE - All Rights Reserved Worldwide

 

 

More Topics:

Working with Flash Documents

How to work in Flash WorkSpace

Working with Projects in Flash

Process to Build your First Application in Flash

Using Symbols, Instances and Library Assets in Flash

How to Build Video Player in Flash

How to Work with Color, Strokes and Fills in Flash

How to Create Document in Flash

What is Vector and Bitmap Graphics in Flash

How to Create a Banner in Flash, Part 1

How to Work with Text in Flash

How to Create a Banner in Flash, Part 2

How to Use Imported Artwork in Flash

How to Create a Banner in Flash, Part 3

How to Work with Graphic Objects in Flash

How to Work with Layers in Flash

How to Use Filters and Blends

Working with Graphics in Flash

What is Accessibility Features in Flash

How to Create Motion (Shape Tween & Motion Tween) in Flash

How to Create an Application in Flash

What is Masking in Flash

How to Work with Video in Flash

How to Use Layout Tools in Flash

What are Behaviors in Flash

How to Work with Sound in Flash

How to Create Symbols and Instances in Flash

What is ActionScript in Flash

How to Write ActionScript With Script Assist in Flash

How to Add Button Animation and Navigation in Flash

What is Data Integration in Flash

How to Work with Screens

How to Create a Presentation with Screens

What is Extending Flash

How to Create Multilanguage Text in Flash

How to Create Graphics: Draw in Flash

What is Flash Lite

Ways of Data Integration

How to Create Graphics: Create a Timeline Animation in Flash

Getting Started with Flash Lite in Flash

How to Publish Flash Documents

How to Create Graphics: Making Animations with Easing

Learning Flash Lite 1.X ActionScript in Flash

How to Export Flash Content and Images from Flash

How to Create Graphics: Applying Gradients in Flash

Process of Writing and Editing ActionScript 2.0 in Flash

How to Create Accessible Content in Flash

How to Create Graphics: Apply Graphic Filters and Blends

What is Data and Data Types in Flash

Process of Printing from SWF Files in Flash

Using ActionScript: How to Use Script Assist mode in Flash

Learn Syntax and Language Fundamentals in Flash

How to Create E-learning Content in Flash

Using ActionScript: How to Write Scripts in Flash

Working with Functions and Methods in Flash

Process of Using Templates in Flash

Using ActionScript: Process of Adding Interactivity in Flash

What are Classes in Flash

Control Tag Summary of XML to UI in Flash

Using ActionScript: How to Create a Form with Conditional Logic and Send Data in Flash

What is Inheritance in Flash

What is Data Integration: Overview

Using ActionScript: How to Work with Objects and Classes in Flash

Overview on Interfaces in Flash

What is Data Integration: Using XML for a Timesheet

How to Work with Text and Strings in Flash

How to use Handling Events in Flash

What is Data Integration: Using XUpdate to Update the Timesheet

Learning Animation, Filters and Drawings in Flash

How to Work with Movie Clips in Flash

How to Create Interaction with ActionScript in Flash

How to Work with Images, Sound, and Video in Flash

How to Work with External Data in Flash

What is Security in Flash

How to Debug Applications in Flash

List of Error Messages in Flash

Using Object-Oriented Programming with ActionScript 1.0 in Flash

How to Write Scripts for Earlier Versions of Flash Player in Flash

List of all Keyboard Keys and Key Code Values for using in Flash

Terminology

Introduction to Components in Flash

What are Components in Flash

How to Create an Application with Components

How to Work with Components in Flash

How to Handle Component Events in Flash

How to Customize Components in Flash

How to Create Components in Flash

What is Collection Properties in Flash