• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
New and changed ActionScript language elements
This section describes the ActionScript language elements that are new or changed in Flash MX 2004. To useany of these elements in your scripts, you must target Flash Player 7 (the default) when you publish yourdocuments.
The
and
 methods let you add parameters to specify additional sortingoptions, such as ascending and descending sorting, whether to consider case sensitivity when sorting, andso on.
The
,
, and
properties work with the new ContextMenu andContextMenuItem classes to let you associate context menu items with Button, MovieClip, or TextFieldobjects.
TheContextMenu classand ContextMenuItem classlet you customize the context menu that is displayed when a user right-clicks (Microsoft Windows) or Control-clicks (Macintosh) in Flash Player.
TheError classand the 
and
commands let you implement more robustexception handling.
The
and
methods add or change HTTP requestheaders (such as
Content-Type
or
SOAPAction
) sent with
POST
actions.
 
The
function lets you issue Flash JavaScript API commands from ActionScript.
(Windows only) The
 event listener is generated when the user scrolls using the mousewheel.
The
method lets you create MovieClip instances at runtime and beguaranteed that their objects render in front of the other objects in a parent movie clip's
 z 
-order space. The
method lets you access dynamically created MovieClip instances usingthe depth as a search index.
The
 method lets you determine which version of Flash Player is supported bya loaded SWF file.
The
method and the TextSnapshot objectlet you work with text that is in static text fields in a movie clip.
The
property lets you specify that a movie clip will act as
_root
for any movie clipsloaded into it, or that the meaning of 
_root
in a movie clip won't change if that movie clip is loaded intoanother movie clip.
TheMovieClipLoader classlets you monitor the progress of files as they are being loaded into movie clips.
TheNetConnection classand NetStream class let you stream local video files (FLV files).
ThePrintJob classgives you (and the user) more control over printing from Flash Player.
The
event handler provides access to ID3 data associated with a Sound object that containsan MP3 file.
The
property provides access to the metadata that is part of an MP3 file.
TheSystem class has new objects and methods, and theSystem.capabilities object has several new properties.
The
property lets you remove extra white space from HTML text fields that arerendered in a browser.
The
property lets you specify whether a text field's contents should scrollwhen the mouse pointer is positioned over a text field and the user rolls the mouse wheel.
TheTextField.StyleSheet classlets you create a style sheet object that contains text formatting rules suchas font size, color, and other formatting styles.
The
property lets you attach a style sheet object to a text field.
The
 method accepts a new parameter, and the object it returns contains anew member.
 
The
method lets you add or change HTTP request headers (such as
Content-Type
or
SOAPAction
) sent with
POST
actions.
New security model and legacy SWF files
Rules for how Flash Player determines whether two domains are the same have changed in Flash Player 7. Inaddition, rules that determine whether and how a SWF file served from an HTTP domain can access a SWF fileor load data from an HTTPS domain have changed. In most cases, these changes won't affect you unless youare porting your existing SWF files to Flash Player 7.However, if you have SWF files published for Flash Player 6 or earlier that load data from a file stored on aserver, and the calling SWF is playing in Flash Player 7, the user might see a dialog box that didn't appearbefore, asking whether to allow access. You can prevent this dialog box from appearing by implementing a
 policy file
on the site where the data is stored. For more information on this dialog box, seeAbout compatibilitywith previous Flash Player security models.You might also need to implement a policy file if you are using runtime shared libraries. If either the loading orloaded SWF file is published for Flash Player 7 and the loading and loaded files aren't served from the exactsame domain, use a policy file to permit access. For more information on policy files, see About allowing cross-domain data loading. 
Porting scripts
As with any new release, Flash Player 7 supports more ActionScript commands than previous versions of theplayer; you can use these commands to implement more robust scripts. (SeeNew and changed ActionScriptlanguage elements.)However, if you used any of these commands in your existing scripts, the script might notwork correctly if you publish it for Flash Player 7.For example, if you have a script with a function named Error, the script might appear to compile correctly butmight not run as expected in Flash Player 7, because Error is now a built-in class (and thus a reserved word) inActionScript. You can fix your script by renaming the Error function to something else, such as ErrorCondition.Also, Flash Player 7 implements a number of changes that affect how one SWF file can access another SWF file,how external data can be loaded, and how local settings and data (such as privacy settings and locallypersistent shared objects) can be accessed. Finally, the behavior of some existing features has changed.If you have existing scripts written for Flash Player 6 or earlier that you want to publish for Flash Player 7, youmight need to modify the scripts so they conform with the implementation of Flash Player 7 and work asdesigned. These modifications are discussed in this section.
ECMA-262 Edition 4 compliance
Several changes have been implemented in Flash Player 7 to conform more closely to the ECMA-262 Edition 4proposal (seewww.mozilla.org/js/language/es4/index.html). In addition to the class-based programmingtechniques available in ActionScript 2.0 (seeNew object-oriented programming model), other features havebeen added and certain behaviors have changed. Also, when publishing for Flash Player 7 and usingActionScript 2.0, you can cast one object type to another. For more information, seeCasting objects. Thesecapabilities don't require you to update existing scripts; however, you may want to use them if you publish yourscripts to Flash Player 7 and then continue to revise and enhance them.Unlike the changes mentioned above, the changes listed in the following table (some of which also improveECMA compliance) may cause existing scripts to work differently than they did previously. If you used thesefeatures in existing scripts that you want to publish to Flash Player 7, review the changes to make sure yourcode still works as intended or to determine whether you need to rewrite your code. In particular, because
undefined
is evaluated differently in certain cases, you should initialize all variables in scripts that you port toFlash Player 7.
SWF file published for Flash Player 7SWF file published for earlier versions of FlashPlayer
Case sensitivity is supported (variable names that differonly in capitalization are interpreted as being differentvariables). This change also affects files loaded with
#include
and external variables loaded with
LoadVars.load()
. For more information, see Casesensitivity.Case sensitivity is not supported (variable namesthat differ only in capitalization are interpreted asbeing the same variable).Evaluating
undefined
in a numeric context returns
NaN
.
myCount +=1;
 
