ptg
368 Chapter 15
To take advantage of the new powerful AVM 2.0 and ActionScript 3.0
you must be publishing your Flash movies to target Flash Player 9 or
later. Adobe has done a great job of ensuring that the latest release of
the Flash Player is installed on your computer. For instance, with the
release of Flash Player 9, Adobe installed a feature that automatically
updates your Player on your PC, Mac users receive updates through the
Mac OS update tool and—as part of Flash Player 10.1—will now receive
automatic updates as soon as new releases are available. Flash Player
10.1 will help your Flash movies to play back more efficiently on Mac
based computers, especially for mobile devices, such as an Android,
Palm Pre or BlackBerry phones. Flash Player 10.1 dramatically optimized
code for the Cocoa Framework, it uses Apple’s Core Animation to render
animation). Mobile users simply have not been able to view Flash. Now
they can. To change which Flash Player you are targeting you need to
open the Publish Settings and modify the Flash Player settings.
Changing ActionScript
3.0 Settings
Change Publishing Setting for
ActionScript 3.0
Click File, and then click Publish
Settings.
The default settings on the
Formats tab include Flash and
HTML.
Click the Flash tab.
Click the Player list arrow, and
then click Flash Player 9 or Flash
Player 10.
Click the Script list arrow, and
then click ActionScript 3.0.
Click the HTML tab.
To publish settings for a specific
subversion (an update to a main
release) of the selected Flash
Player, select the Detect Flash
Version check box, and then enter
the Flash Player subversion you
want. For example, 10.1.52. This
uses SWObject2 for version
detection and embedding SWF
into Web pages. (New!)
Click OK.
You are ready to start developing a
ActionScript 3.0 Flash movie that
uses AVM 2.0.
7
6
5
4
3
2
1
4
3
7
52
From the Library of Wow! eBook
ptg
Chapter 15 Working with ActionScript 3.0 369
6
Change ActionScript 3.0 Settings
Click File, and then click
ActionScript Settings.
To create a document class, enter
the filename of the ActionScript
file without the .as extension.
Specify the frame where the class
definition resides.
Specify any of the following
options:
◆ Strict Mode. Select to to report
compiler warnings as errors.
◆ Warnings Mode. Select to
report warnings for issues
when updating ActionScript 2.0
to ActionScript 3.0.
◆ Automatically declare state
instances. Select to
automatically declare instances
on the Stage.
◆ Dialect. Select ECMAScript or
ActionScript 3.0
(Recommended).
Click any of the following tabs:
◆ Source path. Specify the
location of the external
ActionScript files that contain
the class definition.
◆ Library path. Specify the
location of pre-compiled
ActionScript code, which
resides in the SWC files.
◆ Config constants. Specify any
configuration constants for use
with conditional compilation.
Click OK.
6
5
4
3
2
1
See Also
See “Creating a New Document” on
page 12 for more information on creat-
ing an ActionScript 3.0 FLA document.
2
5
3
4
From the Library of Wow! eBook
ptg
370 Chapter 15
Code hints makes it easy to insert and edit code accurately. With Code
hints, you don’t have to remember all of the objects, methods, and prop-
erties used in ActionScript. As you enter to type code, you can display
the Code Hints popup menu to help you enter it correctly (New!). Code
hints can appear after the dot (.) following a statement or command,
where a property or method needs to appear next, or between paren-
theses [()] in a method name. The Code Hints popup menu displays
appropriate code options based on the currently entered code. When
you enter code that refers to a custom ActionScript 3.0 class, you can
also display the Code Hints popup menu to help you access the appro-
priate code options (New!). When you use a custom class in a script,
Flash automatically imports the related code for its use. Code hinting
also works for nested class references, and all classes included in a
SWC file.
Inserting Code with
Code Hints
Use Code Hints
Create or open a Flash document.
Open the Actions panel or Script
window.
Place the insertion point where
you want to add code.
Start to type the code you want,
and then press Control+Spacebar
(Win) or A+Spacebar (Mac) or
click the Show Code Hint button
on the toolbar to manually display
the code hints popup menu.
Scroll through the list by using the
scroll bar or pressing the Up
Arrow and Down Arrow keys.
To insert a code hint, double-click
an item, or select it and then press
Enter (Win) or Return (Mac).
◆ Press Esc to dismiss the list of
code hints.
6
5
4
3
2
1
See Also
See “Setting ActionScript
Preferences” on page 349 for
information on enabling code hinting.
2
4
3
5
6
From the Library of Wow! eBook
ptg
Chapter 15 Working with ActionScript 3.0 371
Use Code Hints for Custom
Classes
Create or open a Flash or class
document (ActionScript 3.0).
◆ Store the custom classes in the
same folder as the document.
Open the Actions panel or Script
window.
Place the insertion point where
you want to add code.
Start to type the code you want,
and then press Control+Spacebar
(Win) or A+Spacebar (Mac) or
click the Show Code Hint button
on the toolbar to manually display
the code hints popup menu.
Scroll through the list by using the
scroll bar or pressing the Up
Arrow and Down Arrow keys.
To insert a code hint, double-click
an item, or select it and then press
Enter (Win) or Return (Mac).
◆ Press Esc to dismiss the list of
code hints.
6
5
4
3
2
1
Did You Know?
You can reload code hints without
restarting Flash.
Open the Actions
panel, click the Options menu, and then
click Reload Code Hints.
You can save time with Auto close-
bracket insertion.
When you type an
open bracket { in the Actions panel or
Script window, Flash automatically
adds the corresponding close
bracket }. (New!)
Properties Options
Type
this
Code hints for that same class
Type
new+<space>
Displays a list of available classes and
packages
Type
import+<space>
Displays a list of all the built-in packages
and custom packages
Code Hinting for Custom Classes
2
4
3
5
6
From the Library of Wow! eBook
ptg
372 Chapter 15
As you build Flash documents for ActionScript 3.0, it's almost a certainty
that you will use elements over and over again. Flash created a solution
that makes it easier to reuse elements called Code Snippets (New!).
Snippets offer a simple and convenient method of creating reusable
code, which especially helpful for those transitioning from ActionScript
2.0 to ActionScript 3.0. They are composed of bits of code and/or content
along with comments for usage that you can save, edit, use, and reuse
as often as you want. You can use a pre-defined code snippet supplied
by Flash or create your own in the Code Snippets panel (New!).
Inserting and Creating
Code Snippets
Insert a Code Snippet
Select the object or Timeline frame
in the Flash document where you
want to insert/apply the code
snippet.
Open the Code Snippets panel.
Click the arrow icon next to the
folder (Actions, Timeline
Navigation, Animation, Load and
Unload, Audio and Video and Event
Handlers) to display the snippet
you want to insert.
Select the snippet you want to
insert.
Click the Add to current frame
button in the Code Snippets panel.
TIMESAVER
You can also drag
a snippet from the Code Snippets
panel directly onto an element, or
double-click the code snippet in
the Code Snippets panel. In the
Actions panel, you can click the
Code Snippets button.
Click Yes to convert your selection
to a movie clip, if necessary.
A new ActionScript is added to a
new layer, labeled Actions, in the
Timeline.
6
5
4
3
2
1
1
2
5
3
4
Click to Play/Stop
Sound snippet code
New layer with ActionScript
From the Library of Wow! eBook
ptg
Chapter 15 Working with ActionScript 3.0 373
Create a Code Snippet
Open the Code Snippets panel.
Click the Options button in the
Code Snippets panel, and then
click Create New Code Snippet.
Type a title and tooltip.
Type the code you want to use in
the Code box or click Auto-fill to
insert the code selected in the
Actions panel.
Select or clear the Automatically
replace instance_name_here
when applying code snippet
check box.
Click OK.
6
5
4
3
2
1
Did You Know?
You can edit an existing code snippet.
In the Code Snippets panel, select the
snippet you want to edit, click the
Options button, click Edit Code
Snippets XML, make the changes you
want, click the File menu, click Save,
and then click the Close button in the
Code Snippets tab.
You can copy a code snippet to the
clipboard.
In the Code Snippets panel,
select the snippet you want to copy,
click the Copy to Clipboard button, and
then click OK, if necessary. Now, you
can paste it into the Actions panel or
ActionScript file.
Importing and Exporting Code Snippets
If you want to share code snippets with others, you can import or
export one or more from the Code Snippets panel. To import a code
snippet, click the Options button in the Code Snippets panel, click
Import Code Snippets XML, select the XML file, and then click Open.
To expo rt a code snippet, select the snippet you want to expo rt in the
Code Snippets panel, click the Options button, click Export Code
Snippets XML, type a name, specify a location, and then click Save.
For Your Information
1 2
3
4
5
6
From the Library of Wow! eBook
. tool and—as part of Flash Player 10.1—will now receive
automatic updates as soon as new releases are available. Flash Player
10.1 will help your Flash movies. the
Formats tab include Flash and
HTML.
Click the Flash tab.
Click the Player list arrow, and
then click Flash Player 9 or Flash
Player 10.
Click the