Tài liệu Macromedia Flash 8 (P2) - Pdf 86

Undo command works (the Undo feature is
accessible by pressing Ctrl+Z). The default,
Document-level Undo, means that every time
you undo (by pressing Ctrl+Z), you go back
to the state before the last change. Perhaps
this is the most intuitive behavior. However,
the other option, Object-level Undo, is very
useful. With this option, if you make changes
while inside one movie clip and then make
changes to another movie clip, you can
return to the first clip and press Ctrl+Z to
undo the last thing you did in that clip! It’s
the way Flash used to work (before version
MX2004), and it’s back as a preference.
The margins for your text fields are also
easier to modify in Flash 8. You can now
grab any one of the six handles, as shown in
Figure 1.6. In previous editions, there was
only one special margin-changing handle;
dragging any other handle scaled and
stretched the text rather than the text field. In
Flash 8, if you want to scale the text, you can
use the Free Transform tool or the Properties
panel’s W (width) and H (height) fields.
FIGURE 1.6
Drag any handle on a text field to modify the
margin width in Flash 8.
CHAPTER 1: Exploring Flash 8
14
In addition to the previously mentioned fact
that gradients can be applied to strokes,

single symbol scaled to multiple sizes and
dimensions, but the corners won’t stretch or
appear distorted. You can see the difference
between shapes scaled in various ways with
9-slice scaling in Figure 1.8. Notice how the
word
close
doesn’t appear stretched even
though the clip’s width and height vary.
What’s New in Flash 8
15
FIGURE 1.8
The same symbol scaled to different dimen-
sions, yet the corners don’t scale.
FIGURE 1.7
The Enable
Guides for 9-slice Scaling
option lets you identify
which portions of your clip
shouldn’t scale (the four
corner squares).
One drawback of the Enable Guides for 9-slice Scaling
option is that it doesn’t work when your clip contains
nested clips.Everything inside the movie clip on which
you want 9-slice scaling to work must be plain shapes
(not clip instances).
NOTE
Flash Player
Interestingly, it took a separate team about
the same size as the team that built Flash 8

project—makes an upgrade requirement
worthwhile. I’d imagine the video quality or
alpha channels will be enough to convince
many users to make the leap to Flash player
8. Only you can answer whether a new
feature is profound enough or saves you
enough time in production to require Flash
8—but there’s a lot of new stuff that could
easily tip the scale.
The upgrade process to Flash player 8 has
been vastly improved through what’s called
Express Install. If your user has Flash player
6.0r65 or later, he already has an integrated
feature you can trigger to install Flash player
8 inline. That is, the user doesn’t have to
download something, quit the browser, run
an installer, and so on. He simply clicks Yes
in a security dialog box that appears right
inside the Flash application (shown in Figure
1.10); a new browser window opens with
your content, and Flash player 8 has been
installed!
FIGURE 1.10
The inline Express Install dialog box
appears inside your Flash application.
CHAPTER 1: Exploring Flash 8
16
installed. One nice new feature when plan-
ning to deliver to an earlier version of the
Flash Player is that you’re given feedback (as

has and creating a Flash player 6
.swf
to
perform the Express Install. Just read the 25-
page document and associated sample files
in the Flash Deployment Kit (www.
macromedia.com/go/fp_detectionkit), and
you’ll learn all the available options. I
predict that this Express Install feature, along
with the killer features such as filters and
video, will greatly accelerate the adoption
rate for Flash 8 (historically taking 12
months for a new player version to reach
80% of all Internet users).
ActionScript Additions
17
The express install is simply the most advanced option
available because it performs the install from within
the older Flash player.Traditional ways of upgrading
users still exist.For example, the default
.html
gener-
ated when you publish automatically presents the user
with a traditional Active X install dialog box in Internet
Explorer or the Missing Plug-ins button in Netscape
and Firefox.
NOTE
Flash Professional 8 and Flash Basic 8
I suppose this is a bit of a sour way to end an
otherwise exciting section about what’s possi-

ActionScript hasn’t gotten the same facelift it
did when AS2.0 was introduced in Flash
MX2004. Nevertheless, there are some pretty
major additions to the ActionScript feature
list—too many, in fact, to list them all here.
However, I’ll list the major new features in
the following sections because most appear
in later chapters (even if the appearance is
often hidden away in the support files).
A Programming Primer
Because the section that follows this section
covers new ActionScript features, you’ll find it
peppered with terms such as variables,
instances, and properties. If this kind of infor-
mation is familiar to you, feel free to skip
ahead to the next section (on the
flash.filters
package). If such terms are
new to you, you’ll find additional definitions
for such terms in the Glossary (as well as in
underscore in their names). Movie clip
instances are the easiest type of object to
understand because you can see them. But
there are also instances of the Sound and
Date classes—just to name two.
Chapter 2). However, instead of having you
keep one thumb in the Glossary while you
read this chapter, here’s a narrative defini-
tion of the terms that appear throughout the
rest of this chapter and the book. Let me