trace(myCount); // NaN
 Evaluating
undefined
in a numeric context returns0.
myCount +=1;
 
trace(myCount); // 1
 
When
undefined
is converted to a string, the result is
undefined
.
firstname = "Joan ";
 
lastname = "Flender";trace(firstname + middlename + lastname);
 
// JoanundefinedFlender
 When
undefined
is converted to a string, the resultis "" (an empty string).
firstname = "Joan ";
 
lastname = "Flender";trace(firstname + middlename + lastname);
 
//Joan Flender
 When you convert a string to a Boolean value, the result is
true
if the string has a length greater than zero; the resultis
false
for an empty string.When you convert a string to a Boolean value, thestring is first converted to a number; the result is
true
if the number is nonzero,
false
otherwise.When setting the length of an array, only a valid numberstring sets the length. For example, "6" works but " 6" or"6xyz" does not.
my_array=new Array();
 
my_array[" 6"] ="x";trace(my_array.length); // 0
 
my_array["6xyz"]="x";
 
trace(my_array.length); // 0
 
my_array["6"]="x";
 
trace(my_array.length); // 7
 When setting the length of an array, even amalformed number string sets the length:
my_array=new Array();
 
my_array[" 6"] ="x";trace(my_array.length); // 7
 
my_array["6xyz"]="x";
 
trace(my_array.length); // 7my_array["6"] ="x";
 
trace(my_array.length);// 7
 
Domain-name rules for settings and local data
In Flash Player 6, superdomain matching rules are used by default when accessing local settings (such ascamera or microphone access permissions) or locally persistent data (shared objects). That is, the settings anddata for SWF files hosted at here.xyz.com, there.xyz.com, and xyz.com are shared, and are all stored atxyz.com.In Flash Player 7, exact-domain matching rules are used by default. That is, the settings and data for a filehosted at here.xyz.com are stored at here.xyz.com, the settings and data for a file hosted at there.xyz.com arestored at there.xyz.com, and so on.A new property,
System.exactSettings
, lets you specify which rules to use. This property is supported for filespublished for Flash Player 6 or later. For files published for Flash Player 6, the default value is
false
, whichmeans superdomain matching rules are used. For files published for Flash Player 7, the default value is
true
,which means exact-domain matching rules are used.If you use settings or persistent local data and want to publish a Flash Player 6 SWF file for Flash Player 7, youmight need to set this value to
false
in the ported file.For more information, see
.
Cross-domain and subdomain access between SWF files
When you develop a series of SWF files that communicate with each other—for example, when using
loadMovie()
,
MovieClip.loadMovie()
,
MovieClipLoader.LoadClip()
, or Local Connection objects—youmight host the movies in different domains, or in different subdomains of a single superdomain.In files published for Flash Player 5 or earlier, there were no restrictions on cross-domain or subdomain access.In files published for Flash Player 6, you could use the
LocalConnection.allowDomain
handler or
System.security.allowDomain()
method to specify permitted cross-domain access (for example, to let a fileat someSite.com be accessed by a file at someOtherSite.com), and no command was needed to permitsubdomain access (for example, a file at www.someSite.com could be accessed by a file atstore.someSite.com).Files published for Flash Player 7 implement access between SWF files differently from earlier versions in twoways. First, Flash Player 7 implements exact-domain matching rules instead of superdomain matching rules.Therefore, the file being accessed (even if it is published for a Player version earlier than Flash Player 7) mustexplicitly permit cross-domain or subdomain access; this topic is discussed below. Second, a file hosted at asite using a secure protocol (HTTPS) must explicitly permit access from a file hosted at a site using an insecureprotocol (HTTP or FTP); this topic is discussed in the next section (see HTTP to HTTPS protocol access betweenSWF files).Because Flash Player 7 implements exact-domain matching rules instead of superdomain matching rules, youmight have to modify existing scripts if you want to access them from files that are published for Flash Player 7.(You can still publish the modified files for Flash Player 6.) If you used any
LocalConnection.allowDomain()
or
System.security.allowDomain()
statements in your files and specified superdomain sites to permit, you mustchange your parameters to specify exact domains instead. The following code shows an example of the kinds of changes you might have to make:
// Flash Player 6 commands in a SWF file at www.anyOldSite.com// to allow access by SWF files that are hosted at www.someSite.com// or at store.someSite.comSystem.security.allowDomain("someSite.com");
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...