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

How to Write ActionScript With Script Assist in Flash

Using Script Assist to write ActionScript

Creating a startDrag/stopDrag event using Script Assist

Using Script Assist to write ActionScript

TOP

To add an action to a Flash document, you must attach it to a button or movie clip, or to a frame in the Timeline. The Actions panel lets you select, drag and drop, rearrange, and delete actions.

To write ActionScript using Script Assist:

  1. Select Window > Actions.

    The Actions panel appears.

  2. Click the Script Assist button,

The Actions panel enters Script Assist mode.

NOTE : If the Actions panel contains ActionScript code when you click the Script Assist button, Flash compiles the existing code. If there are errors in the code, you will not be able to use Script Assist until you fix the current code selection.

When Script Assist in enabled, the Actions panel user interface and behaviors change in the following ways:

  • The Add (+) button functions differently in Script Assist mode. When the focus is on the ActionScript window, it adds the selection after the currently selected text block. If the focus is in the edit pane, the selection is added to that text block.

  • The Remove (-) button lets you remove the current selection in the scrolling text area.

  • The Up and Down Arrow buttons let you move the current selection in the scrolling text area forward or backward within the code.

  • The Check Syntax, Auto Format, Show Code Hint, and Debug Options buttons and menu items normally visible in the Actions panel are disabled, as they do not apply to Script Assist mode.

  • The Insert Target button is disabled unless you are editing a field. Clicking Insert Target places the resulting code in the current edit field.

To view a description of an action, do one of the following:

  • Click a category in the Actions toolbox to display the actions in that category, and click an action.

  • Select a line of code in the Script pane.

The description appears at the upper left of the Actions panel, beginning with the Property or Event name.

To add an action to the Script pane, do one of the following:

  • Click a category in the Actions toolbox to display the actions in that category, and then do one of the following: double-click an action, drag it to the Script pane, or right-click (Windows) or Control-click (Macintosh) and select Add to Script.

  • Click the Add (+) button and select an action from the pop-up menu.

  • Press Escape and a shortcut key.

For example, Escape+st adds a stop action. (To view a list of shortcut keys, select View Esc Shortcut Keys in the Actions panel pop-up menu; select this option again to hide the list.)

To delete an action:

  1. Select a statement in the Script pane.

  2. Click the Delete (-) button or press the Delete key.

To move a statement up or down in the Script pane:

  1. Select a statement in the Script pane.

  2. Click the Up Arrow or Down Arrow button.

To work with parameters:

  1. Add an action to, or select a statement in, the Script pane.

    Depending on the action you selected, parameter text boxes or radio buttons appear above the Script pane. (Only those parameters relevant to the action you selected appear.)

  2. Enter values in the parameter text boxes above the Script pane.

To search for text in a script, do one of the following:

  • To go to a specific line in a script, choose GoTo Line from the Actions panel pop-up menu or press Control+G (Windows) or Command+G (Macintosh); and then enter the line number.

  • To find text, click the Find button above the Script pane, select Find from the Actions panel pop-up menu, or press Control+F (Windows) or Command+F (Macintosh). Enter the text you want to find in the dialog box that appears.

  • To find text again, press F3 or select Find Again from the Actions panel pop-up menu.

  • To replace text, click the Find button above the Script pane, or press Control+H (Windows) or Command+H (Macintosh). Enter the text you want to find and the text you want to replace it with in the dialog box that appears.

    In expert mode, Replace scans the entire body of text in a script. In normal mode, Replace searches and replaces text only in the parameter box of each action. For example, in Script Assist mode you cannot replace all gotoAndPlay actions with gotoAndStop.

    NOTE : The Script Assist find and replace feature searches the current Script pane. To search through text in every script in a Flash document, use the Movie Explorer (see Using the Movie Explorer).

To pin a script to the Actions panel:

  • Click the Script Pin button.

    The Actions panel displays the script in the Script pane, even when you click away from the object or frame.

To resize the Actions toolbox or Script pane, do one of the following:

  • Drag the vertical splitter bar that appears between the Actions toolbox and Script pane.

  • Double-click the splitter bar to collapse the Actions toolbox; double-click the bar again to display the Actions toolbox.

  • Click the arrow button on the splitter bar to expand or collapse the Actions toolbox.

    When the Actions toolbox is hidden, you can still use the Add (+) button to access its items.