to address each one individually. Why would
you want to address a clip? Usually to
change one of its properties such as its posi-
tion on stage (either its
_x
property or
_y
property, although there are many other
properties and they don’t always have an
CHAPTER 1: Exploring Flash 8
18
I capitalized
Sound
and
Date
because, when you
create an instance of these object types, you must use
the exact, case-sensitive spelling.
NOTE
Think of this analogy: People have properties
(such as hair color, weight, and age) and cars
have properties (such as horsepower, make,
and model). Interestingly, sometimes two
different object types share the same property.
Cars and humans both have a weight prop-
erty. Similarly, movie clip instances and
button instances both have a
width
property.
Often, however, the available properties

instruction—basically one line of code.)
Check out this example:
myClip._x = otherClip._x
When Flash encounters this line of code, it
interprets the code and executes the instruc-
tions (meaning it does what the code says to
do). In this example, the instance called
myClip
gets its
_x
property set to a value
equal to the
_x
property of another instance
called
otherClip
. (Anytime you see a single
equals sign, it’s an assignment meaning “is
now equal to,” as in “
myClip
’s
_x
is now
equal to
otherClip
’s
_x
”.) Notice that you’re
setting the
_x

tional details. For example, when you say
myClip.gotoAndPlay(1)
,
1
is a parameter
indicating which frame you want to go to.
Events are things that happen while a Flash
movie plays. The most intuitive event types
are things the user does, such as clicks, drags,
ActionScript Additions
19
or presses a key. Naturally, there are all kinds
of events, and like properties and methods,
events vary depending on the object type. For
example, Sound instances trigger or fire
events when the event
onSoundComplete
is
encountered (that is, when the sound ends).
A button instance has an
onPress
event (but
no
onSoundComplete
event). Just as trees can
fall in the woods without anyone to hear
them, events can fire in Flash and—unless
your code is listening for that event—they go
unnoticed. You have to write code to trap (or
listen for) an event and define exactly how

you were to assign the
label
property for a
Button component, you would want to use a
value of the data type
String
. The value you
assign to an event is of the type
Function
.
You can create variables as a way to store
data for later use. For example, you could
assign a variable’s value with this code:
myName = “Phillip”
(which means the vari-
able named
myName
is now equal to the string
“Phillip”
). You can change the value of a
variable by simply reassigning a value, but
at any one instant, a variable has a single
value. You can store any data type in your
variable, but you’ll often want to type your
Sometimes the class you instantiate is part of
Flash and other times the definition for its
behavior resides in a class file (
MyClass.as
,
for example). For instance, I created an

foldername.subfolder.MyClass()
I’ll discuss class paths in Chapter 2, but just
realize that there may be a
MyClass
class in
the previous path shown and another—
completely different—version of the same
name in another path. There’s no conflict
because the code doesn’t refer to
MyClass
but
rather to
foldername.subfolder.MyClass
.
Think how we have a president (like the
variables—that is, to define the variable with
the data type it is allowed to contain. Here is
an example of typing the
myName
variable as
a
String
data type:
var myName:String = “Phillip”;
The reason you type a variable is simply so
that Flash will give you a warning when you
publish if you write code that tries to assign a
value that doesn’t match the data type you
declared. That way, Flash helps you uncover
mistakes in your code.

21
code applies a
BlurFilter
with a factor of
50
to a clip instance named
myClip
when the
user clicks the stage; it then applies a differ-
ent filter, with a factor of
5
, when the user
lets go:
onMouseDown = function(){
var veryBlurry =
new flash.filters.BlurFilter(50,50);
myClip.filters = [ veryBlurry ];
}
onMouseUp = function(){
var lessBlurry =
new flash.filters.BlurFilter(5,5);
myClip.filters = [ lessBlurry ];
}
The
flash.filters
package lets you create
any kind of filter the Filters panel can create,
but you do it with ActionScript so it can
respond to any event, such as the user’s
mouse movement. One other thing to note is

we will move onto the key new ActionScript
features in Flash 8.
The flash.filters Package
Filters can be applied using the Filters panel
(while authoring) or using ActionScript code.
This enables you to write scripts that modify a
filter’s effect at runtime. For example, you
could make some text get blurrier as the user
moves the mouse away and sharper as the
mouse moves closer. Writing the code to
apply a filter at runtime is a two-step process.
First, you create a filter instance and store it
in a variable. Second, you apply the filter to a
movie clip instance through its
filters
prop-
erty. If you want to change the filter applied
to a clip, you simply modify the filter or
create another filter with different properties
and (in either case) overwrite the clip’s
filters
property. Here’s a simple example in
which we apply a blur filter to a movie clip
instance named
myClip
:
myFilter = new flash.filters.BlurFilter();
myClip.filters = [ myFilter ];
Notice that the filters property is assigned an
array that contains just one item (


Nhờ tải bản gốc
Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status