To view line numbers in the Script pane, do one of the following:

  • Select View Line Numbers from the View Options pop-up menu above the Script pane.

  • Select View Line Numbers from the Actions panel pop-up menu.

  • Press Control+Shift+L (Windows) or Command+Shift+L (Macintosh).

To print actions:

  1. From the Actions panel pop-up menu, select Print.

    The Print dialog box appears.

  2. Select options and click Print.

    Because the printed file won't include information about its originating Flash file, Macromedia recommends that you include this information in a comment action in the script.

Creating a startDrag/stopDrag event using Script Assist

TOP

The following example walks you through the process of creating a simple startDrag/stopDrag event using Script Assist. When you complete this procedure, you will have a movie clip that you can drag around within a constrained rectangle using your computer's mouse in a published SWF file.

To learn more about the methods and functions used to create this example, see Learning ActionScript 2.0 in Flash.

To create a startDrag/stopDrag event using Script Assist:

  1. Create a new Flash document, and save it as circle.fla.

  2. Draw a circle on the Stage.

  3. Select the circle on the Stage, and convert it into a movie clip symbol by doing one of the following:

    • Select Modify > Convert to Symbol.

    • Drag the selection to the Library panel.

    • Right-click (Windows) or Control-click (Macintosh) and select Convert to Symbol from the context menu.

  4. In the Convert to Symbol dialog box, enter circle_mc for the name of the symbol and select the Movie Clip behavior. For more information.

  5. Click OK.

    Flash adds the symbol to the library, and the selection on the Stage becomes an instance of the symbol.

  6. With the circle_mc movie clip still selected, enter the instance name myCircle in the Instance Name text box of the Property inspector.

  7. Place the circle_mc move clip on the Timeline. To do this:

    1. Select the circle_mc movie clip on the Stage.

    2. Select Modify > Timeline > Distribute to Layers. This menu command automatically adds a layer to the Timeline and places the circle_mc movie clip instance on the Timeline. It names the new layer according to the symbol name and places it beneath the already existing Layer 1.

     

  8. Rename Layer 1 by double-clicking its name in the Timeline and typing the name "Actions" in its place.

  9. Select the first frame of the Actions layers.

  10. Select Window > Actions to display the Actions panel, and click Script Assist. The Actions panel enters Script Assist mode.

  11. In the Actions Toolbox, navigate to ActionScript 2.0 Classes > Movie > MovieClip > Events > onPress, and double-click onPress. The onPress method is added to the Actions panel.


     

  12. Click in the Object text box, and click the Target Path button.

  13. Click the Target path button.

    The Target Path dialog box is displayed.

  14. In the Target Path dialog box, select the MyCircle movie clip instance, and ensure that the Relative path option is selected. Click OK.


     

  15. Click the Add (+) button, and select Global Functions > MovieClip Control > startDrag.

  16. Enter type into the Target text box.

  17. Select the Expression and Constrain to Rectangle check boxes.

  18. Enter the following values in the L, T, R, and B text boxes: L:0, T:0, R:300, B:300.

    These values constrain the movement of the movie clip.

     

  19. Click beneath the last line of the code currently inserted in the Actions panel.

  20. In the Actions Toolbox, navigate to ActionScript 2.0 Classes > Movie > MovieClip > Events > onRelease, and double-click onRelease. The onRelease method is added to the Actions panel.


     

  21. Click in the Object text box, and click the Target Path button.

    The Target Path dialog box is displayed.

  22. In the Target Path dialog box, select the MyCircle movie clip instance, and ensure that the Relative path radio button is selected. Click OK.

  23. Click the Add (+) button, and select Global Functions > MovieClip Control > stopDrag.

    The finished code looks like this:

    this.my_mc.onPress = function() {

    startDrag(this, false, 0, 0, 300, 300);

    };

    this.my_mc.onRelease = function() {

    stopDrag();

    };

  24. Test your completed code by selecting Control > Test Movie. In the Test Movie window, move the pointer over the circle you created, and drag it around the Text Movie window.

To learn more about writing ActionScript, see Learning ActionScript 2.0 in Flash.

 

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