Академический Документы
Профессиональный Документы
Культура Документы
Script 2.0
Flash MX 2004
1. . ActionScript:
1.1. ActionScript:
1.1.1. Flash
1.1.2. Actions
1.1.3. . Behaviors
1.1.4. Actions
1.1.5.
1.1.6.
1.1.7.
1.1.8.
1.1.9. ActionScript-
1.1.10. trace() Output
1.1.11.
1.2. ActionScript
1.2.1.
1.2.2.
1.2.3.
1.2.4. ActionScript
1.2.5.
1.2.6.
1.3.
1.3.1. -262 ActionScript
1.3.2. ActionScript Flash-
1.3.3. ActionScript. Flash-
1.3.4.
1.3.5.
1.3.6.
1.3.7.
1.3.8.
1.3.9.
1.3.10. ActionScript
1.3.11. _root, _parent, Leveln this
1.3.12.
1: ( )
2.
2.1.
2.2. ( number)
2.2.1. ActionScript
2.2.2.
2.2.3.
2.2.4. Number
2.2.5. . parseInt() parseFloat()
2.3. . Math
2.3.1.
2.3.2.
2.3.3.
2.3.4.
2.3.5.
2.3.6.
2.3.7.
2.3.8.
2.3.9.
2.4. ( string)
2.4.1.
2.4.2.
2.4.3. String
2.4.4. . lengths
2.4.5. . concat()
2.4.6. . charAt()
2.4.7. . indexOf() lastIndexOff()
2.4.8. . substring(), substr(), slice()
2.4.9. . split()
2.4.10. . toLowerCase() toUpperCase()
2.4.11. . fromCharCode() charCodeAt()
2.4.12. . eval()
2.4.13.
2.5. . Flash
2.5.1.
2.5.2. Flash-
2.5.3.
2.5.4.
2.5.5. 8- . System.useCodepage
2.6. ( boolean)
2.6.1. Boolean
2.7. undefined
2.8. null
2.9. ( object)
2.9.1.
2.9.2. . ASSetPropFlags()
2.10. ( movieclip)
2.11.
2.11.1.
2.11.2.
2.12. ActionScript
2:
3.
3.1.
3.2.
3.3.
3.4.
3.5.
3.6. ActionScript?
3.7.
3:
4.
4.1.
4.2.
4.3. return
4.4.
4.5.
4.6. arguments
4.6.1. arguments
4.6.2. arguments
4.7.
4.8.
4.8.1. Function
4.8.2. prototype
4.8.3.
4.9. .
4: -
5.
5.1.
5.2.
5.3.
5.4.
5.5.
5.5.1. =
5.5.2.
5.5.3.
5.6.
5.6.1.
5.6.2.
5.7.
5.8. (?:)
5.9.
5.9.1.
5.9.2.
5.9.3.
5.9.4.
5.9.5. new
5.9.6. super
5.9.7. delete
5.9.8. typeof
5.9.9. instanceof
5.9.10. void
5.9.11. ..
5.10.
5.10.1.
5.10.2.
5: 3D-
6.
6.1.
6.2. var function
6.3.
6.4. return
6.5. with
6.6.
6.6.1. if
6.6.2. switch
6.7.
6.7.1. (while dowhile)
6.7.2. (for)
6.7.3. forin
6.7.4. break continue
6.7.5.
6.7.6. onEnterFrame
6.7.7. . setInterval()
6.8. . try-catch-finally, throw Error
6:
7. ( Array)
7.1.
7.2.
7.3. . length
7.4.
7.5.
7.6.
7.7.
7.8.
7.9.
7.10.
7.11.
7.12. forin
7.13. ActionScript
7:
8.
8.1.
8.1.1.
8.1.2.
8.2.
8.3. Flash 5
8.4.
8.5. AsBroadcaster.
8:
9. -
9.1. -
9.2. - ActionScript 1.0
9.2.1.
9.2.2.
9.2.3.
9.2.4.
9.2.5.
9.2.6.
9.2.7. Flash 6
9.2.8. super
9.2.9.
9.2.10.
9.2.11. . Global
9.3. Object
9.3.1. Object
9.3.2. registerClass().
9.3.3. addProperty(). getter/setter
9.3.4. watch() unwatch().
9.3.5. Object
9.4. - ActionScript 2.0
9.4.1.
9.4.2.
9.4.3. .
9.4.4. AciionScript2.0
9.4.5.
9.4.6.
9.4.7.
9.4.8.
9.4.9.
9.4.10. getter/setter
9.4.11.
9.4.12.
9.4.13.
9.4.14.
9.4.15. . intrinsic
9:
10.
10.1.
10.2.
10.2.1.
10.3.
10.3.1.
10.3.2. MovieClip
10.4. _root
10.5.
10.5.1. duplicateMovieClip()
10.5.2. attachMovie().
10.5.3. createEmptyMovieClip().
10.6.
10.6.1. . swapDepths()
10.6.2. . getlnstanceAtDepth() getNextHighestDepth()
10.7.
10.7.1. flash-.
10.7.2. loadMovie() loadMovieNum()
10.7.3.
10.7.4. MovieClipLoader
10.7.5.
10.7.6. swf-
10.7.7.
10.7.8.
10.7.9.
10.8.
10.9.
10.9.1. _lockroot
10.9.2.
10.9.3. Insert Target Path
10.10.
10.10.1. _x _y
10.10.2.
10.10.3.
10.10.4.
10.10.5.
10.10.6.
10.11.
10.11.1. _alpha
10.11.2. _visible
10.12. . startDrag()
10.12.1. _droptarget
10.13. . hitTest()
10.13.1.
10.13.2.
10.13.3.
10.14.
10.14.1.
10.14.2.
10.14.3.
10.15.
10.16.
10.16.1. . removeMovieClip()
10.16.2. . unloadMovie()
10.16.3.
10.17.
10.17.1. Flash 5
10.17.2. (onEnterFrame)
10.17.3. (onLoad)
10.17.4. (onUnload)
10.17.5. (onData)
10.17.6. (onMouseDown, onMouseUp, onMouseMove)
10.17.7. (onKeyDown, onKeyUp)
10.17.8. ..
10.17.9. (onSetFocus, onKillFocus)
10.18.
10.18.1.
10.18.2.
10.18.3.
10.18.4.
10.18.5.
10.19. . Color
10.19.1.
10.19.2.
10.19.3. . setRGB()
10.19.4. . setTransform()
10: 3D-
11.
11.1.
11.2.
11.3.
11.3.1.
11.3.2. Flash 5
11.4.
11.5.
11.6.
11.7.
11.7.1.
11.7.2. _focusrect
11.7.3. onSetFocus onKillFocus
11.7.4.
11.7.5.
11.8.
11:
12.
12.1.
12.1.1.
12.1.2.
12.1.3.
12.1.4.
12.1.5.
12.2.
12.2.1. . ContextMenu
12.2.2.
12.3.
12.3.1.
12.3.2. onKeyDown onKeyUp
12.3.3. . getCode()
12.3.4. . getAscii()
12.3.5. . isDown()
12.3.6. . isToggled()
12:
13.
13.1.
13.1.1. Text
13.1.2.
13.1.3.
13.2.
13.3.
13.4.
13.5.
13.5.1.
13.5.2.
13.5.3.
13.5.4.
13.5.5.
13.5.6.
13.5.7.
13.6. . TextFormat
13.6.1.
13.6.2.
13.6.3.
13.6.4.
13.6.5.
13.6.6.
13.6.7.
13.6.8.
13.6.9.
13.7.
13.7.1.
13.7.2.
13.7.3.
13.7.4.
13.7.5.
13.7.6.
13.8. onChanged
13.9.
13.10.
13.11. HTML
13.11.1. < > ... < / >
13.11.2. < BR >
13.11.3. < U > ... < /U >
13.11.4. < > ... < / >
13.11.5. < FONT > ... < /FONT >
13.11.6. < I > ... < /I >
13.11.7. < >... < / >
13.11.8. < LI > ... < /LI >
13.11.9. < >
13.11.10. < TEXTFORMAT > ... < TEXTFORMAT >
13.11.11. < SPAN > ... < /SPAN >
13.11.12. < IMG >
13.11.13. . condenseWhite
13.12. (CSS)
13.12.1. CSS
13.12.2.
13.12.3.
13.12.4. CSS, Flash-
13.13. . Selection
13.13.1. . getFocus() setFocus()
13.13.2. (onSetFocus)
16.2.7.
16.2.8.
16.3.
16.3.1.
16.3.2. fscommandf()
16.4. ,
16.4.1.
16.4.2.
16.4.3. LocalConnection
16.5.
16.5.1. < EMBED > < OBJECT >
16.5.2. HTML-
16.5.3.
16.5.4. . getURL()
16.5.5. JavaScript fscommand()
16.5.6. SWF- JavaScript
16.5.7. Flash-
16.6.
16.6.1. Actions
16.6.2. CustomActions
16.6.3. JSFL
16.7.
16.8.
16.9.
16.9.1. SharedObject
16.9.2. SharedObject
16.9.3. sol-
16.9.4. SharedObject
16.9.5.
16.10.
16.10.1.
16.10.2. PrintJob
16:
17.
17.1. Flash MX 2004
17.1.1.
17.1.2.
17.1.3.
17.1.4.
17.1.5.
17.1.6. ,
17.2.
17.2.1.
17.2.2. loadVariables()
17.2.3. LoadVars
17.3.
17.3.1.
17.3.2.
17.3.3.
17.4.
17.4.1. XMLSocket
17.4.2. -
17.5. XML
17.5.1. L
17.5.2. XML. DOM
17.5.3. XML- DOM
17.5.4. DOM
17.5.5. XML-
17.5.6. XML-
17:
18.
19.
20.
,
.
ActionScript
1995 .
, Web-
. .
World Wide Web, American Online , . , Web- .
, . , . ( ): ,
, (
). : ; GIF- Java (
) , . Web- ,
, . - ,
HTML, , , ,
, . , ,
, ,
. , ,
; Navigator Explorer, PC Macintosh. .
Macromedia. , .
Macromedia Future Animation, ( 3 ), FutureSplash Animator,
. , Web-, Macromedia Flash
().
. 1. FutureSplash. , ,
, , , .
Flash : , W3C -
Flash 3 . , .
loadMovie(),
swf-, fscommand(), .
Flash 4 .
, , ,
, . Flash , .
, , ,
, .
, , . , -
, . , Flash 4
, ActionScript.
2000 . Flash 5 Macromedia Flash 4 . JavaScript,
. Macromedia ActionScript JavaScript. ActionScript Web-, . , Macromedia
ECMAScript ,
(), JavaScript.
ActionScript Flash .
- .
Flash . , , Flash 5.
Flash MX ActionScript . , , .
ActionScript Flash MX 2004 . -,
- , .Java. -, ,
. -, . ActionScript Flash
MX 2004 ( ) .
Flash ActionScript 2.0. ActionScript
ActionScript 1.0.
ActionScript
| ActionScript? . ,
, . , .
, Flash . , ActionScript, .
Flash- .
, ActionScript.
, gif . , ,
. ,
.
ActionScript, . ,
Flash- usability , . Flash
Web-.
. ActionScript ,
. , Flash, ,
, HTML. Flash- , .
Flash . ,
Flash , ,
.
Flash . , . ActionScript .
, Flash-. ,
. , ActionScript . , ,
.
ActionScript .
, .
, ,
. ,
ActionScript,
. .
ActionScript , . . ActionScript
, -, Windows
. , Flash!
Flash MX 2004 ActionScript.
.
, , , XML. ,
. , .
, , . ,
.
? , , .
, ActionScript . , .
. 18, 19 20 , doc- . . -, . -, , ,
, - . , ,
.
, ? ActionScript, , Flash. ,
Flash. . , (Library), (Symbol),
(MovieClip), | (Button), (Frame), (Layer), (Instance), ,
, , *.fl *.swf, ActionScript .
Flash , .
? , Flash . ActionScript, . ,
. .
, .
fla-.
- .
Flash? .
, ActionScript. . , ,
, ,
, , .
.
, ActionScript ( Actions) . ,
. -262.
. , .
, , Flash? , . ,
, .
.
, , , ActionScript? ,
. , ActionScript .
, Flash (.
), , ,
. , , .
(http://www.flasher.ru/forum) , , . , FAQ, , - . .
.
.
, , . , , , . , , ,
, diis_ignotis@tut.by.
, .
!
Flash , ,
. ,
, Flash MX 2004 Flash 4. Macromedia
. Flash .
ActionScript ,
- , , . , ActionScript, : , 90 % . .
, Flash,
ActionScript-, . : Flash ActionScript ; , . ,
,
! ,
, ,
. !
.
ActionScript:
- ? , .
, , . ,
, ( ) ,
! ,
, , - ?
, Flash ?
Macromedia Flash , , .
: ActionScript. . , , , , , , , .
Flash , , . 500 , ActionScript . , .
, . : ,
Present Indefinite , Flash . , , .
,
. ActionScript Actions,
. , , , .
, ,
Hello, Bob!, . ActionScript 1.
.
, , .
. , . : , 20 ,
Flash. , ActionScript ,
.
1.1. ActionScript:
1.1.1. Flash
Flash MX 2004 .
, . ?
, Flash . ,
, , , . ActionScript Flash
. , Flash MX Professional
, , -. -
online- . , ActionScript.
Flash ,
, . , . ActionScript- (*.as), .
Flash Communication Server ( , ,
). . Flash MX 2004 Professional
JSFL (JavaScript Flash Language).
, , , . ,
500 , Flash MX 2004
Professional . .
Flash. ,
. , , ActionScript, ,
Flash MX 2004 Professional.
1.1.2. Actions
, . .
,
.
, .
Actions () (. 1.1). ,
, Flash. , ( Properties ()).
, , , , .
Window/Panel Sets/Default Layout (/ / ), , .
Actions , ,
. 1.1 1. ,
. , , . Act
ions , .
. Properties () .
.
Actions ( . 1.1 2),
ActionScript.
.
, , , Built-in Classes ( )
, ActionScript. , Index. ,
Flash. ,
. , , ActionScript !
Actions , 3.
, .
, . 1.1 4,
, . , - , Actions. , , . ,
( , , ). , , , Actions, , ,
Actions . , , .
- ,
Actions. Pin Script
. . , .
, Actions ,
.
, Actions ,
. , <F9> ( , ).
Actions , Window/Development panels (/ ) Close Panel ( ) .
1.1.3. . Behaviors
Flash , , .
, Flash 5 Flash MX Actions Normal Mode. ,
ActionScript , , .
. 1.2. Behaviors
, Behaviors ActionScript, .
, http://www.flasher.ru ( , ).
1. . ,
(Window Other Panels Common Libraries Buttons).
2. Behaviors, . , - mi .
3. , +. , , (
, , ). ,
Sound : Load Sound From Library ( ), Load Streaming MP3 File ( 3), Play Sound ( ). Stop All Sounds ( ), Stop Sound ( ).
, Go to Web Page ( Web). . Go to URL, . URL , . http://www.flasher.ru/. Open in ( ) , .
, , _blank.
4. Behaviors . , , . Event
, ( ). Action . Action
Go to Web Page. Event : on Release. onRelease , , , , .
onPress, , .
, , . , .
on Press.
. (<Ctrl> + <Enter>) . http://www.flasher.ru/.
Behaviors . , ActionScript, Flash. , , . Action (<F9>):
on (press) {
//Goto Webpage behavior
getURLC'http: //www. flasher.ru", "_blank") ;
//End Behavior
}
, . . , .
Behaviors. , .
, Behaviors.
, - Behaviors.
, Behaviors .
. ? -, ,
, Behaviors, .
.
, . -,
Behaviors . , , ActionScript.
1.1.4. Actions
, Actions ,
Behaviors. ActionScript, ,
. . , , .
. ,
Actions . ,
ActionScript. ,
( ). , ,
: gotoAndPlay. , , ,
.
(, GotoAndPlay), , .
, ActionScript , .
, ,
Actions (
Index ).
Normal Mode. , , . - ,
.
.
, , , , .
ActionScript Flash MX . . , ,
( ),
, , (. .
1.3). ,
. ,
ActionScript.
,
. , , . . , myClip_mc , my_string_str . .
. 1.1.
.1.3.
1.1
Array
_array
Button
_btn
Camera
_cam
Color
_color
ContextMenu
_cm
Context MenuItem _cmi
Date
_date
Error
_err
LoadVars
_lv
LocalConnection _lc
Microphone
_mic
MovieClip
_me
MovieClipLoader _mcl
PrintJob
NetConnection
NetStream
SharedObject
Sound
String
xtField
TextFormat
Video
XML
XMLNode
XMLSocket
_pj
_nc
_ns
_so
_sound
_str
_txt
_fmt
_video
_xml
_xmlnode
_xmlsockei
,
. :
//
, my_clip , ,
MovieClip , :
// MovieClip my_clip;
, ;.
( 2).
. .
ActionScript . Actions, . Actions, .
, , UltraEdit. , .
1.1.5.
Actions -: ,
. Flash. ActionScript : , .
, .
.
: , , ,
. , , , .
, <F9>.
(Keyframe Blank Keyframe). , ,
. (. 1.4).
. 1.4.
, .
. , , ,
. onEnterFrame ( ), , ,
. , , , .
, , . , .
( ,
, ) Actions, .
, , ,
.
( ) , ,
. , .
, , : . ,
. Flash, , , .
Flash 5, . ,
, () ,
.
, . Flash
MX ,
. ,
, .
, Actions, <F9>.
.
onCIipEvent(), ,
, ,
. , (
, ) 10 % :
onClipEvent (mouseDown) {
_xscale += 10;
_yscale += 10;
}
,
. ,
fla-, Flash 5.
, Flash MX 2004,
.
, - :
,
. , , ,
on(). , . Buttons Flash (Window/Other Panels/Common Libraries):
on (press, keyPress "<Space>") {
_visible = false;
}
, ,
.
, , Actions:
Frame, Button Movie Clip.
1.1.6.
, Flash ActionScript , ,
. , ,
. ,
Flash 5
, .
. ,
. , ,
, .
ActionScript-
, . , Movie
Explorer (Window/Movie Explorer), ,
( , Actions).
. , , .
.
Flash MX , . . ( ). ,
. .
1.1.7.
ActionScript, . , , ,
. 1000 , ,
, Flash . , . , Actions (. 1.5).
. 1.5.
, 1, ActionScript, , Actions ( Index). , ,
. , ,
. , , (.
1.6). ActionScript,
View Esc Shortcuts Keys ( Esc- ) Actions.
Puc. 1.6.
2 (. 1.5) , | . ActionScript- , , , ( ).
3 . 1.5 ,
.
, , . , , .
, .
4 , . ,
. ( , ) . .
, 5, . , Output.
, ,
.
, , .
20 .
, , , 6 . 1.5.
. ,
(. 1.7). , , , .
( <Ctrl> + <Shift> + <F>).
function func (a,b){
if (atrue) trace {b);}
, , , Auto Format
Options ( ) Actions.
Flash MX 2004 , Word Wrap (
) ( Actions), ,
. Word Wrap,
.
, 7 (. 1.5),
. ( ).
ActionScript , , , Actions
(. 1.8).
Puc. 1.8.
, , .
Go to Line ( ) Actions, <Ctrl> + <G>. ,
, . - .
. , View Line Numbers (
) Actions <Ctrl> + <Shift> + <L>. , .
, Actions. , , .
.
1.1.8.
. , ActionScript Editor ( ActionScript) Preferences ()
Edit () ( Preferences
Actions) (. 1.9).
Automatic Indentation ( ) ,
, . , , , .
Tab Size ( ).
Open/Import Save/Export ,
ActionScript, .
.
Code Hints ( ) ,
. Delay ().
(Delay-0).
Text () , .
, ,
, .
Syntax Coloring ( ) ,
. .
, Actions ( Background ( )). , - ,
.
.
1.1.9. ActionScript-
- , , , . , , ,
, ?
, ActionScript- fla-, . , , ,
. -, , fla- Flash.
, ActionScript ( )
. , , *.txt.
.
fla-.
ActionScript *.as. Actions B , Export Script ( ) .
1.10.
s-
, .
#include, , . ;
. ,
fla-. ,
script.as, , , :
#include "script.as"
, , , :
#include
C:\\MyScripts\\project.as
, trace() ,
(,
, - , ).
, , trace() swf-: Omit Trace Actions ( )
Flash Publish Settings ( ) ( File). trace() swf-.
, Output Flash . , , ( ), . . 1.11 , trace()
( ).
. 1.11. Output
( ,
). Output , , .
Output . Word Wrap ( ), . .
Output Clear. .
1.1.11.
Flash (
ActionScript). Flash MX 2004 . , . ,
Reference, Actions.
Help () ( 1.12).
Help () :
Help. Flash,
, , ActionScript.
How Do I...( ). ,
Flash, .
, , , Flash.
Help.
.
Windows .
:
, .
,
View Help ( ).
, Actions ().
Using Components ( ). ( ,
).
Help () . . , -
.
Flash. Macromedia .
, Update () Help.
ActionScript .
, Flash -
Macromedia (http://www.macromedia.com).
Flash-. , http://www.vmstudio.com Flash-.
http://www.flash-ripper.com , Flash.
Flash-
http://www.flasher.ru. , , ActionScript.
, ActionScript, .
, :
.
1.2. ActionScript
. ActionScript.
, , ,
. ActionScript, , , . , ,
.
1.2.1.
. , ,
. (
), .
.
: ( ),
( ) ( ). , , ,
!
ActionScript ( , ) . :
varmyVar;
//
//
var myVar; //
//
var
myVar;
//
//
:
:
:
,
.
x=y * z;
=
z;
//
, !
.
, .
, (, ). ,
. ActionScript-. , Actions, , ,
. ,
, .
,
.
1.2.2.
, . ActionScript.
, -
.
( , ). :
var a="Hello, "; // 1: ,
var b="World!!!"; // 2:
trace(a+b);
// 3: ,
//
ActionScript .
, . ,
(
).
//
// ";"
var a="Hello, "
var b="World!!!"
trace(a+b)
ActionScript , -
, . , (,
, ).
// ";"
//
var A=[l,2,3] var B=l
//
var A=[1,2,3]; var B=l;
, . , . ,
. .
function func(a,b){ //
var c=a*b; // 1: ";"
return ; // 2: ";"
} // : ";"
, , :
, . :
_root.onEnterFrame = function() {
trace(_root._currentframe);
};
// ";"
ActionScript, #include (
), #initclip ( ), #endinitclip ( ).
, .
.
1.2.3.
-262, ActionScript, . s ActionScript FlashMX Flash 5
(, : ).
,
Flash, .
, , , ActionScript . , .
ActionScript 2.0 . , date Date ,
Date , Flash:
var date = new Date();
,
. , .
,
:
, ,
.
, . ,
. ,
(var function), (while, continue, break) (if, else, switch,
case, default), (
).
While(1) {} //
//
//
, , , Flash MX Flash 5 ,
Flash 7, . , , . Find
And Replace ( ) Actions Match Case (
).
, ActionScript . ; Macromedia , Flash- .
1.2.4. ActionScript
-262
(reserved words). , .
, . , , ,
. ActionScript:
break
case
class
continue
default
delete
dynamic
else
extends
for
function
get
if
implements
import
in
instanceof
interface
intrinsic
new
private
public
return
set
static
switch
this
typeof
var
void
while
with
:
. , ActionScript, -262, .
1.2.5.
ActionScript . ,
, ,
. ? -, , , . -,
, -
. -, flash, , , ActionScript.
.
, ,
.
( , +, @, ^, (, *, +, /,-, [ , .) , ActionScript.
.
var
var
var
var
my variable;
my-variable;
my2variable;
my_variable;
// :
// :
// :
// :
.
,
ActionScript.
var 2myVariable
var _myVariable
// :
// , : "_"
//
-262
.
. ,
(,
, ) .
ActionScript. , . , ActionScript.
var Date = new Date(); //
//
//
var default = true;
//
//
--!
Date!
(), ()
, . (, , ) , .
var obj=new Ball (] ; //
//
myOwnFunction();
//
//
,
,
, ,
. , .
var MAX_NUMBERS_OF_CLIPS=1000;
//
var numbers_of_clips = arr_of_clips . length; //
( :
, . : . ( ): ,
( , .
var CHISLO_SHARIKOV = 10; // :
//
bedinGradientFill ()
// :
var CHISLO_SHARIKOV=ftp2n; // :
// ftp2n?
. - . , Flash-
Flash 6. Flash MX 2004,
Actions. , 65
000 , .
var ="11";//
.
, . , , . ,
: . ,
. (legends)
, .
1.2.6.
- , . . , , -. , , , , , , ,
! , , ,
. .
, , , .
( ) , .
,
.
, : , , ,
, , ,
, , .
, .
ActionScript, , Java, :
. //.
, , (
). Actions, ( ) . :
var n=0; //
: /* */. ,
, . , . :
var n=0 /*
ball.
100, "" */
.
. , ,
.
, ,
. ? , .
, ,
. , , . . .
- . , , , .
// - ...
/* this.attachMovie ("ball", "ball"+r, ., |_: 10*, _:20*.));
eval("tbis.ball"+n>._visible = false; */
. :
, :
//:ODO: tonic
- ( , ). ,
(bug ID). :
//:BUG: [bug ID] topic
, . . :
//:KLUDGE:
, :
//:TRICKY:
. , ,
.
1.3.
overview. -
, , , . , , ,
, . ,
, : ( ActionScript, ).
ActionScript ,
, ( ) . ,
, .
,
. ,
, , . ,
- , trace() , . -
, : ,
. , .
ActionScript ECMAScript . ,
, . , ActionScript
-262. ,
, , ActionScript ECMAScript . ,
ActionScript ,
-262, .
ActionScript JavaScript. ,
, -262,
Flash-, .
ActionScript
, -262.
, ActionScript. , .
ActionScript -262, , .
ECMAScript pdf- :
http://www.ecma.ch/ecmal/STAND/ECMA-262.htm. ECMAScript Netscape : http://www.mozilla.org/js/language/Edition4.pdf.
,
( ,
Java).
ActionScript .
,
, .
ActionScript ( 500),
. swf-
ActionScript -
Flash-. , , .
var a
var b
var
trace
//
ActionScript
// 3
// b 2
b);
// , b
// Output
//
Flash-
'a', 'b', '' //
3
// 5
//
2
//
= 3;
= 2;
= ( +
();
constants
push 'a',
varequals
push 'b',
varequals
push '', ''
getVariable
push 'b'
getVariable
add
varequals
push ''
getVariable
trace
end
// :
// -
// b
// b
// b
//
//
//
// Output
//
Flash- .
ActionScript.
- . Flash-
, , , ActionScript. , , -
var . - , .
Flash . , , . Flasm, 20.
ActionScript- Flash- ,
, Action Script Viewer Manitu Group.
swf- -.
, , .
20 .
1.3.4.
Flash ( ) FutureSplash
Animator, 1996 . Macromedia. .
(symbols) , .
- . , , ? , , . . , , Flash . , ,
.
Flash . , . ,
, , , , . ,
swf-, .
Flash : MovieClip (), Button
(), Graph (). ,
FutureSplash. , Graph? , , Flash. Graph
, MovieClip, .
, MovieClip ActionScript, a Graph .
,
, , , ActionScript,
Graph.
, , , , .
. ActionScript attachMovie(). .
. <Instance Name> . ActionScript, . ,
, ,
.
ActionScript ,
. , , , . ,
. ,
( , ). , .
. , (<F8>),
big_round. , , :
big_round._xscale=1000;
big_round._yscale=1000;
(<Ctrl> + <Enter>). ,
10 .
. ,
, . ( , ) , , . , MovieClip , .
L root ( ActionScript ) , root, .
Flash. ActionScript ,
, . movieclip ,
, ,
Object. . , , .
1.3.5.
? ,
, . , .
. , ,
, .
ActionScript :
var
name
value,
var , ( ); name
; = ; value . :
var =" "; // ...
: , , , , . , :
trace(); // :
.
,
.
a=3; //
. ,
, .
a=3 + 5;
trace(a);
// 8, 3+5
. , .
3.
1.3.6.
. ,
. , ,
:
var argl=0;
var cotl=Math.cos(argl)/Math.sin(argl);
var arg2=l;
var cot2=Math.cos(arg2)/Math.sin(arg2);
var arg3=2;
var cot3=Math.cos(arg3)/Math.sin(arg3);
trace(cotl); // : Infinity ()
trace(cot2); // : 0.642092615934331
trace(cot3); // : -0.457657554360286
, . , ActionScript
. , ,
:
function cot (arg) {
return Math.cos(arg) /Math.sin(arg);
}
trace(cot(0)); // : Infinity ()
trace(cot(l)); // : 0.642092615934331
trace(cot(2)); // : -0.457657554360286
:
function name (arguments){statements},
, .
, , .
, , , . 4.
1.3.7.
.
, .
. , , . . if ( ). : ,
, , , . :
var a=4;
var b=5;
if(a<b) {
trace(a*b); // : 20 ( <b
}
if , {} ,
: < (), > (),
( ), ( ), == (), != ( ).
: (= ==).
. (&&) ,
(||) . :
var a = 4;
var b = 5;
if (a<b && typeof a == "number" && typeof b == "number") {
trace(a*b); // : 20 (
// , b )
}
, ,
, . else
( ). :
var a = 5;
var b = 5;
if (a<b && typeof (a) == "number" && typeof (b) == "number") {
trace (a*b);
} else {
trace ("Error!!!");
}
// : Error!!! ( a<b )
1.3.8.
.
,
, while if ,
, a while , .
, Output 0 50, :
var i=0;
// .
while (i<=50) { // .
// .
trace (i); // : 0,1,2... 50
i++;
//
}
: ++ . ,
.
, , ,
i, , .
for. :
for(; ; ){
, for while, . , , (
, var). , ,
;
var n=0;
for(var i=0; i<5; i+=0.1) {
trace(n); // 50
n++;
}
for , , . .
1.3.9.
,
.
.
? , ( ). ( , ). ,
. , -
.
, , .
, ; ActionScript . : ,
, , ,
.
. ,
new:
var arr=new
Array ();
, .
( );
var
arr=[];
, , , :
var
arr = new
rr();
. (
) .
: , , , .
( , ).
var arr=new Array(2,Math.random , ["",""]);
var arr1=[2,Math.random , ["",""]];
trace(arr1); // : 2,0.328608815558255,,
,
. ,
ActionScript . , 0, 1 . . , .
rr=[2,4,8,16];
trace(Arr[0]); // : 2
trace(Arr[3]); // : 8
trace(Arr[5]); // : undefined
ActionScript undefined ( ). ,
, , , .
, (
). , ,
:
var arr=["","" ,"!!!"];
var arr1=[];
rr1[0]="";
rr1[1]="";
arr1[4]="!!!"
trace(arr); // : ,,!!!
trace(arrl) ; // : , , undefined, undefined, !!!
, ,
, (. ).
, , , :
var arr=["","","!!!"];
rr[1]=" ";
trace(arr); // : , ,!!!
, ( 7).
.
1.3.10. ActionScript
ActionScript, , -.
,
. Flash. ,
.
- , 1980- . ,
Smalltalk, C++ Object Pascal. ,
( , , 1 ). -
1 .
- .
. ? . , , ( , ).
, , .
? . , , . , .
. ,
, .
.
, , . ,
, ,
.
ActionScript , .
. Math, , , . ,
. , ,
MovieClip gotoAndPlay(), _alpha, _width . .
( ), new -, :
var arr=new Array (); //
. , .
, . ,
, , ,
.
. . : _rotation MovieClip
; enabled Button , ; length
Array . .
. , ,
mov , :
mov.prog=true;
trace (mov.prog); // "true"
ActionScript 2.0 . , . ,
. ActionScript . MovieClip, Button, TextField, Object, Array.
- .
, . , gotoAndPlay() MovieClip
, setVolume() Sound . , , ,
. , ,
(). :
ball.gotoAndPlay(1); // ball
ActionScript , .
, . ,
.
, ActionScript .
, * .
- . , trace() Output,
getURL() . .
( , gotoAndPlay(),
). , ,
Flash.
- . ,
,
. .
, .
ActionScript ,
(prototype). , , , move()
MovieClip,
:
MovieClip.move=move; // !
// move
:
MovieClip.prototype.move=move; // . move()
// ""
, . , , .
, , . , , , .
, , , ,
.
Flash MX 2004 - ,
- ,
Java C++. - 9.
//
,
. , .
. _parent.
_parent , , . .
. , movl. _parent. X mov3 ,
:
trace (_parent .mov2 .mov3 ._x) ,- //
_root
mov1
mov2
mov3
. 1.13.
mov3 movl
:
trace(_parent._rent.movl._x);
:
trace(_root.movl._x); // . ,..
o , ,
, -5.
, _root _parent.
, this, ia , .
trace (this.mov2.mov3._); // ( _root)
// ;
trace (_root.mov2.mov3._x);
this ActionScript . , , ,
- Flash.
, , _leveln. ,
,
:
trace(this); // : _level()
. _root, this
. _level0 _t?
, Flash swf. (level), .
_leveln ,
n. _root this ,
, . , , X mov3
swf-:
trace (_level0.mov2,mov3-_x);
Flash- , loadMovie()
MovieClip ( 10).
1.3.12.
ActionScript .
( ), . ,
,
,
var time=0; //
trace(time); // 0
, , .
, .
, . , , time mov, ,
:
trace (mov.time);
// 0 -
trace (_root.mov.time); // 0 -
, . , , , _root this
_parent.
, ,
, _root.
, . , .
var _root.time=0; // _root,
//
var time=0;
//
, (
). ,
mov time, (
mov):
mov.time=0;
, ,
Global. , .
Global _global:
_global.time=0; // time "" ...
ActionScript , .
, ,
, , . ,
time,
, _root. , MovieClip, . MovieClip Object. Global. , (. 1.14).
,
Global. , MovieClip Object, ,
_root , , MovieClip,
. 1.14, , ,
,
MovieClip, _root this . ,
( , , , ) _root , ,
MovieClip.prototype. , , . .
_root.gotoAndPlay(1); // _root,
//
gotoAndPlay(1);
// ,
, ActionScript, . (, ) ,
ActionScript. , String, String. ,
String, . String() Global,
. MovieClip ActionScript
.
var String=0;
var str=new String(this);
trace(str); // undefined - String
G
L
O
B
A
L
_global.time?
Object.prototype
MovieClip.prototype
_root
_root.time?
trace (time?)
Puc. 1.14. ,
,
. , .
3.
(Event) - , Flash . , , . , . . Flash . , ,
onEnterFrame MovieClip ( ), onMouseDown
Mouse ( ) .
, .
ActionScript (listener - ). , , , . ( , ,
). , , (, Mouse),
MovieClip, . , ,
.
- , - :
.=function () {
};
, , , , .
, , Output ,
:
//
_root.onMouseDown = function () {
trace{" ");
};
,
. . ,
Flash MX, ,
.
ActionScript, ,
, . .
ActionScript 8 .
1: ( )
. , . ,
ActionScript -.
( ) . Flash,
.
,
. , , ! , , -
, .
. ,
. ,
. , , .
Flash 4 :
. .
. , .
. , , (
), .
,
.
(). ,
.
, .
. ActionScript.
.
, , . ,
, ( ,
).
, , ,
. , , .
. , , .
, , ActionScript ( Flash ,
).
. , .
. . :
, Oval () <Shift>.
, .
, - - ( ). , -
( )
-. ,
, . ,
,
. ,
(. 1.15, ). , Fill Transform ( ) , , . . 1.15, (- ).
. 1.15.
. (
). : 300 % Pencil () ( Smooth ())
Array ().
, . . .
, , . .
, . 1.16.
. 1.16.
. -? . . . , . .
, ,
, .
, .
, , . :
.
Oval () , .
( )
( ),
( ).
, 50 % ( Alpha () Color Mixer ( )). ,
. 1.17.
. 1.17.
. 1.18.
. . , . ,
, . ? -, , -,
,
, . , ball :
. ,
, .
: ball.. , -
ball.
, . X:
ball._x. ActionScript, : "_rotation, _xscale, _alpha.
, .
ball , _ . . , =( - - ActionScript, , = =): ball._x=.
-,
. (0, 0) . X
, Y . , , _ .
550 , 50. : ball.
=50;.
Flash . , .
.
, .
Y.
- , 3/5 ( 400 ), , 170.
, :
ball._=-50;
bll._=170;
, , :
contour,_=-50;
contour._y=170;
, , <Ctrl> + <Enter>. ,
.
, ,
. , - , .
:
_root.onEnterFrame. , _root (
) onEnterFrame ( ),
, _root (),
, contour. onEnterFrame , (1/12 ), . ,
( stop()).
, . , :
_root.onEnterFrame=function() {
}
, ,
:
ball._x+=2;
contour._x+=2;
,
. , .
. .
.
. . .
,
Y = Y0 + V y0t + 1 / 2at 2 , Y0 , V y0 , a , t . - ,
() :
ball._y=Y0+Vy*t+a*t*t/2;
* ActionScript . ,
.
, :
X = X 0 + V x t , X 0 , V x . t . :
ball._x=X0+Vx*t;
.
. , ( , ). :
var t=0;
, :
var
var
var
var
var
var
0=50;
Y0=170;
t=0;
a=2;
Vy=0;
Vx=6;
//
//
//
//
//
//
X
Y
, .
. -:
t (
). , . :
t+=0.6;
+= . -=, *=,
/= ( ).
,
, .
. , , , .
, . , .
, -
:
if (bll._>350) {
}
:
. , , . , , .
:
newV=Vy+a*t;
Vy , newV. ,
, :
Vy=-newV*0.85;
( )
:
Vx=0.85*Vx;
, ,
(X0,Y0) (, ). , ,
:
newY=ball._;
newX=ball._;
0 Y0:
X0=newX;
Y0=newY;
, . , t :
t=0.6;
null , - .
.
. , ( , ):
_root.onEnterFrame = function () {
if (ball._y>350) {
Vy = -newV*0.85;
Vx = 0.85*Vx;
t = 0.6;
X0 = newX;
0 = newY;
}
ball._y = Y0+Vy*t+a*t*t/2;
ball._x = X0+Vx*t;
newV = Vy+a*t;
newY = ball._y;
newX = ball._x;
t += 0.6;
}
. ( ).
, . ( ) _rotation. :
contour ._rotation+=8;
fla- , , 1 . ball 1 .. , .
. ,
. :
( ) xscale yscale.
, .
ball2.fla, . , .
, , , Flash. ,
:
, .
. swf- 800 .
, ,
, , ( ). . .
1.19 90 % 80 % ( ,
). ,
. ball3.swf,
.
. 1. 19. .
: 90%, b 80%
. swf
. ,
,
.
. , .
, .
? ,
, .
, . , , , . , ,
. , ,
. : , .
.
. ,
. . boolean. ActionScript 7 : number, string, boolean, null, undefined, object, movieclip.
, object movieclip .
,
. , .
(primitive) .
, , .
, . , , .
, .
2.1.
, , , typeof. :
trace (typeof 4); trace (typeof
root)
// : number () // : movieclip ()
, typeof , :
trace (typeof(4)); //
, , .
typeof , :
trace (typeof
trace (typeof
1+"1");
//
number1
// 1 "1")
(1+"1")); // : string ( :
//
number
string
object
movieclip
boolean
object
object
function
.
- . , ActionScript . , (
, ActionScript). , object, Function.
, typeof function. .
-262 ActionScript typeof
null null ( object).
ActionScript array (). Array, object.
typeof . .
. 2.1 ,
( , ,
). typeof
, ( ActionScript ):
// : value ,
// base
function my_log(value, base) {
// (base=undefined), , ,
//
if (typeof base = "undefined") {
var base = 10;
}
// ,
if (typeof value = "number" && typeof base = "number") {
// ,
return Math.log(value)/Math.log(base);
// number,
//
} else {
trace (" ");
}
}
trace(my_log(100));
// : 2 ( 10 = 100 )
trace(my_log(0.2,5));
// : -1 ( 5
trace(my_log(9, 3));
my_log(_root);
= 1 / 5 = 0.2 )
// : 2 ( 3 = 9 )
2
// :
, . , typeof.
ActionScript instanceof;
var arr=new Array();
trace (arr instanceof Array); // : true (arr )
2.2. ( number)
, ActionScript, . : . , , . ActionScript , .
2.2.1. ActionScript
(integer)
(real), (floatingpoint).
, (, 122 896), (5.8905 0.9067). ( ,
). ,
floating-point. , , ActionScript real integer, number, 64 . .
.
number , , 32- 16 . ,
ActionScript , .
, ActionScript
.
, . ,
.
( trace()
Output ).
trace (0210]; // 136 ( 0 * 8 + 1 * 8 + 2 * 8 = 136 )
0
, , , ,
, .
, , , Flash.
.
0 9 F. ActionScript 0. -
16, , .
trace (0xFF);
// :
255 ( 15 * 16 + 15 * 16 )
0
, , . ,
Color Mixer . ,
, . , 0xFFFFFF, 0x000000, 0x00DD00 , .
, Color. ,
Unicode.
32- . ,
, 232 = 4294962795. 0xFFFF01D5A e .
, . , , .
.
2.2.2.
, . ,
, . . , (, e). . . . , .
, .
64 ( 32-).
26418 446 744 073 709 551 616 . ,
? .
64 ?
. .
() . , 123 1.23 10 2 ,
123000 1.23 10 5 , 0,123 1.23 10 1 .
64 . ,
. (
), .
s m 2 e , s (1 ), , ( 53 ), (10 ) -1074 971.
. 53 , 15 lg(2) 15.
, 15 . 15 , :
trace (1.555555555555557); // : 1.55555555555556
15 , 15 . ,
:
trace (1234568901234567890); // : 1.2345679012346+19
:
trace (0.0000001234567890123956789) ;
// : 1.23456789012346-7
, , , .
, , . , , .
, ,
, , , 53 ,
2 971. :
var n = 0;
//
0
// 252 + 251 +250 +249 +...+21 +2 -
for (i=0; i<53; i++) {
n += Math.pow (2, i);
}
// .
trace (n*Math.pow(2, 971)); // : 1 .7979313486231+308
.
ActionScript Infinity. ,
( ) ,
:
trace (1e+400); // : Infinity
Infinity .
:
trace(-1/0); // : -infinity ( )
Infinity . , :
trace (1/Infinity); // : 0
trace (Infinity*O); // : NaN ( )
, . ,
(, Infinity ). .
-, Infinity:
var value = Infinity;
if (value = Infinity) {
trace(" "); // :
}
.
var value = infinity;
if (isFinite(value) =false) {
trace(" ") // :
}
, . , ,
0.
1 2 1024 4.94065645841247 10 324 :
trace (1e-400); // 0
,
. ,
, :
var a=50O000;
var expr1=a/(Math.pow(+1,1/2)+Math.pow(,1/2));
var expr2=a*(Math.pow(+1,1/2)-Math.pow{,1/2));
trace (expr1-expr2); // : 3.72591557606938-9
, .
, , if(), , , ActionScript , .
, , , . , 15 . , . , :
trace (Math,sin(Math.PI)); // : 1.22460635382238-16 ( -0)
trace (Math.tan(Math.PI/2)); // : 1.63317787283838+16 (
// Infinity)
15 . . , .
, . , Math.round(),
, Math.
. , 0/0, .
, NaN ( Not a Number):
trace(0/0);
// : NaN
trace(4*"");
// : NaN
trace(Math.log(-6)); // : NaN
NaN, Infinity, , ,
, NaN, :
trace(NaN==NaN); // false ( NaN NaN)
isNaN() ,
.
2.2.3.
ActionScript . . , ,
, , . :
var t=10;
t += 2; //
t -= 2; //
t *= 2; //
t /= 2; //
t++;
//
t--;
//
;
:
%, :
trace(14 %3); // : 2 (14=3*4+2)
, , Math().
. Math , . Math 2.3.
2.2.4. Number
number ActionScript Number. ActionScript ECMAScript. -, .
Number() , ,
.
Number , -
Number() new. , , ( ). , .
var numb1 = new Number(1);
var numb2 = new Number ("0xff") ,var numb3 = new Number(true);
trace(numb1); // 1 ( )
trace(numb2); // 255 ( ,
// )
trace(numb3); // 1 (true )
, , , , :
trace (num_simple-num_obj); // : 0
trace (Math.pow(num_obj,2)); // : 9
number object ,
. , , - :
var new_num_simple=6;
var new_num=new Number(6);
new_num.factoria1=720;
new_num_simple.factoria1=720;
trace(new num simple. factorial)
//
//
trace(new num.factorial);
//
//
: undefined (
)
: 720 (
)
Number , .
Number() ,
, .
trace ("12"+"34");
// : 1234 ( )
trace (Number("12")+Number("34")); // : 46 (
// )
Number,
. ,
, .
Number , ,
.
Number toString(), . , , ( ) ( , ).
toString() ,
. 2 32 ( 10). , .
var new_color=0xFFFFFF;
trace(new_color);
//
trace(new_color.toString (16)); //
//
trace(new_color.toString());
//
//
trace(new_color.toString*2));
//
//
trace(new_color.toString (29)); //
//
16777215 ( 10)
: ffffff (
)
: 16777215 (
10)
: 111111111111111111111111
( )
: nkq3j ( 29- (!)
)
, , Number,
. toString()
.
Number(), valueOf().
number. , .
Number . , , , NaN. , :
Number.MAX_VALUE // (1.79769313486231+308)
Number.MIN_VALUE // (4.940656458412476-324)
Number.NEGATIVE__INFINITY // ( -Infinity)
Number.POSITIVE_INFINITY // + ( +Infinity)
Number.NaN
// " ( NaN)
Number,
. , , , ( ), , toString().
/* , .
, "" Number "Number.prototype". factorial.*/
Number.prototype.factorial = function() {
/* , , , .
( NaN Infinity), .
, Math.round{).
- , , , ,
0. this:
, . */
if (isNaN(this) == false && isFinite (this)==true && this>=0 &&
this-Math.round(this) = 0) {
/* , . 1 this (, ),
factor . factor 1. */
var factor = 1,
for (var i = 1; i<=this; i++) {
factor *= i;
}
// return
return factor;
}
/* , ,
NaN*/
else {
return NaN;
}
};
var a=0, b=5, c=3;
trace (a.factorial()); // : 1
trace (b.factorial()); // : 120
trace (.factorial()); // : NaN
, , ActionScript. ActionScript
, .
- Flash .
, Number , . , , , .
:
trace ((1000).toString(16)); // : 3e8
: -45400000 (
)
: NaN (
)
. , ,
, 8 9. .
trace(Number("00067"));
//
//
trace(Number("000678")); //
//
: 55 (
)
: 678 ( 8
)
,
0.
trace(Number("0x99FA")); //
//
trace(Number("99FA"));
//
//
: 39418 (
)
: NaN ( "0" )
parseInt() , ,
, + - . . , NaN.
trace(parseInt("2747464 - ")); //
//
trace(parseInt(" - 2747464")); //
//
: 2747464 (
)
: NaN (
)
.
, ,
. parseInt()
.
trace (parseInt("000123"));
//
//
trace (parseInt("000123",10)); //
//
trace(parseInt("0xFFAA"));
//
//
: 83 (
)
: 123 (
,
)
: 65450 ("0"
)
parseInt(), , , .
2.3. . Math
Math ActionScript . ( Flash , ) . , , . , . - , .
.
. Math
, number. , , , .
2.3.1.
, o , . , , , .
, , .
, , , , . .
. . , , .
, . , ( ,
, ).
, ,
.
, , , , . , , ,
.
a 0 x 0 + a1 x1 + a 2 x 2 + a3 x 3 + K + an x n , , a1, a 2, a3,K an . .
, .
, ,
,
, =0 (12 , 6
0):
1
1
1
1
1
sin( x) = 1 x x 3 +
x5
x7 +
x9
x11.
6
120
5040
362880
39916800
, , . , ,
, . , .
ActionScript, ,
:
function sinus (arg) ( //
// , NaN
if (!isFinite(arg) || isNaN(arg)) {
return NaN;
}
// , // , / 2 / 2
var n - Math.floor(arg/Math.PI); //
var x = arg-Math.PI*n;
// ,
//
if (n %2 == 0) {
var znak = 1;
} else {
var znak = -1;
}
//
return (x-l/6*Math.pow(x, 3)+l/120*Math.pow(x, 5) - 1/5040Math.pow(x,
7)+l/36288G*Math.pow(x, 9) - l/39916800*Math.pow(x, 11) +
l/6227020800*Math.pow (x, 13) - l/1307674368000*Math.pow (x, 15) +
1/355687428096000*Math.pow(x, 17))*znak;
trace(sinus(Math.PI/3));
// : 0.866025403734439
trace(Math.sin(Math.PI/3));
// : 0.866025403784439
trace(sinus(5001*Math.PI/2});
trace(Math.sin(5001*Math.PI/2));
trace(sinus(100*Math.PI));
trace(Math.sin(100*Math.PI)) ;
//
//
//
//
:
:
:
:
1.00000000000004
1
0
1.96479117697823e-15
, , , , .
.
, .
. , 1415-
. ,
. . , . , , , sin(n* ) n 0. ActionScript sin(n* ) = 0 (.
). :
15- . :
trace(Math.tan(Math.PI/2)); // : 1. 63317787283833e+16
// ( Infinity)
trace(Math.sin(Math.Pi/4)-Math.SQRT1_2); // : -1.11022302462516-16
// ( 0)
, , :
,
1213- . .
2.3.2.
ActionScript , Math.pow(x, a),
, . , , , , . :
trace(Math.pow(2,256));
// : 1.1579289237316+77
trace {Math,pow(2,-1.3*156)); // : 0.39349030232429
, ( , ). NaN.
, , , ,
-27, -3. :
trace(Math.pow(-2, 256)); // : 1.15792089237316e+77
trace(Math.pow(-2, -256)); // : 8.63616855509445-78
trace(Math.pow(27, 1/3)); // : NaN
Math.pow(), ,
. ,
. , , :
:
trace(Math.pow{9,1/2)); // : 3 (32=9)
trace(Math.pow(27,1/3)); // : 3 (33=27)
,
:
x n =
.
xn
, . ,
. :
trace(1/Math.pow(9,l/2)==Math.pow(9,-1/2)); // : false
trace(l/Math.pow(9,1/2)-Math.pow(9,-1/2}); //: -5.55111512312578e-17
, ,
. ActionScript Math.sqrt(),
:
trace(Math.sqrt(9)); // : 3
, Flash Math.sqrt(),
Math.pow(). , ,
ActionScript, , , Math.pow() (, , 0,5). , Math.sqrt()
, Math.pow(), ,
.
2.3.3.
e (), 2,718 (
Math.E). , , (, ).
. ,
ActionScript Math.exp(a), e a ,
.
:
trace{Math.exp(-l/2));
// : 0.606530559712633
trace(Math.pow(Math.E,-1/2}); // : 0.606530659712633
, Math.exp() :
Math.pow().
( ). Math.log():
trace(Math.log(Math.E));
// : 1
trace(Math.log(10)=Math.LN10) ; // : true
ActionScript , . , . . , n :
ln( x)
log n ( x) =
.
ln(n)
, ,
2.1.
2.3.4.
. ActionScript Math.abs(). :
trace(Math.abs(-1)); // : 1
, . , , 1 1.
Math.abs() ,
, ( Math.pow()
):
function root1_3(arg) {
if (arg =0) { //
return 0;
}
var znak = Math.abs(arg)/arg; //
//
return Math.pow(Math.abs(arg), 1/3)*znak;
}
trace(root1_3(27)); // : 3
trace(root1_3(-27)); // : -3
2.3.5.
. , , . - , . , , .
ActionScript Math.round(). 0 1. 1 000 000
000 000 000 , , . , , (
- ).
N , N 0 1. Math.random() . N
: ( - N) Math.random() + N. ,
0 100, :
trace (100*Math.random()); // : 1.4111054223031
10 20 :
trace (30*Math.random() -10); // : -4.52681495999017
, Math.randomO, 15- . .
- . , , 1
100. , Math.random() (. 2.3.6):
trace (Math.ceil(Math.random() *100)); // : 56
, :
// .
// molecule.
_root.onEnterFrame = function {
molecule._x += 20*Math.random()-10;
molecule._y += 20*Math.random()-10;
};
2.3.6.
, . , 0 16 777 215 ( 0x000000
OxFFFFFF). ,
OxFFFFFF , Math.random(),
, :
trace(0xFFFFFF*Math.random()}; // : 966372.747087192
, . ActionScript ,
Math.round():
trace(Math.round(0xFFFFFF*Math.random()); // : 11601572
Math.ceil() Math.floor(). ,
:
trace(Math.ceil(2.99999999)); // : 3
trace(Math.ceil(-2.99999999)); // : -2
, . , , ActionScript .
. , n
n
n
, 10 , , 10 . , :
function my_round(number,n) {
var kof = Math.pow(10, n);
return Math.round(number*kof)/kof;
}
trace(my_round(10.198767843)); // : 10.199
2.3.7.
Math , . Math.max(x,y)
( )
. Math.min() :
trace(Math.max(3,2)); // : 3
trace(Math.min(3,2)); // : 2
Math.min() Math.max() , . , :
function maxNumber(array) {
var max_value = -Infinity;
for (var i = 0; i<array. length; i++) {
max_value = Math.max(max_value, rr[i]);
}
return max_value;
)
trace(maxNumber([0, -567, 567, Infinity]));
//
Infinity
2.3.8.
, . Flash
, (, 3 , , ),
.
, . ActionScript Math.sin(), Math.cos() Math.tan(). ,
:
function cot (arg) {
return Math.cos(arg]/Math.sin(arg);
}
trace(cot(Math.PI/4)); // : 1
ActionScript , , , , _rotation, , , . ,
, 360 2 . , /180
. , ,
:
function deg2rad(arg) {
return arg-Math.PI/180;
}
trace(deg2rad(180)); // : 3.14159265358919
.
:
function rad2deg(arg) {
return arg*180/Math.PI;
}
trace(rad2deg(Math.PI/3)); // : 60
, , .
( ),
, . 0 ,
/ 2 / 2. . , ,
. , X Y,
Math.atan()? ,
- / 2 / 2. .
, Math.atan2(y, x) ( ). , (0, 0)
(, ), X. :
trace(Math.atan2(-1,1)/Math.PI*180);
trace(Math.atan2(1,1)/Math. PI*180);
trace(Math.atan2(1,-1)/Math.PI*180);
trace(Math.atan2(-1,-1)/Math.PI*180);
//
//
//
//
: -45
: 45
: 135
: -135
(, ) ,
(0, Y0), : Math.atan2(x-X0, y-Y0).
, Math.atan2() Math,atan(), , a Math.atan()
/2 /2.
.
2.3.9.
Math , . :
Math.PI. . ,
( ) . 3,14159265358979.
Math.E. , . 2,71828182845905.
Math.SQRT2. . ,
(, 30, 60). 1,4142135623731.
Math.SQRT1_2. 1/2. , 45. 0,707106781186548.
Math.LN2. 2.
2. 0,693147180559945.
Math.LN10. 10.
. 2,30258509299405.
Math.LOG2E. 2. 1,44269504088896.
Math.LOG10. 10. 0,434294481903252.
. Math, . , , , Math.sin(Math.PI)
.
2.4. ( string)
(string) , .
ActionScript string ,
, .
2.4.1.
( Hello!!!)
, :
var
my_text=Hello!!!;
,
Hello, my_text. , ! . : ';' expected ';' . , ; , ,
.
, , :
var my_text="Hello!!!";
trace (MyText); // : Hello!!!
. :
trace (typeof "345"); // : string
:
trace('Hello!!!'); // : Hello!!!
, . : , :
trace("" "- "); //
. . ,
. ,
. :
trace('" " - ');
// : "
// "
, , , (I asked:
Good day, isn't it). , , \ ( escape- (escape-sequence)):
escape-, ( ,
).
Unicode. ( )
escape- (single escape sequence).
. escape-, -262, . 2.2.
escape- , , , ( , \ escape):
trace(" ", ', \"); //
,
//
trace(" \",\,\\"); // :
// ",', \
2.2
Escape- -262
Escape-
\b
\u0008
Backspace ( )
\t
\u0009
\n
\u000A
( )
\v
\u000B
(
ActionScript)
\f
\u000C
( ActionScript)
\r
\u000D
( )
\u0022
\
\u0027
\
\u005C
\\
, ,
. , swf-, , , , .
trace ("\t
: \n\t\t\t\t (350
y.e)\n\t\t\t\t(420 ..)\n\t\t\t\t(385 ..]"); /*
:
:
(350 .)
(420 ..)
(385 ..) */
, newline, escape-,
. ,
+.
. , ,
, ( ) , ,
- . , :
str= ;
, .
2.4.2.
- . , ( ) . ( ):
trace[""+","+" "+"!!!"); : , !
, , - , (
). ,
. :
trace(""+"String");
// : String ( )
trace(""+" "+"String"); // : String
. ( ):
trace (""+3); // 3
trace (3+"A"); // 3
. . , ,
, , toString() Number - . :
trace(typeof (100+"")}; //: string
, +=:
var my_string="value=";
trace (my_string+="Ha "); // : vlu=
, , . ,
:
trace ("flash"=="flash"); // true ( )
, , . , .
.
, length String, .
.
(, ), Unicode- (
, 2.5).
trace ("">""); // : true ( ""-97, "A"-65)
trace ("">""); // : false ( ""-1072)
,
2 , .
// : false ("b"
// "")
trace("ab">="abc"); // : false ("" , )
trace("ab">="ac");
Unicode- .
, ,
. , , , . , , ,
, , , Unicode . ,
1040- (\u0430 ) 1103- (\u044F ). ,
. , ,
, , .
function russ_text(str) {
/* , .
- .*/
if (typeof str = "string" && str!= "") {
/* , , . length. */
for (var i = 0; i<str.length; i++) {
/* "" "" (
) ( "" -
). ,
.
false ( return). ,
i, , charAt(). */
if (str.charAt(i)>="A" && str.charAt (i)<="") {
} else {
return false;
// , , //
. true.
return true;
// , ,
// false
} else i
return false;
trace(russ_text("")); // : true
trace(russ_text("Hello")); // : false (
// )
trace(russ__text('_root')!; // : false (_root )
2.4.3. String
String ActionScript , . ,
.
var string=new String(""); //
//
trace(typeof string);
//
//
- trace (string);
:
: object (string
String)
-, , . ,
, - . , String()
.
.
var str=String(0xFFOOF);
trace(str);
// : 1044495
trace(typeof str);
// : string
, , .
ActionScript String.
, , .
, .
, . .
, concat(), . :
/* String, myConcat. "[]", ( , ).*/
String.prototype["myConcat"] = function(str) { // 4 str - ,
//
return this+str; //
/* tbis+=str,
, */
};
var a="A", ="";
trace (a.concat (b));
// :
trace (a.myConcat (b)); // : AB
, String , . :
trace("".concat("")); // :
String ,
, , string. ,
. []
object. String.
- string , valueOf():
var str=new String ();
trace(typeof str.valueOf()); // : string
2.4.4. . lengths
, , ActionScript
length String:
trace ("!!!".length);
// : 9
trace (" !!!".length); // : 14 (
)
, 0:
trace("".length); // : 0
length ,
, , .
,
length.
, length,
.
2.4.5. . concat()
concat() . +=, . -, conat() , ,
:
trace ("".concat(" ","", "!!!")); // :
!!!
-, concat() ,
. , .
var str="";
var new_str=str.concat(" ","","!!!");
trace(str);
// : ( )
trace(new_str); // : !!!
2.4.6. . charAt()
charAt() . . ActionScript , 1, 0. , 0 length1, charAt() .
trace("B".charAt(0)); // :
trace("".charAt(2)); // : ( ,
// 0)
charAt() , , ,
.
.
,
, .
indexOf() ,
. (
):
// mylndexOf ().
// : str ,
//
sub_str ,
//
pos .
function mylndexOf(str, sub_str, pos) {
/* . ,
. -
0.*/
if (pos = undefined) {
var pos = 0;
}
/* , sub_str
pos str ( ).*/
if (pos+sub_str.length<=str.length) {
/* ,
, .*/
for (var i = pos; i<=str.length-sub_str.length; i++) {
/* , i sub_str,
str , sub_str.length,
i, str. ,
charAt() .*/
var String= "";
for (var j = 0; j<sub_str.length; j++) {
string+=str.charAt(i+j);
/* , ( return -
).*/
if (string = sub_str) {
return i;
}
}
}
/* , , (
). -1."/
return -1;
};
lastIndexOf() indexOf() :
, . :
trace ("!!!!!!".lastIndexOf("!",this.length)); // : 11
// ( 12 )
, lastIndexOf() , IndexOf().
substring() ,
, . , . , , , .
, :
trace(" !!!".substring (6,0)); // :
- substring() ,
0. , length 1.
trace(" !!!".substring (-5,6)); // :
trace(" !!!".substring(-5,50)}; // : !!!
substring(), , .
substring() substr(). ,
substr() , :
trace(" !!!".substr(0,6)); // :
substr() , ,
. ,
, :
trace (" !!!".substr(0,100)); // : !!!
.
, . :
. :
trace(" !!!".substr(-14,61); // :
,
substr() 0, 1 ( , +0 = - 0).
String, , slice(). substring(). ,
slice()
. , 1:
trace(" !!!".slice (-3)>; // :!!!
slice() , ,
, , . :
trace (" !!!".slice(-3,-5)); // : (
// )
2.4.9. . split()
ActionScript, . , ,
. , . , split().
split("delimiter", [limit]) :
delimiter. ( ), ( );
limit. .
split() : ,
( ). , , :
var basa="2326264 2616578 2014387"; //
var arr__basa=basa.split(" ");
//
//
trace(arr_basa[0]);
// : 2326264 ( )
. , , ., :
var basa="2326264\n2616578\n2014387";
var arr_basa=basa.split("\n");
trace (arr_basa); // : 2326264, 2616578, 2014387
split() , , .
,
. , ,
@ ( , e-mail ):
function mail_checker (str) {
var str_arr = str.split("");
//
//
/* "@".
, true. */
for (var i = 0; i<str.length; i++) {
if (str_arr[i]="@") {
return true;
}
}
// , false.
return false;
}
trace(mail_checker("diis_ignotis@tut.by")); // : true
trace(mail checker("fhjkdfddffgg"));
// : false
2.4.10. .
toLowerCase() toUpperCase()
, , ActionScript toLowerCase() ( )
toUpperCase() ( ). :
trace("".toUpperCase()); // :
trace("".toLowerCase()); // :
, , (,
. , ( ( .
, :
function password_checker(user_password) {
/* . toLowerCase , ,
.*/
var pass = user__password.toLowerCase();
// , . true
if (pass = "member") {
return true;
}
// false
return false;
}
trace(password_checker("Member")); // : true (
// )
trace(password_checker("12345"));
// : false
2.4.11. .
fromCharCode() charCodeAt()
, , , 2.5.
, . escape- Unicode-. ,
, .
fromCharCode().
String, fromCharCode() , . , String:
String.fromCharCode(code1, code2....);
fromCharCode() ,
, .
Unicode- . , . , :
trace (String.fromCharCode(1055,1088,1080,0x432,0x435,0x442)); // :
//
charCodeAt(index), index
:
var code = "".charCodeAt(0);
trace(code);
// : 1055
trace(String.fromCharCode(code)); // :
, toString() Number:
trace("".charCodeAt(0).toString(16)); // : 41f
2.4.12. . eval()
, ,
( , , ).
, , , , .
, . : .
?
var cod="Math.cos(x)/Math.sin(x)"; //
//
function func (x){
return cod;
//
}
trace(func(0)); // : Math.cos(x)/Math.sin(x)
// ( "" )
,
, , , , , .
ECMAScript ,
eval():
var cod = "Math.cos(x)/Math.sin(x)";
function func(x) {
return eval (cod); // ,
}
trace (func(0));
// : infinity
.
ball. :
for (var i=0;i<=50;i++) { //
//
/* ball balli, i - ( duplicateMovieClip() , ). */
ball.duplicateMovieClip("ball"+i,i);
// eval(),
//
eval("ball"+i)._x=550*Math.random();
eval("ball"+i)._y=45O*Math.random();
}
<Ctrl> + <Enter>. ,
. ,
:
var n = 0; //
for (var i = 0; i<10; i++) {
// ,
//
for (var j = 0; j<5; j++) {
// ,
//
// eval() balln
eval("ball"+n)._x = eval("ball"+n)._width*i;
eval("ball"+n)._y = eval("ball"+n)._height*j;
n++; // ,
// 1
,
eval(). , ;
big_ball.eval("ball"+n)._=100; // !
big_ball balln,
:
eval ("big_ball.ball"+n)._x=100;
eval(), . , ( )
eval():
function func2() {
return " !!!";
}
trace{eval("func"+2)()); // : !!!
2.4.13.
, Flash , . , ActionScript:
(Dynamic Text) (Input Text). . : ,
.
, ,
, ( ).
.
, , , , .
, Text (),
Dynamic Text ( )
.
: , . ,
, ,
( , ).
: Var ( Variable ) . Instance Name ( ).
Var ,
. , . , , Var, Flash, 1. ,
, _root mov, my_text , Var :
_root.my_text
.
!!!. ? .
: , Var,
Instance Name? , , ,
, . , . , din_text 90, :
din_text._rotation+=90;
TextField, . , TextFormat,
.
, . text TextField:
text_field_name.text="string"; //
//
ActionScript- (Input)
.
( ).
Var text ( ) , , .
- , ,
( , , , Word).
.
Input ( Text ()) in_text. Var
inp. :
var inp=null;
// .
in_text.text="He "; // Input ,
//
in_text.autoSize=true;
//
in_text.onChanged=function(){ //
//
trace(" text: "+InText.text); //
// text
trace(" Var: "+inp);
//
// Var
};
, , : . . , Output , text.
. .
Input Text ,
. Flash.
2.5. . Flash
. , , ,
Flash string.
2.5.1.
- .
,
. , .
.
? . ,
, ?! , , ,
. , , .
, 1/44100 . .
, , ? , . , 1 ,
, 2 . . .
? , . ,
, 8 (
, , 1 = 8 ). ,
28 = 256 .
. (
),
256 , 128- . ASCII,
, , , , .
.
, ASCII .
, ,
, . 128 ASCII, . 256 , , ,
. Latinl
8- .
Latinl . , ,
, .
80- . , .
, , .
. , 1- 2- ( 65 356
256). , ,
. . 8- .
. ,
Latinl. Latinl
.
.
, , .
, . Windows,
.
, , , , ,
8- ? , , .
, ,
. .
, 1990- . , ,
. , (
, ). , 8- .
16 . 16- 1990- . , ,
, . 20 . (!) . , 8
.
.
, ,
, , . Unicode (). 65 . ,
.
- Unicode, 32-.
. Unicode
http://www.unicode.org.
2.5.2. Flash-
Flash Player , Flash MX. , 16-
. Flash- ( )
, .
. Flash- 8- Unicode (UTF-8) 16- (UTF-16 BE (Big Endian) UTF-16 LE
(Little Endian)).
http://www.unicode.org.
Unicode ,
, . , , , , , . Flash
, .
,
, . , . . ,
, , ,
.
.
2.5.3.
Flash- . -
8- . . , ,
escape- Output
. , , . , ,
.
Flash MX 2004 (UTF-8). ,
. Output, , :
trace("\u9456\u5674\u7221\u7867"); //
, , ActionScript
, , . Flash 7,
.
, , Actions. Preferences.
Open/Import UTF-8 Default Encoding.
. as- ( Save/Export). , ,
, Flash MX Flash 5.
2.5.4.
Flash MX 2004, Flash . ,
.
,
Word , ,
. (,
):
var
trace (
=""; //
);
// :
fla-. , ,
.
, , .
Unicode- ,
Actions, . :
Unicode , escape.
#include.
L-, ActionScript, loadVariables() LoadVars XML.
.
.
escape- .
, ,
256 :
trace("\324\124"); // :
. 2.1. Unicode
UTF8
#include "my_text.as" //
// ,
6. . , Unicode-
.
XML- loadVariables()
XML LoadVars. , #include,
Unicode-. . , swf-.
, :
. -,
UTF-8, 16- Unicode.
. .
, ,
. , .
, , , .
Flash- ,
, . BOM
(byte order mark ) .
, UTF-8.
BOM 16- Unicode :
0xFE, 0xFF, UTF-16 BE (Big Endian);
0xFF, 0xFE, UTF-16 LE (Little Endian).
, UTF-16 BE LE, . I .
,
, .
L- , , . , Flash- XML- , :
.
2.5.5. 8- .
System.useCodepage
':
, - ""?. | FAQ, .
. Flash- ( . XML-, [ , Unicode. S- , , , -
UTF-8. , UTF-8 ,
- .
( ) , ( Flash 5) . System.useCodepage true:
System.useCodepage=true; // He ...
,
. 8-
, . , , ,
. , , , . , .
System.useCodepage .
, -
, - 8- .
, .
.
2.6. ( boolean)
, , (boolean)
. true () false (). ( ) , . . . true , a false .
? ,
. 0 1. .
ActionScript ;
trace(1==1);
trace(1!=1);
trace(1>2);
trace(2>1);
//
//
//
//
:
:
:
:
true
false
false
true
(&&), (||), (!):
trace(true && false);
trace(true || false);
trace(false || false);
trace(!true);
//
//
//
//
:
:
:
:
false
true
false
false
(0 1=0)
(0 l=l)
(l l=l)
( 1=0)
if, ,
. ,
true, , else ( ).
if ,
:
if(my_var==true){ //
substances
};
: true, . , false, . , .
// ( my_var=false,
// : !my_var)
if (my_var) {
substances
}
, ActionScript , . , _visible, ,
, . hitTest() MovieClip ( ,
) . , true false.
,
,
( ). ,
,
( ,
).
, true false 1 0
, :
trace(0 == false); // : true
trace(1 == true); // : true
trace(1||0);
// : 1 ( ) *f (1) { //
"
if (true) {
trace ("1 true"); // : 1 true
(true*false);
(true+false);
(false-true);
(false/true);
//
//
//
//
:
:
:
:
0
1
-1
0
,
( true>false).
ActionScript , ,
true false.
2.6.1. Boolean
Boolean, true false . ,
( String Number)
- . ,
:
var my bul=new Boolean(1);
trace(my_bul); // : true -
// ,
trace(typeof my_bul); // : object
Boolean() :
trace(Boolean (_root)); // : true (
// )
Boolean :
toString(). . true
false.
trace(true.toString()+"!!!"); // : true!!!
valueOf(). Boolean :
var my_bul=new Boolean(1);
trace(typeof my_bul.valueOf()); // : boolean
Boolean . , .
.
, ActionScript . ,
:
function exclusiveOr (parl, par2) {
var par1=Boolean(par1); //
var par2=Boolean(par2);
// false,
// true, false
if (par1+par2 = 0 || par1+par2 = 2) {
return false;
// true , true,
// false
} else {
return true;
}
};
trace(exclusiveOr(true, true));
// : false
trace(exclusiveOr(false, true)); // : true
trace(exclusiveOr(false, false)); // : false
2.7. undefined
undefined , undefined. ,
:
var new_var;
trace(new_var); // : undefined
ActionScript
, undefined
, , ( ):
trace(sin(0)); // : undefined (
// Math: Math.sin(0))
undefined ,
.
, ActionScript undefined . , , .
,
:
function sealer(clip_name, proc) { // clip name - ,
// proc -
// .
// -
if (eval(clip_name)!= undefined) {
// , , , //
100 %.
if (proc = undefined) {
var proc = 100;
}
//
eval(clip_name)._width+=eval(clip_name)._width"proc/100;
eval(clip_name)._height+=eval(clip_name)._height*proc/100;
} else { // clip_name ,
//
trace (" "+clip_name+" ");
}
}
// , , ball
sealer("ball",100); //
sealer("balll",100); // : balll
ActionScript -262 Flash 5 Flash MX , undefined undefined, ( Flash 4). Flash MX 2004 undefined undefined. ,
.
ActionScript -262 , undefined 0. Flash MX 2004, .
undefined NaN.
2.8. null
null undefined. , null, undefined, ,
. null, undefined, . , : . : , , - .
? , , ,
. ? -
, , undefined . ,
, ( ,
, ). 0
. null, .
null , ,
. ,
ASSetPropFlags().
null undefined,
true:
trace(null=undefined) ; // : true
trace(null=0);
// : false (null )
trace(String (null));
// : null
trace(Number(null));
// : Nan
2.9. ( object)
: ( , ) ,
( ).
. ,
. ,
. , .
. ActionScript . - ,
, object. , ( ). 7.
-262 : , , . , , .
:
ActionScript movieclip (
).
, . . ,
, .
, :
var new_obj={a:l,b:2,c:3}; // Object
trace(new_obj.a);
// : =1, =2, =3
//: 1
:
var new_obj={a:l,b:2,c:3};
new_obj.a=0;
//
new_obj.d=4;
//
trace(new_obj.); // : 0
trace(new_obj.d); // : 4
.
:
// , var new_obj = {:1, b:2, c:3};
new_obj.allProperties = function*) {
for (var i in thisj ! // for-in
// trace (i) ;
new_obj.allProperties(); I! : allPraperties a b
.
30 , . - , C++ Java, ( ActionScript) .
( .) []. [] :
var new_obj = (:1, b:2, :3);
trace{new_obj["a"]); // : 1
trace(new obj[a));
// : undefined ( )
, [] , . . ,
, . . .
. . , , . , [],
:
var new_obj = {};
new_obj["+"] = " 1";
new_obj[2] = " 2";
trace(new_obj["+"]);
trace(new_obj["2"]);
trace(new_obj.2);
//
//
//
//
//
//
//
-
-
: 1
: 2
:
, , , ,
[], : .
, .
, . , , .
undefined (
7).
ActionScript .
, , .
( , ). , , Array.
. , , : , . , . :
// String
String.prototype.prop="pe"; //
//
trace("".prop); //
// :
// There is no property with the name 'prop'
// ( 'prop').
, , . ActionScript ,
. -1 : Object, Array,
MovieClip, TextField, Button.
[], ( 9). :
String.prototype["prop"]=" ";
trace(""["prop"]); // :
2.9.1.
, (attributes).
, , , ,
. , , , . -262 . 2.3.
2.3
ReadOnly
. . , .
,
ActionScript. -: length String
2.3
DontEnum , for-in,
, ,
. ActionScript
Internal
(internal) .
, , . , .
(internal) . , , ActionScript.
, .
, []. ,
. , , , , ( ECMAScript, ActionScript). , .
,
. ActionScript , ,
Macromedia, . [[Get]]. : ,
:
1.
2.
3.
4.
5.
6.
, 4.
.
( ).
__proto__, , _global,
undefined.
[[Get]] , .
( ).
, , , ActionScript, . . ( )
. ECMAScript.
2.9.2. . ASSetPropFlags()
ActionScript, . , . , -262 ,
ActionScript. , , . , , .
. Macromedia. ,
. , Flash- ,
. ASSetPropFlags() .
.
ASSetPropFlags (obj, props, allowTrue, allowFalse) :
obj. , ;
props. , . , , , , :
["propl", "prop2", "3"] //
"propl, 2, 3"
//
null,
;
allowTrue. , .
DontEnum ( forin), DontDelete ( ), ReadOnly ( ).
. 2.4.
2.4
allowTrue
000
0
001
1
010
2
011
3
100
4
101
5
110
6
111
7
allowTrue , , . ., , , n 0, . - 0, .
ActionScript
allowTrue, 7: forin,
( n=3);
allowFalse. , n, , . - , 1. allowFalse , allowTrue, .
allowFalse Flash MX. Flash 5 , ASSetPropFlags(). allowFalse -
.
ASSetPropFlags()
Global ( ActionScript _global).
ECMAScript, ,
. , , , forin
, : Global ,
.
for (var i in _global) {
trace (i); // : for-in
}
, ActionScript. (Number, trace(), parseInt() .), (MovieClip, Button, XMLSocket .). , ActionScript. , , , .
. , Flash MX 2002 .
, SharedObject (
), LocalConnection ( swf). Microphone ( ), Camera ( Web-).
, Flash
ASSctPropFlags().
, .
ASSetPropFlags() , Macromedia, . , , forin, , ,
Debug/List Variables ( 20 ):
// : , b,
var new_obj = {:1, b:2, :3};
// b ,
ASSetPropFlags(new_obj, "a, b", 7, null) ;
delete new_obj.a;
//
trace(new_obj.a);
// : 1 ( )
new_obj.b = 3;
// b
trace(new obj.b);
// : 2 ( )
for (vac i in new_obj) { // new_obj
trace(i);
// : ( b )
ASSetPropFlags, , Flash . , -
. ASSetPropFlags() (
) , .
2.10. ( movieclip)
Flash, swf-.
ActionScript,
. ,
Flash- ,
. ,
ActionScript , , ECMAScript Flash ; Web-, ,
. , ActionScript
, .
ActionScript , ,
-262. ActionScript
.
, , , ,
.
, new .
MovieClip: attachMovie() (
) createEmptyMovieClip() ( ).
delete. removeMovieClip().
. . , , .
swf-. ,
( loadMovie()), , _root movieclip.
.
: :
, .
. ,
. ,
, removeMovieClip().
, ()
. , ,
, . ,
, , : , .
, , .
: ,
. , , , ,
. ,
(, ).
, delete ( , , ).
typeof . , , , object,
movieclip. , , .
movieclip ,
, object.
2.11.
. , ,
. ActionScript , Number(),
String(), Object(), Array(), Boolean(), . , toString
( ),
parseInt() parse Float().
; , ,
. .
,
. , , .
2.11.1.
ActionScript 7 , 4 : boolean,
number, string, object. , .
, .
(. 2.5).
( )
. , Boolean().
2.5
undefined
false
null
false
number
false, 0 NaN, true
string
true. false
boolean
object
true
movicclip
true
Flash MX Flash MX 2004 boolean.
, .
-262, false, true.
, boolean,
(. 2.6). . .
2.6
undefined
NaN
null
NaN
number
siring
,
. NaN
boolean
0, false, 1 true
object
valueOf() ( ),
movieclip
NaN
2.2,
(. 2.7). , , .
String() toString(). string
, trace(),
ActionScript.
2.7
undefined
undefined
null
null
number
,
string
-
boolean
true false
object
valueOf(),
movieclip
,
(level0.box)
object (. 2.8).
Object{). , .
object ( , with(), ).
2.8
object
undefined
null
number
Number
string
String
boolean
Boolean
object
-
movieclip
-
object, number, string, boolean
.
ActionScript rr().
,
. 7.
2.11.2.
, :
,
Output;
.
ActionScript-
. . , ( ):
trace("5"-"3"); // : 2
+ ( ): , .
, , ?
, :
trace("5"+3); // : 53
.
, , .
, . , , :
trace (ball=_root); // : false (_level0.ball _level0)
if() :
if("5") {
trace (true); // : true ( "5" true)
}
. ,
.
2.12. ActionScript
ActionScript 1.0 , , .
. , .
. .
, - , -
.
B , (
) (
). , . . . , , . , . ActionScript 2.0 , , , .
- .
, .
. ,
, , ActionScript
, - :
var variable_name: Type = value,
T .
ActionScript 2.0 ,
, , . , . , rr ,
:
var arr: Array =[];
, , , . , . :
var per:Number = 3;
//
function func (par) { // ,
return par;
}
, , . -, , (type), (value):
type(value);
value type, .
null:
// TextFormat
var textFormat :TextForiiiat = new Text Format 0;
// , textFormat TextFormat
trace(TextFormat(textFormat)); // : [object Object] (=>
// textFormat TextFormat)
// , textFormat TextField
trace(TextField(textFormat)]; // : null (=> textFormat
// TextField
- ,
, , , .
- , Boolean, Number, String, Array, Object, . , , new. , , : . :
trace(Number("")); // : NaN ( )
, ,
instanceof:
var textFormat:TextFormat = new TextFormat();
trace(textFormat instanceof TextFormat); // : true
trace(textFormat instanceof TextField); // : false
instanceof , . . ,
ActionScript 7 , ,
typeof. ,
. , ,
( , , 7).
ActionScript var . , . , var .
. , , ,
. (. 9). , , ,
, __global).
. ActionScript 2.0
. :
function factorial(n:Number) { // ,
if (n>1) {
return n*factorial(n-1);
}
return 1;
}
trace(factorial(5));
//
:
120
trace(factorial ("ss"));
//
. :
function func(par):Number {
return ""; //
}
, Void.
.
, .
, ,
, , .
. ,
(. 1).
, ,
.
2:
- ? , - XXI .
.
1970- ., ( ) .
? , .
, .
Flash ( (
) Windows) .
Flash, ,
, . ,
. 2.2. . ( ,
), , . calc1.fla 2 .
, ,
. , , .
,
Windows-. , ,
. ,
.
. 2.2.
, .
, , Instance Name ( ) .
, ,
,
:
but_, Button.
. ,
but_tochka, but_stepen.
:
0 9 : but_1, but_2 . .
(+/-) but_znak, but
tochka.
:
+
/
*
but_plus
but_minus
but_del
but_umn
but_stepen
( ) , : but_cos, but_sin
. .
: but_PI ( ) but_E ( ).
:
=
Clear
but_ravno
but clear
? .
29! ,
? ? .
,
.
,
: . , , Flash,
.
, , , , (. 2.2). : , , ,
, , .
, 21 (15 , ,
, , 3
) , ( ), , .
, ,
.
( Var) tablo.
. .
, Actions ( , Flash MX 2004 ,
). , .
? :
var tablo =0; // ,
//
. .
, . , , , but_l
111?
, ,
: 10 . ,
33 :
, , 0.
3: 10 3. 3.
3: 3 10 + 3 = 33.
, ( ) . ? , .
, 10 , . , 0,23 :
but_tochka. .
but_2. , ( ), 2, 101=10. 0,2.
but_3. 0,2 3, 102=100. 0,23. ? .
,
, . , .
, :
num=1;
, , . num :
var num:Number=null; // ,
// num
( ).
, . .
num, ,
. ,
, 10
. , ,
myAdd():
, , , myAdd() .
num, , ,
.
9 onPress
, , , ,
, num.
.
myAdd() : .
, . ,
, tochka.
true, , but_tochka .
:
var tochka:Boolean=true;
tochka false, .
but_tochka:
but_tochka.onPress = function():Void {
tochka = false;
};
myAdd():
function
};
myAdd():Void {
tochka. , . :
if (tochka) {
} else {
}
, , :
numbers
numbers*10 + num;
numbers , . ,
( ,
).
, , :
numbers+=num/Math.pow(10,n);
n
Math.pow(10,n) 10 ;
n . ?
1 ( )
:
n++; // else
numbers , :
tablo=numbers; //
// myAdd()
myAdd() , :
function myAdd():Void {
if (tochka) {
numbers = numbers*10+num;
} else {
numbers += num/Math.pow(10, n);
n++;
}
tablo = numbers;
}
. , , . , 16 . ? . ?
?
. 0,0001. , , . :
, Numbers . , . , , .
, ,
Numbers, ,
sir. , :
var str:String="";
:
myAdd() str :
str+=num; // myAdd()
, but_tochka str
. onPress :
str+=".";
myAdd() str
:
tablo= str; //
// "tablo=Numbers";
. , , , , , :
0000032.
buttochka ,
: 1 ..234.6.
. , str , , tochka.
false, but_tochka ,
:
but_tochka.onPress = function():Void {
if (tochka) {
tochka = false;
str +=".";
}
};
, str
, 0. . (
myAdd()):
if (str!= 0) { // "str+=num;"
str = str+num;
} else {
str = String(num);
}
, num str ,
String(), . , str
,
100 % .
. ! , 15 (
ActionScript). - ,
, , 30 ,
.
,
. ,
. , str 16 , ,
numbers, (
MyAdd):
if (str.length<17) { // "tablo=str;"
tablo = str;
} else {
tablo = numbers;
}
. !
, ,
. ...
:
but_znak.onPress = function():Void {
};
, str 0 -
. , , , :
if (str!= 0 && str!= "") {
}
but_znak numbers .
1:
numbers*=-1;
but_znak numbers,
. : ( )
str?
,
. , - , .
, ,
substring():
if (str.substring(0, 1}!=
}
"-") {
, ,
str:
str="-"+str;
, , substring() :
//
else {
str = str.substring(1);
}
.
myAdd() , , str numbers.
:
but_znak.onPress = function():Void {
if (str!= 0 && str!= "") {
numbers *= -1;
if (str.substring(0, 1)!= "-") {
str = "-"+str;
} else {
str = str.substring(1);
}
if (str.length<17) {
tablo = str;
} else {
tablo = numbers;
}
}
};
. ! !
, . but_clear.
;
. ,
.
, :
but_clear.onPress = function():Void {
tablo=0, num=0, tochka=true, numbers=0, n=l, str="";
};
, , ,, .
. . ,
. : 10 %
, 90 % .
. . , , , . ,
, .
.
- ,
. 5 ,
.
, . ,
, . : but_plus plus, but_minus minus . .
but_plus.onPress = function():Void {
calc("plus");
};
, .
, ,
,
. , numbers , ( , , memory, null). numbers
str , . ,
, (
operation, null).
cal():
function calc(operat:String):Void {
memory = numbers;
numbers = 0;
str = "";
operation = operat;
}
, , memory operation
but_clear.
but_ravno .
. , operation,
.
, numbers str. :
but_ravno.onPress = function{):Void {
var result:Number=null;
if (operation == "plus") {
result = memory+numbers;
}
if (operation == "minus") {
result = memory-numbers;
}
if (operation == "umn")
result = memory*numbers;
}
if (operation == "del")
result = memory/numbers;
}
if (operation = "stepen")
result = Math.pow(memory,
numbers);
}
numbers = result;
str = String (result);
tablo = result;
};
if, switch. 6.
. , .
, .
:
.
.
.
, . . , , .
, ? , , .
. ,
but_ravno . - .
, Button enabled. true, . false, (
).
but_ravno onPress.
:
but_ravno.enabled=false;
, . calc() :
but_ravno.enabled=true;
,
. . ,
:
function block(par:Boolean):Void {
but_plus.enabled=par, but_umn.enabled=par, but_minus.enabled=par;
but_del.enabled=par, but_stepen.enabled=par;
}
( ) ,
. , , 100 .
7.
, ,
. , ,
. ,
, ,
. .
:
function block2(par:Boolean):Void {
for (var i = 0; i<=9; i++) ( //
eval("but_"+i).enabled = par;
}
//
but_tochka.enabled = par;
}
, blo2 .
.
but_ravno
par, false. , . calc() :
block2(true);
.
Clear .
:
but_ravno.enabled=true, block2(true), block(true);
. , , , ,
. but_ravno, ,
. , ,
.
, butravno
, :
but_ravno.enabled=false;
(
).
!
.
, . , onPress
, :
but_sin.onPress = function():Void {
func("sin");
};
, .
func() , ,
Math.
, , (sin, cos, tan), , (asin,
acos), . ,
but_ravno ( ), .
, numbers rr.
:
function func(par:String):Void {
var result:Number=null;
if (par = "sin") {
result = Math.sin(numbers/180*Math.PI);
}
if (par = "cos") {
result = Math.cos(numbers/180*Math.PI);
}
if (par = "tan") {
result = Math.tan(numbers/180*Math.PI);
{
if (par = "ln") {
result = Math.log(numbers);
}
if (par aa "asin") {
result = Math.asin(numbers)/Math.PI*180;
}
if (par = "acos") {
result = Math.acos(numbers)/Math.PI*180;
}
if (par == "sqrt") {
result = Math.sqrt(numbers);
}
if (par == "roun") {
result = Math.round (numbers);
}
tablo = result;
numbers = result;
str = String (result);
}
. . ( ) . ,
. ,
:
function bl3(parrBoolean):Void {
but_sin.enabled=par, but_cos.enabled=par, but_tan.enabled=par,
but ln.enabled=par;
but_asin.enabled=par, but_acos.enabled=par, but_sqrt.enabled=par,
but_roun.enabled=par;
}
bl3() , false, ,
.
calc() :
Bl3 (false);
,
( ). onPress but_ravno :
bl3(true);
but_clear,
( ,
, 90).
. , .
, onPress ,
numbers, str tablo .
, .
:
but_PI.onPress = function():Void {
numbers = Math.PI;
str = String(Math.PI);
block2(false);
tablo = Math.PI;
};
.
,
, bl2() :
but_E.enabled=par;
but_PI.enabled=par;
. , . ! !
( )!
. . ,
, , , but_ravno.
. (,
). . , . .
, . -,
,
. -, ActionScript ( ,
).
. .
calc2.fla 2 .
, . , : ,
. ActionScript, , , , , .
.
. , , .
, .
, .
: ,
( ). (
) ( ). , , , . .
, .
, ,
.
.
, . ActionScript - . , ,
. ,
.
, ,
. ActionScript : , , true false, undefined, null, [], {}.
, . JavaScript
const. , -262 Flash.
. ,
. : ,
. ,
, , .
, .
, , ActionScript
.
3.1.
ActionScript, , Pascal JavaScript, ,
var:
var new_obj; // ...
, . , ActionScript , ,
.
undefined:
trace(new_obj); // : undefined
, .
( null). -, :
var new_obj=null; // ,
// null
,
,:
var =1, b=2, =3; // var a=1; var b=2; var c=3;
, .
, :
var number:Number=0;
set() :
var i:Number = Math.round(Math.random()"10); //
// 0 10
set("var"+i," "); //
trace(eval("var" + i));
// : " "
, set, :
this["name"]=value,
this (
); "name" ; value ,
. :
this ["variable"] = "";
trace(variable); // :
, set [],
. , , , .
ActionScript-
. ,
.
.
//****************************************
var speed:Number=10;
//
var size:Number=100;
//
var crash:Number=null; //
//**************************************************
,
. , :
function func():Void { // ,
//
trace(per);
func2();
}
func (); // : undefined !!!
var per:String = "";
function
func2():Void {
trace("!!!");
}
, .
.
. , () (), per, , () per
:
function A():Void {
();
}
(); // : undefined
var par:String = "";
(); // : ( )
function B():Void {
trace(par);
}
ActionScript . , , , , :
my_var = null; //
// var my_var=null;
: .
ActionScript var , J . :
,
.
var, , ,
( ).
var . var, .
, , .
3.2.
, :
, , . . ,
Pascal, ActionScript .
, .
var ;
=3;
+="";
-=0;
//
//
//
//
undefined
number
string
...
:
,
. , .
, . , , ActionScript, .
, , , , . : , , ,
attachMovie(), createEmptyMovieClip(), createTextField() . object ( ,
).
// , :
var N=100; // , ,
// var
var speed=10;
ballArray=new Array(); // , , var
ball = attachMovie ("ball", "b1", 0);
. ,
: var. , var
, .
, , .
Flash MX 2004 . ,
ActionScript - .
. - , . . , , . -
. :
, ,
( , MovieClip, Button, TextField, Array,
Object), .
:
//
var date1:Date = new Date();
//
var date2 = new Dated;
date1.prop = ""; //
date2.prop = ""; //
, ,
( ) , . ,
: ,
. :
// Date -
// String
function func():Date {
return new Date();
}
var per:String = func();
( ) , , [], . , , [],
. :
var date:Date = new Date();
date.prop = ""; //
date["prop"] = ""; //
, . , , ActionScript . ,
.
: .
3.3.
, . , , , . - : , . ,
.
.
, . , , . :
function func():Void {
per = this; // per
// , func()
}
trace(per); // : undefined (
// ) func ();
, ,
. var,
. , ,
:
function func():Void {
var per:Number =0; //
//
}
func();
trace(per); // : undefined (
// )
,
. ,
:
var per:Number = 0;
function func():Void {
var per:MovieClip = this;
trace(per); // : _level0 (
// )
}
func();
trace(per); // : 0 (
// per)
, ,
.
, ,
var, ( ,
). - . , ,
- , .
var i:String="";
for(var i=0; i<=10, i++) { //
//
var new var = i; // , ,
//
};
trace(new var); // : 10 (
// )
trace(i);
// : 11 (
// i )
,
. , -, . ActionScript
. , , . .
.
_4.
, ActionScript,
. , ,
var. ,
, null, . , - .
3.4.
- , ( ) . Flash MX ActionScript
.
_global.
_global Global (
Global, -262), , ActionScript.
, . , , .
.
_global.new_var="Global"; // _root
// _root :
trace (new_var) // : Global
, , , . ,
Global ,
, , . , , ,
, _root, MovieClip,
Object, Global:
_global.new_var=""; //
//
trace(new_var);
// :
//
//
MovieClip.prototype.new_var="";
trace(new_var); // : ( MovieClip
// "" Global)
, , . . ,
:
_global.prop = "";
prop = "";
trace(prop);
trace(_global.prop);
_global. prop="";
trace(_global.prop)
//
//
//
//
//
//
//
( )
:
(
)
""
:
ActionScript . ,
. Global, . , var .
Flash 5 _global .
.
, , , Object (,
- ). , . , Object, .
: Global Object
, , ? . , ,
, . , . ,
Global.
, , . ActionScript Object. , object , ()
( , ).
,
:
Object.prototype.new_var="";
trace(new_var);
// : (new_var
// )
trace([].new_var); // : (new_var Array)
, Object , . ,
. Global,
- , -262
ActionScript.
, , , -1. : -
ActionScript ( 9), .
3.5.
? , . .
. , ?
. , , ,
. , . ,
. ActionScript? . , .
.
var a: String = "";
var b: String = ;
+= "!!!"; // : b
// ,
trace();
// : !!!
trace(b);
// : (: b
// , )
,
. , . , .
, ,
, , :
var a:Object = {property:1}; //
// property=1
var b:Object = ;
// property: b ,
// b
a.property=2;
trace(b.property); // : 2 ( )
, . ,
. ,
, . , Flash-.
, ,
? , .
. , split().
, attachMovie() duplicateMovieClip(). ,
, , .
3.6. ActionScript?
. ,
. , . ActionScript
. , ,
var.
_root ,
, . [].
. MovieClip. To
: (, 4, ).
, , .
, , , , . , -
, .
Flash . . , var, ? ; , . var, ? : , Global. var : .
var _root.myVar=0; // :
, ,
.
. , , , ,
.
, .
, ,
( ).
( , MovieClip, Object)
,
, . ,
. , Global
, :
_global.per=""; //
trace(per);
// : (per )
trace(_root.per);
// : undefined (per )
- , , .
, ,
Global. - ,
MovieClip Object, , , . , ,
, ,
, . ,
,
. ,
3.7.
, delete:
var new_var:Number=3;
delete new_var;
trace(new_var); // : undefined (
, , delete true.
, false:
var new_var=3;
trace(delete new_var); // : true
trace(delete new_var); // : false ( new_var
// )
. ,
delete , ,
, , .
object ,
. , delete . . , removeMovieClip()
delete .
. , , .
3:
.
, .
, , ( ),
, . , . .
, , .
. ,
:
Y = A y cos((k / m)1 2 t + 0 ) e t .
? ! ,
:
Y t.
0 .
, . . ,
0, .
m . , (. . ),
. , (. .
).
t .
0 . ,
. .
, . , .
: ActionScript,
! ? . ,
. ,
. , Flash-.
,
, ( , ).
-
.
?
( ).
, , . ?
? . , , ,
. -. , , (10-20). , .
:
, , ,
, , (. 3.1, ).
(300-500 %) .
45 , .
, <Ctrl>.
,
, .
( Free Transform) , (.
3.1, b). (<F8>).
. 3.1. () (b)
.
, ,
. , , . , . ,
( ) , ( ). , , . , .
.
.
.
(. 3.2). , .
. ,
.
graph.
. 3.2.
. , . 3.2.
, . .
.
pruzina, gruz.
, , .
<F9>. Actions,
: ?
. , , . : , :
var
var
var
var
k:Number = 1000;
n:Number = 200;
alpha:Number = 0.1;
A:Number = null;
//
//
//
//
( )
: . , , , .
,
. , - ,
gruz. ,
onPress ( Flash MX
):
gruz.onPress=function():Void {
trace (this);
}
,
.
( ). , MovieClip startDrag (center, xmin,
ymin, xmax, ymax), :
center , , ,
(false), (true). , ;
xmin, ymin, xmax, ymax , .
:
xmin. , , X : this._x.
ymin. , . , , , . , . , , .
( ):
var gruz_pos :Number=gruZ._y;
xmax. xmin.
ymax. , 34 . 3 pruzina, .
, ,
:
var pruz_height:N =pruzina._height;
startDrag() -:
gruz.startDrag(false,this._x, gruz_pos, this,_x, 3*pruz_height+gruz_pos);
. . -, onRelease.
, .
, onReleaseOutside.
. -: onMouseUp, ,
graz_press. true, , . startDragO ( stopDragO), gruz_press, gruz . ActionScript :
_root.onMouseUp = function():Void {
if(gruz_press) {
gru2_press = false;
gruz.StopDrag();
}
};
, , . , .
, . , . - onEnterFrame, setInterval(). , , :
_root,onEnterFrame = function():Void {
};
, gruz_press.
true, , . -
, :
pruzina._height = pruz_height+gruz._y-gruz_pos;
. ... - , .
_width , .
.
, .
: , ,
. :
var pruz_width:Number = pruzina._width;
, , onEnterFrame
:
pruzina._width = pruz_width;
. , !
, pruz_press false ( ), onEnterFrame , .
ActionScript :
else { // Math.abs ,
pruzina._height = pruz_height + Math.abs(A*Math.cos (Math.sqrt (k/m)*time)
*Math.exp (-alpha*time));
pruzina._width = pruz_width;
gruz._y = gruz_pos+Math.abs (A*Math.cos (Math.sqrt(k/m)*time)
*Math.exp(-alpha*time));
}
, ,
, . ,
. , . ,
: .
, :
. :
= gruz._y-gruz_pos; // onMouseUp
time. 0, , .
time , null.
:
time+=l/12; // else
// onEnterFrame
, Date
getTimer(). .
, , , time null:
if(time!=null) {
}
. . , .
, , , , ( Var) m,
k, alpha. ,
.
, ,
, .
ActionScript .
, . , , , .
, .
. ActionScript
.
, , , .
, . ?
,
, , .
,
.
.
.
ActionScript . , , , , .
4.1.
:
function Identifier (FormalParameterList) {FunctionBody},
:
function , ;
identifier , , , 1;
FormatParameterList ,
( );
FunctionBody , (
).
ActionScript .
:
function (FormalPararneterList) {FunctionBody}.
(, ).
, . :
var func:Function = function (par) {
trace (par);
};
, , ,
.
(
8) ( 9). , :
function func(a){
a();
}
func(function() {trace("!")}); // :
, ,
.
. ,
(. 4.6.1) :
var a:Number = 0;
function func{a) (
return a;
}
trace (func(1)); // : 1 (
// )
JavaScript, ActionScript . - . ,
( ) .
function func() {
function func2() //
trace("!!!);
}
func2();
}
func(); // : !!!
, , .
, , . , . , ( 4.S 4.9).
.
,
. ,
:
//
function concat(par1:String, par2:String) {
return par1+par2;
}
trace(concat("", " !!!")); // : !!!
trace(concat (true, 4)); // "Type mismatch"
// ( ).
. :
// , //
Date
function func():Date {
return 2;
}
, ,
Void ( void, , , , undefined):
// "A function with return type Void may not return a
// value." (" Void ")
function func():Void {
return 2;
}
, ActionScript,
. , .
4.2.
, (
) . , , , , . , :
function func():String {
return "!!!";
}
trace(func);
// : [type Function] (
// )
trace(func());
// : ( )
(, , ). , . , . ,
, , Function (
, ). ():
var func:Function = function():String {
return "";
};
var fund: String = func();
// "()"
// , //
var func2: Function = func;
// "()" -
//
trace(fund);
// : ( )
trace(func2());
// : ( ,
// )
trace(typeof fund);
// : string (fund )
trace(typeof func2);
// : function (func2 )
,
. , ,
(). ,
, .
: , , , , . , , ~
undefined NaN.
// ,
// ( )
function square(a:Number, b:Number, c:Number):Number {
var p:Nurnber = (a+b+c)/2;
return Math.sqrt(p*(p-a)*(p-b)*(p-c));
}
trace(square(l, 2, Math.sqrt(5))); // : 1 ( )
trace(square[1, 2));
// : NaN ( ""
// )
trace(square(1, 2, Math.sqrt(5), 4)); // : 1 (
// )
:
, , . , , trace()
. ,
:
trace(1,2);
trace([1,2]);
// : Wrong numbers of
// parameters, trace requires only 1.
// : 1,2
( , , ):
function func(par:Function):Void {
// , -
//
par();
}
function func2():Void {
trace("!!!");
}
func(func2); // : !!!
Bo Flash 4 ,
call(). . , . Flash call() ,
, .
4.3. return
return, ActionScript . , , -
. return
undefined:
function func(a):Void {
if (typeof a!= "number") {
return;
} else {
trace(a);
}
}
func(5);
// : 5
trace(fun("5")); // : undefined
return , . , . :
// ,
function square(a:Number, b:Number, alpha:Number):Number {
return l/2*a*b*Matb.sin(alpha/180*Math.PI);
}
trace(square(1,1,90); // ; 0.5
-262, return :
. ActionScript return
, ECMAScript:
trace (0);
return;
trace(l);
//
//
//
//
Output 0
.
Output 0
return . break.
4.4.
.
,
.
, , . ,
( ) ( ). , . , .
( , ) ,
. , , .
, , :
, , . , ,
. .
, ,
(n!= 1 * 2 * 3 * K * (n 2) * (n 1) * n ). He :
function factorial(n:Number):Number {
if (n == 0) {
return 1;
// 0!=1
} else {
return n*factorial(n-1);
}
}
trace (factorial(5)); // : 120
3.
, factorial(3). . 3 0, n*factorial(n-l). factorial() , 2. . : n=1 n=0.
n=0, 1. l*factorial(0) ,
, n=2 1.
, 2 3. factorial() 6.
, . , ActionScript .
256 , , , 300, Output :
256 levels of recursion were exceeded in one action list. This is
probably an infinite loop. Further execution of actions has been disabled in this movie. (256- . , , .
.)
.
Flash MX 2004 swf- , . , ActionScript. Flash
(. 20), swf-.
ActionScript , , ,
. , XML- (
, ).
4.5.
, ,
ActionScript. (scope chain) , .
.
ActionScript : ( )
. , : Global.
MovieClip Object, -
, 4 . , .
( , ).
. , 5
. ,
with(),
6 ,
:
, , . Flash 5,
, , -262. Flash MX 2004 , .
, ( ).
, *. , -
, :
// mov , _root
function sizer() :Void {
_xscale = 200;
_yscale = 200;
mov.sizer=sizer; // sizer() mov
mov.sizer();
// _root:
// sizer()
, .
sizer() mov _xscale _yscale, ,
, sizer(). , this.
, , , :
function sizer():Void {
this._xscale = 200; // this
this._yscale = 200;
}
MovieClip.prototype.sizer=sizer;
mov.sizer(); // mov
, -. ,
:
function fun():Void {
var per:String = ""; //
function func2():Void {
// per
trace(per); // :
}
func2();
}
func();
, ( ),
this.
, , ,
,
(, ):
function func():Void {
var per:Number = "";
func2();
}
function func2():Void {
trace(per); // : undefined
}
func();
, ,
, . , , . -, 3 , , , Global (.
9).
- ActionScript, 9.
4.6. arguments
, , ,
. , , . , ,
( ).
arguments.
arguments . ,
. , arguments for
in:
function func(a:Number, b:Number, :Number):Void {
// arguments
for (var i in arguments) {
trace (i); //
}
}
func(l, 2, 3); // : 2 10
, Output , : arguments, . , , .
, .
arguments, []:
Output ,
, .
, arguments : 0, 1 . .
arguments , Array. - , ActionScript , object ( ,
arguments ECMAScript).
function func():Void {
trace(typeof arguments);
trace(arguments instanceof Array);
// : object
// : true (arguments
// Array)
}
func();
arguments , Array.
:
function func():Void {
trace{arguments.join("***",2,3)); // join()
//
}
func(1,2,3); // : 1***2***3
arguments , , ,
, .
, ActionScript. , , -
concat(). : concat()
, . . , arguments, :
function myConcat():String {
var result:String = "";
// ,
for (var i=0; arguments.length; i++) {
result += arguments[i];
}
return result; //
);
trace(myConcat("","!","!","!")); // : !!!
, arguments. Flash ( )
, (
-262 ASSetPropFlags() ).
Flash MX arguments , .
4.6.1. arguments
, ,
arguments. : , arguments[0], arguments() . . , ,
. ,
var
, .
, arguments. , ,
, , arguments. , , .
, , arguments
. , , , arguments ( ):
//
//
function func(par1:Number, par2:Array):Void {
par1 = 2; // ,
par2.push("");
trace(arguments); /* : 1, (
, arguments)*/
}
func(1, []);
4.6.2. arguments
ActionScript, arguments ,
, , :
length. , . , , ,
. length , ,
forin, for.
callee. , , . , callee ,
. .
, , , :
var factor_5:Number = function (par:Number):Number {
if (par = 0) {
return 1;
} else {
return par*arguments.callee(par-1);
}
}.apply(null, [5]); // apply
// (
"()")
trace(factor_5);
// : 120
caller. , ,
. , caller null. :
function fund () :Void {
func2(); // fund() func2()
}
func1.property = "!!!"; // func1
// ( ,
// )
function func2():Void {
trace(arguments.caller.property); // property
// func2 ()
}
funcl(); // :
caller: ,
( . 4.8). , , , , :
arguments.caller.arguments
4.7.
, , . , .
, .
,
.
, , , arguments
, . ,
.
, ,
, :
var obj:Object= {prop:""};
function func(par:Object):Void {
par.prop = "";
}
func(obj);
trace(obj.prop);
// prop
// prop
//
// func obj
// : {
// )
, , . ,
.
. , , , .
, , ActionScript ( ).
4.8.
ActionScript. . ( ) .
(!) :
.
( ) ,
. ( )
.
. , ,
. , . , .
. . .
, ActionScript
. , , ,
. :
// ,
//
var func:Function=function():Void {
//
for (var i in arguments.callee) {
//
trace (i + "=" +arguments .callee [i]);
}
}
func.a-1;
//
func.b=2;
func();
//
: b=2 a=l
Function, , .
, .
, .
, . , ActionScript .
, , , . ,
,
. ,
. .
(). :
function func():Void {} ;
trace(func); // : [type Function]
, , .
.
.
?
, .
.
, ,
, ( , ) :
function func():Void {
trace(prop);
}
func.prop = "";
func(); // : undefined
. , , ,
(700 340 ).
, , , ,
.
, ,
. , , , . , ,
, .
. .
ActionScript. . - ,
.
. ,
4.9.
4.8.1. Function
. .
, ActionScript . .
-262 Function,
. , ,
function. , Function():
var func=new Function("a", "", "return a+b+c");
func(1,1,1);
// JavaScript 3, ActionScript - undefined
. , , . , , .
. ,
ActionScript Function(). ,
eval(): . Flash- ,
.
, ActionScript -262
Function. , . , , Function .
.
function func():Void{};
trace(func instanceof Function);
// : true (func Function)
Function,
. ,
. Function.
4.8.2. prototype
ActionScript - . , Java, C++ Smalltalk. . , new. , String(), new, String. :
// Ball
function Ball(color:String,size:Number):Void {
//
this.color=color;
this.size=size;
}
var bigRedBall=new Ball("red",1000); //
trace(bigRedBall.color); // : red ( )
trace(typeof bigRedBall) // : object ( )
,
. , , . ,
,
, . , ,
( ).
, ,
. prototype ,
, __proto__, .
, . , . , , , .
,
.
, .
prototype ActionScript , (
, , , Number
. ,
, []).
// ,
Number.prototype.deg2rad = function():Number {
return this/180*Math.PI;
};
var deg:Number=360;
trace(deg["deg2rad"]()); //
:
6.28318530717959
ActionScript, . - . , .
4.8.3.
Function : apply()
call(). , ,
, , (). , apply() call() .
, , () (, ). ,
.
apply() :
functionObjt.apply(thisObject, [par]),
apply() ()? -, , ,
. -, apply() , :
// ,
MovieClip.prototype.sizer = function(proc:Number):Void {
this._xscale=proc;
this._Yscale=proc;
};
ball.sizer(200);
//
_root.sizer.apply(ball, [200]);
// _root,
// ball
call() apply() : , .
:
FunctionObject.call(thisObject, par1, par2, par3...)
call() , .
4.9. .
, , . ActionScript, . ,
ActionScript, .
, , , .
,
.
, , . <Ctrl>+<Enter>
Export Movie, , ,
ActionScript - , .
, , .
, ActionScript function:
//
function func(a:Number):Number {
return a
}
// -
function 'func' @5
// @ ,
//
push 'a'
getVariable
return
@5 end
, .
, .
( ),
. , , , , , -
, . , , .
Fortran .
B ActionScript , .
. ,
, ,
. .
,
. ,
.
, . , . , , ,
, .
. .
.
, . , Flash-.
, .
.
, . , , , . , . , , , , , , , ,
, this, ,
. ActionScript
arguments.
,
. ( - )
. , ,
, .
- , ? ,
. ,
. this
-:
function func() :Void {
fun1();
function funcl():Void {
trace(this);
}
}
func(); // : [type Object]
, func() funcl ()
. .
, , arguments this. ,
, , forin. ,
, ASSetPropFlags(). ,
Flash MX. Flash MX 2004 arguments this
, for-in .
function func(a,b,c) { // a, b, -
var per1 = ""; // per1 per2 -
var per2 = "";
func_intro();
//
function func_intro() {
ASSetPropFlags(this, null, null, 1); //
for (var i in this) {
trace(i+"="+this[i]); //
}
}
}
func(l, 2, 3); // ,
, Output :
per2=
per1=
func_intro=[type Function]
c=3
b=2
=1
arguments=l,2,3
this=_level0
, :
(per2 per1).
(func_intro) ( - ).
arguments.
(, b, ), arguments
.
this , , ( , this , ).
,
ActionScript. ,
.
, , :
var obj=null; //
function func():Void {
func1();
function func1():Void {
obj=this; //
}
}
trace(obj);
// : [type Object]( )
. , , , . , object, . , ,
, . - - .
Function!
, typeof
function, object. , .
4: -
-, , , ,
. , . - ,
.
Flash- . ,
.
, , , []. ,
Flash 4, ,
.
fla- 4 .
, - .
, Flash-, ,
, . , ,
.
. ,
(<Ctrl>+<F8>) ( Grid Show Grid
). Rectangle, 3x3.
line .
, Snapping Snap to Grid .
, 90x90 . , , W (weight) (height) .
, ( ) . , ,
( ).
, . , pole.
. ,
, -
. krestik, nolik. , .
.
. .
, ,
, . , onMouseDown:
pole.onMouseDown = function():Void {
};
, ,
. , | . _xmouse _ymouse, . , . _xmouse _ymouse pole. 0 90,
, , :
if (pole._xmouse>0 && pole._ymouse>0 && pole._xmouse<90 && pole._ymouse<90)
{}
, ,
hitTest(), , MovieCIip.
,
. . , duplicateMovieClip():
duplicateMovieClip(user, "obj"+n, n);
duplicateMovieClip() :
user , .
, krestik nolik, user. :
//
var user;String-null;
var computer:String=null;
// , ,
//
function rand():Void {
// ( 0
// 1 - 0, 1)
// 1,
if (Math.round(Math.random()) = 1) {
user = "krestik";
computer = "nolik";
{ else {
user = "nolik"; // 0,
computer = "krestik";
}
}
rand(); // user computer
"obj"+n . ( , ) obj . -
.
, 1. , , :
n++; // n
n . ,
. ,
- n ( , ).
, ,
. - :
far stroke:Number= Math.round {(pole._xmouse-15)/30)*30;
far stolbec:Number= Math.round((pole._ymouse-15)/30)*30;
eval("obj"+n)._x = pole._x+stroka +15;
eval("obj"+n)._y = pole._y+stolbec + 15;
, . obj ( eval(), )
, . .
- pole ( 30), . ,
( stroka stolbec). , .
,
. , 30,
. ,
, .
pole.
. _root,
pole (pole._x, pole._y). , !
, . .
.
. ,
.
, - . ,
, , . ,
, .
, , :
,
. ,
.
. , -
, , , .
, . , ,
, .
.
, .
,
. , ,
.
,
. , ( 2 4) , .
.
, , . .
, - .
, .
, . pole (
). : +
+ . , .
1 , :
// ,
function pole_null():Void {
for (var i = 0; i<=2; i++) {
// 0
// ActionScript
for (var j = 0; j<=2; j++) {
// set ()
//
set("pole.kl"+i+j, 1);
}
}
}
pole_null();
,
10 ( 100). ,
onMouseDown , ,
(stroka stolbec):
set("pole.kl"+stroka+stolbec, 10);
. , ,
, , :
if (eval("pole.kl"+stroka+stolbec)==1) {
//
//
-,
, . ,
, , .
, ,
, . ,
, , ,
. - .
, , :
var
var
var
var
var
var
var
var
var
hod_k100:String
hod_c101:String
hod_k102:String
hod_k110:String
hod_k111:String
hod_k112:String
hod_k120:String
hod_k121:String
hod_k122:String
=
=
=
=
=
=
=
=
=
"000102001020001122";
"000102011121";
"020100021222220";
"101112001020";
"011112011121001122021120";
"101112021222";
"001020202122201102";
"202122011121";
"202122021222221100";
, . .
, , .
: hoc_k1 , 00 ,
(. . ). : 000102001020001122.
, ,
. . .
, :
Function mozg():Void) { // ...
mozg() , . ? , , . ,
,
. , :
pole.klnm, :
for (var i = 0; i<3; i++) { // i ,
for (var j = 0; j<3; j++) {}} // j -
, . , , , :
if (eval ("pole.kl"+i+j) == 1) {}
, , obhod(),
( ) :
ves = obhod(i, j); //
obhod() , , . , . , , (,
). , , , . .
mozg() obhod():
function obhed(i:Number, j:Number) { } // i j ,
//
obhod(), ,
! j:
var wayiString = eval("hod_kl"+i+j);
, ,
, pole.klnm . , 102
, (polc.klnm=100)
(pole.klnm=l). nm way ,
. , . , way :
for (var k = 0; k<way.length/6; k++) {
pole.klnm , , nm.
, pole.kl , ,
.
0:
res = 0; //
for (var m = 0; m<3; m++) {
ves += eval("pole.kl"+way.substring(6*k+m*2, 6*k+m*2+2));
}
, , . . IX .
ocenka() ( obhodO,
):
function ocenka(ves:Number) {
switch (ves) { // ves - pole.klnm
//
case 201:
//
// ( )
return 1000;
case 21:
// - ,
//
return 100;
case 102:
//
return 50;
case 12:
//
return 20;
case 3:
//
return 7;
case 111:
// ,
return 3;
// , ,
//
case 30:
return "user_victory";
}
}
end() , .
, ( ), . end() user, , .
obhod() mozg(), user_victory
( ). , :
} else {
summ_ves += ocenka(ves);
}
summ_ves, , ( )
0:
var summ_ves:Number = 0;
, sum_ves,
obhod() :
return summ_ves;
mozg() , . , - , .
. -. obhod()
max, . max, .
. ,
-. hod:
if (ves>max) {
max = ves; // max
// mozg() 0
// hod mozg() null
hod = ""+i+j; //
}
, hod
. , , ,
.
,
, ,
pole.klnn.
:
comp_hod(hod); //
comp_hod() ,
. ,
:
function comp_hod(kletka:String):Void {
duplicateMovieClip(computer, "obj"+n, n) ;
//
var stroke:String = kletka.substring(0, 1);
//
var stolbec:String = kletka.substring(1, 2);
eval("obj"+n)._x = pole._x+stroka*30+15;
eval("obj"+n)._y = pole._y+stolbec*30+15;
// 100
set("pole.kl"+strcka+stolbec, 100);
n++;
}
, - .
.
, , . obhod{) , . end, :
// if() onMouseDown
// ( n)
if (obhod(stroka, stolbec) == "end") {
game=false;
return;
}
game ,
, . ,
, game true. game
, true.
onMouseDown end()
, . 10.
if (n = 10) {
game = false;
end("null");
return;
}
,
, :
mozg(); //
. - , . -
1000, , :
if (max>=1000) { // mozq()
game = false;
end("computer");
return;
}
. ,
mozg() ( comp hod()) :
if (n = 10) {
game = false;
end("null");
return;
}
. , , Output:
function end(par:String):Void {
trace(par);
}
!
. , ... !
. , .
, !
- ,
. , ,
, . ,
mozg() :
time
setInterval(mozg,1500);
setInterval() .
, ,
. (1 = 1000 ). ,
.
time, setInterval(), , null.
mozg(), setInterval() .
:
clearInterval (time); // ,
. -!
, , , . onMouseDown :
game=false;
, . mozg() :
game=true;
.
( , , ),
, ,
:
function rand_hod():Void {
if (Math.round(Math.random()) == 1) { //
mozg(); // 1,
//
}
}
rand_hod(); //
rand_hod() ,
mozg() hod_kl .
-, .
, . , Flash (Window/Other Panels/Common Libraries/Buttons).
, newgame.
onRelease:
new_game.onRelease=function():Void{ }
, , . , , , obj .
, removeMovieClip():
for (var i = 1; i<=9; i++) {
// 9
eval("obj"+i).removeMovieClip();
:
n = 1; // 1
game = true; // ,
//
pole_null(); // pole.klnm 1 //
, , :
rand_hod();
. . ?
.
. , .
,
.
,
. , -
. ( Var ) info.
? -, . end() :
function end (par : String) : Void {
switch (par) {
case "user":
info = " !";
.
// break,
//
break;
case "computer";
info = " !";
break;
case "null":
info = "";
break;
}
}
-, , . mozg() :
info = "
";
, 1,5-
. ,
, :
info . , .
- . , ( 5 ) schet. :
var schet:String="0:0"; //
,
:
var User_schet:Number = 0;
var computer_schet:Number = 0;
end() , :
case "user":
info = " !";
user_schet += 1;
break;
case "computer":
info = " !";
computer_schet += 1;
break;
schet:
schet = ""+user_schet+":"+computer_scnet; //
// end()
. -,
, . 4.1.
. 4.1. -
. ... - ! , , , , ?
.
.
.
(, -), (==, <), (., []), . ,
.
ActionScript
( ). ,
.
. . .
5.1.
:
. -. ,
+, -, %, ( ). ,
. - (delete. typeof) ,
. - , , ;
. (instanceof, void), ( (
), ( ?:);
. . , ,
, , ;
. , . , , , 2+2*2 6, 8. 5.2;
. , .
, , . ActionScript [], . , () , ++ -- .
. : !
, , typeof .
. . : /(), == ( ), instanceof ( ). ,
, .
-. ActionScript ;
. , . . , 5.3;
. ,
. ActionScript . : + , (
); ()
, ;
.
5.2.
, ,
, 2+3*4+5. ?
,
( , , ). ActionScript, , , Java,
Ada JavaScript, , ,
. ,
, . ,
. , , Output :
var a:Number=2;
var b:Number=3;
trace(a+++b*a);
. , (++)
,
(2+1)+((2+1)*3)=12. , Output
(2+1)+(2*3)=9. ActionScript , , +++b* , ,
(a+1)+b*a, , +(b+1)*. , ,
, . , , . , ,
, , , , , , ,
Output : (2+1)+(3*(2+1))=12. , :
trace(a+++b*a); // : 11
// : 0
// : 1
, . , , typeof:
// :
typeof 1+"1";
typeof(1+ "1") ;
: , typeof
:
trace(typeof 1+"l");
trace(typeof(1+"1"));
// : number1 ( 1
// 1)
// : string
ActionScript . 5.1.
5.1
ActionScript (no )
+
.
.
~
.
!
.
not
Flash 4 ( )
++
, 1
- . 1
()
[]
.
++
. 1
- . 1
new
delete
,
typeof
void
undefined
*
%
+
add
Flash 4 ()
<<
>>
>>>
<
<=
>
>=
in stance of ,
lt
Flash 4 ()
le
Flash 4 ()
gt
Flash 4 ()
gl
" Flash 4 ()
5.1
==
!=
eq
ne
&
^
|
&&
and
||
or
?:
=
*=, /=, +=, =, %=, <<=,
>>=, >>>=,
^=, &=, |=
,
Flash 4 ()
Flash 4 ()
Flash 4 ()
Flash 4 ()
. 5.1 . , .
. , ,
.
. ActionScript
:
var a:Number=2;
var b:Number=3;
trace(a+(++b*a)}; // : 10 [2+((3+1)*2)=10)
, ,
.
5.3.
, , . ,
? ,
+b+?
, , ( ). ,
. ActionScript
. , +b+ (+b)+. ,
, .
, ?:, !, ++
--, - ~, .
,
. , , :
=b=="";
trace(a); // :
, . , , , .
= , b undefined (, ).
, ,
, . , ActionScript
, . ,
:
trace (""+1+2-0);
trace (1-0+2+"");
trace(-0+""+l+2);
// : 12
// : 3
// : 012
,
, .
5.4.
ActionScript . ( +,
*, /, )
, , . %,
, .
. , ,
number. :
trace("20"/"5"); // : 4 ( )
trace[1+true);
// : 2 ( true 1)
trace(null+true); // : NaN (null NaN, true - l)
, , ,
. , + ,
. , , , ,
, .
,
:
trace(0xFA12/05661);
// : 21.3892415636485
// ( )
,
, Infinity (), Number.MAX_VALUE (
), Number.MIN_VALUE ( ), NaN (). :
// : Infinity (
// )
trace(Number.MAX_VALUE*Number.MIN_VALUE); // : 8.83178419700125-16
trace(Infinity*0); // : NaN ( )
trace(Infinity/Number.MAX_VALUE);
. , :
trace(1/0);
// : Infinity
trace (0/0);
// : NaN ( )
trace(""*"b"); // : NaN ( )
+ -, ,
. , ,
.
, , :
trace(+"0.6784e-3");
trace(typeof - true);
// : 0.0006784 (
// )
// : number (-true -1]
, , % :
trace(2%5); // : 2
%, - , ,
, .
, . :
trace(10%9.9); // : 0.0999999999999996 ( - 0.1)
trace(10%4.4); // : 1.2 [ )
.
% . , , ( , 1
):
function prost(a:Number):Boolean {
// , 2,
// ( )
for (var i = 2; i<=Math.round(a/2); i++) {
// - , false
//
if (a%i = 0) {
return false;
}
}
// , , ,
//
return true;
}
trace(prost(131));
trace(prost(1111111111));
// : true
// : false
5.5.
. ActionScript .
.
5.5.1. =
=. , , . - .
(, C++, Java, Fortran .) . , (:= Pascal Ada, APL).
, -?
() . , , . . ( ), , (. 5.1).
=, . , (, , ), : , .
- ,
(. 5.2).
. ,
3.
b
. 5.1. : ; b
. 5.2. ()
(b)
, , .
. delete
, . ,
, . , .
, ,
, , .
, , ,
. , (
, ).
// ball;
var rad:Nurnber=ball._width/2; //
// ,
ball.onMouseMove=function():Void {
// ,
ball._xscale = ball._yscale = rad / (rad + (Math.sqrt (ball-_xmouse ball.xmouse *
ball._xmouse * ball._xmouse))) * 100;
};
5.5.2.
.
n=n op value,
n ; ; value ( ). :
var n:Number=0;
n=n+l;
trace(n); // : 1
, . ActionScript. 11:
+=
-=
*=
/=
%=
<<=
>>=
>>>=
^=
&=
|=
, ,
:
var a:Number=5;
+=/=*=-= %=2; //
//
trace(5+5/(5*(5-5 %2))); // : 5.25
trace(a);
// : 5.25
,
,
. ,
, . , ,
, :
var a:Number =5;
%= 2, -= , *= , += ;
trace{a); // : 0
, undefined:
+=1;
// var , =+1;
trace(); // : NaN (undefined NaN)
, , 3, .
5.9.
5.5.3.
( ) . , , , .
,
: .
, , -
( C++ ,
). ++ --. ActionScript, , :
var a:Number=0;
++;
// : =+1 +=1
--;
// ; =-1 -=1
trace();
// : 0 (0+1-1=0)
: . :
var a:Number=0;
// if
e(); // : 0
. , . ,
. ++ --, , :
var a:Number=0, b:Number=0;
trace(a++); // : 0
trace(++b); // : 1
trace(a);
// : 1
trace(b);
// : 1
. .
, undefined:
trace(+=1); // : NaN
trace();
// : NaN
, ,
.
5.6.
,
.
if elseif, 6 .
, ActionScript.
5.6.1.
, =.
!=. :
trace (1 = 1); // : true
trace (1!=1); // : false
true ( ) false ( ).
: =b b=.
!=
== : !=b !(=b).
, , , , . , :
, .
. , NaN=NaN false, a Infinity=lnfinity
true, NaN. , ,
isNaN() isFinite():
var a:Number=NaN;
trace(a=NaN);
// : false (
// )
trace(isNaN()); // : true ( )
, .
. ,
toLowerCase() toUpperCase() String:
trace(""="");
trace(""="".toLowerCase());
// : false
// : true
, , ,
. , ,
:
trace(" "="
");
// : false (
// )
, true, false.
, (,
), , .
, , ,
, , . :
// object , b,
var obj1:Object = {:1, b:2, c:3};
// , obj1
var obj2:Object = {:1, b:2, c:3);
// , obj1
var obj3:Object = obj1;
trace(obj1 == obj2);
// : false (
// )
trace(obj1 == obj3);
// : true (
// )
,
, ( ):
trace([1,2,3]==[1,2,3]); // : false
, ActionScript , . ,
, , :
// , arrl arr2
function arrEq (arr1:Array, arr2:Array):Boolean {
if (arr1 == arr2) { // ,
//
return true;
}
if (arr1.length!= arr2.length) { // ,
//
return false;
}
for (var i = 0; i<arrl.length; i++) { //
if (arr1[i]!= arr2[i)) {
// i-e arr1 arr2
// ,
return false;
}
}
return true; // arr1 arr2 , true
}
trace(arrEq([l,2,3], [1,2,3])); // : true
trace(arrEq([l,2,3], [1,2,4])); // : false
, , , , for-in, . , , , .
,
(number) . :
trace(true=l);
trace("0.01"=0.01);
// : true (true 1)
// : true ( "0.01"
// 0.01)
, , 2,
.
null undefined, true. , Number(null)=Number(undefined)=NaN, a ,
( ). null, undefined,
!=, ,
:
trace(null=undefined); // : true
, , . :
// Boolean
// true
// : object bul )
// : true (bul
// true, 1)
, , , ( ).
. == !=
, (. 2).
,
:
: ""+=""+b
: -0==b-0 ( +=+b)
: !==!b
:
var a ="";
var b=null;
trace(a=b);
trace(!a=!b);
// : false (
// )
// : true ( , )
, , == /=. , , , . . , , null, , :
var a=null;
trace (a=b); // : true
- ,
ActionScript (strict) , false,
. =: = !. , , . :
trace(true=l);
trace(true===l);
tra(3!="3");
trace(3!=="3");
//
//
//
//
:
:
:
:
true (true 1)
false ( )
false ( "3" 3)
true ( )
5.6.2.
ActionScript, , :
<
>
<=
>=
, ,
. :
trace(l<=2);
trace("A">"B");
// : true
// : false
.
, , .
, ,
. , , < > (NaN), :
trace(Number.POSITIVE_INFINITY>Number.MAX_VALUE); // : true
trace(NaN<=NaN); // : true (NaN==NaN false)
trace(NaN < NaN); // : undefined
, (NaN)
<= >= (true). , = = false.
, ( >b):
1. , b . , true. , , .
2. b, false.
3. , b . k.
4. Unicode- , k b. .
5. >, true. false.
:
trace("">"");
trace("">"");
trace("ABC">"abc");
trace("">"");
//
//
//
//
//
//
//
: false (
0x0041, - 0x0042)
: true ("" "ABC")
: false (
, )
: false ( Unicode
"" , )
,
. , Unicode
, .
, .
2,
, string number (null, undefined boolean), :
trace(true>false); // : true ( 1>0)
,
, . :
// object obj1 obj2
var obj1:Object = {a:1, b:2, c:3};
var obj2:Object = {a:4, b:5, c:6};
trace(obj1.toString()); // : [object Object]
trace(obj1>=obj2);
// : true (
// [object Object])
trace(obj1>obj2);
// : false
,
, . , .
5.7.
XIX . - (
). , . , , : , ,
, .
( 1) ( 0).
ActionScript true ( ) false (
) boolean. , 5.9, .
ActionScript 3 , :
&& ( , , (^)). , . , .
|| ( , , ( )).
, , . , , .
! ( , , ( )). , .
. ,
, , .
, . , ActionScript . , (
2).
. . :
trace(true && true);
trace(true && false);
trace(true || false);
trace(false || false);
trace(!true);
//
//
//
//
//
//
//
: true (1*1=1 (
))
: false (1*0=0)
: true(1+0=1 (
))
: false (0+0=0)
: false
, , boolean,
( 2):
trace("1" && true);
// :
trace("true"||"false"); // :
// true)
trace(1 || 0);
// :
trace(![1,2,3]);
// :
.
|| 0 1
1? , , (0 NaN
false, true). ,
, ECMA-262:
1. ||
2. .1, boolean.
3. . 2 true, . 1.
4. . 2 false, .
. ,
( !) ,
. , true false, , . :
trace(_root || _global);
trace([1, 2, 3] || [3, 4, 5]);
// : level0
// : 1,2,3
. , . ,
.
5.8. (?:)
?: ActionScript ifelse. :
condition? trueExpression: falseExpression,
:
condition ;
trueExpression ( ), , ;
falseExpression , ;
, ?: - ( ) ActionScript.
ifelse ?::
var a:Number = 1;
var b:Number = 2;
// if-else
if (a>b) {
trace(a);
} else {
trace(b); // : 2
}
// ,
a>b? trace(a): trace(b); // : 2
, ?: . , ,
. (,
, ). ?: - . :
var per:Number = 2*Math.random(); // 0 2
var per2:Number = per>1? "big_value": "small_value"; //
// per2 per1
trace(pre2); // : small_value
5.9.
, , , . , . . .
5.9.1.
. ,
. ,
33 . ,
, 10001 ( 33
).
, ActionScript , ,
, , NaN, undefined, null.
, .
, . ,
. :
var str:String=""; // ""
2.
(, ,
), :
var arr:Arreay=[1,2,3]; // [1,2,3]
ActionScript-
Array, :
7.
Object. :
var obj:Object={a:1,b:1,c:1}; // {a:1,b:1,c:1}
, , Object():
var obj:Object=new Object();
Object 9.
5.9.2.
()
. , . :
trace((2+3)*5);
// : 25 (
// , "*" , "+")
, , . ,
, .
5.9.3.
ActionScript , , .
. . :
var obj:Object={a:1, b:2, c:3};
trace(obj.a); // : 1
[] :
trace(obj["a"]); // : 1
.
, [] , .. , ,
, :
var obj:Object={};
obj["1+1"]="!!!"; // 1+1
trace(obj ["1+1"]);
// : !!!
5.9.4.
,
. , ,
(). , , .
(), .
, ,
:
trace(1);
trace(trace);
// : 1 ( trace())
// : [type Function] (
// )
4.
5.9.5. new
new ActionScript .
- .
:
var arr:Array=new Array(); //
new 9, ActionScript.
5.9.6. super
super . , .
, super, .
super 9, - .
5.9.7. delete
delete . , undefined:
var per:String="!!!";
delete per;
trace(per); // : undefined
delete ,
, , . object
: , .
, . , removeMovieClip().
5.9.8. typeof
typeof . , ActionScript 7 : null, undefined, string, number, boolean, object movieclip.
, . typeof
, :
trace(typeof 1);
trace(typeof _root);
// : number
// : movieclip
object, ,
typeof :
trace(typeof trace); // : function
typeof
. , . . , . , - .
, , instanceof.
5.9.9. instanceof
instanceof , . :
object instanceof class,
:
bject , ;
class ( instanceof ).
object ' true. false:
class, instanceof
trace(_root instanceof MovieClip);
trace(_root instanceof String);
// : true (
// )
// : false
, instanceof -
. . :
trace(_root instanceof Object); // : true (_root
// MovieClip, Object)
instanceof :
trace("!!!" instanceof String);
trace(new String("!!!") instanceof String);
// : false
// : true
instanceof 9, - .
5.9.10. void
, void , , ActionScript.
undefined:
trace(void _root); // : undefined
, void, undefined , :
if (per = void per) {
trace(" !"); )
} // Output : !
, .
, , void , ?
, ActionScript ECMAScript,
( ). ActionScript void Web- (
JavaScript). , JavaScript void: , , javascript: -URL HREF SRC HTML (, ).
, , URL,
. ,
. , void.
? . , ActionScript void , -262.
void ,
Void. , , .
5.9.11.
, , . ,
:
var a:Number = 0, b:Number = 1, c:Nunber = 2;
trace(b); // : 1
, , for
:
for (var i=0, j=0; i<100; i++, j+=2) {
}
, . ,
- , :
trace(("", "")); // :
, .
5.10.
, .
? ,
. , , ,
. , . , .
, ,
. ActionScript , . ,
, ActionScript .
.
.
ASSetPropFlags(), . . . , 7 ( 111), , , ,
forin. 5 ( 101) , . . ASSetPropFlags() , 8. 3, 5? 20 . . , ActionScript .
5.10.1.
true false 1 0.
. -
, , , . :
00011101
00111000
------------
00111101
ActionScript, :
trace(parseInt("00011101", 2) | parseInt("00111000", 2)); // : 61
ActionScript , parseInt.
, toString():
trace((parceInt("00011101",2) | parceInt("0011100",2)).toString(2));
// : 111101
ActionScript 4 :
&
(XOR). 1, 1. 0 1 0
XOR.
, , . ; ?
, ,
1 .
, , . ,
0:
// ,
1001101
0001000
------------
0001000 ==>
// ActionScript:
if (parseInt("1001101", 2) & parseInt("1000",2)!= 0) {
trace(true);
} else {
trace (false);
} // : true
, ,
. : &=, |=, ^=,
~=.
x
:
, , 64-
32- . , ,
232, .
5.10.2.
2.
, , - .
>>. :
numberInt
>> n.
:
numberint , ;
n , .
, , . ( ) ( ). :
000111001
-----------------
000000111
// ActionScript:
trace((parseInt("111001", 2) >> 3).toString(2)); // : 111
n
n 2 ( ):
trace(111 >> 3);
trace((111-111 %(2*2*2))/(2*2*2));
// : 13
// : 13
>>
>>>. , >>>
, :
trace(-33>>2);
// : -9
trace((-33)>>>2); // : 1073741815
, , .
. ActionScript
n
<<. n 2 :
trace(10<<3);
trace(10*2*2*2);
// : 80
// : 80
var per:Number=16;
per>>=4;
trace(per); // : 1
RGB- .
, :
var R:Number = 255, G:Number = 255, B:Number = 255;
var color = R << 16 | G << 8 | B;
trace(color == 0xFFFFFF); // : true
5: 3D-
, , . , . , , . , , Flash, .
!
. , , , . ?
.
Flash . 2
2 .
?
, , , . ! , ,
. , 3DStudio Max
Bruce 3D,
. , , ,
?
, , .
. .
. .
, ? . ,
. , , , ,
. , ,
. , , .
, , Brace? , ,
Flash. ,
. , , .
.
. , . , Flash, , .
.
, .
. ,
. , . 5.3,
Flash.
. 5.3.
20 .
ZOY ? 20 ? ,
, , ...
.
, , . , , . ! , -
(. 5.4, ).
, Z .
(
) 0,5, . . Z
, X Y. ,
10 . , . :
( Grid Show Grid ). & , ,
Grid Edit Grid .
200 %.
, :
o Line () ( , <Shift>);
o width 10;
o 45, Free Transform ( ) <Shift>;
o ;
o , 500-800 % , .
, ,
.
. 5.4. : ; b
, , , (. 5.4, b), .
(<F8>), kubik.
, , . , duplicateMovieClip()- , ActionScript
attachMovie().
attachMovie(identifier, name, depth) :
identifier ( ),
. ,
Linkage () . Export for ActionScript ( ActionScript) Identifier ()
. cub;
name , , Instance
Name . ;
depth , .
depth , . .
, depth.
? , , :
, . .
, , .
, 3 .
, , .
Z, Y, X ( ).
5x5x5=125 :
for (var i = 0; i<5; i++) {
for (var j = 0; j<5; j++) {
for (var k = 0; k<5; k++) {
}
}
}
,
kubik:
:
// ""
//
// ,
// ( )
arr[n]=attachMovie("cub","cub",n);
n++;
n. , .
( ,
), . (n=25 i+5 j+k).
0.
rr. 125 . (
), eval(). , ,
, . :
var arr:Array[];
, .
, , X=150,Y=150, Z=0.
X ( k)
:
x=150+20*k;
Y , ( ) ( j)
:
y=150-20*j;
* Z. , , . :
z=10*1;
, , z , null.
, . Flash , _ _. , z X Y. ? , (. 5.5).
, =0, Y=0, Z=Z0, x=-Z0cos(45) y=Z0cos(45) ( .
5.5). , =0,Y=Y0, Z=Z0,
=0 - Z0cos(45) y=Y0 + Z0cos(45).
:
arr[n]._x=x-z*Math.SQRTl_2;
arr[n]._y=y+z*Math.SQRT1_2;
. <Ctrl> + <Enter>. ?!
?! ! (. 5.6)!
- .
,
. ?
. 5.5.
. 5.6.
: onMouseDown
, hitTest() . ,
,
, .
.
, , Button.
onPress,
. , , ...
( , Flash MX Macromedia ,
MovieClip, t onPress, onRelease,
onRollOut, onRollOver, onDragOut, onDragOver , , ,
onEnterFrame. .
125 ? - , ?
-. , . , ?
.
. , , ?
, this. ,
, :
trace(this); // : _level0 (
// )
, kubik,
:
this.onPress = function():Void {
this.removeMovieClip ();
}
, , this
. :
onPress=function() {
removeMovieClip();
}
. ! , . , . ,
( 5.7).
. 5.7. ,
! , , :
(. . ). ,
, ?
MovieClip. ,
- ,
:
MovieClip.prototype.onPress=function()Void {
this.removeMovieClip();
}
, ,
. ,
, .
,
. , , . , n
.
, . ?
, , I
, MovieClip I
. , ,
. , ActionScript .
9.
. . , , ,
. , MovieClip useHandCursor. (
n) :
arr[n].useHandCursor=false;
,
. , .
-. , - , .
.
, :
arr[n]._visible=false.
,
, . , ,
, , ,
. ,
enabled, , :
arr[n].enabled=false;
, , onEnterFrame.
, .
- setInterval().
10 :
//
var time:Number=setInteval(Visual,100);
function Visual():Void {
//
var t:Number=Math.round(Math.random()*arr.length);
arr[t]._visible=true; //
arr[t].enabled=true;
}
,
arr:
arr.splice(t,1); // splice()
, Visual() . :
if(arr.length==0) {
clearInterval(time);
}
(. 5.8). ! ,
,
( fla- 5
cub.fla).
. 5.8.
.5.9.
: , (.5.9).
. , ( ), 5 sphere.fla.
1950- . , .
(, , ,
), ( ), ().
ActionScript . , .
.
. . (statement) , - ;. ActionScript , .
? ,
? , . , -,
, -,
-.
, ,
. , . , . , , :
function bolshoi_vopros():String {
return
""
}
, , . bolshoi_vopros() undefined.
ActionScript :
var
a:String
=
"";
trace(a); // :
, bolshoi_vopros() , . :
trace(bolshoi_vopros 0); // : undefined
, .
ActionScript ; .
. , , ,
:
var a:Number=0 var b:Number=l
//
var a:Number=0; var b:Number=l; //
. ,
( -
),
, , . ActionScripi.
, -,
,
6.1.
. ee
.
, ,
, {}:
//
function fun(:Number, b:Number):Number {
var :Number = a+b;
return c;
}
,
. , .
, , .
ActionScript ,
Object . , .
. ,
, -. ,
-:
//*************** "{}"
var obj:Object=(a:1};
// -
push 'obj', 'a', 1, 1
initObject
varatequals
end
// ,
// =1
//
//
//
//
//
,
,
//*************** "{}"
function func(a):Void { //
trace (a);
}
// -
function 'func' @5
//
//
//
push 'a'
//
getVariable
//
tr
//
end
//
,
5
func
, {} . , , , . ,
( ) .
var :
var per1:Number=1, per2:Number=2, per3:Number=3;
ActionScript var , . , . , ,
. var .
3.
function . ,
. var, function :
func(a:String):Void{ //
trace(a);
}
, function .
var , . , .
, , ,
. , -262 var function
(Statements () Function Definition ( )).
4.
6.3.
, .
, (expression statement) , var function (
). , :
; //
, ,
. , - . . ,
for, while ( , for
while):
var i:Number = 0; //
for (; i<10;) {
//
//
trace (i);
// : 1 2 3 ... 9
i++;
//
}
6.4. return
return
. :
function func(a:String):String {
return a;
trace(""); //
}
trace(func("")); // :
return , undefined.
return ActionScript , , , .
-262, return
.
return 4.
6.5. with
, ActionScript, . , . , . - ,
Math, .
,
. :
trace(Math.asin(Math.cos(0))/Math.Pl*180+ " ");
var m:Object=Math;
trace(m.asin(m.cos(0)) /m.PI*180+ "");
// :
// 90
// :
// 90
. , - ,
with. :
with (expression) statements,
expression , ,
with. , ;
statements , .
:
with (Math) { // Math
trace(asin(cos(0))/{PI*180+""); // : 90
}
, with?
( , ) ,
, with(). ,
, with :
Math. ;
(_root) ( , MovieClip Object);
Global.
with() :
Global.
, with, . , . , ,
. , ,
:
with (bigBall.smallBall) {
//
//
var a:Number = 1; // smallBall
}
trace(bigBall.smallBall.a); // : undefined
trace(a);
// : 1 (
// )
, (
with):
bigBall.smallBall.=1;
with . , .
Flash- with, ,
. , , , .
, ,
Math
with. ,
100 000 . , , ,
getTimer(), ,
:
// Math
for (var i = 0; i<100000; i++)
{
Math.sin(Math.PI*Math.cos(0)*Math.tan(Math.PI/4)); {
}
trace(getTimer()); // : 545
// with
with (Math) {
for (var i = 0; i<100000; i++) {
sin(PI*cos(0)*tan(Pl/4));
}
}
trace(getTimer()); // : 2455
,
with ( 5 ).
, . , , .
Flash 4 with -262 tellTarget. , . tellTarget with :
with . tellTarget .
teliTargct , with ,
.
tellTarget , . , (- ).
6.6.
, , ,
. ,
(). ActionScript : if switch.
else , if.
6.6.1. if
if . :
if (. 6.1, a). , . :
// : 0 , 1
var numb:Number = Math.round(Math.random 0);
if (numb = 1) {
trace("");
//
//
if
if
else
if
else
if
else
if
else
. 6.1. : a c ; b c ;
c
:
var numb:Number = Math.round(Math.random());
if (numb =1) {
//
// Output
trace("");
} else {
trace ("");
}
, else
. ,
. , if elseif
. ,
. 6.1, c:
// ActionScript-,
//
var numb:Number = Math.random(); //
if (numb>0.45 && numb<0.55) {
// - 1 10
if (numb == 0.5) { // ,
//
trace(" - ");
} else {
trace(" - ");
} else if (numb<0.45) { // - 1 2
trace(" ");
} else { // - 1 2
trace (" ");
}
if,
. ,
true. , false. , if ,
, , boolean?
( 2);
if (_root) { // true
trace(_root); // : level0
}
. if. ,
, true, ==:
if (per==true) { //
, if
( if , , ):
if (per) { //
if , false,
( , ==
if (!=per) { // , - if (per=faise){
if . , , 1, 0, :
if (per) { // 1 true
statements
} else if (!per) { // 0 false, true
statements
}
, .
, ,
.
, , {}:
if (true) trace(""); // :
,
. , :
. , , . , , Auto Format ( ) Actions.
6.6.2. switch
-
, if.
. , , , -,
. ,
.
, , if:
// "",
//
if (operation = "plus") {
result = memory+numbers;
}
if (operation = "minus") {
result = memory-numbers;
}
if (operation = "umn") {
result = memory*nurabers;
}
if (operation = "del") {
result = memory/numbers;
}
. ,
. . , ActionScript goto,
, , . ,
( ,
, ,
). ,
.
switch. , Macromedia,
ActionScript Flash MX, .
case Ada switch Java JavaScript.
switch :
switch(expression) {
case clause1: statements
[break]
case clause2: statements
[break]
..............................
[default: statements]
}
:
expression ,
. ;
case , expression;
clause1, clause2... expression;
statements , , ;
[break] , statements, , .
break ;
[default] , ,
, .
, switch .
, :
switch (operation) {
case "plus":
result = memory+numbers;
break;
case "minus":
result = memory-numbers;
break;
case "umn":
result = memory*numbers;
break;
case "del" :
result = memory/numbers;
break;
}
switch , ,
, , .
if, = !=,
== !==:
var per:Boolean = true;
if (per = 1) { // true 1 Output ""
trace ("");
}
switch (per) { // Output
//
case 1:
trace("");
}
, expression, break. , ,
expression case:
var per:Number=1;
switch(per){ // : 1 2 3 per
case 1:
trace (1);
case 2:
trace (2);
case 3:
trace (3);
default: trace ("per ");
}
6.7.
.
, . -
:
expression , . ,
true, . false,
;
statements , , expression .
, while if. , if ( ) , while ( ) . :
var per:Boolean=true;
while (per){
trace (per);
}
while.
, . ,
per,
. , true, , . ActionScript,
( ,
).
- ,
. :
var i:Number =0; // -
while (i<5) {
//
trace!!);
//
i++;
//
)
// Output : 0 1 2 3 4
10;
: while(i>0) 0 false,
true
10 9 8 7....1
dowhile ,
.
, dowhile .
( iteration ). , ,
, , ( ) . AclionScript ,
. (
), ActionScript . , , 15 .
, . , , :
van i:Number=0;
while (getTimer()<15000) { // getTimer()
//
i++; //
}
trace(i); // : 1965236 (!)
15 !
. ,
, .
6.7.2. (for)
:
( ), , .
. : , , , ? , ,
ALGOL 30 for,
.
for :
for(initValue; condition; next) statements,
for ,
; ,. , ,
, ,
.
, , . , for , . ,
( while, for).
for . var . , , , . ,
, var ,
. , , var ,
:
// func ,
// 10
for (i=0; i<10; i++) {
func();
}
function func():Void {
func (i=0; i<10; i++) {
trace(i);
}
}
for ( )
. . , . ,
for, , ASCII 40 60:
for (var i = "", n = 0; i.length<20; i += String.fromCharCode(40+n++)) {
trace(i);
}
: ,, .
for , , ,
. ,
. :
// , .
//
for (var i:Boolean = 1; i<10; i++) {
trace (i);
}
var per:Boolean=1; //
, ,
, .
, ( while). :
var i:Number = 1;
for (; i<10; i++) {
i = true; //
//
}
, . , ,
. ActionScript -,
, :
// 3x3, 1 9
var arr:Array = [];
//
for (var i = 0; i<3; i++) {
// ,
arr[i] = [];
// ,
for (var j = 0; j<3; j++) { // ,
arr[i][j] = i*3+j+l;
}
}
for while , ?
, . (, , );
// while
var i:Number = 0;
while (i<500000) {
var per:Number = Math.sin{Math.PI)*Math.cos(Math.PI);
i++;
}
trace(getTimer()); // : 3365
//
for (var i = 0; i<500000; i++) {
var per:Number = Math.sin(Math.PI)*Math.cos(Math.PI);
}
trace(get Timer()); // : 3381
, while for .
, , ,
.
, for while , ,
-. , , for while, Flash-:
//
//
//
varequals
//
push 'i'
// "i"
getVariable
// push 5000OO
// 500000
lessThan
// , 500000, i
not
// , 500000, i,
// , i, 500000, ,
// lessThan,
branchIfTrue @17 // 17 ,
// ,
push 'per1, -1.22460635382238-16
//
// per .
// sin( ) cos( ) 0.
// ,
varequals
// per
push 'i', 'i'
// i
getVariable
// i
increment
//
setVariable
// i
branch @4
// 4
//
end
//
constants 'i', 'per'
push 'i', 0.00
- , while for -,
swf- ActionScript-. swf .
.
6.7.3. forin
forin , , ActionScript. , .
forin :
for (variable in expression) statements,
:
variable , . , ,
for;
expression ,
, .
, ;
statements ,
.
:
//
var obj:Object = {property1:1, property2:2, property3:3};
// obj
// utput
// : property1 property2 property3
forin? , , . , , ,
. ? ,
. ,
, , (. 2) ( ECMAScript
ActionScript, ). . , .
forin :
var obj:Object = {property1:1, property2:2, property3:3};
for (var i in obj) {
trace(typeof i);
// , i
}
// : string string string
forin
, , . ,
[] eval get,
:
var obj:Object= {property1:1, property2:2, property3;3};
for (var i in obj) {
trace(eval(i));
// : undefined undefined undefined (
// o )
trace(obj[i]];
// : 1 2 3 (
// )
trace(eval("obj."+i)); // : 1 2 3
trace(get{"obj."+i)); // : 1 2 3
}
forin , . , ,
forin , :
var obj:Object = {prl:l, pr2:2, pr3:3};
var n:Number= 4;
for (var i in obj) {
trace();
obj["pr"+n]=n; // pr4=4, r5=5, r6=6
n++;
} // : prl, r2, 3 ( )
// ,
for (var i in obj) {
trace(i);
} // : r6, pr5, pr4, pr1, pr2, r3 (
// , )
forin delete ,
, undefined.
,
:
var obj:Object = {prl:1, r2:2, r3:3};
for (var i in obj) {
trace(i+"="+obj[i]); //
delete obj.r3;
// r3
ActionScript, Output
. , forin. - ? . .
, 2 , . 3 : Readonly (, ), DontDelete (, ), DontEnum (,
forin). (DontDelete=l) (DontEnum=l), (ReadOnly=l). ,
ASSetPropFlags(). , . :
for (var i in Boolean.prototype) {
//
//
trace (i);
} // Output
//
// Boolean
ASSetPropFlags(Boolean.prototype,null, null, 1);
for (var i in Boolean.prototype) {
trace (i);
} // : toString valueOf __proto__ (
// )
// constructor ( )
forin , ,
', . , ,
, , .
, , ( , , ). ,
Boolean, Object toString, Output
:
var bul:Boolean=new Boolean(1); // Boolean
bul["isTrue"]=true; // bul isTrue
ASSetPropFlags(Object.prototype,null,null,1); //
// Object
ASSetPropFlags(Boolean.prototype,null,null,1); //
// Boolean
for (var i in bul) {
trace(i);
} /*
: toLocaleString isPropertyEnumerable isPrototypeOf hasOwnProperty
addProperty unwatch watch ( Object) toString valueOf
__proto__ constructor ( Boolean) isTrue ( )*/
, , ,
, , .
forin ,
. , , , , :
for
(var i in _root) {
forin ,
. , , ,
forin , for:
var arr:Array = []; // 100000
for (var i = 0; i<100000; i++) {
arr[i] = i;
}
var time:Number = getTimer(); // ,
// for
for (var i = 0; i<100000; i++) { // arr
arr[i] = Math.sqrt(i);
}
trace(getTimer()-time); // : 2190
time = getTimer();
// for-in
for (var i in arr) {
arr[i] = Math.sqrt(i);
}
trace(getTimer()-time); // : 3926
, forin for. ,
for.
0;
//
{
// i 99,
//
}
i++;
}
trace(i); // : 100
break, , return.
, . break return, , .
break - . (
) . ,
break .
switch, .
continue, break, . . break ,
continue . :
var i:Number = 0;
while (++i) { // ( i
// )
if (i<100) {
continue; // i 100
//
}
// , i
//
trace("i 100!"); // i 100,
//
break;
} // : i 100!
continue ,
(
100). , continue . continue
, ifelse.
6.7.5.
,
. ! ! , -. . , - , .
. , 15 , , . 6.2.
Puc. 6.2.
, : , Flash- . ,
. , ,
. 15
, .
, Flash- ,
. ( - ) . Flash-, ,
. ,
. . ,
Flash- , , , , . , .
Macromedia, ,
Flash- .
JavaScript.
30 , Internet Explorer , (. 6.3). , ,
,
Flash- ? ,
, , :
ActionScript , ,
( ). . : , , ( ,
), , . , ActionScript ,
Flash, C++ Pascal.
swf- , !
- ,
? . , ,
.
, . , , ( ) .
, :
, - , , . , - ,
length:
for (var i=0; i<arr.length; i++) {
// He
,
length arr. ,
,
:
var arr_length:Number = arr.length;
for (var i = 0; i<arr_length; i++) {
10 000 . , ,
.
.
, . ,
. ,
, , (,
, ). .
,
, . :
var str:String = "123"; //
// , , 3
var numb:Number = 123;
var time:Number = getTimer{); //
//
for (var i = 0; i<100000; i++) {
var zn1:Number = (numb-numb %100)/100;
//
var zn2:Number = (numb %100-numb %10)/10; //
var zn3:Number = numb %10;
//
}
trace(getTimer()-time); // : 2033 - ,
//
time = getTimer();
//
for (var i = 0; i<100000; i++) {
var strl:String = str.charAt(0); // c
var str2:String = str.charAt(1);
var str3:String = str.charAt(2);
}
trace(getTimer()-time); // : 7894
, ,
4 . , , ,
, . , ,
15 ( 10).
ActionScript
. , forin
for, if switch, +=
++> . .
-, Flash, . ,
. Flexm, , , .
, .
, 15 .
?
.
, . , , 10 , :
1. 0.
, :
var
n:Number=0;
2. , 200 000 :
for(var i=0; i<200000; i++) {
n 1 ( , ):
n++;
3. , -.
50, 10 , , . 50,
:
if (n<20) {
gotoAndPlay(2);
} else {
stop();
}
, ( ) onEnterFrame. :
// , 5000000
var numb:Number =0; // ,
var n:Number = 0;
// ,
_root.onEnterFrame = function():Void {
if (n<50) {
// ,
// 100000
for (var i = 0; i<100000; i++) {
numb++;
}
n++
} else { // 5000000 ,
// { )
trace(numb);
delete onEnterFrame;
}
}; // : 5000000
.
1/120 , , ,
,
.
onEnterFrame , . ,
. , Flash ActionScript- , - . swf- 7 , , .
swf- ( Flash).
6.7.6. onEnterFrame
, ,
. ?
var dx:Number = 100-ball._;
// X
var dy:Nuiriber = 100-ball,_y; // Y
while (ball._x<100 && ball._y<100) { // ,
// ""
// ,
//
bll._ += dx/1000;
ball._ += dy/1000;
}
. , . ActionScript , , , , .
ball , .
, - , ? , , . , , ,
onEnterFrame.
onEnterFrame . ,
, .
, .
- onEnterFrame,
:
var dx:Number = 100-ball._;
var dy:Mumber = 100-ball._y;
_root.onEnterFrame = function():Void {
if (ball._x<100 && ball._y<100) {
ball._x += dx/100;
ball._y += dy/100;
} else {
delete onEnterFrame // ,
//
};
ball.
2. , -
. dx dy, .
, , , .
var dx:Number = 100-ball._x;
var dy:Number = 100-ball._y;
3. ,
ball:
ball._x+=dx/100;
ball._y+=dy/100;
4. , , ball.
, .
:
if (ball._x<100 && ball._y<100) {
gotoAndPlay(2);
} else {
stop();
}
,
. Flash MX, , onEnterFrame.
6.7.7. . setInterval()
onEnterFrame : .
, .
, ,
.
Flash 5 :
, ,
.
onClipEvent(EnterFrame) ( Flash 5
. 8) ,
, , , , . , ,
, . .
,
EnterFrame, Flash 5 , . getTimer().
Flash MX , ,
onEntcrFrame, . setInterval().
setInterval() . ( ):
setlnterval(function, time, [arg1, arg2... argn]],
:
function , . , . () ,
;
time , . ;
arg1, arg 2, ... argn ,
.
:
var n:Number = 1; //
function func():Void {
trace(n++); // : 1 2 3 4...
}
setInterval(func,100); // func 10
, setInterval(), , :
//
setInterval(function (par):Void {trace(par);), 100, "!!!");
, sell nterval() , , :
myObject:Object = {}; //
myObject.method = function (par:String):Void { //
trace(par);
};
setInterval(myObject, "method", 100, "!!!");
, setInterval()
, .
, setInterval(), .
setInterval():
var func:Function=function():Void {};
trace(setInterval(func,100)); // : 1
trace(setInterval(func,200)); // : 2
setInterval() , undefined.
setInterva() ? .
setInterval() ActionScript clearInterval(), -
. , , setInterval():
var func:Function = function():Void
trace(time);
clearlnterval(time);
}; // Output : 1
var time:Number = setInterval(func,
{
//
//
100); // time
//
setInterval(), ,
. , , , , .
Frame Rate , , setlnterva(), ,
.
, :
1 ;
ball;
, :
function timer():Void {
ball._width = ball._height += 1;
}
setInterval(timer, 50);
, , ,
timer() , . , .
, timer()
:
updateAfterEvent();
, , .
updateAfterEvent() . , setInterval, .
updateAfterEvent() .
setInterval() ActionScript setTimeout() Javascript.
, , setTimeout()
.
6.8. .
try-catch-finally, throw Error
, ( ) . , , ,
NaN, , .
, , , e-mail
(, @). .
. , , ,
, , .
, , ,
. , ,
,
,
? if. . ,
. ActionScript trycatchfinally, throw
Error. -262, ActionScript Flash
MX 2004, Flash .
trycatchfinally , , , (
if,
). :
try {
statements
} catch (error){
error_statements
} finally {
fin_statements
}
:
try. , . (- try )
, ,
catch. , . ,
throw if,
. throw:
throw expression;
expression. , catch , .
. Error ( );
catch. ,
. , ,
catch , (error).
:
,
catch. ,
throw.
catch, ,
. , throw,
catch, .
, catch trycatchfinally
. ;
finally. ,
, . , , ( ). finally , , . , , try catch.
trycatchfinally :
function lg(arg:Number):Number {
try {
// , number.
//
if (typeof arg!= "number") {
throw " ";
}
// , NaN
if (isNaN(arg)) {
throw " ";
}
// , (
// )
if (arg<0) {
throw " ";
}
// ,
//
return Math.log(arg)/Math-log(10);
// ,
//
} catch () { // , throw
// , ,
//
switch (e:String) {
case " ":
return Math.log(Number(arg))/Math.log(10);
case " ":
trace(" ");
return NaN;
s " ":
trace(" "];
return NaN;
}
// finally
} finally {
trace(" ");
}
}
finally. , ,
return. , , finally, .
throw . try
catch ( catch ),
throw Output. ;
try {
throw ""; // Output - ""
} finally {
}
throw
try. . .
catch . finally,
catch, . catch , throw Output. :
function func():Void
try {
} finally {
trace("");
}
throw "";
}
try {
func();
} catch (e:String) {
trace(e);
//
} finally {
trace(""); //
{
// :
:
:
throw , , , try
.
try throw. ,
try. , . , , .
try catch. : catch . .
try
catch . .
. : catch , throw
. - throw catch. :
try {
throw 1;
} catch (a:Number) {
trace(""); // :
} catch (b:String) {
trace("");
}
catch , , .
catch, finally try
.
trycatchfinally . .
. , , . Error.
Error . :
message.
;
name. .
, . , Error name
Error. ;
toString(). . , message.
throw.
Error , message.
:
// ,
function cot(arg:Number):Number {
try {
if (typeof arg!= "number") {
throw new Error("
}
return I/Math.tan (arg);
} catch (err:Error) {
trace(err.message);
}
}
");
, Error
. , .
- , - .
,
Error. catch.
catch, .
-262 Error, . , .
Error . . . :
EvalError (, eval() ), SyntaxError ( ), Type Error (, ,
), ReferenceError (, ), URIError (
).
Error , . :
var err=new SyntaxError(" ");
trace(err.name);
// : SyntaxError
trace(err.message);
// :
trace(err.toString()); // :
, ActionScript
. " , if.
.
, , .
6:
, -
1985 . , . ,
. , Pentomino Puzzle,
. ,
,
.
Pascal 2 . ,
ActionScript, . ? ,
, , , , .
? , , . Flash,
,
.
, , tetrisl.fla 6. (.
6.4).
, , ,
. , , .
, . , .
.
, , .
: !
. 6.4.
, . , , ,
. ,
(. 6.5).
. 6.5.
, , , . , . , , ,
, . , , .
, ,
. ekran. ,
.
, :
function create():Void {}
:
4x4 .
.
. (. 6.6).
, ,
. :
o , . 6.6.
.
o , , . , , . ,
. ,
, , ,
. .
? . ActionScript
.
create() , :
var figura:Array = [];
, :
var n:Number=0;
3 , , 4:
while(n<4) {}
,
:
// i j
i = Math.round(Math.random()*3)+1; //
j = Math.round(Math.random()*3)+1; //
, i j, 1
4.
, .
( , ) , . , , , , kubik 11, kubik44 . ,
, i j :
if(_root("kubik"+i+j)==undefined) {}
. , :
if(!_root["kubik"+i+j]){} // undefined false, - true
, , , :
if (_root["kubik"+(i-1)+j) || _root["kubik"+ i+(j+l)+j] ||
_root["kubik"+i+(j-1)] || _root["kubik"+i+(j+1)]) {}
, . ,
:
if(_root["kubik"+(i-l)+j]!=undefined || _root["kubik"+(i+1)+j]!=undefined
|| _root["kubik"+i+(j-1)]!undefined || _root["kubik"+i+(j+1)]!=undefined)
{}
, .
, , ,
. , .
, , . . ,
, , true, figura,
, , false :
if (!figura.length || _root["kubik"+(i-1)+j] || _root["kubik"+(i+1)+j] ||
_root["kubik"+i+(j-1)] || _root["kubik"+i+(j+1)]) {}
, , ,
,
if:
// ,
if (!_root["kubik"+i+j] && (!figura.length || _root["kubik"+(i-1)+j] ||
_root["kubik"+(i+1)+j] || _root["kubik"+i+(j-1)] || _root["kubik"+i+(j+1)]))
{ }
.
&& ||, . , && -
, ||, , .
,
n- figura:
figura[n] = attachMovie("kubik", "kubik"+i+j, numb++);
, ,
, ,
. ,
attachMovie()
. , , numb:
var numb:Number=0; //
, numb , .
. , - ,
ekran. , ( i 1
- , ).
, ekran
( ):
figura[n]._x = ekran._x+ekran._width/3+figura[n]._width*(i-1);
figura[n]._y = ekran._y-figura[n]._width*j;
n- , n:
while figure, ,
. ,
, :
fg = figura; // fg null
. create() . ,
ekran (. 6.7).
<Ctrl> + <Enter> , ( , ).
. 6.7.
, .
creale(), .
, 12,5 _
:
function toDown():Void {
for (var i = 0; i<4; i++) {
fg[i]._y += fg[i]._height;
}
}
, toDownO
. setInterval(), , :
timer = setlnterval(toDown, interval);
//
// create()
interval, ,
350. timer, setInterval(),
null.
. ,
.
, ,
, ,
, .
, , , , 19x12 . , . ,
1. ,
. , , ,
.
1, .
.
. ActionScript , , .
1:
,
pole
, null
//
// 19
pole[i] = [];
//
for (var i = 0; j<12; j++) { //
// 12
pole[i][j] = 1;
//
}
function createPole():Void {
pole = [];
//
//
//
for (var i = 0; i<19; i++) {
}
}
CreatePole(); //
, , ,
, .
toDown(). ,
. , , , , 1.
, , ,
, ekran . -
pole. ,
, , .
4,
:
var schetchik:Number = 0;
/* , pole,
*/
var x:Number=null, :Number=null;
for (var j = 0; j<4; j++) { //
// pole,
//
x = (fg[j]._x-ekran._x)/fg[j]._width;
= (fg[j]._y-ekran._y)/fg[j]._width;
// , , ,
// schetchik 1. 0.
schetchik += pole[+1][]? 1: 0;
}
// ,
if (schetchik = 4) {
for (var i = 0; i<4; i++) {
fg[i]._y += fg[i]._height;
}
- 1 (
), . setInterval ():
} else {
clearInterval(timer);
}
. , . , :
ekran.
, pole.
schetchik .
, ,
ekran. , schetchik 1 (
schetchik ) :
if (fg[j]._y-ekran._y<0) { // j
schetchik += 1;
continue;
}
. , . , . .
, pole, 4
. , ,
fg. , , create()
(, ). ,
, (, ). , ,
create():
} else {
for (var k = 0; k<4; k++) { //
, , , ,
(. 6.8).
,
. ,
, . , ,
, ,
. , , , , ,
. :
. 6.8. ...
, ,
, 1 -1 ( ) , .
_, _.
(, ):
// 1, ,
// -1
function toLeftOrRight(par:Number):Void {
var schetchik:Number = 0;
var x:Number=null, var y:Number=null;
for (var j = 0; j<4; j++) {
x = (fg[j]._x-ekran._x)/fg[j]._width;
y = (fg[j)._y-ekran._y)/fg[j]-_width;
schetchik += pole[y][x+par] = 1? 1: 0; // 1
}
if (schetchik == 4) {
for (var i = 0; i<4; i++) {
fg[i]._x += fg(i)._height*par;
// 2
}
}
}
. , ,
: left right. blok.
blok.left blok.right toLeftOrRight
1 1 ( ):
blok.left.onPress = function():Void {
toLeftOrRight(-1); //
};
blok.right.onPress = function():Void {
toLeftOrRight(1); //
};
, . ,
( tetris2.fla 6).
, 90 (
). . , , , :
, . , , , 4 , ,
.
90 Y
, X
( = ). , ,
, ( =- ) (
). , .
, .
, , , .
,
. , :
function rotation():Void {
// pole,
var xsr:Number = 0;
var ysr:Number = 0;
// , toDown() toLeftOrRight()
var scetchik:Number = 0;
//
var x:Number=null, :Number=null, deltaX:Number=null, deltaY:Number=null;
// ,
//
for (var i = 0; i<4; i++) {
xsr += [fg[i]._x-ekran._x)/fg[i]._width/4;
ysr += [fg[i]._y-ekran,_y)/fg[i]._width/4;
}
xsr = Math.round(xsr);
ysr = Math.round(ysr);
// , ,
//
for (var j = 0; j<4; j++)
{
// ,
= [fg[j]._y-ekran._y)/fg[j]._width;
x = [fg[j]._x-ekran._x)/fg[j]._width;
// ,
deltaX = x-xsr;
deltaY = y-ysr;
// , ,
//
_root["newI"+j]= ysr-deltaX;
_root["newJ"+j]= xsr+deltaY;
// , scetchik 1
scetchik += pole[_root["newI"+j]][_root["newJ"+j]] = 1? 1: 0;
}
// ,
//
if (scetchik == 4)
{
for (var k = 0; k<4; k++) {
fg[k]._x = ekran._x+_root["newJ"+k]*fg[k]._width;
fg[k]._y = ekran._y+_root["newI"+k]*fg[k],_width;
//
delete _root["newJ"+k];
delete _root["newI"+k];
}
}
}
rotation() ,
. rotat :
bl.rotat.onPress = function():Void {
rotation();
};
. . ! , , , , .
.
,
. ,
, ( 19). ,
- 1, . ,
0- ( ). , .
,
, :
function obhod():Boolean {
// , true, ,
// false -
var flag:Boolean = null;
// - ,
//
var n:Numoer = 0;
for (var i = 0; i<19; i++) { //
flag = false;
// ,
for (var j = 0; j<12; j++) { //
if (pole[i][j] = 1) {
// ,
// flag
flag = true;
} else if (i == 0) {
//
// 0-,
end();
// ,
return false;
//
}
}
// , ,
if (!flag) {
radok(i, n++); // i - , n -
//
}
}
return true; //
}
obhod() toDown():
if (obhod()) {
// (obhod() true),
//
create();
clearInterval();
}
radok() . , ,
. pole 1, . ,
, :
function radok(index:Number, n:Number):Void {
// index
for (var i = index; i>=0; i--) {
for (var j = 0; j<12; j++) {
if (i = index) { // index
pole[i][j].removeMovieClip();
pole[i][j] = 1;
} else if (pole[i][j] != 1) {
// pole,
//
pole[i+l][j] = pole[i][j];
// , ,
pole[i][j] = 1;
//
pole[i+1][j]._y += pole[i+l][j]._width;
}
}
}
}
}
, . , . .
, .
, , , .
, , , .
.
dSpeed. .
? :
toDown. , , setInterval(),
, . , , :
// par , ,
//
function speed(par:Number):Void {
clearInterval(timer); //
//
timer = setInterval(toDown, interval/par);
}
blok.dSpeed.onPress = function():Void { //
// dSpeed
speed(5);
};
blok.dSpeed.onRelease = function():Void { //
speed(1); // dSpeed
//
};
// onReleaseOutside , ,
// .
// onRelease
blok.dSpeed.onReleaseOutside = function():Void {
speed(1);
};
, -
setlnterval(). , dSpeed
. - .
- , . ,
setInterval() .
? , , , -
, -. .
setInterval()
, , .
: 1 . , .
create() setInterval():
//
for (var i = timer-5; i<=timer; i++) {
clearInterval(i);
}
. !
, , . (Your Score). ,
( Var ) score. score
, 0.
radok(). :
score += Math.pow(5, n+1);
, . 5
( ), 750 ( ).
, , end(), . :
function end():Void{}
end() :
setInterval(). , :
for (var j = timer-5; j<=timer; j++) {
clearInterval(j);
}
. , , , (,
rotat). , -
forin enabled
false:
for (var i in _root) {
_root[i].enabled = false;
}
: ,
. , ,
. , los,
. newG exit.
. :
los._visible=false;
end() :
los._visible=true
los :
newG
newGameO los :
los._newG.onPress = function():Void {
los._visible = false;
newGaine();
};
exit .
fscommand() quit:
los.exit.nPress=function():Void {
fscommand("quit");
}
}
createPole();
numb = 0;
score = 0;
create();
//
//
//
//
new, . newG :
blok.newG.onPress = function():Void {
newGame();
}
. , .
. , gStart
. start.
, ,
urov ( Var _root.urov).
urov :
var urov:Number=5;
urov ,
:
var interval:Number = 1000-100*urov;
start, . , , :
for (i in _root) {
root[i].enabled=false;
}
,
. .
start create(), , interval gStart :
gStart.start.onPress = function():Void {
for (var i in _root) {
_root[i].enabled = true;
}
interval = 1000-100*urov;
create();
gStart._visible = false;
};
create(), ,
.
blok , .
. , bl :
blck.swapDepths(1000000);
. (.
6.9).
! ... , , , .
! , . ( ), . .
, . . .
. , .
. 6.9.
( Array)
(Array) , . , . ActionScript
. object,
Array. ( 7.13) ActionScript .
ActionScript , , Java ,
. ActionScript Array .
. ActionScript , (-). .
. 0,
1 . . 0, 1 , .
, , 0 .
ActionScript : , ,
. , . , , .
, . , .
, . , . arr,
3, obj,
mov, . 7.1.
, ( )
. . .
. 7.1.
7.1.
Array. ,
, , - new:
var arr:Array=new Array[]; //
() , , new
. ActionScript , .
var arr:Array=Array[);
trace(arr instanceof Array};
// new
// : true (arr
// Array)
(). . :
var arr:Array=new Array(1,2,3,4,5);
trace(arr); // : 1, 2, 3, 4, 5
, ActionScript, () : , .
. 4
294 967 296 (232). ,
, ,
, .
() . N, N
(
length N):
var arr:Array=new Array(5);
trace (arr); // : undefined,undefined,undefined,undefined,undefined
To, () , ,
, . ,
.
().
, [].
,
rr(). :
var arr:Array=[l,2,3,4,5];
//
tracetarr instanceof Array); // : true (arr
// Array)
trace(arr); // : 1, 2, 3, 4, 5
rr(), , :
trace([5]); // : 5
, .
:
var arr:Array=[2*2, Math.random(), ""+""];
trace(arr); // : 4, 0.764446393121034,
7.2.
Array ,
: . , . (
, ). ,
[]. :
var arr:Array=["",""];
trace(arr[0]);
// : ( )
trace(arr["1")); // : ( )
, ,
, ,
[] .
, ,
, .
[] ,
, :
var arr:Array=[l,2,3];
trace(arr[Math.sin(Math.PI/2)]); // : 2 (sin<90) =0)
undefined.
, , , = ( ):
var arr:Array=[l,2,3];
arr [1]="";
trace(arr); // : 1, "", 3
, ActionScript . :
var arr:Array=[];
[0]=1;
[1]=2;
trace (arr);
//
//
//
//
1
2
: 1, 2
, , . :
var arr:Array=[l,2];
arr.property=3;
// arr property
trace(arr);
// : 1, 2 ( -)
trace(arr-property); // : 3
- .
, Array , .
7.3. . length
. ActionScript ,
, , length Array:
var arr:Array=[l,2,3];
trace(arr.length); // : 3
, 0.
0, . length .
, Pascal, ActionScript
. . length:
var arr :Array= [1, 2, 3]; //
rr[5J=6;
// 5
race(arr.length);
// : 6 (
// )
trace(arr);
// : 1, 2, 3, undefined, undefined, 6
,
. , , ,
,
undefined. , , . -
forin:
var arr:Array = [1, 2, 3];
arr[5] = 6;
for (var i in arr) {
trace(); // : 5, 2, 1, 0
}
, .
. undefined. ,
, , ,
length.
length String, length Array . , ,
undefined (, ). length , , :
var arr:Array=[l,2,3);
arr.length=5; //
trace(arr);
// : 1, 2, 3, undefined, undefined (""
// undefined)
arr.length=l; //
trace(arr);
// : 1
, ActionScript
, . ,
length . , ,
:
var arr:Array=[1,2,3); //
arr.rrty="!"; //
trace(arr.length);
// : 3 (
// )
length , . , ,
.
7.4.
,
. :
;
;
.
( ) . , unshift().
:
myArray.unshift (valuel, value2... valueN),
myArray , ;
value1, value2, , valueN ,
.
myArray, unshiftO .
unshift():
var arr:Array=[l,2,3];
trace(arr.unshift(-2,-l,0)); // : 6 ( arr
// )
trace(arr); // : -2, -1, 0, 1, 2, 3
,
. .
,
, Array, , . :
var arr:Array=[l,2,3];
arr[arr.length)=arr.length+1;
trace(arr); // : 1, 2, 3, 4
,
push(). ,
unshift(). :
var arr:Array=[l,2,3];
trace(arr.push(4,5,6)); // : 6 (
// )
trace(arr);
// : 1, 2, 3, 4, 5, 6
,
splice(). :
myArray.splice(start, deleteCcunt, valueO, value1...valueN),
:
myArray ;
start , ;
deleteCount , ,
start. , start
. deleteCount 0, ;
value1, value2, ..., valueN , , , start. He .
splice() . -, ,
:
var arr:Array=[l,2,3,4,5,6];
arr.splice(1,2,"",""); //
//
trace(arr);
// : 1, , , 4, 5, 6
-, . , , ,
. :
var arr:Array=[l,2,3,4,5,6];
arr.splice(1,0,"",""); //
//
trace(arr); // : 1, , , 2, 3, 4, 5,
-, splice()
. .
7.5.
,
. ,
delete:
var arr:Array=[l,2,3];
delete arr[1];
trace(arr); // : 1, undefined, 2
delete , one -
. , ,
undefined. .
, . delete
, undefined. ,
Array forin:
var arr:Array = [1, 2, 3];
delete arr[1];
// "1"
for (var i in arr) {
trace(i);
// : 2 0 ( 1 )
};
, delete . undefined, :
var arr:Array = [1, 2, 3];
arr[1] = undefined;
for (var i in arr) {
trace(i); // : 2 1 0 ( 1 .)
undefined , -
, toString().
, undefined delete, ,
forin. ( 7.12.)
. , :
;
;
.
, shift() ( unshift(), ). unshift(), shift()
. :
var arr:Array = [1,2,3];
trace(arr.shift()); // : 1
trace(arr);
// : 2, 3
, shift() .
shift(), , (). :
var arr:Array = [1, 2, 3];
trace(arr.pop()); // : 3
trace(arr);
// : 1, 2
length :
var arr:Array = [1, 2, 3];
arr.length=1; //
trace(arr);
// : 1
, length ,
, forin.
.
splice(). , .
splice() , . :
var arr:Array = [1, 2, 3, 4, 5];
trace(arr.splice(1, 2)); // : 2, 3 ( )
trace(arr);
// : 1, 4, 5
splice() , .
.
unshift(), push(), shtft(), pop()
, . , , .
FILO (first-in-last-out , . . -
.
, , , (. . FIFO first-in-first-out ( )).
7.6.
, concat().
:
myArray.cencat(value0,value1,...valueN),
:
myArray - , ;
value0, valuel, ..., valueN , myArray . , , .
, concat() push().
, push() , a concat()
:
var arr:Array = [1, 2, 3];
trace(arr.concat(4, 5)); // : 1, 2, 3, 4, 5
trace(arr);
// : 1, 2, 3 ( arr )
arr.push{4, 5);
trace(arr};
// : 1, 2, 3, 4, 5
concat() push() ,
. push() , . concat() ,
. . :
var arr:Array = [1, 2, 3];
arr=arr.concat([4,5],[6,7]); //
trace(arr);
// : 1, 2, 3, 4, 5, 6, 7
trace(arr.length); // : 7 (
// )
t() , .
7.7.
ActionScript . , splice(),
, . :
var arr:Array = [1, 2, 3];
var arrl = .arr.splice (1); //
trace(arrl);
// ; 2, 3
trace(arr);
// : 1 ( arr )
, , slice(). :
:
myArray , ;
start , . start
, -1;
end , .
, start .
slice() , . :
trace[1,2,3,4,5].slice(2,4));
trace[1,2,3,4,5].slice(-3,-1));
// : 3, 4
// : 3, 4
, Array
, , .
7.8.
( ) ,
reverse():
var arr:Array=[1,2,3,4,5];
arr.reverse();
trace(arr);
// : 5, 4, 3, 2, 1
. ,
/ . , , reverse().
Flash , reverse() ActionScript , JavaScript. . , .
. , :
Array.prototype.myReverse = function() {
// ,
var.arr:Array = this.concat();
// this
//
for (var i = 0; i<this.length; i++) {
this[i] = arr(this.length-i-1];
}
};
var myArr:Array = [1, 2, 3, 4, 5];
myArr.myReverse();
trace(myArr); // : 5, 4, 3, 2, 1
7.9.
.
ActionScrip. -
, Flash .
sort(). :
array, sort (comparefn),
:
array , ;
comparefn , ,
, . :
o comparefn , y;
o , comparefn 1;
o , comparefn -1;
o , comparefn 0.
, sort() . , :
//
arr:Array = [3, 2, 4, 1, 5, 0]; //
function mySort(x:Number, y:Number):Number { //
if (x>y) {
return 1;
// ,
//
if (x<y) {
return -1;
if (x = ) {
return 0; // ,
}
}
arr.sort(mySort);
trace(arr); // : 0, 1, 2, 3, 4, 5
- (. . undefined),
:
var arrrArray = [3, 2, 4,undefined, 1, 5, 0];
rr.sort(mySort); // : undefined, 0, 1, 2, 3, 4, 5
sort() 1, 1 0, .
, 1,
, 1. , . , mySort :
var arr:Array = [3, 2, 4, 1, 5, 0];
function mySort(x:Number, y:Number):Number {
return x-y;
}
arr.sort(mySort);
trace(arr); // : 0, 1, 2, 3, 4, 5
comparefn sort() . ,
Unicode-
, ( 5).
- ,
sort() :
var arr:Arr=["", "", "",""];
arr.sort();
trace (arr); // : , , ,
, , , ,
, toLowerCase()
toUpperCase() String, :
//
var arr:Array = ["", "", "", ""];
arr.sort(); //
trace(arr); // : , , , ( )
function mySort(x:String, y:String):Boolean {
return x.toLowerCase()>y.toLowercase();
}
arr.sort(mySort); //
trace(arr);
// : , , ,
Flash MX 2004 .
sort() , Array:
Array.CASEINSENSIT1VE ( 1). . toLowerCase() toUpperCase() String. :
var arr:Array = ["", "", "", ""];
arr.sort(Array.CASEINSENSITIVE); //
trace(arr); // : , . ,
Array.DESCENDING ( 2).
. , ,
, . ,
:
var arr:Array = ["", "", "", ""];
arr.sort(Array.DESCENDING);
// ,
//
trace (arr); // : ,,,
Array.RETURNINDEXEDARRAY ( 8). , , . .
, .
. :
var arr:Array = ["", "", "", ""];
trace(arr.sort(Array.RETURNINDEXEDARRAY)); // : 1, 3, 2, 0
//
//
trace(arr); //
//
(
)
: , , , (
)
Array.NUMERIC ( 16). . | , . :
var arr:Array = [1, -23, 78, 0, 4.89, Number.MAX VALUE,
Number.NEGATIVE_INFINITY];
arr.sort(Array.NUMERIC); //
trace(arr); // : -Infinity, -23, 0, 1, 4.89, 78,
// l.79769313486231e+308
.
|.
, ( , NUMERIC
DESCENDING)
var arr:Array=[l, -23, 78, 0, 4.89, Number.MAX VALUE,
Number.NEGATIVE_INFINITY];
arr.sort(Array.NUMERIC|Array.DESCENDING);
trace(arr); // : 1.79769313486231e+308, 78, 4.89, 1, 0, -23,
// -Infinity
, , ,
| . ,
sort() .
: I, , 0, .
Array , , , 1. ,
, ( 1) , ,
.
:
// UNIQUESORT (4 100)
// RETURNINDEXEDARRAY (6 - 1000)
trace((Array.UNIQUESORT|Array.RETURNINDEXEDARRAY)) // : 12
trace((12).toString(2)); // : 1100 (
// )
//
trace((parseInt ("100",2] parseInt ("1000",2]).toString(2)); // : 1100
sort() , ( ). , 1, .
. , .
-262 ActionScript (,
JavaScript ).
Flash MX , -262, sortOn(). -
. , .
sortOn():
Array.sortOn ("property"),
:
Array , ;
"property" ,
.
property, , sort().
:
var arr:Array = [{pr:"C"), (pr:"A"}, {pr:"B"}]; //
// pr
arr.sortOn("pr");
for (var i = 0; i<arr. length; i++) {
trace(arr[i].pr); // : , ,
}
sortOn(), sort(), . :
var arr:Array = [{pr:"C"}, {pr:"A"}, {pr:"B")];
// :
arr.sortOn("pr", Array.DESCENDING);
for [var i = 0; i<arr.Length; i++) {
trace(arr[i].pr); // : , , I
}
sortOn() ,
. sort().
7.10.
. , swf-.
Web-, JavaScript ,
. : , ,
.
, ,
join(). :
arr.join (delimiter),
:
arr , ;
delimiter , . , .
join() , - . :
var arr:Array=[_root, 0x87, {}];
trace(arr.join("***")}; // : _level0***135***[object Object]
(. . ),
. , join(), ( toString()), , ,
:
var arr:Array = [[1,2], [3,4], [5,[6,7]]];
trace(arr.join("***")); // : 1, 2***3, 4***5, 6, 7
, join(), split()
String. . :
var str:Atring="1***2***3";
var arr:Array=str.split("***");
trace(arr); // : 1, 2, 3
Array, ,
toString(). . toString() join(), :
var arr:Array=[_root,{},undefined]
trace(arr.toString()); // : level0,[object Object), undefined
trace(arr.join());
// : level0,[object Object], undefined
Output ,
, . ,
length N>0, ( forin).
,
Output:
var arr:Array = []; //
arr.length = 5;
// 5
for (var i in arr} {
trace (i); // Output -
}
trace(arr]; // : undefined,undefined,undefined,undefined,undefined
Output ,
length
undefined. , delete.
, ,
, .
, forin, . 0 length-1. ,
undefined. , , , undefined.
7.11.
.
,
. , ,
, , .
, , .
, , (. 7.2).
. 7.2. ,
ActionScript .
(. 7.3). , 5x3 , 5 , 3 :
var arr:Array=[[1,1,1], [2,2,2], [3,3,3], [4,4,4], [5,5,5]];
trace (arr.join("\n")); // Output
, .
. , ,
.
, -, , , :
var arr:Array=[[l,2],[3,4]];
trace (arr[1] [0]); // : 3
, ,
:
var arr:Array[[[l,2], [3,4]], [[5,6], [1,8]]];
trace(arr[1] [0] [1]); // : 6
0 1 2 3 4
4
3
2
1
0
. 7.3.
, , .
.
,
.
, 10x10 1
100:
var arriArray = []; //
for (var i = 0; i<10;) {
arr(ij = [];
// -
for (var j = 0; j<10;) {
arr[i][j] = i*10+j+l;
//
}
}
trace(arr.join("\n")); // \n - escape-,
//
7.12.
forin
, : for
forin. , forin , for, . .
forin ,
. .
, .
for. , . , for
0 length-1. - ,
. forin.
, , ( delete), :
// for
var arr:Array = [1, 2, 3]; //
arr.length = 5;
// 5 -
//
for (var i = 0; i<arr.length; i++) {
arr[i] = 0;
}
trace(arr); // : 0, 0, 0, 0, 0 ( )
// forin
var arr1:Array = [1, 2, 3];
arrl.length = 5;
for (var j in arr1) (
arr1[j] = 0;
}
trace(arr1); // : 0, 0, 0, undefined, undefined (
// )
. , , , , .
, , .
, forin :
var arr:Array = [1, 2, 3];
arr[5] = 5;
arr[4] = 4;
for (var i in arr) {
trace (i); // : 4 5 2 1 0
}
, , forin
. Array .
for: 0, 1..
for in ,
. , 0, , ,
5. , .
, reverse(),
for forin:
var arr:Array = ["", "", ""];
arr.reverse();
for (var i = 0; i<arr.length; i++) {
trace(arr[i]); // :
}
for (var j in arr) {
trace(j); // : 2 0 1 (
// )
trace(arr{j]); // : (
// )
}
,
forin .
, forin , , for.
7.13. ActionScript
ActionScript ? ,
. ,
array ActionScript . , , .
, , .
, ActionScript , ,
.
object?
,
. , . : ,
, , , . ActionScript?
object ,
:
;
. ,
.
;
;
, . . , , ,
n 1.
ActionScript. ,
( ) . Array ,
.
object , ,
. ? -,
. -, , . -,
.
. ,
( ), . -
, . , .
, ActionScript ,
. ,
, . , :
var time:Number = null; // -
var obj:Object = {};
// 100000
for (var i = 0; i<=100000; i++) {
obj [i] = 1;
}
time = getTimer(); // ,
// 50000 0
for (var j = 0; j<50000; j++) {
obj[0] = j;
}
trace(getTimer()-time); // : 494
time = getTimer();
// , 50000
// 100000
for (var k = 0; k<50000; k++) {
obj[100000] = k;
}
trace(getTimer()-time); // : 509
, , , , . , . ?
ActionScript: ,
. , , , ActionScript, .
, , .
, Perl .
, , (set). , (
, ).
-. .
. ,
.
. , .
, . . , ,
, ,
, -, .
, - , , .
- .
.
, , ActionScript , , . -
:
;
. ,
, .
-, ,
forin. , ,
, ,
. , .
, Flash .
, , Array. -
, , Object? , . Array
,
. , length,
length.
Array , ,
length , ActionScript . .
. ActionScript .
, , . Array ,
. Array
, Java, object. ActionScript
, length .
7:
. ( ,
, ). swf-, .
, , . , ,
.
. . .
ActionScript?
, .
. ,
TextField.
. , , . ?
.
,
.
, - .
, ,
. , ,
, , . .
.
, 8x8 ( ) . ,
. , - 1 (), . , .
? , , .
. , ,
200 . .
-.
. : .
, . ActionScript .
, , , , Pascal ( ). 7 . font.txt
(. 7.4).
. 7.4. ,
,
fnt_matr. ,
. 8 , 8 .
* , . , .
, . fnt_matr,
. .
.
,
. , ,
, 10x10 . 80 .
7 . ,
7x80=560 .
560x80 , pole.
pole .
. . . , , . 70 , , . -: .
ActionScript . , , .
. , ,
. , ,
.
() 2 . -. (
lin) ( , , _width ). . ,
lin.
, 9 . lin pole ( ). pole , . X
, Y 10
. :
var n:Number = 0; //
for (var i = 0; i<=3; i++) {
pole.attachMovie("lin", "lin"+n, n); //
pole["lin"+n]. += 10*i;
//
pole["lin"+n]."width = 560;
//
//
n++;
}
lin , . .
pole, ,
lin
.
. , lin 90:
for (var j = 0; j<=56; j++) {
pole.attachMovie("lin", "lin"+n, n);
pole["lin"+n].width = 80; //
pole["lin"+n]._x += 10*j;
//
pole["lin"+n]._rotation += 90; //
n++;
}
. , ,
. 7.5.
. 7.5.
. .
.
. 6 (10 , , 2 , 2 ).
.
,
pixel.
. ,
,
, .
.
pole.
, . ,
. , , , ;
var arr_pix:Array = [];
for (var i = 0; i<8; i++) {
//
arr_pix[i] = [];
//
for (var j = 0; j<56; j++) {
//
arr_pix[i] [j] = pole.attachMovie("pixel", "pixel"+n, n++);
arr_pix[i][j)._x = j*10+5;
//
arr_pix[i][j],_y = i*10+5;
// )
}
}
<Ctrl>+<Enter>, (. 7.6).
. 7.6.
, j :
arr_pix[i][j]._visible = false; //
. .
. , , . .
, #include. ,
fla- font.txt 6 . () :
#include "font.txt"
, font.txt, .
#include, , :
, ; ;
;
, , .
, .
fnt_matr.
, . :
,
.
. ,
charCodeAt(), ,
Unicode- , 8- .
-. ,
font.txt RANGE, ,
fht_matr (, RANGE
escape-). &. -
, fnt_matr, , RANGE (,
String ),
, , , (. 7.7).
. 7. 7.
.
: ,
, . .
, , .
7.7 , , - .
, , :
str:String = "!!!"; //
signal:String = "";
// ,
function rd():Void {
for (var i = 0; i<str.length; i++) {
//
// str
// ,
var pos:Number = RANGE.indexOf(str.charAt(i));
//
for (var m =.0; m<8; m++) {
for (var k = 0; k<8; k++) {
signal += fnt_matr[k+8*pos-8].charAt(m); {
}
}
}
}
rd(); //
, , ;
signal+="\n"; // m
, . :
signal 8x56 ( ). . *, .
.
, 8x56 ,
8 . ,
. .
8x56 signal,
, . .
8x56 ,
undefined. ,
.
,
(-8*56) .
, , . .
:
var sdvig:Number = 0; // ,
function tablo():Void {
// ,
if (sdvig<signal.length/8+56) {
//
for (var i = 0; i<56; i++) {
for (var j = 0; j<8; j++) {
// signal, , "*",
// . undefined,
//
if (signal.charAt(-8*56+sdvig*8+i*8+j> = "*") {
arr_pix[j][i].^visible = true;
} else {
arr_pix[jI[i]._visible = false;
}
}
}
sdvig++; //
} else {
// ,
sdvig = 0;
}
}
setInterval(table,100); //
. . , . 7.8, :
! ! .
. 7.8.
.
. ? ,
.
updateAfterEvent(). ?
.
, . , .
tablo.fla 7.
? - . , , , , . Flash. , , , ,
Flash-.
( ActionScript),
,
. , ActionScript. ,
, , ,
ActionScript, . Tie . , ActionScript.
8.1.
. , ,
. - , , Flash .
, , , . ,
-. Flash- ,
. , ,
-?
. , ,
, ,
-.
(3050 ), , .
, , , , . ActionScript.
- AsBroadcaster,
Flash-. .
, , ( listener ).
, . , onEnterFrame , . ,
Flash- , . ,
, onEnterFrame onMouseDown. , . , Key . , addListener() , -
. remove Listener() .
? , , , . ,
- AsBroadcaster
, . addListcner()
. removeListener() .
. ActionScript
, . . ,
. , ball ,
:
ball.onMouseDown=function():Void {
this._visible=false;
}
//
onMoussDown
, , - AsBroadcaster , , .
- , . .
ActionScript
. . , , .
8.1.1.
, , . . , , , onMouseMove. , , onRelease . . .
, . onEnterFrame, . , ,
.
.
9 18 (!).
:
listener.eventHandler=function(){
statements;
}
:
listener ;
eventHandler .
, ,
, . :
function onEnterFrame():Void {
trace("!!!"); // : ...
}
, ,
, .
,
.
, ,
delete. ,
. , ( ,
onEnterFrame onMouseMove) . :
_root.onEnterFrame = function(): Void {
trace("!!!"]; // : !!! (
// )
delete _root.onEnterFrame;
};
,
. ? , , . ,
?
, . ,
,
MovieClip Button. :
// ball
for (var i = 0; i<100; i++) { // 100
// ball
ball.duplicateMovieClip("ball" + i, i, {_x: Hath.random()*550, _y:
Math, random!)*400>);
}
//
MovieClip.prototype.onPress = function():Void {
this.removeMovieClip();
};
, ,
.
, -
. ,
, , onEnterFrame (
). .
, ,
.
8.1.2.
, , . , . ,
. , , Mouse. , , :
_root.onMouseDown = function():Void {
trace(" !!!");
//
// Output
};
Mouse . on Mouse
Down :
// but
but.onMouseMove = function():Void {
but._xscale=but._yscale+=30; //
};
,
Mouse. addListener(),
, . :
eventObj.addListener (listener),
:
eventObj , ;
listener , eventObj.
:
Mouse.addListener(but); // but
but.onMouseDown = function():Void {
but._xscals=but._yscale+=30;
//
//
};
Mouse ,
onMouseDown (, ).
addListener() true, , false,
:
trace(Mouse.addListener(but)); // : true
Listeners.
addListener(). ,
but Mouse:
trace(Mouse["_listeners"]); // : level0.but
Listeners , . , Mouse , .
, _listeners ,
addListener(). ,
, . Listeners Mouse , , _root.
, Listeners , addListener(). push()
Array:
Mouse["_listeners"].push(but); // : Mouse.addListener(but);
addListener ,
. Listeners :
Mouse.addListener(1);
trace(Mouse["_listeners"]); // : 1
, removeListener() , :
Mouse.removeListener(but);
trace(Mouse["_listeners"]);
// Output //
// : true
// : false (but
// )
?
. , Mouse
, :
for (var i=0; i<Mouse["_listeners"].length; i++){ //
//
Mouse.("_listeners")[i].onMouseMove();
}
, , AsBroadcaster. ActionScript, . , .
, .
, . , Mouse ? , , .
Button.
, ,
, . , Mouse, listeners . ,
? , . ,
Mouse.
,
. ,
. :
// ,
/* globalListener()
. ,
Mouse. , ,
, */
function globalListener(level:MovieClip):Void {
for (var i in level) {
if (level[i] instanceof Button) {
Mouse.addListener(level[i]);
}
if (level[i] instanceof MovieClip) {
globalListener(level[i]);
}
}
}
globalListener(_root);
trace(Mouse["_listeners"].join(" + ")); // : _level0.mov.but +
// _level0.mov.mov_intro.but + _level0.but ( )
Button.prototype.onMouseDown = function():Void {
this._xscale = this._yscale += 10;
//
//
};
. ,
,
, .
ActionScript,
. - ,
AsBroadcaster().
, ,
ActionScript.
: Flash, ,
, Mouse, Key, Stage ? , , . , . , . , , . , , Rash-
Pentium 4. , swf- , .
8.2.
, , , , onRelease, . ,
- , , .
.
- . .
, .
( ).
, , , .
Actions Events. , ( Listeners).
: onSelect ContextMenu (
), onChanged TextField ( ), onLoad LoadVars (
).
, . -
, . onDCIick, mov:
// mov
mov.useHandCursor=false; //
mov.onPress=function():Void {
// , ,
if(mov.flag!=true) {
mov.time=getTimer();
mov.flag=true
// , ,
// . , 300 , onDCIick().
} else if (getTimer()-mov.time <300) {
mov.onDCIick();
mov.flag=false;
} else {
mov.flag=false;
//
mov.onDClick=function():Void {
trace(" mov");
}
? , . , -.
- , , ,
.
. , ,
, , . . onChanged TextField.
, . , , ,
Actions .
8.3. Flash 5
Rash 5 , . , (
) .
.
Flash 5 ( ), , , , .
, Actions -: , . ,
.
, Flash 5, :
1. , , but.
2.
<F9>. Actions.
, .
3. on onCIipEvent. ( ):
on (Event) {
statements
}
Event , -
statements , .
, -.
, 10 %
:
on (release) {
but._xscale = but._yscale += 10;
}
:
//
onCIipEvent (mouseMove) {
this._xscale = this._yscale += 1; //
}
Flash MX, .
onClipEvent(event), on(event). , , , . ,
. ,
on(event).
, . - .
Output : Statement must appear within on (onCIipEvent) handler
( on (onCIipEvent)).
Flash 5 . . ?
, . . :
Flash 5 , , .
, .
- , Flash 5 ,
.
( ) . , , ,
,
. !
. ,
. , Flash-. ,
,
. .
: .
.
- , ,
, . .
Flash 5 attachMovie() duplicateMovieClip(), . , ,
. , .
Flash MX 2004 . ,
. ,
. .
Flash 5 , .
Flash 5
, onSetFocus onKillFocus ( 11).
, Flash 5 ,
.
ActionScript- (Piter Hail). FLEM, , . , , , Flash MX .
: Flash 5,
? -, Flash 5. - ( ), ,
Flash MX Flash MX 2004, Flash 5. ?
, ( ) , . , . -,
Flash 5, , Flash Player 6 , ,
Flash Player 7 (, ,
).
8.4.
Flash- ,
. ,
, , ,
. , , , , (12 ), . , -
, . ,
. - . , ,
mov , 1 , :
mov.onMouseMove = function():Void {
this._xscale = this._yscale += 1; //
//
};
, , , . ,
, .
- ,
setInterval() updateAfterEvent().
, , :
mov.onMouseMove = function():Void {
this._xscale = this._yscale += 1;
updateAfterEvent(); //
8.5. AsBroadcaster.
Flash MX 2004
AsBroadcaster. , , . ,
. AsBroadcaster
ActionScript ASSetPropFlags(). - ,
, .
AsBroadcaster() 4 , :
AsBroadcaster.initialize(obj), obj .
. AsBroadcaster , (
addListener() removeListener()), , (broadcastMessage()). , Listeners,
.
, AsBroadcaster.initialize() , ,
:
var obj:Object = {}; //
// ,
//
ASSetPropFlags(obj, null, null, 1); //
//
for (var i in obj) {
trace(i); // : __proto__ (
// ) constructor
// ( )
// ,
// AsBroadcaster.initialize()
AsBroadcaster.initialize(obj);
ASSetPropFlags(obj, null, null, 1);
for (var i in obj) {
trace(i); // : _listeners removeListener addListener
// broadcastMessage __proto__ constructor
}
AsBroadcaster.addListener(listener). , _listeners.
.
AsBroadcaster.removeListcner(listener). , , , _listeners.
AsBroadcaster.broadcastMessage("Event", parameters), "Event" ,
parameters . , ,
. : _listeners " Event". H, , :
Mouse["broadcastMessage"]("onMouseDown");
, , :
for (var i = 0; i<Mouse["_listeners"].length; i++;) {
Mouse["_listeners"][i]["onMouseDown"]();
}
.
broadcastMessage(). , . , onSetFocus onKillFocus ( , ), ,
, . , ,
( onKeyDown Key)
. Key.getCode(),
, :
_global.myKey = {}; // Key
AsBroadcaster.initialize(myKey);
// myKey
//
Key.addListener(myKey); // myKey Key
// myKey onKeyDown
//
myKey.onKeyDown = function():Void {
var kod:Number = Key.getCode();
myKey.broadcastMessage("onKeyDown", kod);
};
my.addListener(_root); // _root myKey
_root.onKeyDown = function(kod:Number):Void {
trace(kod);
// Output
//
};
, AsBroadcaster., ,
.
onEnterFrame:
// but
//
this.createEmptyMovieClip("eventClip", 100000);
//
AsBroadcaster.initialize(eventClip);
// onEnterFrame
//
eventClip.onEnterFrame = function():Void {
this.broadcastMessage("onEnterFrame");
};
// but eventClip
eventClip.addListener(but);
but.onEnterFrame = function():Void {
this._xscale = this._yseale += 1; //
};
AsBroadcaster , . , . ,
.
8:
, ActionScript, , , ,
.
, .
- (,
).
AsBroadcaster.
( onDoubleClick). ,
-, :
( onMouseDown Mouse), , . ,
( 300 ), ,
. Mouse .
, , , , , . , .
onDoubleClick, ,
, -
. , , onDoubleClick , 300 .
, onDoubleClick, Mouse:
Mouse.addListener(Mouse); // Mouse
//
// , , Mouse
// ,
// onMouseDown "[]"
Mouse["onMouseDown"+""] = function():Void {//
//
//
if (getTimer()-this.time<=300 && this.flag) {
// onDoubleClick ,
// Mouse ,
Mouse["broadcastMessage"]("onDoubleClick");
this.flag = false;
} else {
// , , ,
//
this.time = getTimer();
this.flag = true;
}
};
Mouse.addListener(_root); // _root
_root.onDoubleClick = function():Void {
trace(" "); //
// Output
};
, , Mouse,
_root , . , , ( ), , . , root onMouseDown, AsBroadcaster .
onDoubleClick ActionScript, .
. ,
ActionScript .
, , ,
. 2, ,
. isDown() Key.
, , , , . ,
setInterval().
, onRightClick, :
Mouse("rightClick"] = function():Void {
if (Key.isDown(2)) {
Mouse["broadcastMessage"]("onRightClick");
);
setInterval{Mouse, "rightClick", 100);
_root.onRightClick = function():Void {
trace(" ");
}
, , .
. , ,
Flash ,
. - ? ,
- , , . , , . , , swf . JavaScript, ,
HTML-. Flash-
, :
Stage.showMenu=false;
Mouse.
, , .
?
FLEM Flash 5 , , .
, , AsBroadcaster.
, :
_global.myAsBroadcaster={};
initialize(), .
initialize() addListener(), removeListener() broadcastMessage(),
myAsBroadcaster, , . ,
listeners, :
myAsBroadcaster.initialize = function(obj):Void {
obj.addListener = this.addListener;
obj.removeListener = this.removeListener;
obj.brcadcastMessage = this.broadcastMessage;
obj._listeners = [];
}
removeListener() ( ) ,
:
myAsBroadcaster.removeListener = function(listener):Boolean {
var list:Array = this._listeners; //
//
var list_length:Number = list.length;
for (var i = 0; i<list_length; i++) { //
// , true
if (list[i] = listener) {
list.splice(i, 1);
return true;
}
}
return false; // ,
// false
};
addListener() , , .
, , ,
, , _listeners
, :
myAsBroadcaster.addListener = function(listener):Boolean {
this.remcveListener(listener);
this._listeners.push(listener);
return true;
};
broadcastMessage(), , -
.
AsBroadcaster. ,
, .
myAsBroadcaster. 6: , .
, myAsBroadcaster, AsBroadcaster(). , , ,
Flash. . myAsBroadcaster, Flash-. myAsBroadcaster() - ActionScript 2.0
Classes, ,
. , .
-
ActionScript - . , ,
, , , . : , ,
. : ActionScript -
-
? ,
.
9.1. -
- , 1980- .
. -
? , : , , .
-
. ( ) , .
? , , , , 3-5
. . , .
, (, Microsoft
). . , , . .
, , , - . ,
, pea , . ?
, .
. , . , .
. , - . ,
X , .
.
- . , , , ( , ActionScript ). -
.
,
. -
, .
, . , , , . . ,
. , , , , , .
. ActionScript
for
in, .
. -, , , ,
. -, .
. ,
concat(). , . -,
, - . - .
. , .
, , new. ,
new Ball() Ball. .
, , .
. - .
. ? , , . ,
Line Rectangle. ,
, , . , ,
. ,
Line Rectangle , ,
.
, .
, . , . ,
. , , .
. .
. .
- .
, . , .
, . - . , - , , .
- . , , .
, , . (
, ) ( -
) (, ).
(, ) , , . , , . . ,
. , , , . , .
-.
- (
). . , , ,
. - .
- . , ActionScript,
.
9.2. -
ActionScript 1.0
Flash MX 2004 - . , - ActionScript 2.0 ,
Flash . -
ActionScript -
, C++ () Java. .
- Flash MX 2004 . - ActionScript 1.0. :
- ActionScript 2.0
, - . , , .
. - . - ActionScript 2.0 .
- - ActionScript 1.0, .
.
- - Java , . , - . , , onPress, MovieClip.
.
, Flash 5 Flash MX.
, fla-, , .
, , -
ActionScript 1.0 . 9.1 , , 9.2. - ActionScript 2.0 9.3.
9.2.1.
ActionScript , , object, ,
. ,
. , , forin { . 2). , ,
. , , .
, , (
, , ). ,
( , _global
).
new. ,
Date:
var time:date=new Date();
. , -,
, -,
. , . , - , -
, , , .
ActionScript , .
, , , . ,
, ASSetPropFlags() (. 9.2.2).
9.2.2.
, . , , , .
, . . []. :
var obj:Object = {a:1, b:2}; // obj b
obj[3] = 3;
// "3",
//
trace(obj[3]); // : 3 ( "3" )
obj.a = ""; // "."
trace(obj.a);
// : ( )
delete obj.b;
//
tr(obj.b);
// : undefined ( )
.
(. 3). ,
, . ,
ActionScript .
, . ,
, - , (
-262 , , ).
. , .
.
ActionScript : ReadOnly (, ), DontDelete (, ), DontEnum (, forin). , false . , , forin. . ,
, , ASSetPropFiags():
var obj:Object = {a:l, b:2}; // obj b
ASSetPropFlags{obj, null, 7, null); // ,
//
delete obj.a;
//
trace(obj.a);
// : 1 ( )
obj.b = "";
//
trace(obj.b);
// : 2 ( )
for (var i in obj) {
//
trace (i);
// Output
}
, ( )
. , - , , ASSetPropFlags():
//
ASSetPropFlags(System, null, null, 7);
for (var i in System) {
trace(); // : setClipboard
}
security
System
...
ASSetPropFiags() 2 .
ActionScript ,
, , . ,
.
, -
. . , . Flash Remoting ( , 18) ,
__resolve ( ), . .
, :
// ,
//
Object.prototype.__resolve = function(name:String):Void {
trace(" "+name+" ");
}
__resolve - , :
this.__resolve = function():Boolean {
return true;
};
trace(this.property); // : true
getter/setter
addProperty(). , area, :
MovieClip.prototype.__resolve = function(par:String) {
if (par == "area") {
return this._width*this._height;
}
};
9.2.3.
ActionScript , . ( ) , ,
. , , Math,
.
, , . , .
. , ()
object, Function. ,
, ( . 4):
function func():Void {}; //
func.a=1;
//
trace(func.a); // : 1 ( )
. , .
, , , . ,
, :
//
var obj:Object={a:l,b:2,func:function():Void {trace (a)}};
var a:String-""; // ,
// obj
obj.func();
// : ( "" )
trace(obj.a); // : 1 ( )
-, :
. . -,
. -, . -
(), . .
. , , , .
- , ,
, . ( ,
.) , this.
:
// this ,
var obj:Object={a:1,b:2,func:function():Void {trace(this.a)}};
var a:String="";
obj.func(); // : 1
, ,
this: this ,
. this , . , , this ?
. , . , ActionScript
, . this :
function func():MovieClip {
return this;
}
trace(func()); // : _level0 ( _root)
, , , .
. . ,
. , , -,
, -, , . :
function func():MovieClip {
return this;
}
trace(func()); // : _level0 (
// -)
var obj:MovieClip = createEmptyMovieClip("clip", 1); //
obj.func = func;
//
trace(obj.func(]); // : _level0.clip (=> func()
// )
9.2.4.
, . :
. ,
;
.
. .
, C++ Java, , class. BActionScript 1.0 . , . , new:
function Func():Void {} //
var obj = new Func(); // Func .
// - Func
trace(typeof obj);
// : object ( )
trace(obj instanceof Func); //: true (obj Func)
. .
-, . , , Flash 7, -
ActionScript 1.0.
, , . , .
, this,
:
function Ko():Void { //
this. = 4;
// ,
this. = 1;
this. = 1;
}
var = new ();
//
for (var i in ) {
// ,
//
trace(i+"="+[i]);
// : =1 =1 =4
}
.
. .
, , , :
function (:String, :String, xapaep:String):Void {
// , :
this.=4, this.=1, this.=1;
//
this.=,
this.=,
this.=;
}
var = new ("", "", ""); //
for (var i in ) {
trace (i + "="+[i]); // :
// = = =
// =1 =1 =4
}
, .
.
. ,
. :
function Ko():Void {
function _():Void {
trace("Mpyyyyyy...");
}
this. = _;
this. = _;
}
function _():Void {
trace ("!!!!!!!"};
}
var = new ();
.();
.();
//
//
//
//
// : Mpyyyyyy...
// : !!!!!!!
, ,
. ,
( ,
. 4). , . , .
.
, , . , ,
. ,
, . :
function fund():Void{};
fund.r=1;
function Class(){
function func2():Void{};
func2.prop=1;
this.method1=func1;
this.method2=func2;
}
var obj1=new Class();
var obj2=new Class();
obj1.method1.prop=2;
//
//
//
//
//
//
//
-
,
// Class
//
//
obj1.method2.prop=2;
trace(obj2.method1.prop);
trace(obj2.method2.prop);
// : 2 ( )
// : 1 ( )
: , ,
? . , , . ,
, , . ,
, . , , .
, , ActionScript
, , ,
, , ,
.
. , . , ,
:
var arr:Array = [1, 2, 3];
function Class():Void {
this.arr = arr;
}
var obj1 = new Class();
var obj2 = new Class();
obj1.arr[0] = "";
trace(obj2.arr[0]);
//
// Class
//
// : (
// )
, , .
.
-, , this
, . . ,
,
. . ,
:
function Class(arg:String):Void {
//
this.prop = arg;
//
arguments.callee.array.push(this); //
//
// ,
Class.array = [];
// prop
var obj1 = new Class("");
var obj2 = new Class("");
for (var i in Class.array) {
// Class
trace(Class.arrayfi].prop);
// :
}
, , , . , new? -
,
, :
function Class():Void { //
this.prop = "";
}
ClassO();
// new
var obj = new Class(); //
trace(prop);
// : ( - )
trace(obj.prop);
// :
: new
this .
, , :
function Class():Void {
trace(this);
}
new Class();
// : [object Object]
Class();
// : _level0
, , , .
.
new. this
. .
this.property=expression; .
, .
, __proto__ constructor,
. .
. , , , ActionScript 1.0 . , , , new:
function my_new(constructor:Function):Object { // constructor
// -
var obj:Cbject = [];
// Object
obj.constructor = constructor;
//
// obj ( this)
obj.constructor();
//
obj.__proto__ = constructor.prototype; //
return obj;
// ""
}
// new
function Class():Void { //
this.prop = "";
}
var new_object = my_new(Class);
// Class
trace(new_object.prop);
// : ( )
trace(new_object instanceof Class); // : true (new_object
// Class)
, ,
. ,
, .
- , . .
Array. -
.
, , , , , .
,
- . , ActionScript 1.0
. , -262 ( ) . - (, Array, Array), - ActionScript i .0
, , C++. , , , .
, .
9.2.5.
, - new
. .
. ,
, .
, , . - ,
. , , .
ActionScript .
, prototype . ,
, :
function func():Void {}
ASSetPropFlags{func, null, null, 1);
for (var i in func) {
trace(i); // : prototype __proto__ constructor
.
, . , . .
, , ,
:
function (:String, :String, :String):Void {
// ,
this.=, this.=, this.=;
}
// ,
.prototype.=4, .prototype.=1, .prototype.=1;
var = new ("", "", ""); //
//
for (var i in ) {
trace(i+"="+6ap[i]);
// : =1 =1 =4
// = = =
}
, , . ,
, ,
, :
function Func ():Void{};
Func.prototype.prop="";
var obj=new Func();
obj.r=""; //
trace(obj.prop); // :
trace(Func.prototype.prop);
// : (
// )
,
. .
Object. , ,
, Object.
:
Object . ,
. Global, Object();
( Object). , . ( , .)
:
//
Object); // : true (
// Object)
//
// Object
ASSetPropFlags(Object.prototype, null, null, 7);
var obj = new Func();
// func
for (var i in obj) {
//
// obj
trace();
// : toLocaleString isPropertyEnumerable
// isPrototypeOf hasOwnProperty
// toString valueOf addProperty unwatch watch constructor
// ( Object()))
function Func():Void {}
trace(Func.prototype instanceof
, (
XML, XMLNode) , , . 9.1.
Object.prototype
Constructor.prototype
Constructor
Obj1
Obj2
Obj3
. 9.1.
, ,
__proto__. ,
. __proto__ , Global:
function Func():Void{}
var obj = new Func();
// __proto__ //
ASSetPropFlags(obj, null, null, 1);
for (var i in obj) {
trace(i); // : constructor __proto__
//( )
}
trace(obj.__proto__ == Func.prototype); // : true (
// __proto__ )
__proto__ , .
, , ,
.
, , constructor.
, :
function Func():Void {}
var obj = new Func();
trace(obj.constructor Func); // : true
__proto__ constructor , , ,
my_new,
new.
String, Boolean,
Number. ,
, . :
trace("".length); // : 6
:
? . . ( Object). ,
, ..
, , this , :
String.prototype.method = function() {
trace(typeof this);
};
par=""; // ,
par.method(); // : object ( )
. , . .
, , . . ,
. , . Object, Object ActionScript. __proto__( )
constructor ( ).
9.2.6.
ActionScript ( Object). .
, .
, .
. , __proto__
( ) constructor . __proto__ , constructor .
, , , .
, , ( , , . .):
function ():Void {}
//
//
.prototype.=4;
.prototype.xoc=1;
.prototype.=1;
function (:String, :String, :String) {
//
this.o=, this.=, this.=; }
//
.prototype.__proto__ = .prototype;
.prototype.constructor = ; //
//
//
var = new ("", "", "");
for (var i in ) { //
trace(i + "="+6apc[i]); // :
// =1 =1 =4 ( )
// = = =
, , ,
.
__proto__ constructor, ,
, . , , ,
. ,
. , . , , onPress.
, MovieClip. .
, , , .
, , , .
, MovieClip, onPress .
. , :
// bl
function Ball():Void {} // ,
// Ball MovieClip
Ball.prototype.constructor = MovieClip;
Ball.prototype.__proto__ = MovieClip.prototype;
// 100
for (var i = 0; i<100; i++) {
bl.duplicateMovieClip("bl"+i, i, {_x:Math.random()*550,
_y:Math.random()*450});
// Ball
this["bl"+i].__proto__ = Ball.prototype;
this["bl"+i].constructor = Ball; //
}
//
Ball.prototype.onPress = function():Void {
this.removeMovieClip();
};
ActionScript. , ,
. , __proto__ .
- ActionScript 1.0. , ,
. , .
instanceof ,
, constructor , ,
.
- , ActionScript 1.0
__proto__ , ,
. , . , ActionScript 256 .
, : 256 levels of prototype chain were exceeded. This is probably a circular prototype chainFurther execution of actions has been disabled in this movie. (256
. , , .
).
:
function Func(){};
//
Func.prototype.__proto__ = Func.prototype;
var obj=new Func(); // Output
. ,
- , C++.
ActionScript, __proto__, . .
, ASBroadcaster. ,
, . , proto , , . ASBroadcaster . , , .
9.2.7. Flash 6
__proto__
Flash 5, Flash MX . , __proto__ ,
. ,
,
. - ,
.
Flash MX prototype , . . :
//
function (:String):Void {
this. = ; //
}
var o:Object = .prototype; //
.=4, .=1, .=1; //
//
function (:String, :String, xapaep:String):Void {
// o
this.=, this.=, this.=;
}
// ;
.prototype = new ("");
//
.prototype.=true, Ko.prototype.=1;
var = new ("", "", ""); //
// ,
for (var i in ) {
trace(1+"="[i]); /* : =1 =1 =4 =1
= = = = =true
}
*/
. -
,
,
__prolo__.
. ,
, .
, ,
Object. , __proto__ , ,
Object.prototype. , .
-262 __proto__.
, , . , , JavaScript
.
? , , , ,
Flash 6. , , . , Flash 5 , .
9.2.8. super
super ,
. ,
,
( , ).
,
. , , .
super :
super.property
super.method ([arg1, arg2... argn)),
:
property , ;
method , ;
[arg1, arg2, ..., argn] , .
.
super , , , . :
function lassA{):Void {}
ClassA.prototype.r=" # 1";
ClassA.prototype.method = function():String {
//
//
//
//
prop
method
return "!!!";
};
function ClassB():Void {}
//
ClassB.prototype.=" # 2"
// prop
// method
ClassB.prototype.method = function():String {
return "";
};
// ClassA ClassB
ClassB.prototype._proto__ = ClassA.prototype;
// , method prop
ClassB.prototype.parent_props_methods = function() {
trace(super.prop,super.method());
};
var obj = new ClassB();
//
trace([obj.prop,obj.method()]);
// : # 2,
obj. parent_props_methods ();
// : # 1,!!!
super . , :
function mySuper(name:String) {
return this.__proto__.__proto__[name];
}
, super . :
super([arg1, arg2... argn])
super
. , ,
. :
function ClassA():String {
return "!";
}
function ClassB():Void {
this.prop = super();
}
ClassB.prototype= new ClassA();
var obj = new ClassB();
trace[obj.prop); // :
9.2.9.
-
. . , . , ( ).
ActionScripi 1.0 -
. ,
Function, . :
// items,
//
function NewClass():Void {
arguments.callee.items.push(this);
}
NewClass.items = [];
var item=new NewClass();
trace(NewClass.items[0]); // : [object Object]
, .
String.fromCharCode(),
Object.registerClass(). :
. ,
, .
, , . ,
.
,
. , String.fromCharCodeO . , String, , , .
9.2.10.
, ActionScript 1.0 .
, , . , __proto__, , . , , , .
: , ,
, ?
, , ActionScript 1.0 . . ,
, . , .
, constructor (
, ),
- instanceof:
function Superlass():Void {}
//
function Class():Void {}
// Superclass Class
Class.prototype.__proto__ = Superclass.prototype;
var obj = new Class();
// Class
trace(obj.constructor = Class);
// : true (Class
// obj)
trace(obj instanceof Class);
// : true (obj
// Class)
trace(obj instanceof Superclass);
// : true (obj
// Superclass)
// : true (obj
// Object)
Flash MX 2004 ,
. . , , . null. ,
( , ), ActionScript 2.0. :
var obj:Sound=new Sound();
trace(Sound(obj));
//
//
trace(TextField(obj)); //
//
}
, . ,
. .
, ActionScript
?
. , constructor , _listeners ,
. , forin ( ). . , .
. , , , , , .
9.2.11. . Global
ActionScript ,
. , . ,
, , ,
MovieClip, Object,
Global. , ,
, .
(scope chain) ,
,
,
. ,
,
, . ,
, ( this, , , ).
,
, , ,
.
, . ,
ActionScript 1.0 - , ,
. , MovieClip Object, -.
, , : Global.
. , MovieClip Object . , , .
, , .
. ,
. ,
. , Global:
trace(Math);
//
//
trace(this.Math); //
//
: [object Object] (
)
: undefined (
)
,
,
Flash.
Global. , ActionScript. - , Global, . Global ,
ASSetPropFlags():
ASSetPropFlags(_global, null, null, 1);
// Global
// _global
Global
Object.prototype
MovieClip.prototype
-
. 9.2.
Global,
. (
3).
ActionScript , Global
__proto__ Object,
:
trace(Object.prototype.__proto__
_global.r="";
//
trace({}.prop);
//
//
trace(prop);
//
//
= _global);
// : true
Global
: undefined (
)
: (
)
, , . Global , , Object.
, , Global.
,
. with ( 6).
, , , .
9.3. Object
Object ActionScript. . , , Object, .
, , Global
, .
Object .
9.3.1. Object
Object , new:
var obj:Object=new Object(); // obj
Object() , .
Number, String Boolean (
). null undefined, Object. , :
trace(new Object("!!!") instanceof String); // : true
trace(new Object(_root) instanceof MovieClip);
// : true
Object() new.
object.
2.
Object() . . Object :
var obj:Objt={propl:"",prop2:"");
trace(obj.prop1); // :
Object() c
. ,
, ,
[], .
:
var obj:Object={method:function():Void{trace("")}};
obj.method();
// :
:
function type(arg):Void {
trace(typeof arg);
}
type({});
// : object
Object
. ,
ActionScript. Object. .
9.3.2. registerClass().
- ActionScript 1.0 .
9.2.6 , . , , .
, ActionScript
registerClass():
Object.registerClass(clipID, class);
:
Object ,
Object, ;
clipID , .
;
class , .
, registerClass() true. false.
registerClass() . , . registerClass() , , .
__proto__ .
MovieClip, registerClass() class MovieClip.
. ,
.
, .
.
.
box, ball. ,
:
// ,
function Ball():Void {
// , ball
Ball.prototype.onPress = function():Void { this._alpha = 0; };
// ,
// "ball" ball
Object.registerClass("ball", Ball);
// 100
for (var i = 0; i<100; i++) {
attachMovie("box", "box"+i, i++, {_x:Math.random()*550,
_y:Math.random()*400));
attachMovie("ball", "ball"+i, i++, {_x:Math.random[]*550,
_y:Math.random()*400});
}
<Ctrl> + <Enter>, , .
registerClass() ,
, attachMovie()
duplicateMovieClip, , , .
, . registerClass() ,
.
SymbolID class, registerClass() null :
Object.registerClass(SymbolID, null);
. class .
( attachMovie()
registerClass()) registerClass() class ( ). this
. , , . ,
Ball , on Press ( ):
this.enabled=false;
registerClass(), ,
MovieClip. , ,
removeMovieClip(), getDepth(), swapDepths(), loadMovie(). , registerClass() __proto__ MovieClip.
Object.prototype:
trace(Ball.prototype.__proto__==MovieClip.prototype); // : false
trace(Ball.prototype.__proto__==Object.prototype);
// : true
. __proto__ :
Ball.prototype.__proto__=MovieClip.prototype;
, , onPress
:
Ball.prototype.onPress = function():Void { this.removeMovieClip();
};
, , :
,
. , , , get (), set (), delete ();
ASSetPropFlags(). DontDelete, Readonly,
DontEnum, , forin.
, AclionScript 1.0 ( ). ,
( private ActionScript 2.0).
:
//
// o
// ,
// property
this.setProperty = setProperty; // ,
// property
ASSetPropFlags(this, null, 3, null);
//
//
function Class{par:String):Void {
this.property = par;
this.getProperty = getPioperty;
}
// getProperty()
function getProperty():String {
return this.property;
}
// setProperty()
function setProperty(value:String):Void {
this.property = value;
}
var obj = new Class("!!!");
//
trace(obj.getProperty());
// :
obj.setFroperty("");
// property
trace(obj.getProperty());
// : ( )
delete obj.property;
// property
trace(obj.getProperty());
// : ( )
for (var i in obj) {
// obj
trace(i); // Output : forin
}
getset . ActionScript
, , . , . Flash 6 addProperty()
Object, .
addProperty() getter/setter. , .
getter/setter ,
.
addProperty() . , ,
.
addProperty() :
obj.addProperty("name", getMethod, setMethod);
:
obj , getter/setter;
"name" ;
getMethod , ,
getter/setter-. getter/setter-. getter/setter-.
getMethod , ;
setMethod , .
getter/setter-.
setMethod. ,
.
getter/setter- , addProperty() true. false.
, ,
setMethod null. .
Class , addProperty():
function Class(par:String):Void {
this.property = par;
this.getProperty = getProperty;
this.setProperty = setProperty;
ASSetPropFlags(this, null, 3, null);
// getter/setter- _property,
// property
this.addProperty("_property", this.getProperty, this.setProperty);
}
function getProperty():String {
return this.property;
}
function setProperty(value:String):Void {
this.property = value;
}
var obj = new Class("!!!");
trace(obj._property);
// : !!! (
// )
obj._property = ""; //
// getter/setter-
trace(obj._property);
// : (
// )
trace(obj.property);
// : (
// - ...)
for (var i in obj) {
// obj
trace (i);
// : _property ( property
// )
}
delete obj._property;
// getter/setter-
trace(obj._property);
// : undefined ( )
delete (obj.property); //
trace(obj.property);
// : ( )
ActionScript getter/setter.
_, _, _width, _alpha .
, .
ActionScript- addPropertyO. , ,
ActionScript 1.0 (, ). , getter/setter- , , . , , addProperty(), , ,
. addProperty() .
:
obj , ;
"name" ;
func , . ,
broadcastMessage(), ;
[data] ,
. .
, watch() true.
false. :
var obj:Object={prop:1}; // prop
// prop Output
obj.watch("prop", function(){trace(" !")});
obj.prop=2; // Output : !
watch 4 .
, , , , watch:
var obj:Object={prop:l};
//
obj.watch("prop", function(){trace(arguments)}," ");
obj.prop=2; // : prop,1,2,
watch()
, . data , undefined. watch() .
.
watch() (,
), .
watch() getter/setter. , ,
.
getter/setter- . ,
( getter/setter-)
,
.
, watch() , . getter/setter-. ActionScript,
, . , watch() . , (.. onChanged):
// txt
// ( Var
// )
var txt=""; //
// Output
this-watch("txt", function(){trace(" !");});
, watch(), , . . ,
unwatch():
obj.unwatch(prop);
:
obj , ;
prop .
, unwatch() true.
false.
9.3.5. Object
, Object 6 . , ,
. Object:
valueOf(). this . , .
String, Boolean, Number
:
var obj:Number = new Number(3);
trace(typeof obj);
trace(obj.valueOf());
trace(typeof obj.valueOf());
//
//
//
//
//
Number
: object
: 3
: number (
)
toString(). . ,
[object Object] ,
. , Number, String, Boolean, Array,
Date LoadVews, XML, . , Date , . , toString(),
trace:
trace(new Date()); // : Thu Oct 16 00:34:12 GMT+0300 2003
toLocaleString(). , , toString().
-262. toString() toLocaleString() :
var obj:Date=new Date();
trace(obj.toLocaleString()); // : Thu Oct 16 00:35:49 GMT+0300 2003
hasOwnProperty() .
isPrototypeOf(obj). , , obj:
function Superclass():Void {} //
function Subclass():Void {}
//
//
var protObj = new SuperClass();
SubClass.prototype = protObj;
var obj = new SubClass();
//
trace(protObj.isPrototypeOf(obj);
// : true (protObj
//
// SubClass)
propertyIsEnumerable(name), name . ,
forin. :
var obj:Object= (prop:"!!!"};
trace(obj.isPropertyEnumerable("prop")); // : true
//
ASSetPropFlags(obj, "prop", 7, null);
trace(obj.isPropertyEnumerable("prop")}; // : false
9.4. -
ActionScript 2.0
, , ActionScript, -
. Flash
, . , ActionScript Flash MX 2004 ,
- , Java C++. , , . ,
.
. , ,
, , . ActionScript 1.0,
, , . , . , Java C++, , - ActionScript , , (private) (public),
. . Macromedia ActionScript,
, .
- .
ActionScript 2.0 , Java.
, , (classes), (interfaces), (packages)
. Java ActionScript. ,
, , . . . , . ,
- .
ActionScript 2.0 , Java? : . , , , ( , ActionScript 1.0 , ). .
- . :
- , , .
Java ,
ActionScript 1.0. ,
, - . . ActionScript 2.0,
. ,
, ,
.
ActionScript .
. , , , fla- ,
. *.as- -
.
-, _global.
. , , - , as-, . ,
ActionScript . ,
- ,
. , .
ActionScript 2.0, ,
, , . -,
- , - ActionScript 2.0
ActionScript 1.0. - , , .
9.4.1.
. . , , .
ActionScript 2.0, - , class. ,
(, ),
. , {}, , -.
class ClassName { //
classBody
//
}
,
. . .
.
, .
:
class {}
*.as. Actions,
Export Script ( <Ctrl> + <Shift> + <>).
,
.
,
. Flash
.
, .as .
. Flash , *.as-. : , fla-, .
. , , ( ).
, , new - ( ):
// , ,
// .as
var : = new ();
trace();
// : [object Object]
trace( instanceof o); // : true
MyClass.as , . - , . _global, .
:
var : = new ();
for (var i in _global) {
trace(i);
trace(typeof _global[i]);
}
// :
// : function
, , .
, . :
; //
for (var i in _global) {
trace(i); // : ( )
}
,
. , , . ,
.
,
. , , ,
.
, , . ,
.
- ,
*.as - ,
.
9.4.2.
, .
, . ,
.
ActionScript 2.0
. :
class {
var :Number = ;
var :Number = 1;
}
, , :
var :Ko=new ();
trace(.);
// : 4
trace(.);
// : 1
,
var. . ,
var . ,
. ,
.
, .
undefined. , , , null.
, , :
class MyClass {
var property1: Type;
var property2: Type=null;
}
// ,
//
,
. , , :
// ,
// name
name = Name;
}
}
//
var : = new ();
.setName(""); //
trace(.name);
// :
. setName()
name. , ,
name . . .
ActionScript , . , :
class {
var naine:String = null;
var setName:Function = function (Name: String):Void {
name = Name;
};
}
. , . .
.
. : , , , , , null
undefined. (
).
, , , . , : Number, Boolean, String, Object, Array.
, . , . , ,
, .
class MyClass {
var a:Number = 3;
var b:String = new String("");
// :
// :
// String
var c:Number=a*5+5;
// :
var d:Funccion=function():String (return "!";};
// :
//
var e:String=d();
// :
//
var f:Object=Math;
// :
//
}
. , .
, ,
. ActionScript 1.0,
, . , ,
, , . , :
// MyClass.as
class MyClass {
var a:Number = 3;
var b:String = new String{"");
var c:Number=a*5+5;
var d:Function=function():String{return "!";};
}
// MyClass ,
// , MyClass.as
var obj:MyClass = new MyClass();
// MyClass
ASSetPropFlags(MyClass.prototype, null, null, 7);
for (var i in MyClass.prototype) {
trace(i+" "+MyClass.prototype[i]);
} // : d=[type Function] c=20 b= =3
. , ActionScnpt 2.0
ActionScript 1.0.
9.4.3. .
, , . . , .
, .
ActionScript 1.0
-. ActionScript 2.0 . new
- ,
-,
.
- , .
:
//
class {
var :String = null; //
var :String = null;
function (_:String, _:String):Void { // -
= _; //
= _;
}
}
//
var : = new ("", "");
trace(.); // :
trace(.); // :
, (.
).
, ,
-, , .
, ,
, . , ,
, :
, . :
// ,
var : = new ("",
trace(.prototype.);
//
trace(.);
//
"");
: null
:
. , -
. - ?
, , , . (
ActionScript 1.0).
. -,
. .
, . ( .
9.4.7.)
,
. ,
, .
; ,
, .
, . , , .
.
-, , _global. , . - ,
, , ,
. , .
- , .
. , , - , _global.
9.4.4. AciionScript2.0
. ,
ActionScript 1.0 , , this.
, , . ,
, , , . ,
: ,
, , _global. , this,
, . .
this, :
.
// , ActionScript 1.0.
// , , this
MyClass.prototype.setName = function(Name):Void {
this.name = Name;
};
// ActionScript 2.0. this .
var setName:Function = function (Name):Void {
name = Name;
};
ActionScript 2.0 ,
. . - , ActionScript 1.0
, , , , -
. , , , ,
. , , ,
, _global.
, ,
. ActionScript 2.0 . -
, , .
, ,
. , ?!
9.4.5.
,
:
;
;
.
, , . , . .
. ,
Object.registerClass()
MovieClip. String.fromCharCode()
. . , , , .
ActionScript 1.0
-. ActionScript 2.0 static,
. :
// .as
//***********************************************************************************
class {
static var _:Number = 0;
//
static function _():Number {
//
return _;
}
function () {
// _ 1
++;
}
}
// ,
for (var i in ) {
trace(i);
// : _ _
}
var :Ko=new ();
//
var :Ko=new ();
trace(._());
// 2 (
// )
static
-. , .
, , . , . , - ,
.
9.4.6.
- , C++ Java,
. , C++ , .
. public () ,
. protected () ,
. private (),
, , , .
ActionScript 2.0 .
public private, :
public. C++, ActionScript ,
. , ( ), , . public?
. ,
.
public , .
, , (, , );
private. protected C++ ( private C++
ActionScript ). , , ( ,
).
The member is private and
cannot be accessed ( , ).
, , :
// .as
//***********************************************************************************
class {
private var :String=""; //
private function _():String{ //
return "!!!"
}
// ,
public function _():String{
return ;
}
public var __:String=null;
function () {
// , ,
//
__=_();
}
}
//***********************************************************************************
var : = new ();
//
trace(._());
// :
trace(.__); // : !!!
trace(.); // -
//
private ,
(
ASSetPropFlags()). , ,
, , .
C++ . ,
, , ActionScript
,
.
ActionScript 1.0 .
ActionScript 2.0 , public private
. swf- - . , :
//
ASSetPropFlags(.prototype, null, null, 7);
for (var i in .prototype) { //
trace(i);
// : __ (public),
// (private), _ (public), _ (private)
}
9.4.7.
.
. :
// MyClass
class MyClass {
var prop_a: String = "";
}
// ,
// , MyClass.as
var obj: MyClass = new MyClass();
trace(obj.prop_a); // : ( )
trace{obj.prop_b); // : There is no property
// with the name 'prop_b'
To,
, . ActionScript
1.0 undefined. , , ( __resolve).
, . .
.
dynamic, class:
//
dynamic class MyClass {
var prop_a: String = "";
}
// MyClass
//
var obj: MyClass = new MyClass();
trace(obj.prop_a); // :
trace(obj.prop_b); // : undefined (
// )
, ,
( . 9.4.3). :
dynamic class MyClass {
function MyClass(value:String) {
this.property = value; //
}
}
// MyClass ,
//
var obj:MyClass = new MyClass("");
trace(obj.property); // :
, this. , : , , _global. ,
, ,
_global.
, , . , , this, :
dynamic class MyClass {
function MyClass(value:String) {
property = value; // this
}
}
var obj:MyClass = new MyClass("");
trace(obj.property);
// : undefined ( property
// )
trace(_level0.property); // : ( _root)
this .
, , , , .
,
ActionScript 2.0.
. .
, .
, null undefined, .
9.4.8.
ActionScript 1.0, ActionScript 2.0
Object. . , . ActionScript 1.0
. , , :
A.prototype = new ();
__proto__ ( ):
A.prototype.__proto__ = .prototype;
ActionScript 2.0 ,
ActionScript. extends:
class Subclass extends Superclass {
statements
}
extends . , ,
, .
, , .
.
, :
// .as ,
// fla-
class {
public var _:Number=4;
}
// .as
class extends {
public var :Number=0x000000;
}
//***********************************************************************************
var : = new ();
trace(.);
// : 0 ( )
trace(._a); // : 4 (,
// o )
ActionScript (,
Sound MovieClip). class
Name extends Superclass{} . ,
Name.as. -
ActionScript 1.0, . ,
- .
, - , , extends. :
trace(.prototype instanceof );
trace(.prototype.__proto__ = .prototype);
// : true
// : true
, ,
new. , , . . ,
super. :
class {
public var :String = null;
function (:String) {
// ,
= ;
}
}
class extends {
function () {
// ""
super(" ");
}
}
var : = new ();
trace(.); // :
-,
. ,
, -.
, . super (. ). , , , .
// , name
class {
public var name:String = "";
}
class extends {
public var name:String = "";
// get_super_name() name
public function get_super_name{):String {
return super.name;
}
}
var : = new ();
trace(.name);
// :
trace(.get_super_name()); // :
9.4.9.
ActionScript, Flash. ,
. ,
, , , ,
.
, , .
. , , . ,
. , . , ,
, .
. , .
, interface,
class:
// InterfaceName.as
interface InterfaceName {
//
}
, . ,
( , ). , private. . ,
.
interface InterfaceName {
public function method(par1:Boolean, par2:String):Void;
}
(. . {}),
. : , , .
. , (.
9.4.14). .
, , , extends:
interface InterfaceName extends SuperInterface{
//
)
, , ,
. implements ( ). :
class MyClass implements InterfaceName {
//
}
. , implements. , , ActionScript
. :
// MyClass
class MyClass implements InterfName1, InterfName2, InterfName3 {
//
}
implements extends.
, .
:
class MyClass extends Superclass implements InterfaceName
//
)
, .
, _global.
. , , , (. ).
ActionScript , . , , .
, ,
. ,
, . :
// InterfaceName.as
interface InterfaceName {
public function method1():Void;
public function method2();Void
}
// MyClass.as
class MyClass implements InterfaceName
{
public function methodl():Void {}
public function method2():Void {}
}
var obj:InterfaceName=new MyClass(); // .
// , MyClass InterfaceName
, , , (
) . , , .
, .
null-:
var obj:MyClass=new MyClass();
trace(InterfaceName{obj)=obj); // : true ( )
trace(InterfaceName({}));
// : null
9.4.10. getter/setter
- , . ,
.
( get
set, get/set-).
private, , .
,
get/set:
class MyClass {
private var prop:String = ""; //
public function getProp():String { // ,
return prop;
}
// ,
public function setProp(arg:String):Void {
prop = arg;
}
}
var obj:MyClass = new MyClass();
// MyClass
trace(obj.getProp());
// :
obj.setProp("");
//
trace(obj.getProp());
// :
Getter/setter- , get/set -.
get-. . getter/setter- set. . , .
var obj:MyClass = new MyClass();
// prop_intro
trace(obj.prop); // :
obj.r=""; // prop_intro
trace(obj.prop); // :
Get/set-, gctter/setter-,
public. static private .
getter/setter-, , ,
:
get/set- .
. , set- , -
, . Get-
, . , _square , .
get - ;
getter/setter- , set. ActionScript , ,
ASSetPropFlags().
Getter/setter- ActionScript 1.0.
Object.addProperty(). , Setter/setter-: .
9.4.11.
, - ,
MovieClip. ActionScript 1.0 Object.registerClass().
ActionScript 2.0 .
. , , . .
?
, ,- onPress .
, .
. ,
.
MovieClip. , ,
.
MovieClip, onPress . :
. :
// Rounds.as
class Rounds extends MovieClip {
//
//
public function onPress():Void {
this.swapDepths(10000);
this.removeMovieClip();
}
}
Rounds
Linkage (). Linkage Properties ( ) Export
for ActionScript ( ActionScript). AS 2.0
Class. , .
Rounds.
. , , , Rounds. , .
9.4.12.
ActionScript 2.0, , .
fla- swf- . , .
ActionScript 2.0 ActionScript 1.0. . , , . ,
. , , . [], :
var str:String = new String("");
str.property = "";
//
str["property"] = "";
//
, [] , , .
, .
, , . , ,
, :
var str:String = new String{"");
var arr:Array = [];
arr[0] = str;
//
arr[0].property = ""
//
//
trace(str["property"]);
// ; (
// )
trace(str.property);
// : There is no
// property with the name 'property'
, - ,
- ActionScript 2.0
( ),
. ,
. , , ,
. ,
.
.
,
. ActionScript 2.0 :
var str1:String = new String("");
//
var str2 = new String("");
//
str1.property = "";
//
str2.property = "";
//
. . .
,
, ActionScripl 1.0. ,
. , , ,
:
// ,
Number.prototype.factorial = function():Number {
var f:Number = 1;
for (var i = 1; i<=this; i++) {
f *= i;
}
return f;
};
var numb1:Number = 5;
var numb2 = 5;
(5).factorial();
numb1.factorial();
numb2.factorial();
//
//
//
//
//
//
//
( ,
)
( )
, .
, Array, MovieClip, Object, Button, TextField, SharedObject, ( , as- ( Windows 98) C:\WINDOWS\Application Data\Macromedia\ Flash MX 2004\en\Configuration\Classes).
,
.
. - , - ActionScript 2.0 , , :
, ;
, , ;
, . [].
9.4.13.
, , Flash,
. , as-, (classpath).
, ,
.
. ,
. :
, as-, (
TextField MovieClip). ( Windows 98); C:\WINDOWS\ Application
, + ActionScript Settings. . ,
. ,
.
, .
.
, -.
, ActionScript Settings, , .
(,
). ,
.
, . ActionScript Settings Settings () ActionScript
Version ( ActionScript) Flash Publish Settings (
File).
Export frame for classes ( ). , ,
.
( ).
, ,
, . . ,
. ( )
, ,
. ,
. , .
Export frame for classes ,
, .
9.4.14.
,
. (package) ,
.
, .
Windows, . , ,
, .
, . ,
, :
class . {}
, as-.
, , , . , , , , :
class .. {}
-, .
, , , ,
. ,
, :
var :.Ko=new .();
, , ,
, .
, ,
. ,
. import. , .
import ,
. :
import ..;
var : = new ();
import
. *:
import ..*;
var : = new ();
, import ,
, , , import .
, ,
as- . ,
import ( ) with. , , ,
. , , ,
import.
import : ,
. ,
, import.
, , . , , .
, -.
, _global. , , -
. , , () ,
_global.
9.4.15. . intrinsic
, . , as-,
.
.
Flash-,
AetionScript. , Array ActionScript, . , Flash-,
C++. Array , -.
ActionScript,
Classes ( C:\WINDOWS\Application
Data\Macromedia\Flash MX 2004\ en\Configuration\Classes) as-?
, Boolean.as,
:
intrinsic class Boolean
{
function valueOf():Number;
function toString():String;
}
, as-
. , ,
( - ). -?
, , Classes - , .
. Classes
( ), ,
, , . ,
, . , Boolean
,
. Array , . , Array.as dynamic, . Number , toString(),
, ,
toString() .
.
, Flash-
. , , ,
Classes. as- . , . ,
as- Classes.
- ActionScript. , Global , ,
, (, Math,
Stage, Mouse, Key ). , , static:
intrinsic class Stage
{
static var width:Number;
**************************************************************
static function removeListener(listener:Object):Void;
function onResize():Void;
}
: Math , . , . , , .
, , , . ,
Math .
, , -
intrinsic. , ActionScript . .
,
. ,
{} . , :
function func():Void; // : ";" expected (";" )
9:
, . - .
.
, , .
. , .
Flash .
(),
.
, , . , , , , .
.
. -, (- Flash, ). , , , , , , , .
, , .
, , . ,
, .
(. 9,4).
, . ,
. 200 . ,
, . ,
100 . Free Transform
45. <Ctrl> .
. . , (alpha = 20-25 %), .
.
, , box_up
box_down.
. , box. ,
. , .
. .
, (. 9.5).
. , .
. 9.4. : , b
attachMovie(), . ball.
. .
. 9.5.
. , (10 000), (10 000). 20
000 , (,
).
, , . ,
.
. , swapDepths():
box.box_down.swapDepths(-10000);
box.box_up.swapDopths(10000);
//
//
.
, (Window/
Other Panels/Common Libraries/Buttons). ,
new_mol.
onPress attachMovie(). , box;
new_mol.onPress = function():Void {
box.attachMovie("ball", "ball"+n, n++);
}
n, , 0.
, ,
, .
, . ,
,
MovieClip. , as- ,
fla- . Molecules ,
. Molecules.as Actions, :
class Molecules extends MovieClip {}
Molecules, .
.
linkage. AS 2.0 class , , Molecules,
Molecules.
. :
function Molecules() {}
.
,
_ _ . Flash 3D-, . , -
. ,
.
, , . , , z. (
). , , R 200-R, R .
Y
:
= radius+Math.random()*(200-2"radius);
= -(radius+Math.random()* (200-2*radius));
z = radius+Math.random(}*(200-2*radius);
x, , z :
private var x:Number = null, y:Number = null, z:Number = null;
radius , 10. , .
radius
, :
static var radius:Number = 10;
radius,
Molecules _width _height:
_width = _height=2*radius;
,
. . 9.6.
. 9.6.
, , , x = x + z sin(45)
y = y + (z cos(45)) . - Z
2 , : x = x + 0,5 z sin(45), y = y + (0,5 z sin(45)).
, :
12
_ = +0.5*z*Math.SQRT1_2; // 45 1 2
_ = -0.5*z*Math.SCRTl_2;
, .
new_mol. ,
, .
, . , , , .
, .
, , .
, , .
(. 9.7).
. 9.7.
, . , - ,
. ,
,
.
v_max v_max, v_max ,
.
, , speed_y, speed_x,
speed_z. Molecules.
v_max. :
speed_x = (l-2*Math.random());
speed_y = (l-2*Math.random());
speed_z = (l-2*Math.random());
v_max , 7.5.
v_max ( , radius):
static var v_max:Number = 7.5;
, . , , .
, ,
3D- . ,
(
).
, , ,
, , ,
. ,
Flash-
, . updateAfterEvent() . ,
setInterval(), .
, . , .
, .
Molecules:
static var arr:Array = [];
Molecules . :
arr.push(this);
, , . Molecules, . :
static function move():Void {
var arr_length:Number = arr.length; //
for (var i = 0; i<arr_length; i++) {
//
arr[i].x += arr[i].speed_x*v_max;
arr[i].y += arr[i].speed_y*v_max;
arr[i].z += arr[i].speed_z*v_max;
// 3D- 2D
arr[i]._ = arr[i].+0.5*arr[i].z*Math.SQRT1_2;
arr[i]._y = arr[i).y-0.5*arr[i].z*Math.SQRTl_2;
}
,
move :
updateAfterEvent();
move ,
setIntcrval(). . , Molecules :
if (arr.length = 1) {
setInterval(move, 50);
}
. , . , , . .
, . , . ,
, .
, - . ,
. ,
, . ,
, . , Molecules.move
.
, , move , , , z.
if (arr[i].x<=radius || arr[i].x>=200-radius) {
arr[i].speed_x *= -1;
arr[i].x += arr[i].speed_x*v_max;
}
if (arr[i].y>=-radius || arr[i].y<=-200+radius) {
arr[i].speed_y *= -1;
arr[i].y += arr[i].speed_y*v_max;
}
if (arr[i].z<=radius || arr[i].z>=200-radius) {
arr[i].speed_z *= -1;
arr[i].z += arr[i].speed_z*v_max;
}
, ,
radius,
, .
, .
, . , , . : ,
. ,
, , .
.
,
.
, .
. ,
, ,
.
, , . , ,
sort() Array. ,
,
7:
static function sort_on_depths():Void {
var arr_length:Number = arr.length;
arr.sort(sort_func);
function sort_func(a:MovieClip, b:MovieClip):Number {
// -
return -(((200-.)*(200-.)+(-200-.)*(-200-.)+(200-.z)*(200-a.z))-((200-b.x)*(200-b.x)+(-200-b.y)*(-200-b.y)+(200-b.z)*(200-b.z)));
}
// ,
// arr
for (var i = 0; i<arr_length; i++) {
arr[i].swapDepths(i);
}
}
move():
sort_on__depths();
.
9 .
,
( ) (. . ). ,
.
, , .
. . .
, .
; , ,
.
, ,
. :
.
, .
, .
, , .
,
, , -
. .
:
static function udar_mol():Void {
var arr_length:Number = arr.length;
for (var i = 0; i<arr_length; i++) {
for (var j = i+1; j<arr_length; j++) {
var rast:Numbers(arr[i).x-arr[j].x)*(arr[i].x-arr[j].x)+
(arr[i].y-arr[j].y)*(arr[i].y-arr[j].y)+(arr[i].z-arr[j].z)*
(arr[i].z-arr[j].z);
if (rast<=4*radius*radius && arr[i].udar && arr[j].udar) {
var v_x:Number = arr[i].speed_x;
var v_y:Number = arr[i].speed_y;
var v_z:Number = arr[i].speed_z;
arr[i].speed_x = arr[j].speed_x;
arr[i].speed_y = arr[j].speed_y;
arr[i].speed_z = arr(j].speed_z;
arr[j].speed_x = v_x;
arr[j].speed_y = v_y;
arr[j].speed_z = v_z;
arr[i].udar = arr[j].udar=false;
break;
}
}
}
for (var = 0; k<arr_length; k++) {
arr[k].udar = true;
}
}
udar() move().
. 9.8.
. (. 9.8).
,
, . ,
, , .
, .fla 9 .
10
Flash, .
FutureSplash - Flash. .
ActionScript . ,
, . ,
.
, , .
. :
11 . . , enabled (
), trackAsMenu (, ), useHandCursor ( , , ).
11 , . : focusEnabled ( ), tabEnabled (, ), tabChildren ( ,
), tabIndex ( ). onSetFocus ( ) onKillFocus ( ) _focusrect
(, ).
12 _xmouse _mouse
( ). 12 .
13 createTextField(), . getTextSnapshot(), .
16 getSWFVersion(),
, . accProps,
Flash- .
17 getURL() ( HTML-
JavaScript) loadVariablcs() (
). _url (
, swf-).
MovieClip. , ,
, .
ActionScript, ,
. , 10.7 MovieClipLoader,
. 10.19 Color, , . .
10.1.
_Props
_alpha
_currentframe
_droptarget
_focusrect
_framesloaded
_height
_lockroot
_name
_parent
_rotation
_root
_soundbuftime
_target
_totalframes
_url
_visible
_x
_y
_xscale
- ?
?
_scale
_width
_height
_xmouse
_ymouse
10.1
?
10.2.
ActionScript. 2000 . Macromedia
, ECMAScript, JavaScript Flash. Web- . - ECMAScript , ActionScript,
, , . ,
, , new :
var clip:MovieClip=new MovieClip(); // ...
object MovieClip:
trace(typeof clip);
// : object
trace(clip instanceof MovieClip);
// : true
, MovieClip.
, . , , , , . . , swf-.
, -262 movieclip.
. , ,
delete , .
. , .
, . , , ,
, ,
.
ActionScript .
. ,
.
: , , . ,
, ActionScript
. , . . __proto__ constructor, ,
.
ActionScript , .
, , 10.3.
10.2.1.
, , , , , . , ( ). ,
. :
1.
MovieClip.
. [] .
2.
,
, .
.
3.
, .
.
,
but mov. :
this.prop = "";
var per:String = "";
function func():Void {}
//
//
//
,
. for-in:
for (var i in this) {
trace(i);
// : per prop func $version but mov
, , ,
. :
(, , ), ,
, :
. []. , , . :
trace(_root.mov);
trace(_root["mov"]);
// : _level0.mov
// : _level0.mov
,
( ):
trace(_root.mov.mov_intro);
// : level0.mov.mov_intro
trace(_root["mov"]["mov_intro"]); // : level0.mov.mov_intro
, ,
, .
. , ,
.
trace(_root.mov);
// : _level0.mov ( ,
// _root)
trace(mov);
// : _level0.mov
, , ,
, ,
. , (
). mov , . ,
:
trace(mov);
// : ( )
- (, , ), , forin.
, ,
,
:
// ,
for (var i in _root) { //
// ,
if (typeof _root[i] = "movieclip") {
// ,
_root[i].swapDepths(100000);
_root[i].removeMovieClip();
//
}
}
, , ,
. , .
. , , , , ,
, , ActionScript,
. . , , , ,
.
10.3.
Flash .
gotoAndPlay(), gotoAndStop(), play(), stop().
, . . Flash , - (
, ).
Flash 5 ActionScript ( ).
: , FutureSplash?
. , ActionScript, , .
ActionScript
. Flash
, ( onRelease -
), getURL(), loadMovie(). , , . ,
, , , -
.
ActionScript -
, ,
. . , , ,
, . ,
. .
,
. ,
, , , . , : 30-50 , 14 , , .
: .
, , .
, , (, ), . . ? . - ?
. ,
, .
ActionScript - ,
ECMAScript , , Flash.
, JavaScript, ActionScript
. :
ActionScript - .
, - . , , , , var.
ECMAScript .
,
, ,
. ActionScript , - Global,
MovieClip Object. , , , Object.prototype,
.
, .
, ,
ActionScript . Flash . , -, . , -, , ,
Flash , ,
, . :
, .
10.3.1.
. Flash. ,
, , . ? ,
, , .
, ,
.
.
, ,
,
, .
,
. , , .
,
, .
, , . , ( ECMAScript ).
, , .
, . ,
, , .
, ,
.
, . , ,
. ()
.
,
, , . , , . , , , .
, .
(
), ( Load Order Flash Publish Settings).
, , . ,
. . , , . , .
, . . .
10.3.2. MovieClip
Flash , (
) .
-. ActionScript
, , MovieClip
Object.
, , . , , , .
. :
_root.attachMovie("ball","new_ball",0);
attachMovie("ball","new ball",0);
//
//
//
,
. MovieClip.
. :
_root.startDrag(); //
//
startDrag();
//
, MovieClip , . ,
, Flash 4 ( ). ActionScript
-262, , .
, (actions).
ActionScript ( Global Functions Timeline Control Movie Clip Control).
, , . , startDrag(), . , , .
. , ,
startDrag, , ,
. , , .
- ,
( ) . ,
, .
. ,
, , -
.
,
, . , , , undefined,
, . undefined , , ,
- , .
,
. , ( ) , , , . :
duplicateMovieClipt)
loadMovie()
startDrag()
stopDrag()
removeMovieClip()
unloadMovie()
loadVariables()
//
//
//
//
//
//
//
swf-
10.4. _root
() _root
. , _root
MovieClip. , :
_root._x+=100;
, , . , 100
.
:
//
//
_root._rotation+=45;
_root._xscale+=30;
_root :
c_root.startDrag(); //
,
.
_root :
trace(typeof _root);
trace(_root instanceof MovieClip);
// : movieclip
// : true
. :
_root duplicateMovieClip()
removeMovieClip().
(
),
_root , (, _parent
swapDepths()).
swf-.
, , .
, ASSetPropFIags():
ASSetPropFlags(_root, null, null, 1);
for (var i in _root) {
trace(i); // : __proto__ constructor $appPath
// $version
}
. . , :
trace($appPath);
trace($version);
// : file:///C|/Program%20Files/Macromedia/
// Flash%20MX%202004/
// : WIN 7,0,14,0
10.5.
. , MovieClip, , .
, . .
,
, . , ,
ActionScript , , , .
10.5.1. duplicateMovieClip()
duplicateMovieClip() .
:
clip.duplicateMovieClip("name", depth),
:
clip , ;
"name" , ;
depth ( ), .
, .
, , , ( , depth ).
10.6.
duplicateMovieClip() , . _ _ :
// , ,
box.duplicateMovieClip("box1",0);
//
// box1
b1._+=50;
//
box1._y+=50;
box
box
0
Flash MX
. duplicateMovieClip() , :
box.duplicateMovieClip("box1", 0, {_:box._x+50, _:box._+50});
duplicateMovieClip() ,
. , attachMovie().
.
( ). ,
, . (
).
, :
box.prop = "";
box.duplicateMovieClip("box1", 0);
trace(box1.prop);
//
//
// : undefined ( )
, ,
.
Flash 4. dupiicateMovieClip(). ActionScript. dupiicateMovieClip() (,
), .
10.5.2. attachMovie().
dupiicateMovieClip(), attachMovie() . attachMovie() ,
. ,
.
attachMovie() , ,
. ,
ActionScript-. :
1.
, <F11>.
2.
3.
Linkage().
4.
:
clip , ;
"identifier" , .
;
"name" ;
depth , ;
[propobj] - ,
.
:
// ball
// ball
for (var i = 0; i<100; i++) { // 100
_root.attachMovie("ball", "ball"+i, i, {_x:550*Math.random(),
_y:400*Math.random()});
}
attachMovie() . _root , .
attachMovie() .
, , , undefined:
trace(attachMovie("ball","new ball",0) // : level0.new ball
attachMovie() . , . attachMovie
.
, ,
:
var arr:Array = [];
for (var i = 0; i<100; i++) {
arr[i] = attachMovie("ball", "ball"+i, i, _x:400"Math.random(),
_y:550*Math.random()});
}
, ( ),
, .
,
duplicateMovieClip() attachMovie(), .
10.5.3. createEmptyMovieClip().
Flash MX . createEmptyMovieClip(). :
clip.createEmptyMovieClip("name", depth),
:
clip , ;
"name" ;
depth , .
attachMovie(), createEmptyMovieClip() .
:
trace(createEmptyMovieClip("clip", 0)); // : _level0.clip
, .
, (<Ctrl> + <F8>)
. attachMovie(),
createEmptyMovieClip().
, MovieClip.
, , ,
, .
( , ) ,
hitTest() ( , )
startDrag() ( ). ,
MovieClip - .
createEmptyMovieClip()
, , -. ,
:
// , , ball,
//
// ball
ball.createEmptyMovieClip("new_clip", 0);
trace([ball._x, ball._y]);
// : 251.6, 184.4
// ( ball)
trace([ball.new_clip._x, ball.new_clip._y]);
// : 0, 0 (
// )
: , _ _.
, .
. .
createEmptyMovieClipO
loadMovie() . ,
.
. ,
, .
10.6.
ActionScript , . , , ,
(, , ). ,
, .
, Graph, .
, , ,
, . , Arrange
Modify.
. , .
, . . , , . , swf- ,
fla-. , fla-, swf- .
, , , . ,
, , .
, * , (depth).
, , .
, ( ) .
, ( ). , .
getDepth(), ,
( , , , ):
// , ,
// . ball.
trace(ball.getDepth()); // : -16383
""
,
-16383.
, getDepths(), MovieClip, Button TextField. , .
-16383 . Flash- 16384, ,
, . .
, , ,
.
,
, -16383.
. , , . , ball ball 1:
trace(ball.getDepth());
trace(ball1.getDepth());
// : -16383
// : -16381
:
2 ( 1). ,
, . . ,
.
. .
, , , , , , , , .
- (,
, swapDepths()).
, .
ball 1 , .
, . :
traceball.getDepth());
trace(ball1.getDepth());
// : -16381
// : -16383
, .
, -16383,
:
trace(attachMovie("ball","ball",-16385); // : undefined
, ,
:
attachMovie("ball", "ball1", 1000000);
trace(ball.getDepth());
// : 1000000
, 1000 (
).
. , , ,
MovieClip. , , removeMovieClip() ( ) , , 0xFFFFF.
.
, . , attachMovie depth:
attachMovie("ball","ball1",1,{_x:100});
attachMovie("ball","ball2",1,{_x:200});
//
//
,
, , , , . .
, .
. , , ,
. , .
, ,
. ActionScript ,
, . .
, ,
. :
// -
// 1000
for (var i = 0; i<1000; i++) {
//
createEmptyMovieClip("clip", -16384+i);
// removeMovieClip()
//
clip.removeMovieClip(); //
} //
clip.swapDepths(1);
, , .
clear().
10.6.1. . swapDepths()
swapDepths(), ,
, . ,
,
. .
swapDepths() :
clip.swapDepths(depth),
:
clip , ;
depth , .
:
//
trace(ball.getDepth());
ball.swapDepths(1000);
trace(ball.getDepth());
ball
// : -16383
//
// : 1000
, swapDepths(),
, . , , . . , , ( swap ). - , swapDepths(), attachMovie(), duplicateMovieClip(),
createEmptyMovieClip(), .
//
createEmptyMovieClip("clip1",
createEmptyMovieClip("clip2",
clip2.swapDepths(-1000);
trace(clip1.getDepth());
trace(clip2.getDepth());
-1000);
1000);
//
// : 1000
// : -1000 ( )
, , , ,
, .
, swapDepths() .
swapDepths() , :
createEmptyMovieClip("clip1", -1000);
createEmptyMovieClip("clip2", 1000);
clip2.swapDepths{clip1);
trace(clip1.getDepth());
// : 1000
trace(clip2.getDepth());
// : -1000
getDepth(), swapDepths() .
, , . , .
swapDepths() , . ,
.
10.6.2. .
getlnstanceAtDepth() getNextHighestDepth()
, dupticateMovieClip(), attachMovie(),
createEmptyMovieClip(), createTextFileld(), , .
, ( , ), . , ,
, .
getInstanceAtDepth(depth), depth , . , depth.
, undefined.
:
this.createEmptyMovieClip("clip", 0);
trace(this.getInstanceAtDepth(0)); // : _level0.clip
trace(this.getInstanceAtDepth(1)); // : undefined
getInstanceAtDepth() , . Graph . , ,
. .
, , , ? ,
. , , , ,
, :
var i:Number=0;
while (clip.getInstanceAtDepth(i) != undefined) {
i++;
}
clip.createEmptyMovieClip("new_clip", i);
,
getNextHighestDepth().
. :
this.createEmptyMovieClip("clip",100);
trace(this.getNextHigheatDepth()); // : 101
getNextHighestDepth() , . , , 0:
this.createEmptyMovieClip("clip",-100);
trace(this.getNextHighestDepth()); // : 0 ( : -99)
getNextHighestDepth() , , ,
.
10.7.
Flash online-.
. .
, , . ,
.
. , ,
. .
10.7.1. flash-.
, , _root _level0. :
trace(_root);
// : _level0
_level0, _root, ,
. :
_level0.startDrag();
//
//
, (. . ).
,
. , ,
. , ,
, _level0.
, , .
, _level0, . , ,
, . , _levell
, _level0, .
_levell , _level0.
, , .
, , , .
_level0
. .
flash- . ,
. ActionScripl, , .
10.7.2.
loadMovie() loadMovieNum()
, ,
loadMovie(). :
loadMovie("url", target, [method]),
:
"url" swf-.
. , , _level0 .
: http://, https:// ftp://;
target , . , loadMovie(), .
loadMovieNum();
[method] , HTTP-,
.
GET POST. , method
.
loadMovie(), MovieClip. , , , . loadMovie()
.
loadMovie() swf- . , , ,
, but :
//
but.onRelease=function():Void {
// -
_root.createEmptyMovieClip("clip", 0);
loadMovie("2.swf", clip); //
}
1.swf .
. ,
but. , , , ,
2.swf , 1.swf.
1.swf but. 2.swf (, , ) 1.swf. !
, swf- , . , , , swf -
swf-.
, .
, (
).
, , , , , .
Flash 5. ,
, . ,
-.
, , , .
,
.
.
loadMovie(),
.
, . , ,
, , ,
loadMovie(), _root.
.
_level0 , , , .
.
, loadMovie() . ,
. ,
, loadMovie(), -
, . ,
.
loadMovie() , ,
.
, ,
, loadMovie(). loadMovie(),
. loadMovie() ,
, .
. , string, .
, HTTP- :
GET POST. GET URL .
, URL 256 . POST HTTP-,
. POST ,
. , GET.
HTTP-,
loadMovie(). for-in
, loadMovie(),
, URL- .
loadMovie() , .
,
. ,
. .
, . .
. , ?
. , -,
. ,
ActionScript-. ,
. , . ,
, . ,
, , . , attachMovie(), , , . , , .
.
- , , , -
(, ),
. ,
duplicateMovieClip().
(, ),
.
, Flash-,
, .
loadMovie() , , ( ). ,
, , ,
. , ,
,
loadMovie(). ,
, .
, . ,
onData getBytesLoaded() getBytesTotal() (
onLoad).
target loadMovie() undefined,
, . , , , . .
loadMovie() , .
,
. ,
loadMovieNum(). :
loadMovieNum("url", level, [method]),
level , ( loadMovie()). :
loadMovieNum("l.swf", 1); // 1.swf _level1
10.7.3.
, ( -
, ), . ,
, .
jpg. loadMovie() loadMovieNum(),
. :
loadMovie("my_photo.jpg", clip);
,
. , ,
-16383.
. , ; , . , , , swf-,
. .
loadMovie() , swf-, , .
.
gif- png-, loadMovie(), . , flash-
jpg-. ,
fla-, jpeg swf-. ,
jpg-.
- jpeg, swf-, .
10.7.4. MovieClipLoader
Flash 5.
loadMovie() ,
getBytesLoaded() getBytesTotal() , , onData (,
), onLoad . , ,
, . ,
. :
onData .
, . onEnterFrame,
getBytesLoaded().
Flash MX . ,
, . ,
onLoad onData, .
. -,
onLoad onData . , ,
,
. -, Flash 5 .
, Flash 5 . -, . .
. ,
, .
getBytesLoaded() - , .
http- 404 (, ) 403 (, ).
- ,
, , ,
.
getBytesTotal() getBytesLoded() . , , . - .
, , , ,
ActionScript Flash 6. , ( ActionScript; , +) Macromedia ActionScript i
. .
Flash MX 2004 . , , . MovieClipLoader,
.
MovieClipLoader , :
- new. MovieClipLoader :
var loader:MovieClipLoader=new MovieClipLoader();
// ...
MovieClipLoader
loadClip(url, target),
:
url swf- ;
target , .
loadClip() loadMovie(), ,
. , loadClip()
. :
// picture.jpg.
// . ""
// :
this.createEmptyMovieClip["clip", 0);
var loader:MovieClipLoader = new MovieClipLoader();
loader.loadClip("picture.jpg", clip);
//
//
loadClip(), loadMovie(), ( ) .
, loadMovieNum().
MovieClipLoader.unloadClip(), unloadMovie() MovieClip,
10.16. :
// _root , ;
var loader:MovieClipLoader = new MovieClipLoader();
loader.unloadClip(_root);
//
, , .
:
o URLNotFound , ;
o LoadNeverCompleted ,
( ,
. .).
onLoadError . , onLoadError ,
. ,
.
onLoadError MovieClip .
onLoadInit. , (
). ,
, , ActionScript. ,
, :
listener.onLoadInit=function(target_clip:MovieClip): Void {
target_clip.stop();
}
onLoadInit , .
onLoadInit MovieClip.
on Load Progress. , MovieClipLoader.
. - :
o , ;
o ( );
o ( swf-, , -
).
onLoadProgress . e
, , ( )
. , . ,
onLoadProgress 100.
, .
. .
onLoadProgress ,
. .
onLoadProgress MovieClipLoader
onData MovieClip. ,
,
getBytesLoaded() getBytesTotal(). onData
onLoadProgress , .
onLoadProgress , . , onLoadProgress
, onData.
onLoadComplete. .
-. onLoadComplete
, (, ,
).
onLoadComplete MovieClipLoader onLoad MovieClip.
MovieClipLoader . , ,
addListener(). , , removeListener().
MovieClipLoader.
/* 1.swf 50-100 (,
). . , onLoadProgress . : */
this.createEmptyMovieClip("clip", 0);
// -
var loader:MovieClipLoader = new MovieClipLoader(); //
var listener:Object = ();
//
loader.addListener(listener);
// ,
loader.loadClip("http://www.myserver.ru/mysite/flash/l.swf", clip);
// ,
//
listener.onLoadStart = function():Void {
_root.createTextField("preloader", -1, 250, 200, 50, 30);
preloader.utoSize=true, preloader.border=true, preloader.text="0 %";
};
//
//
listener.onLoadError = function(clip:MovieClip, message:String):Void {
_root.createTextField("error", 1, 250, 100, 50, 30);
error.autoSize=true, error.border=true;
if (message = "URLNotFound") {
error.text="H - ";
}
if (message == "LoadNeverCornpleted") {
error.text="np ";
//
//
listener.onLoadProgress = function(clip:MovieClip, bytesLoaded:Number,
bytesTotal:Number):Void {
preloader.text = Math.round(bytesLoaded/bytesTotal*100)+" %";
};
listener.onLoadComplete = function():Void {
preloader.removeTextField();
};
MovieClipLoader . . , .
, - , MovieClipLoader .
,
MovieClipLoader - .
, unloadClip(). onLoadError
LoadNeverCornpleted.
10.7.5.
:
swf- .
, . , , ( ).
, . , 100 %, , .
, , . ,
(,
, , ), ( ).
.
( ) .
. , , swf-. .
. :
this.onData = function():Void {
if (this.getBytesLoaded() = this . getBytesTotal()) {
this.play();
delete this.onData;
}
};
this.onEnterFrame = function():Void {
this.stop();
delete this.onEnterFrame;
};
, , . onData
. , ,
. getBytesLoaded() (
) getBytesTotal() ( ). , , , . -
, ( onEnterFrame) stop() .
, . , . , View Simulate
Download ( ) ( <Ctrl> + <Enter>). , Download Settings ( ) View. ,
onLoadProgress MovieClipLoader. , . .
, , .
. , , , , ,
. , , , . , .
, . ,
. ,
(, ).
, :
/*
1:10. polosa . polosa
( ,
). , . pole. , swf-
*/
// onEnterFrame (
// onData -
// onLoadProgress MovieCHpLoader MovieClip )
this.onEnterFrarae = function():Void {
// onEnterFrame (
// pole)
if (pole.text = "") {
this.stop();
}
//
var percent:Number = Math.floor(this.getBytesLoaded() /
this.getBytesTotal()*1000)/10;
// pole
pole.text = percent+" %";
// ,
//
polosa._xscale = percent;
// ,
// onEnterFrame
if (this.getBytesLoaded (1 == this.getBytesTotal()) {
this.play();
delete this.onEnterFrame;
}
};
,
, , .
, ,
. ,
. , , , :
/* time.
( ), */
// getTimer() ,
//
var prognoz:Number = ((100-percent)*getTimer()/percent)/60000;
time.text = Math.round(prognoz*10)/10;
,
, . , . ,
( , ) .
- . ,
,
. ,
.
,
, ( ).
:
, . , . ,
. , - . , , ,
ActionScript 2.0, .
.
, . 78 %,
.
,
MovieClipLoader.
, , .
,
.
,
, .
? , . , . ,
, .
Export in first frame ( )
Linkage () Linkage Properties ( ) (
Linkage ). ,
( , , ), . Export frame for classes (
) ActionScript Settings ( ActionScript), Settings -
//
//
listener.onLoadError = function():Void {
clip.createTextField("error", 0, 50, 50, 0, 0);
clip-error.autoSize = clip.error.border=true;
clip.error.text = " ";
};
//
// ,
listener.onLoadInit = function{):Void {
clip._visible = false;
clip.stop();
}
// ,
// r time
listener.onLoadProgress = function(clip:MovieClip, l_b:Number, t_b:Number):
Void {
var percent:Number = l_b/t_b;
preloader.proc.text = Math.floor(percent*1000)/10;
preloader.polosa._xscale = percent*100;
preloader.time.text = Math.round((1-percent)*(getTimer-timer) / percent
/ 6000) /10;
};
// .
// clip
listener.onLoadComplete = function():Void {
preloader.swapDepths(1000), preloader.removeMovieClip();
delete loader, delete listener, delete timer;
clip._visible=true, clip.play();
};
, . , Flash- ,
. ,
. ,
.
, , . ,
Flash MX 2004
Loader ProgressBar. , .
, , . _framesloaded ( ) _totalframes ( ). , , , _framesloaded
_totalframes.
_framesloaded _totalframes . , . , ,
.
, ( Flash 5 , getBytesLoaded() , ). , _totalframes , 10,14.
10.7.6. swf-
.
, .
, , swf-. , ,
Flash, , loadMovie().
. -, ,
( Windows
Temporary Internet Files). Windows 2000 : C:\Documenls and Settings\user\Local Settings\Temporary Internet Files. -,
, ,
. .
, swf- , . ,
, .
.
, . , ,
. , swf-
. , . , , ,
. Temporary Internet Files.
? , , ,
. ;
Temporary Internet Files. ,
;
, URL ( GET),
URL, . ,
URL ,
, .
: swf- , . :
this.createEmptyMovieClip("clip", 0);
clip.loadMovie("http://www.mysite.ru/film.swf?"+Math.random());
,
( , ).
, HTML-, .
URL, , ( JavaScript).
, . :
<D>
< HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</HEAD>
10.7.7.
, . , . , , , .
, getDepth(),
swapDepths():
trace(_root.getDepth());
// : -16384
_root.swapDepths(1000);
trace(_root.getDepth());
trace(_root);
//
//
//
//
_root
: 1000 ( )
: _level0 (
)
, :
, . ,
-16384
. -16383.
, ,
.
, - . , , . , . ,
:
trace(_root.getDepth());
, 1 .swf.
:
loadMovieNum("1.swf", 1);
1.swf ,
fla- . <Ctrl> + <Enter>. Output
-16383. , 1.swf, 100-.
Output -16284.
, , . , ,
: depths=-16384+level. , (. )?
, , . , .
. .
loadMovie (, 16384, ). _lvel0
, , . , .
,
. , , . but :
but.onRelease=function():Void {
_root.swapDepths(1000);
}
, :
loadMovieNum("2.swf", 1);
n 1.swf 2.swf.
1.swf. .
but .
, swapDepths(),
, . ,
swf- (, ,
, , ). ,
loadMovie() swf- .
, , . swapDepths():
_level0.awapDepths(_level1);
IoadMovie() .
loadMovieNum(1.swf,1) , -16383.
_level1, . .
10.7.8.
, . ,
, . ;
_level1.mov.start Drag(); // mov level1
.
ActionScript , Global
. ,
, , .
Global , ,
,
. ,
, ,
,
( ).
,
. :
_level1.prop = "";
trace(_level1.prop);
// : undefined
,
, ,
, , swf-
. , ,
Flash MX 2004.
, , Flash-. ,
, , . . , ,
. , , , .
, , ,
,
. , :
. ,
, , , . System.security.allowDomain(), ( IP-). :
System.security.allowDomain("www.mysite.ru", "www.macromedia.com");
,
, .
,
Global. , ,
, ,
. Global,
allowDomain()
allowInsecureDomain() System.security.
Flash MX 2004 ActionScript. ,
. 17.
10.7.9.
Flash- swf-,
. ,
. ,
. ( ), , . - , , ,
. ,
, . . , , .
(shared
libraries). swf-, .
swf- ,
.
, .
, , , , , 3- .
, .
fla- ,
.
, . Linkage .
Linkage Properties Export for runtime sharing. Identifier. ( ).
URL Linkage Properties , swf . , . , ,
. ,
.
, swf-, ,
URL Linkage Properties. .
, :
,
, . . .
.
Linkage Properties Linkage . Import for runtime sharing.
Identifier , . swf URL ( ,
).
, ,
. , . , ,
.
10.8.
, . , . , .
, ,
, , .
var obj:Object=new Object(); // obj
. , , ,
. ,
(, r ).
. , <Instance Name> .
duplicateMovielip(), attachMovie() createEmptyMovieClip().
, , ( ) : instance 1, instance 2, ... instancen. , ,
.
, n .
.
, ,
, .
. name:
// clip
var per:MovieClip = createEmptyMovieClip("clip", 0);
trace(per._name);
// : clip
per._name = "new_clip"; //
trace(per._name);
// : new_clip
, .
name . , ,
.
,
. , , ,
. . , .
, . , , , :
// ""
var per:MovieClip = createEmptyMovieClip("2+/*3", 0);
trace(per);
// : _level0.2+/*3
trace(this["2+/*3"]._name);
// : 2+/*3
.
, , . , .
ActionScript. ,
.
,
ActionScript, , , , ,
. ,
.
10.9.
,
, .
. , , ,
. . , . .
. , ,
. , .
.
, , , . . _root,
, . , , _leveln. :
_root.mov.mov1
_level3.mov.mov1
// ,
// ,
_root , . :
trace(_root._root);
// : _level0
trace(mov._root);
// : _level0
trace(_root.mov._root.mov);
// : _level0.mov
, ,
.
. , ,
. , , :
_root.mov.mov1
mov.mov1
// (,
// _root)
//
, , ,
. , .
? , . , , , , , .
, , . , ,
. ,
, .
, , ,
, _root _leveln, ActionScript , , .
_parent.
_parent , , . .
. :
//
// clip1
_root.clip1.createEmptyMovieClip("clip2", 0);
//
// clip2
trace(_root.clip1.clip2._parent);
// : _leveI0.clip1 ( )
trace(_root.clipl.clip2,_parent._parent); // : _level0
// ( )
_root.createEmptyMovieClip("clipl", 0);
, , , . , , , , .
,
, , , . , , , _root . ? , :
. _parent,
( ).
, , this. , ,
,
(, - ).
this MovieClip, (. 10.3.2).
, this . , this
, . ( ), - . :
// main_clip , -
//
_global.main_clip=this;
, , . .
, . , _parent. -
this .
,
, , , , ,
, .
10.9.1. _lockroot
, Flash MX , . _root , swf- _root .
,
-.
, . ",
(, _root). .
, _root , , . Flash MX 2004 .
_lockroot. false, _root ( ) , ,
. true, _root
:
createEmptyMovieClip("clip", 0);
trace(clip._root);
clip._lockroot = true;
trace(clip._root);
// : _level0
// ""
// : _level0.clip
_lockroot, .
, , .
10.9.2.
.
, . _name .
, targetPath(),
:
targetPath(clip),
clip , .
targetPath() ,
. :
var per:MovieClip=createErnptyMovieClip("clip", 0);
trace(targetPath(per));
// : _level0.clip
targetPath() . ,
, . , . ,
String():
var per:MovieClip=createEmptyMovieClip("clip",0);
trace(targetPath(pert=String(per));
// : true
Bo Flash 4 , /.
, _target:
//
var per=createEmptyMovieClip("clipl",0).createEmptyMovieClip("clip2",0);
trace(per._target);
// : /clipl/clip2
trace(per);
// : _level0.clipl.clip2
target . ,
.
, , , eval():
createEmptyMovieClip("clip1",0).createEmptyMovieClip("clip2",0);
trace(typeof eval("_level0.clip1.clip2"));
// : movieclip
,
. ,
, . , . ,
. , ,
(Abcolute), (Relative).
,
, , . ,
.
Insert Target Path , , . _root.
10.10.
. , , , ,
,
. , ,
dynamic input.
Flash , . :
. ,
.
. , , ,
. ,
(0,0).
. , . .
, Y . , - , , , , .
X , .
Flash, , , ,
, .
. . . , N , , , 550x400 .
Y
. . , , . ,
, .
. , .
_root , . ,
,
. , , _root
.
,
createEmptyMovieClip(), . , ,
_root (0, 0).
. . , . ,
. , _ _
. _xscale _yscale .
_width _height.
, _rotation. .
, .
. :
,
.
10.10.1. _x _y
,
ActionScript, _ _ .
, ActionScript .
, , . _ _ .
, _ _, , ( , ). , .
, .
, , , .
ActionScript , _ _
. , _ _ . . :
this._=2.123;
trace(this._);
// : 2.1
:
, 0,05, :
this._x = 20;
for (var i = 0; i<10000; i++) {
this._x += 0.02;
// _x 220
}
trace(this. x);
// : 20
, ,
, . _ _
, 0,05.
.
, _ _ , . , . , , .
, .
0,1 _ _ .
, _ _
, . ,
, localToGlobal() (. 10.10.2).
.
: ? , :
( )
-. .
, ,
.
.
. .
. , _ _ _root 0.
,
-, . , , ,
90 , _x , . ,
. , , N 2 N ,
10.10.2.
. ,
, _root.
, , _ _, ,
-.
, , .
. ,
_root,
, . . :
//
// _root
var x:Number=clip._x+clip.but._x;
var :Number=clip._y+clip.but._y;
//
var x:Number=clip1._x+clip1.clip2._x+clip1.clip2.but._x;
var :Number=clip1._y+clip1.clip2._y+clip1.clip2.but._y;
, ,
, . ,
, ActionScript , .
_root , localToGIobal(). :
clip.localToGlobal(point),
clip , _root
;
point Object, . localToGlobal() . ,
point.
localToGlobal() . , , ,
.
:
createEmptyMovieClip("clip", 0);
clip._x = clip._y += 200;
//
//
//
//
// : 250,250
X
//
. globalToLocal ().
localToGlobal(),
:
createEmptyMovieClip{"clip", 0);
clip._x = clip._y += 200;
var coord:Object = {x:50, y:50};
clip.globalToLocal(coord);
trace([coord.x, coord.y]);
// : -150, -150
10.10.3.
, Flash .
, -.
, , , , , . , ,
/
. 100 %,
, . 100 %,
, ,
X 200 %, 1 2 ,
. 50 %, 2 1
.
ActionScript ,
_xs1 _yscale. , .
100 %. :
//
_root._xscale = _root._yscale=200; //
// ,
_ _, _xscale _yscale . ,
:
_xscale=100.0000000000001
trace(_xscale);
// : 100.00000000000001
,
.
0, 1
. 0, (
).
, , Free Transform. _xscale _yscalc 100 %, .
, , , -. , _ 10 , -
. , , .
:
100 %. .
_xscale _yscale ,
.
. ,
. , _level0 .
.
, , 0,
. .
: , , . , 0.
. 0 ,
. , .
, , ( )
, . , 50 10 40 , 50 % , 20
, 5 . ,
, .
, _xscale _yscaie, .
. , .
, hairline.
.
, _xscale _yscale .
,
. , _xscale 100 % X
, -1 .
. , ,
_xscale -1. _yscale. . ,
,
.
, ,
-
. _xscale jyscaic , , Flip Vertical / Horisontal ( / ) Transform
() Modify ().
10.10.4.
, , , ,
.
, ,
. , ,
Y , . :
X , , , . : , . ,
.
W .
ActionScript _width _height, . , _xscale _yscale. , ,
. , _width height
_xscale _yscale. , , - ( ) . .
,
0. _width _height ,
1 . 0 ,
, ( ).
//
//
//
//
: 100.1 ( 0.1)
: 100.1 ( )
_width _height .
_root , .
_root.
, _width _height Stage:
trace([_root._height, _root._width]);
trace([Stage.height, Stage.width]);
// : 0, 0 ( _root )
// : 400 550
10.10.5.
. ,
, . , _width _height. .
ActionScript getBounds(), . :
clip.getBounds(targetCoordinateSpace).
:
clip , ;
targetCoordinateSpace , clip.
getBounds() Object, xMin, xMax, yMin,
, . , . :
// mov1 mov2
// mov1 mov2
var coord:Object = mov1.getBounds(mov2);
for (var i in coord) {
//
trace(i+"+"+coord[i]);
// : =102.9 yMin=-29.3 xMax=-196.3
// xMin=-328.5
}
getBounds(), , . . ,
hitTest(). getBounds()
, ,
. , , . . N% , N% . ,
, , ? getBounds(), , .
10.10.6.
,
_rotation:
_root._rotatior += 30;
// 30
_rotation . , Math: .
_rotation , .
.
_rotation . 360 ( ), ,
360. _rotation
-180 180 :
_root._rotation=574;
trace {_root._rotation);
// : -116
_rotation . , , .
_rotation 0. ,
. , _rotation
. , ,
Free Transform. 180: ,
.
, _rotation , . ,
,
. , , , .
10.11.
, .
ActionScript, .
10.11.1. _alpha
ActionScript -
_1. :
_root._alpha=0;
//
// : 77.734375
, 0
( ) 255 ( ), ( ) .
ActionScript .
setTransform() Color. :
(new Color(_root)).setTrasform({ab:-255});
// _root._alpha=0
. , , , ,
_alpha 100 %. , ( ) .
,
_alpha, _visible,
10.11.2. _visible
_visible .
true ( ) false ( ).
_visible true.
_visible , , .
, . _alpha, . _visible:
, , .
_visible
_alpha . _visible
, onRelease, onPress . . , , , <Shift> + <Tab> (
11). ,
. ,
, . _alpha , , ,
onRelease. .
MovieClip , .
, , , hiiTest() ,
.
10.12. . startDrag()
ActionScript- ,
. , , drag and drop ( ,
, - ).
, . , (
onMouseMove), ,
( _xmouse _mouse).
:
// mov
// mov
_root.onMouseDown = function():Void {
_root.onMouseMove = function():Void {
_root.mov._x = _root._xmouse;
_root.mov._y = _root._ymouse;
updateAfterEvent();
//
//
};
};
// mov
_root.onMouseUp = function():Void {
delete _root.onMouseMove;
};
,
startDrag(). :
clip.startDrag([point], [left, top, right, bottom]),
:
clip , ;
[point] ,
. true, , startDrag().
point false, , , . . ,
, , .
, , , ,
.
point . , false;
[left, top, right, bottom] , , . , , , .
. , - .
startDrag() .
, .
, ,
startDrag() . . ,
ActionScript stopDrag().
, . , ,
stopDrag() .
startDrag() stopDrag()
mov :
_root.onMouseDown = functions):Void {
mov.startDrag(true);
};
_root.onMouseUp = function():Void {
_root.stopDrag();
// He ,
// startDrag()
};
, startDrag() stopDrag()
. startDrag() ,
. ,
. ,
, .
, . , startDrag() , updateAfterEvent().
, startDrag()
stopDrag(). , , .
startDrag() stopDrag() :
,
( . .3.2).
10.12.1. _droptarget
_droptarget , drag and drop startDrag().
, .
_droptarget :
, , . ,
.
__droptarget Flash 4.
, / - :
// mov1 mov2
mov2.startDrag(true);
// mov2 , mov1
this.onMouseDown = function():Void { //
trace(mov2._droptarget);
// : /mov
};
Flash 4, , _droptarget,
. , eval():
mov2.startDrag(true);
onHouseDown = function():Void {
trace(eval(mov2._droptarget) == mov1); // : true
};
, , _droptarget, . startDrag() .
.
, hitTest().
, _droptarget ( undefined, ).
, .
_droptarget ,
( ).
.
_droptarget, ,
, .
10.13. . hitTest()
hitTest(), ,
: , , , . , .
10.13.1.
, , hitTest() :
clipl.hitTest(clip2),
clip1 clip2 , .
hitTest() true,
, false, .
,
, . ,
.
, . hitTest() , ( , getBounds()). ,
,
, , , .
, , ,
hitTest() .
, hitTest() . . 10.2 , . , hitTest() true, , .
: ,
. , .
, ,
Flash. He ,
. ,
hilTest().
-, ,
(, ) (,
).
.
-, ,
( , ).
:
, .
-, . -. , hitTest() . , , . -.
,
. , - , , .
-, , , , . , 10.13.3.
10.13.2.
, ,
hitTest() :
clip.hitTest(, , shapeFlag),
:
x .
. ,
, localToGlobaI();
shapeFlag , , , (true) ,
(false).
, hitTest() true. false.
, , :
this.onMouseDown = function():Void {
if (mov.hitTest(_root._xmouse, _root. _ymouse, true)) {
mov.startDrag(true);
}
};
, , .
_xmouse _ymouse. hitTest() ,
_root.
, hitTest() , . , ,
, ,
, .
hitTest() , .
Flash MX , . , onPress. , :
mov.onPress = function():Void {
this.startDrag(true);
};
,
. ,
:
mov.useHandCursor=false;
10.13.3.
, hitTest() ,
, . , ,
. , , ActionScript.
? . ? . ,
, , .
Flash . ,
, . .
, ( getBounds()), . ( , hitTest()), , . , ,
.
, .
, . ,
? .
( ). ,
, .
, , .
:
// , hitTest()
MovieClip.prototype.myHitTest = function(clip:MovieClip, n:Number):Boolean {
// n "". -
// 2
if (n == undefined) {
var n:Number = 2;
}
// .
// hitTest(),
// _root.
var coord1:Object = this.getBounds(_root);
var coord2:Object = clip.getBounds(_root);
// . ,
//
var squarel: Number =
Math.abs((coord1.xMax-coord1.xMin)*(coord1.yMax-coord1.yMin));
var square2:Number =
Math.abs((coord2.xMax-coord2.xMin)*(coord2.yMax-coord2.yMin));
var coord:Object = square1>square2? coord2: coord1;
// ""
for (var i = coord.xMin+n/2; i<=coord,xMath; i +=n) {
for (var j = coord.yMin+n/2; j<=coord.yMax; j += n) {
// "" , true
, , , .
, .
myHitTest()
. . :
, . ,
. ,
. ,
myHitTest.fla 10 .
10.14.
Flash . , 1996 , , . , , . ActionScript,
.
10.14.1.
, , play().
, :
play();
// ,
mov.playl); // mov
play()
. , .
. , , . . ,
Frame Rate .
0,01 120 .
. , , , . ,
, stop().
, , . , swf-
HTML- .
, false loop,
<OBJECT> ( <EMBED>).
Flash, Loop () -
, . stop().
, HTML-. <OBJECT> play, , .
Flash ,
Paused at Start ( ), , Loop.
. play.
, . Loop.
10.14.2.
, . ActionScript
:
,
gotoAndPlay() ( ).
,
gotoAndStop() ( ).
,
nextFrame() ( ). , , prevFrame().
,
nextScene(). , ,
prevScene(). ,
gotoAndPlay() gotoAndStop() scene.
gotoAndPlay()
. :
clip.gotoAndPlay(frame),
:
lip ,
;
frame , .
gotoAndPlay(), . :
_root.gotoAndPlay(2);
//
//
.
gotoAndPlay() , . 1, .
, , ,
, . (label)
. Frame
. . , gotoAndPlay():
_root.gotoAndPlay("frame#2"); // frame#2 -
.
, .
.
, . Frame , //. , . swf- .
gotoAndPlay() , , ,
. , . ,
.
:
gotoAndPlay(scene, frame),
:
scene , . . gotoAndP!ay() ,
;
frame . :
qotoAndPlay("scene1",5);
//
// 5- scene1
, , , . ,
Flash, ActionScript. ,
_root . . swf
, , . , , ,
, . ,
gotoAndPlay() : .
, . , ,
. .
gotoAndPlay() ,
, .
.
gotoAndStop() .
gotoAndPlay(), . :
_root.gotoAndStop(2);
gotoAndStop("scene1", "framet#1");
.
, .
. ,
gotoAndStop() _currentframe ( ):
gotoAndStop(currentframe+1);
//
//
,
nextFrame() prevFrame():
_root.nextFrame();
_rt.prevFrame();
// ""
// ""
nextFrame() prevFrame() .
, , . , , .
, , prevFrame() nextFrame(),
. Forward,
. , Back.
Rewind .
, , . , , .
. ,
, :
Stage.showMenu=false;
//
,
. ActionScript prevScene()
nextScene(). Flash, .
10.14.3.
,
_currentframe:
_root.onEnterFrarae = function():Void {
trace(_root._currentframe);
// : 1, 2, 3...
};
Flash 5 _currentframe
. , , , ,
. Flash 6 7 __currentframe ,
, .
, , , . , , , . , , -,
, , _currentframe. :
.
(
onEnterFrame) , .
, .
:
// :
trace(" "); //
function frame_2():Void {
trace(" ");
//
}
function frame_3():Void {
trace(" ");
//
}
_root.onEnterFrame = function():Void {
// , ""
switch (_currentframe) {
case 2:
frame_2();
break;
case 3:
frame_3();
}
};
_currentframe ,
. ,
nextFrame():
MovieClip.prototype.myNextFrame=function():Void {
this.gotoAndStop(this._currentframe+1);
}
10.15.
Flash 4. . , ,
, .
, , . , , . -
, , . ,
,
, , .
,
. :
.
.
, .
.
Flash 6 setMask(), .
:
masked.setMask(mask),
:
masked ;
mask , .
setMask() mask , masked. , , . , setMask(), , mov1 mov2 :
mov1.setMask(mov2);
mov2.startDrag(true);
// mov1 ,
// mov2
//
setMask() , , ,
. , setMask()
, .
.
. ,
( ), . ,
(, -), .
setMask() . , ,
. ,
setMask(), . .
,
. :
setMask() .
setMask() :
, .
setMask() . ,
, , . ,
, ,
, A.setMask(B) .
,
: , , .
, . (
), , ( ).
, , .
, 13.
6- flash- (device) . 2003 . , , , (6.0r47 ).
, setMask() null;
clip.setMask(null);
// clip
10.16.
, . ,
, delete, . , , , . ,
, , .
, :
. , , , . ,
, , .
,
ActionScript. .
ActionScript . , , , attachMovie() duplicateMovieClip() . loadMovie()
. loadMovieNum(), ,
, .
,
. . ActionScript, . removeMovieClip(),
unloadMovie() unloadMovieNum().
10.16.1. . removeMovieClip()
removeMovieClip() .
:
createEmptyMovieClip("clip",0);
clip.removeMovieClip();
trace(clip);
//
//
//
//
: undefined (
)
ActionScript , removeMovieClip() , . . , , . , , . ,
,
swapDepths():
//
mov.removeMovieClip{}; //
trace(mov);
//
mov.swapDepths(10000); //
//
mov.removeMovieClip(); //
trace(mov);
//
mov
: _level0.mov ( )
removeMovieClip()
: undefined ( )
removeMovieClip() ,
. ,
0 0xFFFFF (1048575).
:
//
createEmptyMovieClip("clip", 0xFFFFF+1);
clip.removeMovieClip(); //
trace(clip);
// : _level0.clip ( )
10.16.2. . unloadMovie()
unloadMovie(), removeMovieClip(), , . -, , , createEmptyMovieClip(). :
// mov
mov.unloadMovie(); // -
trace(mov);
// : _level0.mov (
// )
unloadMovie() , . , .
, , , , .
Flash 5, .
. . ,
Flash 6, - , , onLoad (. 10.17.3).
, unloadMovie()
loadMovie(). . ,
loadMovie() . ,
, , .
unloadMovie() ( ). ,
.
, unloadMovie(), Flash 3. ActionScript . ,
, .
unloadMovie() ,
.
10.16.3.
, unloadMovie() leveln, , :
_levell, unloadMovie(); // 1
, removeMovieClip(), ,
unloadMovie().
, loadMovie()
loadMovieNum(), unloadMovie()
ActionScript unloadMovieNum(). , :
unloadMovieNum(1) // 1
10.17.
. ,
onCIipEvent on ( Flash 5) ( Flash 6).
(,
), . -, . ,
, . , , . -
10.17.1. Flash 5
Flash 6 (. 8)
. Flash 5 ~
, .
.
Flash 5, ,
:
onClipEvent(event) {
Substances
}
:
onClipEvent , ;
event 9 (. );
substances , .
Flash 5 , ,
on. :
load
unload
enterFrame
mouseMove
mouseDown
mouseUp
keyDown
keyUp
data
:
// 1
onClipEvent(enterFrame) {
_xscale=_yscale+=1;
Bo Flash MX . , on. :
// ,
on (press) {
_xscale=_scale+=10;
}
, onClipEvent(event), on(event).
on(event).
, Flash 5 ,
8.
onClipEvent:
Flash 5
(onSetFocus onKillFocus), ,
.
Flash 5
(_root), . , ,
, enterFrame,
, onClipEvent, , , ,
creareEmptyMovicClip().
Flash
5 . :
onClipEvent, , -. .
10.17.2. (onEnterFrame)
onEnterFrame . ,
, , , , ,
, . , onEnterFrarae
, (,
stop()). :
createEmptyMovieClip("clip", 0);
//
// ,
clip.onEnterFrame = function():Void {
trace(getTimer()-time);
// : 789 1086 1000 1000 1000 1000
time=getTimer();
};
onEnterFrame
. , , .
Frame Rate . 120, 0,01 .
. , . :
onEnterFrame .
, ,
.
, , ,
fps.
, , -
. , onEnterFrame
.
,
,
. , onEnterFrame
. ,
( ), onEnterFrame , ,
, ( )
, .
onEnterFrame ,
. ,
, .
Flash 5 onEnterFrame , . .
Flash MX setInterval(), (
) . , , . ,
- . ,
, : . updateAfterEvent(), , , , , . setInterval() ,
,
(, ),
, .
onEnterFrame ,
(,
). , , .
10.17.3. (onLoad)
onLoad swf-
loadMovie() loadMovieNum(). , .
- , ( , , ) ,
.
onLoad .
( ) . onLoad, :
createErTiptyMovieClip("mov", 0);
mov.loadMovie("1.swf");
mov.onLoad = function{) {
trace(" ");
// -
//
// Output
onLoad , e , . MovieClip. ,
, onLoad:
createEmptyMovieClip("mov", 0);
// -
//
MovieClip.prototype.onLoad = function():Void {
if (this == mov) { // ,
trace(" ");
}
};
mov.loadMovie("1.swf");
// : (
// )
onLoad ,
, .
onLoad. , , onClipEvent()
, . ,
. , , Flash 5 . :
// mov ""
onClipEvent (load) {
trace(" ");
}
// , mov,
mov.loadMovie{"1.swf"); //
// Output :
load ,
. , load . (
attachMovie(),duplicatcMovieClip() createEmptyMovieClip()), onLoad, . , Flash 6, .
onClipEvent(load) - . ,
.
, . , . ,
.
Flash 6 onLoad
, , .
Flash MX 2004 onLoad MovieClip
onLoadComplete MovieClipLoader.
, .
10.17.4. (onUnload)
onUnload , .
:
, .
removeMovieClip().
- .
unloadMovie().
loadMovie().
, onUnload, . , , , {onLoad onUnload).
. , , . onUnload. ,
onLoad. :
// rnov. :
// cnLoad ()
MovieClip.prototype.onLoad = function():Void {
if (this == mov) {
trace{" ");
}
mov.onUnload = function() { // onUnload
trace(" ");
};
mov.loadMovie("1.swf");
//
// Output :
, onUnload , onLoad, . ,
, - . onLoad , .
onUnload Flash 5,
onLoad, . - , onClipEvent.
onUnload , - . , .
10.17.5. (onData)
onData ,
loadVariables() loadMovie(). .
ActionScript .
,
. , , , .
, . .
loadVariables(),
, . , , . ,
. ,
loadVariables(). , , . onData ,
.
, loadVariables(), onData
loadMovie(). ,
, .
onData, , . , Flash
MX 2004. - , onData . , ,
, onData . - ,
.
on Load Progress MovieClipLoader ( onEnterFrame). onData , (, ).
onData , onLoad:
. ,
Flash 5.
). .
.
, Flash-. , .
Key).
10.17.8.
Flash MX ,
. , ( 7). , ;
onPress. , . , .
onRelease. ,
.
onReleaseOutside. ,
, .
onRollOver. .
onRolIOut. , . .
onDragOver. ,
, .
onDragOut. , ,
, , .
-. Flash 5.
, onClipEvent . ,
on(event):
on(press){ //
this.removeMovieClip();
}
,
.
. ,
. , false
useHandCursor.
mov.useHandCursor=false;
.
enabled:
mov.enabled=false;
,
. . ,
, onRollOut
_root. , ,
.
, . ,
onPress, ,
onMouseDown. onRollOver , hitTest()
onMouseMove . .
Flash 5, , .
, Macromedia, , . 11.
10.18.
ActionScript Flash. . ,
, 3D-
- Doom. , (. 10.3).
. 10.3. ( )
FIash-
Flash 5 ( Flash 4).
. , ( )
. , ,
. , -, ,
. . , , , .
Flash MX , , , , . , . , ,
- . , .
( )
. MovieClip. ,
.
ActionScript,
.
, .
, ,
10 .
10.18.1.
, . 10.3 , ( ).
.
, . MovieClip, ,
, . , ,
. .
. -, , , . -, -
- , . -,
.
, :
_root.createEmptyMovieClip("my_mc", 0);
, ,
.
lineStyle(thickness, rgb, alpha),
:
thickness . 0 255. 0 hairline Flash , , . thickness
, ;
rgb . .
( Color Mixer). ,
;
alpha , ,
: 0 , 100 .
, 100.
. lineStyle() , .
, , 3 :
my_mc.lineStyle(3,0xFF0000,100);
? , ,
. , . Flash.
( ). moveTo(x,y), , ( , ).
, .
:
my_mc.moveTo(250, 200);
( ) , lineTo(,), ,
-.
100 . :
my_mc.lineTo(350,200);
//
my_mc.lineTo(350,300);
my_mc.lineTo(250,300);
my_mc.lineTo(250,200);
//
//
//
. . , ?
, , . ,
, ? . ( ).
, , , ( ) .
, . ,
, ,
(. 10.4).
. 10.4. .
(. 10.4) , R
0(,) :
X = x + R cos( ) Y = y R sin( ).
,
( ) 0 2 ,
:
//
// X
// Y
// ,
//
_root.createEmptyMcvieClip("round",0);
// ""
with (round) {
// with
lineStyle(2,0xFF0000,100);
//
// 2
moveTo(X0+R*Math.cos(0),Y0+R*Math.sin(0));
//
// (=0)
// N ,
// 0 2
for(var alpha=0; alpha<=2*Math.PI; alpha+=2*Math.PI/N) {
lineTo(X0+R*Math.cos[alpha),Y0-R*Math.sin(alpha));
}
}
var
var
var
var
R:Number=100;
X0:Number=200;
Y0:Number=200;
N:Number=100;
, N, (. 10.5).
. 10.5. (N)
, .
, swf- , ,
, , , .
, .
, , , .
R , , . ,
,
:
var r:Number=0;
, - 510
( a = 10 20 ). 0:
var alpha:Number=0;
2 :
_root.lineStyle(2,0x0000DD,100);
:
_root.moveTo(200,200);
,
: onEnterFrame setInterval().
( ) , :
_root.onEnterFrame = function():Void {}
, ,
:
_root.lineTo(200 + r*Math.cos(alpha),200-r*Math.sin(alpha));
, . , , :
alpha+=0.3;
, ,
. , ,
( ,
):
r+=0.2;
. (. 10.6).
. , _height _width .
.
,
. ,
root. :
. 10.6.
//
var alpha:Number = 0;
var r:Number = 0;
_root._x += 250;
_root._y += 200;
_root.moveTo(0, 0);
_root.lineStyle(2, 0x0000DD, 100);
_root.onEnterFrame = function():Void {
_root.lineTo(0+r*Math.cos(alpha), 0 - r*Math.sin(alpha));
r += 0.3;
alpha += 0.3;
_root.rotation -= 7; //
//
_root._xscale = _root._yscale += 0.1;
};
. , ( ,
300 )? ,
24 .
, , . Flash ? , .
.
, ( 5)?
, . , , , , .
.
Z .
R:
// ,
//
var X:Number=R*Math.cos(alpha);
var Y:Number=R*Math.sin(alpha);
var Z:Number=R;
, :
//
_root.lineTo(X-Z/2*Math.SQRT1_2,Y+ Z/2*Math.SQRT1_2);
. , , - (. 10.7, ). - . ?
,
.
, . { ), . , ,
X Z (. 10.7, ).
. 10.7.
. ,
. ,
. ,
(-16384-) , ,
. , , .
.
( ,
).
,
, , , , .
, , .
10.18.2.
,
. ,
.
swf-. , ,
1 1000, 300 .
, , , . , , , .
, , . : , , lineTo().
Flash ,
swf- , . ,
, . (, , ), , (
). , .
ActionScript curveTo(controlX, controlY, anchorX, anchorY).
, ,
( ), X=anchorX, Y=anchorY. ,
, .
controlX controlY, , (. 10.8).
.
. 10.8. curveTo()
, curveTo(), ,
, , . . ,
. , curveTo().
, :
/* (
) "round" */
// ,
// (prev_anchor), (anchor), (control) ,
//
attachMovie("round", "prev_anchor", 0, {_:550*Math.random(), _y:400*Math.random()});
attachMovie("round", "control", 1, {_x:550*Math.random(), _y:400*Math.random()});
attachMovie{"round", "anchor", 2, {_x:550*Math.random(}, _y:400*Math.random()});
// , ""
function draw():Void {
lineStyle (4, 0xFF0000);
moveTo(prev_anchor._x, prev_anchor._y);
curveTo(control._x, control._y, anchor._x, anchor._y);
}
draw();
//
/* "" .
, draw() onMouseMove */
MovieClip.prototype.onPress = function():Void {
this.startDrag();
_root.onMouseMove = function() {
clear ();
//
draw();
updateAfterEvent();
};
};
// ""
// onMouseMove
MovieClip.prototype.onRelease = function():Vcid {
stopDrag();
delete _root.onMouseMove;
};
,
. ,
,
, . ,
. , , , . curveTo()
lineTo() .
, curveTo(), .
,
.
, . circle. 7
: , , , ,
:
function circle(radius:Number, number_of_steps:Number, x_center:Number,
y_center:Number, thickness:Number, rgb:Nuraber, alpha:Number):Void { }
ActionScript ,
. , .
, , .
,
. , , circle. ,
50 (0, 0). 5
2 :
var arr:Array=[50,10,0,0,2,0,100];
,
. , , - ,
:
for (var i = 0; i<7; i++) {
if (arguments[i]!= undefined)
arr[i] = arguments[i];
}
}
, .
:
var R:Nuraber = arr[0], X0:Number = arr[2], Y0:Number = arr[3];
:
this.lineStyle(arr[4], arr[5], arr[6));
// ,
// , 0
this.moveTo(X0+R, Y0);
, ,
:
var step:Number=2*Math.PI/arr[1]; //
// moveToO,
// step
for (var phi=step; phi<=2*Math.PI; phi += step) {}
Puc. 10.9.
. , , . ( R1), :
// controlX, controlY, anchorX, anchorY
// null
controlX=X0+Rl*Math.cos(phi-step/2);
//
controlY=Y0-Rl*Math.sin(phi-step/2);
anchorX=X0+R"Math.cos(phi);
//
anchorY=Y0-R-Math.sin{phi);
//
this.curveTo(ControlX, ControlY, AnchorX, AnchorY);
. ,
. , . , :
R1 , ( ) .
. , , . Object (
, ):
Object.prototype.circleTo=circle;
, , , :
_root.circleTo(100,15,200,20 0,4,0x00BB00, 100);
! ! !
. , , ( ) (. 10.10). 8 , 5 , lineTo(). , 24 , 50.
!
. 10.10.
curveTo() circlc() ,
. . , , , , curveTo, . !
10.18.3.
, , .
,
beginFill(color, alpha),
:
color , ;
alpha , . .
.
beginFill()? , (
moveTo) , , ,
Paint Bucket.
, -
, . , beginFillO ,
(. 10.11):
with(_root) {
lineStyle(l,0xFFO000,lO0);
beginFill(0xEE3F00,100);
//
moveTo(100,100);
lineTo(200,100);
lineTo(200,200);
endFill();
//
}
Puc. 10.11.
endFill().
, , (
, ).
beginFillO (.
10.12).
. 10.12. , , endFill()
beginFill(), , endFill(), . . , . ,
, endFill()
.
, .
(, ). , beginFill(),
. , endFill(),
. beginFill()
endFill{) , . ,
beginFill() , .
beginFill() endFill() ( beginFill()), . , 100 :
with (_root) {
lineStyle(0, 0x001F00);
beginFill(OxOODDOO);
for (var i = 0; i<100; i++) {
x = Math.random()*550, = Math.randomf)*400;
moveTo(x, y);
lineTo(x, y+10), lineTo(x+10, y+10), lineTo(x+10, y), lineTo(x, y);
}
endFill()
};
, . beginFill() . ,
, , .
:
, . , ,
, . , . ,
-, .
beginFill() XOR .
, ,
, .
, . , ,
. (.
10.13):
with (_root) {
lineStyle(3);
beginFill(0x555555);
//
moveTo(100, 100);
//
lineTo(200, 100), lineTo(200,
moveTo(150, 150);
//
lineTo(250, 150), lineTo(250,
endFill();
}
200), lineTo(100, 200), lineTo(100,100);
250), lineTo(150, 250), lineTo(150, 150);
. 10.13.
,
, beginFill() . , , ,
( , ). , , ( Flash). , , . , (. 10.14).
:
with (_root) {
lineStyle(3);
beginFill(0x555555);
moveTo(100, 100);
Puc. 10.14. , no
beginFill() ,
. , .
. , ,
. , , , .
10.18.4.
ActionScript , .
, .
. , , , . , .
- ,
, , - 3D- ActionScript. .
, , beginFill(). , , .
ActionScript
beginGradientFill(fillType, colors, alphas, ratios, matrix),
:
fillType , : linear , radial ;
colors , ,
. colors,
,
, , 8. -
, , Color Mixer.
colors 8 ,
. ,
,
, , ;
alphas , ;
ratios , ,
Color Mixer. , , , ratios . 0,
255. - ratios .
10.15.
. 10.15. ratios
, ,
matrix, . 10.16.
. 10.16. :
; b 50
(); w ();
d w 45
( )
matrix box
, , w .
. ,
, . .
, beginGradientFill()
, ( 10 rpaaHeHT_l.swf).
. , , beginGradientFilI(), .
beginGradientFilI() . ,
, , .
, colors, alphas ratios .
.
Color Mixer Transform Gradient. ,
, beginGradienFill(), . ,
.
beginGradientFill() , .
drawCirdes() : n , r :
MovieClip.prototype.drawCircle=function(n:Number,rMax:Number):Void{}
,
:
this.lineStyle(0,0,0);
, :
var i:Number= 0;
while (i++<n) {
}
:
// null
x=Math.random()*Stage.width;
y=Math.random()*Stage.height;
rad=Math.random{)*rMax;
begmGradientFill():
, , ,
:
fillType="radial";
. ,
, . :
colors=[0xFFFFFF*Math.random(), 0x000000];
:
alphas=[100,100];
,
. :
ratios=|25,255];
matrix :
o matrixType : box;
o
, .
, ( ,
);
o w h ;
o r ( ).
matrix = {matrixType:"box", :x-rad*l.25, :y-rad*l.25, h:2*rad, w:2*rad};
:
beginGradientFill(fillType, colors, alphas, ratios, matrix);
. , line():
this.moveTo(x+rad*Math.cos(0), y+rad*Math,sin(0));
for (var alpha = 0; alpha<=2*Math.PI; alpha += Math.PI/50) {
this.lineTo(x+rad*Math.cos(alpha), y-rad*Math.sin(alpha));
}
.
drawCircle():
MovieClip.prototype.drawCircle=function(n:Number, rMax:Number):Void {
this.lineStyle(0, 0, 0);
//
var x:Number=null, :Number=null,rad:Number =null, colors:Array=null,
matrix:Object=null;
//
var alphas:Array = [100, 100];
var ratios:Array = [25, 255];
, (
). drawCircle n=20 r=50 . 10.17.
. 10.17. ,
, , ,
, .
3x3 , b, , d,
e, f, g, h, i:
a d g
b e h .
c f k
//
var matrix:Object={a: 100, b: 0, : 0, d:0, e:100, f: 0, g: 200, h: 200, i:0};
x m1 m3 m5 x
y = m 2 m 4 m6 y .
1 0
0
1 1
(1)
(2)
, : , .
.
. (x1, y1), x1
, y1 .
,
. :
x = x + x1
.
y = y + y1
(1), , ,
,
1 0 x1
0 1 y1.
0 0 1
matrix box
, .
g h , , .
,
, N , , ,
N K . ,
, :
x = x S x
y = y S y ,
S x S y .
(1), , :
Sx 0 0
0 Sy 0 .
0 0 1
: matrix.
1 1 ,
. ,
100 , :
var matrix:Object={a:100, e:100...};
.
, , :
x = x cos( ) + y sin( )
.
y = x sin( ) + y cos( )
(1), , :
cos( ) sin( ) 0
cos( ) sin( ) 0 .
0
0
1
, .
matrix:
// 45
var matrix:Object={a:Math.cos(Math.PI/4), b: -Math.sin(Math.PI/4), d:
Math.sin(Math.PI/4), e: Math.cos(Math.PI/4)... }
, , ,
, .
. (skew).
skew , , , Free Transform.
.
.
, 90.
: , . , (. 10.18). ,
,
( ).
. 10.18.
.
, . , Y,
( ):
x = x
.
y = y + x / tan( )
X :
x = x + y / tan( )
.
y = y
(1),
skew:
1
1
skewY =
tan( )
0
0 0
1 0
0 1
skewX = 0
0
1
tan( )
1
0
0 .
1
. , , .
,
. , . , , , :
1 0 Sx cos( ) sin( ) 0 cos( ) sin( ) Sx
. , ,
, . , , . , .
, ActionScript, . 100x200 (300, 300),
/ 4 (. 10.19):
var colors:Array=[0,0xFFFFFF];
var alphas:Array={100, 100];
var ratios:Array=E34,255];
var Sx:Number=100, Sy:Number=200;
//
var xl :Number=300, yl :Number=300;
//
var phi:Number=Math.PI/4;
//
var matrix:Object={a:Sx*Math.cos(phi), b: -Sx*Math.sin(phi), d:
Sy'Math.sin(phi), e: Sy*Math.cos(phi), g:x1, h: y1};
lineStyle(1);
beginGradientFill("radial",colors,alphas, ratios, matrix);
moveTo(200,200);
lineTo(200,400); lineTo(400, 400), lineTo(400, 200), lineTo(200, 200);
endFill();
, , , , matrix box.
. , ,
skew . .
, ,
.
, , matrix
:
, ,
skew. , . , : , .
. 10. 19. ,
, .
, , , , , . :
a 0 d 0 g 0 a1 d1 g1
b0 e0 h 0 b1 e1 h1
c0 f 0 i0 c1 f 1 i1
a 0 a1 + d 0 b1 + g 0 c1 a 0 d1 + d 0 e1 + g 0 f 1 a 0 g1 + d 0 h1 + g 0 i1
b0 a1 + e0 b1 + h 0 c1 b0 d1 + e0 e1 + h 0 f 1 b0 g1 + e0 h1 + h 0 i1
c0 a1 + f 0 b1 + i0 c1 c0 d1 + f 0 e1 + i0 f 1 c0 d1 + f 0 e1 + i0 f 1
, , :
GradientMatrix.matrUmn = function(m1:Object, m2:Object):0bject {
, f, i . , , . .
,
, , :
// ( )
GradientMatrix.sdvig = function(x:Number, y:Number):Object {
var matr:Object = {a:1, d:0, g:x, b:0, e:1, h:y, c:0, f:0, i:1);
// this.matrix
return this.matrUmn(this.matrix, matr);
};
// (w , h )
GradientMatrix.scale = function[w:Number, h:Number):Object {
var matr:Object = {a:w, d:0, g:0, b:0, e:h, h:0, c:0, f:0, i:1};
return this.matrUmn(this.matrix, matr);
};
// (phi )
GradientMatrix.rotation = function(phi:Number):Object {
var matr:Object = {a:Math.cos(phi), d:Math.sin(phi), g:0,
b:-Math.sin(phi), e:Math.cos(phi), h:0, c:0, f:0, i:1);
return this.matrUmn(this.matrix, matr);
};
// (skew )
GradientMatrix.skew = function(alpha:Number):Object {
var matr:0bject = {a:l, d:1/Math.tan(alpha), g:0, b:0, e:1, h:0, c:0, f:0, i:1};
return this.matrUmn(this.matrix, matr);
};
X. Y.
. ,
.
: ; w h ; r ; skew . , -, . ,
: , , .
, , .
(, ) . ,
. , sdvig(), . * . w h . .,
. .
GradientMatrix.createMatr = function(obj:Object):Object {
this.matrix = {a:1, d:0, g:0, b:0, e:1, h:0, c:0, f:0, i:1};
this.matrix = obj.x!= undefined && obj.y!= undefined? this.sdvig(obj.x,
obj.y): this.matrix;
this.matrix = obj.w!= undefined && obj.h!= undefined? this.scale(obj.w,
obj.h): this.matrix;
this.matrix = obj.r!= undefined? this.rotation(obj.r): this.matrix;
this.matrix = obj.skew!= undefined? this.skew(obj.skew): this.matrix;
return this.matrix;
};
. ,
matrix.fla. , , .
skew.
, matrix box.
10.18.5.
:
, ;
clear(). :
this.createEmptyMovieClip("clip",0);
clip.lineStyle(3,0xFF0000);
//
clip.moveTo(300, 50);
clip.beginFill(0x881D00);
clip.lineTo(100, 100), clip.lineTo(150,200), clip.lineTo(300,50);
clip.endFill();
clip.onPress=function():Void{
//
this.clear();
}
endFill() lineStyle() . , ,
.
10.19. . Color
Flash
Color. , , . ActionScript Color.
Color, , .
. Color .
, Color, . .
10.19.1.
: ( RGB) (CMYK). Flash .
, ,
. , ,
.
.
(). , - , , , , , .
, , ,
.
Flash RGB.
. , , ,
, , , . , ,
(, ).
RGB : Red , Green Blue . 0 255, 16 .
, , .
, . , ,
, , , .
. 10.20.
. 10.20. RGB
, (0,0,0) (1,1,1) , .
, .
RGB- , , (. .
, ). ,
. . 10.21.
, , :
.
, , .
, , .
, 16
( -), ,
( ), .
. 10.21. RGB-
,
, rgb.swf
10. RGB-, ,
, .
WEB- RGB . 0 9
F. , 6 ( ). 00, 255 FF. 000000,
FFFFFF, FF0000.
HSB.
, , . , , . . 360 ( 0, 60, 120 . .).
, .
, . 0 , 100
.
, . . 0 .
HSB RGB, . . , .
( Brightness ).
Flash MX 2004 RGB. HSB Color Mixer. ,
RGB HSB.
Flash- RGB. . , , , .
HSB-, RGB.
10.19.2.
. , , , ,
Color Mixer.
. .
24 .
Flash-. 8 , 9 16 , 17 24 . , :
111010001110110010001100
. 2n. , , , , .
, (,
). 24- 6 0 F. ,
, .
:
trace(parseInt("111010001110110010001100",2).toString(16));
// : 88
, . ,
256 (28), 0 FF. , 24 , 16 777 216 (224).
, 0 (0x000000 ) 16 777 215 (0xFFFFFF
), .
, Math.random(),
, :
function randornColor () :Number {
return Math.round(Math.random()*0xFFFFFF);
}
trace(randomColor().toString(16)); // : 652bab
, 24- , , . , , , , .
- 8- 24. . , , , :
function RGB(R:Number, G:Number, :Number):Number {
// : ffffff
,
( ). 8-
24-, . :
1. 16 .
.
2. 1, 8 .
3. ,
, .
4. . .
:
function RGB(R:Nuraber, G:Nuinber, B:Number):Number {
return R << 16 | G << 8 | B;
}
trace(RGB(255, 255, 255).toString(16);
// : ffffff
,
.
, . 0xFF.
, 8 . , :
function G(color:Number):Number {
return (color >> 8) & 0xFF;
}
trace(G(0x00FF00).toString(16));
// : ff
, .
24- , 8 , ,
. , , :
function newG(color:Number, G:Number):Number {
var col:Number = color & 0xFF00FF;
var g_s:Number = G << 8;
return col | g_s;
}
trace(newG(0xAAFF11, 0x77).toString(16)); // : 7711
, . , ,
.
10.19.3. . setRGB()
setRGB() ( ) .
, Color, . Color:
var color:Color=new Color(_root.clip);
setRGB() RGB- , :
color.setSGB(0xFF0000); // _root.clip -
setRGB() (. 10.22). :
50 %, 100 %, setRGB().
, alpha Color , setRGB().
setTransform() Color Advanced Color setRGB() .
, , getRGB().
setRGB() , gctRGB() 0 (
, ). getRGB()
, Tint, Advanced Brightness Color ( setTransform Color). .
, setRGB() gctRGB() .
setRGB() , , .
ActionScript ,
setTransform() Color.
10.19.4. . setTransform()
, 100 . ,
, . '
, . ,
setRGB(). (
, )
ball. :
var color:Color = null;
for (var i = 0; i<100; i++) {
this.attachMovie("ball", "ball"+i, i, {_x:550*Math.random(),
_y:400*Math.random()});
color = new Color(this["ball"+i]);
color.setRGB(0xFFFFFF*Math.random());
};
, ,
.
, . setRGB()
, . , ?
, . , Color .
Tint Advanced.
, ,
. Tint
. .
Advanced (. 10.23):
. , :
, . 0 255.
. , 255, - ,
255 - .
, , . (255),
(0). ( , 255, 255), . , , (, , ), . . ,
, R 255.
,
. 100 -100, . .
, ( Advanced Effect).
Advanced Effect. , 0 -
, ?
, swf-.
, (addition) (multiplications transforms).
Advanced Effect, .
:
R = R parR / 100
G = G parG / 100
B = B parB / 100.
R, G, ; R', G', ' ; parR, parG, parB Advanced
Effect.
. , N %,
%, X-NM/10000, X . , . : .
, Advanced Effect
, : .
.
, .
, , ActionScript
:
R_new = Math.max(0, Math.min(R + parR, 255));
G_new = Math.max(0, Math.min(G + parG, 255));
B_new = Math.max(0, Math.min(B + parB, 255));
. , ,
.
Advanced Effect ( ) , Alpha (). ,
( , alpha 8- , R, G ).
Advanced Effect? , ActionScript
, setTransform() Color().
8 :
ra,ga,ba,aa 100 100, , ( ). Advanced Effect;
rb, gb, bb, ab -255 255, , ( )
ab , , , ( ).
. (. 10.24)!
. 10.24.
, aa , getTransform(), , setTransform(). , , - .
getTransform() , , Color .
10: 3D-
Flash , 3D-rpa. swf, , . : ?
, 3D- .swf:
3D-.
Flash ( ),
swf- . :
. :
3D- .
3D- ActionScript. .
: , ,
. : .
ActionScript , , Flash-. . , 3D-. , ,
, createPolOut.swf 10 .
3D- ActionScript . . :
, . , , , . : , 3D- , .
,
( , ). . , , . , , , , , .
Flash (. 9.5),
.
. , ,
:
x = x + 0,5 z sin(45),
y = y + (0,5 z cos(45).
9, . .
. , , . , . , . ,
. ,
.
3D- , , , .
, ,
:
k = F /(F z).
F Z (
1000 ); z Z. z , k ,
. , , , .
, z , , 0.
, , , :
x = ( x + 0,5 z sin(45)) k,
y = ( y + (0,5 z cos(45))) k.
, . ,
, . , . , , . , , , , , .
. , , ,
.
, , z.
, , . 10.25.
var points:Array = [];
//
//
points[0] = [[0, 0, 0], [0, 100, 0], [100, 100, 0], [100, 0, 0]];
//
points[1] = [[0, 0, 0], [0, 0, -100], [0, 100, -100], [0, 100, 0]];
//
points[2] = [[0, 0, 0], [0, 0, -100], [100, 0, -100], [100, 0, 0]];
//
points[3] = [[100, 0, 0], [100, 0, -100], [100, 100, -100], [100, 100, 0]];
//
points[4] = [[0, 100, 0], [0, 100, -100], [100, 100, -100], [100, 100, 0]];
//
points[5] = [[0, 0, -100], [100, 0, -100], [100, 100, -100], [0, 100, -100]];
. , , . points
, .
, , 3 :
(points), - (clip), , (lineSt).
3: thickness , rgb , alpha .
Puc. 10.25. Bu
, draw,
. , .
, .
, rgb alpha lineSt , :
if (lineSt.rgb == undefined) {
lineSt.rgb = 0;
}
if (lineSt-alpha == undefined) {
lineSt.alpha = 100;
}
:
clip.linestyle(lineSt.thickness, lineSt.rgb, lineSt.alpha);
, :
var points_length:Number = points.length;
for (var i = 0; i<points_length; i++) {
, , . moveTo(), :
per_kof_0 = 1000/(1000+points[i][0][2]);
//
clip.moveTo((points[i][0][0]+points[i][0][2]/kof)*per_kof_0,
(points[i][0][1] - points[i][0][2]/kof)*per_kof_0);
kof .
:
var kaf:Nu.Tiber = 2*Math.SQRT2;
, :
for (var j - 1; j<numb_points; j++) {
per_kof = 1000/(1000+points[i][j][2]);
clip.lineTo((points[i][j][0]+points[i][j][2]/kof)*per_kof,
(points[i][j][1]-points[i][j][2]/kof)*per_kof);
}
, j
:
clip.lineTo(points[i][0][0]+points[i][0][2]/kof, points[i][0][1]points[i][0][2]/kof);
. :
this.createEmptyMovieClip(clip, 0);
o.draw(clip, points,(thickness:3,rgb:0xFF0000, alpha:100});
. ! (. 10.26)!
o.draw()
, , ,
,
, .
, 3D-
.
. 10.26.
,
beginGradientFill(). , , , .
3D-.
? .
?. , .
.
, X
;
x = x ,
y = y cos( ) z sin( ),
z = y sin( ) z cos( ).
(3)
, , z ; , , z .
,
. ( ), . , , . 5 . ,
, .
-, . ,
, .
, , , , .
, .
, ,
:
x = a * x + b * y + c * z + p1
y = d * x + e * y + f * z + p2
z = h * x + g * y + i * z + p3.
, b, , d, e, f, h, g, i ; p1, 2, 3 .
. , , , z, , ,
, :
,
, , , .
, , .
, , n-
n- .
a b c p1 x
d e f p2 y .
z
g h i p3
1
(4)
.
n- n- .
x
x a b c p1
y
y = d e f p2 .
z g h i p3 z
1
(5)
, ,
. , : . , . , ,
.
,
,
. , ,
. .
3x4 (5) . ,
. , X 9
(3):
0
0
0
1
0 cos( ) sin( ) 0 .
0 sin( ) cos( ) 0
, , , . ,
, .
, ,
, . ,
, (
)-
. ,
. :
a
x
d
y =
z g
0
b c p1 x
e f p2 y
.
h i p3 z
0 0 1 1
,
9 (x1, y1, z1):
1
0
0
0
1
0
0
0 x1 1
0
0
0 y1 0 cos( ) sin( )
1 z1 0 sin( ) cos(0)
0 1 0
0
0
0 1
0
0
x1
0 0 cos( ) sin( ) y1
.
0 0 sin( ) cos( ) z1
1 0
0
0
1
(AB BA). , , , . , , , (, , ). ,
: , , .
, .
, , .
, . 16 (
matrix beginGradientFill()) , , . . , :
var matrixRotatX:Array = [
[1,
[0,
[0,
[0,
0,
1,
0,
0,
0,
0,
1,
0,
x1],
y1],
z1],
1]];
, , , . , , . ( ) N . C(i, j)
i- j-ro
. , C(i, j)
:
C(i, j) = A(i,0) B(0, j) + A(i,1) B(1, j) + A(i,2) B(2, j) + A(i,3) B(3, j).
, , 44 :
//
o.matrMult = function(a:Array, b:Array}:Array {
var matrix:Array = [[], [], [], []];
for (var i = 0; i<4; i++) {
for (var j = 0; j<4; j++) {
matrix[i][j] = a[i][0]*b[0][j]+a[i][1]*b[1][j]+a[i][2]*b[2][j]+
a[i][3]*b[3][j];
}
}
return matrix;
};
,
. : points ,
transformObject ,
. :
shift. . , : [x1, y1, z1];
scale. .
: [Sx, Sy, Sz];
rotation. . :
[, rY, rZ].
o.createTransform= function(points:Array, transformObject:Object):Array {
, transformObject ,
points - :
//
//
if (tr.shift == undefined && tr.scale == undefined && tr.rotation == undefined) {
return points;
}
var tr:Object = transformObject;
transformObject ,
. 4x4 ( (), () : ( A E = A ):
var matrix:Array = [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]];
, , shift transformObject, . , ,
matrix:
if(tr.scale[0]*tr.scale[0]+tr.scale[1]*tr.scale[1]+tr.scale[2]*tr.scale[2]>0)
{
var shiftMatrix:Array = [
[1, 0, 0, tr.scale[0]],
[0, 1, 0, tr.scale[1]],
[0, 0, 1, tr.scale[2]],
[0, 0, 0, 1
]];
matrix=o.matrMult(matrix, shiftMatrix);
}
scale ,
, :
if(tr.scale[0]*tr.scale[0]+tr.scale[1]*tr.scale[1]+tr.scale[2]*tr.scale[2]>0)
{
var scaleMatrix:Array = [
[[tr.scale[0], 0, 0, 0],
[0, tr.scale[1], 0, 0],
[0, 0, tr.scale[2], 0],
[0,
0,
0,
1]];
matrix = o.matrMult(matrix, scaleMatrix);
}
, 0 , rotation.
, ,
X, matrix:
if (tr.rotation[1]*tr.rotation[1]>0) {
//
var phi:Number = tr.rotation[0]/180*Math.PI;
var rotationMatrixX:Array = [[1,
0,
0,
[0, Math.cos(phi), -Math.sin(phi),
[0, Math.sin(phi), Math.cos(phi),
[1,
0,
0,
matrix = o.MatrMult(matrix, rotationMatrixX);
}
0],
0],
0],
0]];
, X, Y Z:
if (tr.rotation[1]*tr.rotation[1]>0) { // Y
var psi:Number = tr.rotation[1]/180*Math.PI;
var rotationMatrixY:Array=[[Math.cos(psi),
0, Math.sin(psi), 0],
[
0,
1,
0,
0],
[-Math.sin (psi), 0, Math.cos (psi), 0],
[
0,
0,
0,
1]];
matrix = .MatrMult(matrix, rotationMatrixY);
}
if (tr.rotation[2]*tr.rotation[2]>0) {
var thi:Number = tr.rotation[2]/180*Math-PI;
var rotationMatrixZ:Arrays[[Math.cos[thi), -Math.sin(thi), 0, 0],
[Math.sin[thi), Math.cos(thi), 0, 0],
[0,
0,
1, 0],
[0,
0,
1, 0],
, . .
:
var new_points:Array = [];
//
var points_length:Number = points.length;
// ,
for (var i = 0; i<points_length; i++) {
new points[i] = []; //
var points_i_length:Number *= points[i].length;
//
for (var j = 0; j<points_i_length; j++) {
var np:Array = new_points[i][j]=[];
//
//
var op:Array = points[i][j];
/* .
.*/
np[0] = matrix[0][0]*[0] + matrix[0][1]*[1] + matrix[0][2]*[2]
+ matrix[0][3];
np[1] = matrix[1][0]*[0] + matrix[1][1]*[1] + matrix[1][2]*[2]
+ matrix[1][3];
[2] = matrix[2][0]*[0] + matrix[2][1]*[1] + matrix[2][2]*[2]
+ matrix[2][3];
}
}
o.createTransform() :
return new_points;
. ( )
o.draw() o.createTransform() MovieClip:
MovieClip.prototype.createPolyhedronOutlines = function(points:Array,
lineSt:Object, transformObject:Object):Void {
var trans points:Array = .createTransform(points, transformObject);
.draw(this, trans_points, lineSt);
};
200 ,
45 :
var lineSt:Object = (thickness:3, rgb:0xFF000000, alpha:100);
var tr_obj:Object = (shift:[250, 200, 100], rotation:{45, 45, 45], scale:[2, 2, 2]
};
clip.createPolyhedronOutlines(points, lineSt, tr_obj);
<Ctrl>+<Enter>. ( 10.27)!
. 10.27.
createPolyhedronOutlines(), 3D. ,
. , -
. , , :
this.onEnterFrame = function():Void {
clip.clear();
tr_obj.rotationt[0] += 4, tr_obj.rotation[2] += 5, tr_obj.rotation[2] = 7;
clip.createPolyhedronOutlines(points, lineSt, tr_obj);
}
11
Flash? , : ~ . , ,
, swf- . , Flash , .
,
, MovieClip. ,
Button, . ,
, attachMovie(), .
, 4 ,
, . , .
.
Flash MX .
Button MovieClip.
. Button
MovieClip.
Button.
. ,
, Selection.
11.1.
, : typeof object, Button new :
var but:Button=new Button();
trace(typeof but);
trace(but
instanceof Button};
//
// : objt
// : true
, , Button, . ,
Button . , . <Ctrl> + <F8>. Behavior
Create New Symbol Button.
.
, ,
. , .
, . 4
(. 11.1).
Puc. 11.1.
Up . , , ,
(
enabled);
Over . , .
;
Down . , ;
Hit , . , . , . ,
.
.
. Hit , .
. ,
, .
. ,
.
, .
.
. ,
.
, . <F8>.
Create New Symbol.
, .
, , . Instance
Name .
11.2.
. , .
(. 11.2). , . , Shape Tween,
. ,
. , ,
. ,
, .
. 11.2.
, , . -
(,
). , , , .
, . , ,
instance1, instance2 . . ,
,
.
.
.
. , Button (. 11.3).
, . ,
attachMovie() removeMovicClip() MovieClip, Button .
,
. 26
getDepth() ( , ).
(. . 10.1). ,
, _ _, _width _height, _alpha. - _parent,
_name, _target.
, _currentframe (
), _framesloaded _totalframes (
), _droptarget ( , ).
, , Color.
, , .
, , , . , , , .
.
, .
. .
11.3.
, ActionScript. , .
Button 11 ; 9 .
onSetFocus on Kill Foe us ,
( 11.7.3).
onPress
onPress , , . -
Down. , onPress , .
, . onRelease.
onPress . , .
onRelease
onRelease . onPress, ,
. onPress, onRelease .
onRelease Over. ,
-.
onReleaseOutside
onReleaseOutside , ,
.
onRelease.
onReleaseOutside onRelease.
, , . , onRelease onReleaseOutside.
onRollOver
onRollOver .
Up Over (
). onRollOver , .
Button onRollOver . ,
. ,
. ,
, Over ( 11.8).
, onRollOver , .
onRollOut
onRollOut .
Over Up ( , ). onRollOut ,
.
on RollOut . --, Over Up,
. -, . -, ,
. ( ), . ,
onRollOut.
onDragOut
onDragOut onRollOut , ,
. onDragOut onRollOut,
,
.
onDragOver
, . ,
( onPress), , ,
( onDragOut), .
onDragOver onRollOver, . onDragOver onDragOut , (. 11.4).
onKeyDown onKeyUp
// but
// Key
but.onKeyDown = function():Void {
//
//
if (Key.getCode() == Key.SPACE) {
// ,
this.xscale *= 2, this._yscale *= 2;
}
}
11.3.1.
, , .
, , , , , , enabled.
. , , -,
. -,
,
.
,
. , :
.
.
.
,
.
, . , hitArea.
, onDragOver onDragOut,
Track As Button ( ) Track As Menu Item (
). 11.4.
11.3.2. Flash 5
Flash 5 ( ) , . :
on (event) {
statements
}
:
on , ,
;
event . , ,
on (, HeonPressn onDragOver, a press dragOver);
statements , .
:
on(press) {
trace("
}
!");
. 14 : <Backspace>, <Delete>,
<Down>, <End>, <Enter>, <Home>, <Insert>, <Left>, <PgDn>, <PgUp>, <Right>, <Space>, <Tab>,
<Up>.
:
on(keyPress "<Enter>") {
trace("!");
}
keyPress , , Key, ,
, .
4 onSetFocus, onKillFocus, onKeyUp, nonKeyDown
Flash 5. .
Flash 5 (. 8). . on(event) , , .
11.4.
, , , ,
. , , Over ( ), .
( onDragOver). ,
, .
. , . ,
, .
Windows, -
. ,
, ,
. , ,
?
Flash, , ,
Track As Menu Item.
. , , , Track As Button, .
Track As Menu :
,
Up ( onRelease).
.
(
) , Down. on Press .
, ,
onRelease , onReleaseOutside .
onDragOver , Track As Menu, ,
. .
, onDragOver , onRolIOver
. onDragOut ( onRollOut).
.
trackAsMenu. : true , false
.
trackAsMenu , . ,
, .
false.
11.5.
(. 11.3),
, .
. 11.3. () ()
. , , (
Over). - - . , ,
. ,
. , , onMouseDown hitTest(). onPress.
: ,
, ,
onRollOver. , , .
ActionScript ,
useHandCursor. : true - -, false -. useHandCursor true.
11.6.
.
, .
enabled. true, ( ). false, .
:
Over. , Down .
.
( onSetFocus onKillFocus).
, ,
enabled .
. ,
, onEnterFrame onMouseMove. enabled .
11.7.
Flash Macromedia, , web-. Flash- ( ) , usability (
) . , , , .
HTML- , ,
. <Tab>,
, , . , , . , <Tab>, <Shift> +
<Tab>. , . , .
, , <Enter>. ,
, .
, Flash
usability (. Flash is bad 99 %).
Flash- . Flash MX ( , usability)
swf-.
Flash- , HTML. <Tab>.
, (
). : , . ,
. , <Tab>, a <Shift> + <Tab>. (. 11.4).
. 11.4. ,
,
<Tab>, Flash (
, <Shift>+<Tab>, ).
, .
, Disable Keyboard Shortcuts Control .
<Tab> , .
.
.
Over. , <Enter> (
). onPress onReleasc ( ,
, ,
).
. ,
. : ,
, , ; .
2 . , .
<Tab> , . 13. Tab- .
11.7.1.
, ,
<Tab>. . setFocus(path) Selection, path .
Button, :
Button.prototype.setFocus = function():Void {
Selection.setFocus(this);
};
, setFocus() null.
, , ,
Selection.getFocus(). . , null.
getFocus() , , .
11.7.2. _focusrect
- . .
, , (, , ). .
_focusrect.
_focusrect : true , false
Over. _focusrect true.
Flash 5 _focusrect , . .
. Flash MX , . _focusrect , .
.
, ,
. 11.7.3.
// ,
clip.createEmptyMovieClip ("hoist", 10000);
with (clip.hoist) { //
lineStyle(thickness, rgb, alpha);
moveTo(coords.xMin, coords.yMin);
lineTo(coords.xMin, coords.yMax), lineTo (coords.xMax, coords.yMax),
lineTo(coords.xMax, coords.yMin), lineTo(coords-xMin, coords.yMin);
// ,
clip.holst.onMouseMove = function{):Void {
_root.newKillFocus(clip);
};
}
}
// , clip
function newKillFocus(clip:MovieClip):Void {
clip.holst.renroveMovieClip();
};
// mov
// ""
mov.onPress = function():Void {
trace (" !");
};
mov._focusrect = false;
//
mov.onSetFocus = function():Void { //
//
newSetFocus(this, 3, 0xAAAAAA, 100);
};
mov.onKillFocus = function():Void { //
newKillFocus(this);
};
, ,
. ,
. newSetFocus :
.
11.7.4.
, , , <Tab> (<Shift> + <Tab>)
. . , , .
.
, ,
tabEnabled. ( undefined) true, . tabEnabled false,
.
tabEnabled .
undefined.
, <>, , tabEnabled false,
, , . ,
Selection.setFocus().
tabEnabled , , false,
. , ,
. , Tab-
.
.
tabIndex. . . tabIndex, ( <>, <Shift> + <Tab>, ).
, tabIndex .
.
, , tabIndex . ,
tabIndex, .
tabEnabled tablndex: false,
, .
11.7.5.
, .
, .
.
, tabEnabled
true. ,
, (
- , tabEnabled false).
,
. , enabled
,
tabIndex. . ,
, tabChildren false.
undefined (. . ). ,
tabChildren true, .
, ActionScript , , Selection.setFocus(), , .
, focusEnabled
true.
focusEnabled , .
Selection.setFocus().
11.8.
Flash MX . Button MovieClip.
, ,
.
, . ,
. ,
. Over Down, , , -
, . , , , , ,
, -. - , . ,
, .
- , , , Tab-.
- .
Up, Over, Down, . Up , . Over . Down , .
- , , ,
, : _up, _over, _down. , , , . , .
, : ,
_down _up. .
, -
. , . , -,
, stop().
Up, Over, Down, . -
. , , . , , , _up _over, ( ). - .
hitArea.
hitArea ,
. Hit , . , , _visible false.
, ,
. - . , ,
, -.
-
Button , . , , , . -
. - ,
. - . hitArea,
- . , , -
, , .
11:
. ,
, .
, . , . , ,
fakel.swf 11 .
. ,
? , . , -,
, -, , , , . ,
, . , , . ,
.
? , . . .
, ,
. :
MovieClip.
(10-15 ) - .
. , . 80 %.
. ,
- - . , , , , . .
, Shape.
, . , 20 - (5060 %) .
.
. 3540- - (2030 %) .
2-3 .
.
, . ( ), alpha .
fla- fire0. ,
- .
, .
, , . ,
( Duplicate ),
. .
, : fire0, fire1, fire2, fire3.
, ,
. MovieClip,
:
MovieClip.prototype.fire = function(x:Number, ;Number, scale:Number, depth:Number) {
fire() , .
, depth ,
. setInterval() fire().
. , , ,
:
if (this.fr == undefined) {
this.createEmptyMovieClip("fir", depth);
this.fr = setInterval(this, "fire", 10, x, y, scale, detpth);
}
, . , :
var fire:MovieClip = this.fir.attachMovie("fire" +
Math.round(Math.random()*3), "fire"+n, n);
n , . ,
. , getNextHighestDepth():
var n:Number=this.fir.getNextHighestDepth();
n :
.
, . , .
:
fire._x=x+10*Math.random()*scale/100, fire._y-y+10*Math.random()*scale/100;
:
fire._xscale = fire._yscale=scale*Math.random();
(
). , ,
:
fire.step_y = 2*Math.random()+2;
. :
,
:
fire.alpha =2*Math.random();
, .
, . ,
X, step_x:
fire.step_x = 0.35*(Math.random()*2-l);
-1.
. .
,
onEnterFrame. , , . , :
fire.onEnterFrame = function():Void {
this._y -= this.step_y;
this._x += this.step_x;
this._alpha -= this.alph;
if (this._currentframe == this._totalframes) {
this.removeMovieClip();
}
. :
_root.fire(250,200,100,0);
, (. 11.5).
, .
.
.
,
(. 11.6, ). ,
, .
(. 10.6, ).
(. 10.6, b).
, , , , .
.
. 11.5.
. 11.6. ( )
.
, fakel.
:
// , ,
//
fakel.verh.swapDepths(1000);
fakel.fire(0, 0, 50, 0);
// ""
//
fakel.niz.onPress = function():Void {
fakel.startDrag();
};
//
fakel.niz.or.Release = function():Void {
StopDrag();
};
// onRelease
fakel.niz.onReleaseOutside = function():Void {
StopDrag();
};
. (. 11.7)!
, .
-
( 11)
, .
phon.
, :
, , 7080 %.
Brightness
Color .
fakel 350 . ,
.
mask.
. 11. 7.
mask phon.
, . , setMask():
phon.SetMask(fakel.mask);
. ,
450
, 1 .
,
. , svet
mask.
, svet
. :
function svet():Void {
fakel.svet._xscale = 100-25*Math.random();
fakel.svet._yscale = 100-25*Math.random();
fakel.svet._rotation = 180*Math.random();
}
setInterval(svet, 130);
. .
12
,
. ,
ActionScript ,
, , , ,
, . . Mouse Key. . ,
ContextMenu ContextMenultem, ,
( , ).
12.1.
Mouse Flash 5.
hide() show(). Flash MX, , Mouse
on Mouse Move, on MouseDown
nonMouseUp. . Flash MX 2004 onMouseWheel, .
Mouse,
(, _xmouse _mouse).
12.1.1.
, , ,
_xmouse ( X) _ymouse ( Y).
, :
// ball
var R:Number = 30, STEP:Number = 0.5;
// ,
//
_root.onEnterFrame = function():Void {
//
// step
phi += STEP;
//
ball._x = _xmouse+R*Math.cos(phi);
ball._y = _ymouse+R*Math.sin(phi);
};
_xmouse _ymouse : , , .
, _xmouse _ymouse , . ,
,
, _xmouse _ymousc .
, localToGlobal().
_xmouse _ymouse . ,
. ,
, . ,
, ( .
13).
, _xmouse _ymouse
undefined, . , .
.
, , .
, , , ,
_xmouse _ymouse.
, , . ,
550 , 200 , _xmouse 750 . ,
, .
12.1.2.
Flash 5 . , onClipEvent(event), mouseDown,
mouseUp, mouseMove. ,
. Flash MX
Mouse. ( ). ,
Mouse (,
onMouseWheel):
_root.onMouseDown = function():Void{ //
trace{" !")
}
, , , , Object,
addListener():
var obj:Object = {};
Mouse.addListener (obj);
obj.onMouseDown = function():Void { // ""
//
trace(" !");
};
, removeMovieClip().
Mouse , ,
Flash-. , onMouseDown,
onMouseUp, onMouseMove. , . , , , 12.1.5.
onMouseDown onMouseUp
onMouseDown ( ) . onMouseUp .
onMouseDown onMouseUp , ActionScript. . ,
, onPress
onMouseMove . , 100 . .
, onMouseMove , , , .
, onMouseMove
, .
, onMouseMove .
, ,
.
, onMouseMove , .
onMouseMove , ,
.
onMouseMove ,
- . , :
//
_root.onMouseDown = function():Void {
this.lineStyle(2, 0xFF0000);
//
this.moveTo(this._xmouse, this._ymousel;
//
this.draw = true;
// , ,
};
_root.onMouseMove = function():Void {
//
//
if (this.draw) {
// ,
//
this.lineTo(this,_xmouse, this._ymouse);
}
};
_root.onMouseUp = function():Void { //
//
this.draw = false;
};
, ,
. . onMouseMove. , , ( ,
curveTo()).
onMouseWheel
onMouseWheel . Flash-
onMouseWheel , .
12.1.3.
. hide() Mouse.
, show().
:
_root.onMouseDown = function():Void {
//
//
Mouse.hide();
};
_root.onMouseUp = function():Void { //
//
Mouse.show();
};
, . _xmouse _ymouse
.
hide() ,
. , ,
, .
hide() . . ,
I . , .
, hide() sbow(), . : , . , :
// (20-25 }
// , coord.
// cursor.
cursor.swapDepths(100000);
// -
//
Mouse.hide();
//
cursor.coord.eelectable^false;
// (
// )
cursor.onMouseMove = function():Void {
//
this.coord.text=Math.round(_xmouse} + ", " + Math.round(_ymouse);
// -
this._x=_xmouse, this._y=_ymouse;
updateAfterEvent();
//
};
. , .
, . ,
.
, 12.1.5.
, hide(),
,
.
selectable. ,
onRollOver. .
( onRollOut) .
12.1.4.
ActionScript Flash , .
, , , . , , on KeyPress Key. ,
. getCode(), , .
isDown(), , ,
. , , 1,
2:
// ""
this.onEnCerFrame = function():Void {
if (Key.isDown(1)) {
trace(" ");
} else if (Key.isDown(2)) {
trace(" ");
}
};
isDown(), ,
. , , AsBroadcaster, 8.
,
. ,
. , ,
. , -
, , ( Flash 7 . 12.2).
, .
.
Settings ( ) About Macromedia Flash Player ( ). . .
Flash MX 2004 ContextMenu, . onSelect . , :
// Output
var myMenu:ContextMenu = new ContextMenu();
myMenu.onSelect = function():Void {
trace(" !");
};
_root.menu = myMenu;
( ). .
.
12.1.5.
swf- , , .
. . , , , . , . -
, .
.
, , , , ( ), .
, :
, .
.
, .
onRollOut
, onRollOver.
,
onDragOut onDragOver.
,
useHandCursor.
broadcastMessage() AsBroadcaster (. 8), , , ,
:
// ,
_global.borderWatcher={};
// borderWatcher
AsBroadcaster.initialize (borderWatcher);
borderWatcher.init = function():Void {
//
var clipMovieClip = _root.createEmptyMovieClip("list clip" +
Math.random), 100000);
//
clip.lineStyle(1, 0, 0);
clip.beginFill(0, 0);
// clip
clip.moveTo(0, 0);
var xMax:Number = Stage.width, yMax:Number = Stage.height;
clip.lineTo(0, yMax), clip.lineTo(xMax, yMax), clip.lineTo(xMax, 0),
clip.lineTo(0);
clip.endFill();
clip.useHandCursor = false; // -""
// clip
// borderWatcher onStageRollOut
clip.onRollOut = function():Void {
borderWatcher.broadcastMessage("onStageRollOut");
};
// clip
// onStageRollOver
clip.onRollOver = function():Void {
borderWatcher.broadcastMessage("onStageRollOver");
};
};
// onStageRollOut onStageRoIlOver
borderWatcher.init();
//*********************************************************
// info
// info Stage
borderWatcher.addListener(info);
// info
info.onStageRollOut = function():Void {
this.text = " ";
};
info.onStageRollOver = function():Void {
this.text = " ";
};
. ,
. ,
:
, .
swapDepths() :
16384-. , .
onRollOul onRollOver,
.
onDragOver onDragOul.
, , _xmouse
_ymouse. ,
, . , ,
.
, . , ,
, . .
, .
12.2.
. ( Control
Macintosh). ,
.
, Flash- 4 .
,
. , , , , .
, , , . . , , -
, .
Movie not loaded ( ) About Macromedia Flash Player (
Flash-).
Flash MX 2004 ActionScript ,
.
. , ,
. . , , , .
,
( ,
). Flash 7 ContextMenu ContextMenuItem, . , , , . .
12.2.1. . ContextMenu
Flash MX 2004 , . - .
ContextMenu, :
var myMenu:ContextMenu = new ContextMenu([handler]);
handier , ,
, .
, , (object),
ContextMenus (cont_menu). onSelect, :
myMenu.onSelect=function(object, cont_menu:ContextMenu){}
handler onSelect ,
, .
.
- , , .
menu, MovieClip, Button
TextField. menu undefined null, , .
// Output
var myMenu:ContextMenu = new ContextMenu[handler);
_root.menu = myMenu;
function handler():Void {
trace(" ");
}
,
-.
, , ,
.
, .
, , , (play, rewind .) ,
, ,
( ).
ContextMenu .
, . . ActionScript
, =. , forin.
ContextMenu , ().
:
// clip1 clip2
// clip1 print
var myMenu1:ContextMenu = new ContextMenu(handler);
myMenu1.builtInItems.print = false;
// clip2 clip1
// , quality
var myMenu2:ContextMenu = myMenu1.copy();
myMenu2.builtlnltems.quality = false;
clip1.menu = myMenu1;
clip2.menu = myMenu2;
, , - quality . , , (), - .
. ()
, , builtInItems
, . :
trace(nyMenu1==myMenu2);
// :
false
trace(myMenu1.builtInItems==myMenu2.builtInItems);
//
true
, builtlnltems false.
true . :
// {
// , )
var myMenu:ContextMenu = new ContextMenu();
with (myMenu.builtlnltems) {
play = forward_back=rewind=loop=false;
}
_root.menu = myMenu;
builtInItems, :
Settings ( Flash-) About Macromedia Rash Player ( ), Settings ; , , . , , swf-,
. About Macromedia Flash
Player, . , Debugger ( ) .
, , . ,
. , Macromedia -, Flash - , About
Macromedia Flash Player.
builtInItems
. ,
, , ,
.
, ,
, builtInItems for
in, false.
ASSetPropFlags(), builtInItems (
):
var myMenu:ContextMenu = new ContextMenu();
for (var i in myMenu.builtInItems) {
myMenu.builtInItems[i] = false;
}
_root.menu = myMenu;
.
, :
Stage.showMenu=false;
//
ContextMenu. . , , , .
swf- HTML-,
, ActionScript. false
menu <OBJECT> ( EMBED):
Flash,
HTML- Display Menu HTML Publish Settings.
,
, .
hideBuiltInItems() ContextMenu. :
//
// "", Output
//
var myMenu:ContextMenu = new ContextMenu();
var myItem:ContextMenuItem = new ContextMenuItem("", function ()
{trace("");}));
myMenu.customltems.push(myItem);
myMenu.hideBuiltInItems();
//
_root.menu = myMenu;
hideBuiltInItems()
builtInItems false. , ,
, , builtInItems true:
// print
var myMenu:ContextMenu = new ContextMenu();
myMenu.hideBuiltInIterns();
myMenu.builtInItens.print=true;
_root.menu = myMenu;
hideBuiltInItems() . ActionScript
- ( Dynamic Input ).
, ActionScript. , Flash- , . ?
, , ,
, , . . , , , . ( , . .), , , . , ,
. .
. , play rewind
. , back rewind, . . , , . ,
. play, , . , , . , ,
, -
.
, . ,
(, Full Screen ). -
ContextMenu . ,
showMenu Stage
showmenu fscommand().
. , . . . , ,
:
Stage.showMenu=false;
12.2.2.
o Flash MX 2004 .
, : ( , , , ).
ContextMenuItem.
ContextMenultem .
:
var myMenuItem:ContextMenuItem=new ContextMenultem (caption, callback_func,
separator_before, enabled, visible);
:
caption (, , ).
100 .
(
). .
. , , caption :
.
.
.
. . , . ,
( ). , , ,
.
(. . Loop ,
loop). , ,
, (
).
fscommand("quit", "");
}
// ,
var myMenuItem2:ContextMenultem = new ContextMenuItem("Co ",
func_letter, true);
function func_letter():Void {
getURL("mailto:diis_ignotis@tut.by");
}
// customltems
myMenu.customItems.push(myMenuItem1);
myMenu.customItems.push(myMenuItem2);
. 12.1.
ContextMenuItem .
( ,
). ContextMenuItem,
( ),
(). ,
:
//
var myMenu:ContextMenu = new ContextMenu();
myMenu.hideBuiltlnltems();
_root.menu = myMenu;
var myMenuItem1:ContextMenuItem = new ContextMenultem(" ",
func,true);
//
var myMenuItem2:ContextMenuItem = myMenuItem1.copy();
myMenuItem2.caption = " "; //
function func (obj, menu_item:ContextMenultem):Void {
if (menu_item == myMenuItem1) {
fscommand("quit", "");
} else {
getURL("mailto:diis_ignotis@tut.by");
}
}
myMenu.customItems.push(myMenuItem1, myMenuItem2);
ContextMenuItem , .
ContextMenuItem(), :
caption , ;
enabled , , ;
separatorBefore , , ;
visible , , .
,
. , ,
, .
:
var myMenu:ContextMenu = new ContextMenu();
Object.prototype.menu = myMenu;
//
//
// ,
//
var myMenuItem:ContextMenuItem = new ContextMenuItem(null, func);
myMenu.onSelect = function(obj):Void {
myMenuItem.caption = " "+obj;
};
//
function func(obj):Void {
obj._xscale *= 2, obj._yscale *= 2;
}
myMenu.customItems.push(myMenuItem);
, .
- , , .
12.3.
Flash. keyPress.
, . :
on(keyPress "A") {
trace(" ");
}
12.3.1.
Flash-
, . .
, ,
. , swf- HTML-.
, .
.
:
, .
, .
,
, focus() JavaScript.
.
Flash-, , .
. , , <Ctrl> + <F>. ,
<s>, .. -
, , . ,
<Esc>, onKeyDown . <CtrI>+<F> <Clrl>.
, (, <Esc> ). ,
:
fscommand("trapallkeys", "true");
, .
, <Alt> + <Tab>, . <> +
<F4> . <b> HTML-
. <Esc>, , .
, . <Ctrl> <b>.
Flash. , , <b>
<Esc>. , Disable Keyboards Shortcuts Control. ,
, fscommand() .
Key , removeListener().
Flash 5
. . . , Flash 5:
onClipEvent(keyDown) { //
this._visible=false;
}
, .
-, , onKeyDown onKeyUp;
this.createEmptyMovieClip("clip", 0);
//
clip.onKeyDown = function():Void {
trace(" !");
};
To, , , -, ,
, . , , Flash
. , ,
onKeyDown onKeyUp, ,
:
//
clip.focusEnabled = true;
//
Selection.setFocus(clip);
//
//
clip.onKeyDown = function():Void {
this._xscale = this._yscale *= 2;
}
onKeyDown onKeyUp,
- . , . ,
n , setFocus() Selection,
. . ,
.
onKeyDown onKeyUp , , . , , , Key addListener(). To
( Flash MX 2004 onKeyDown
onKeyUp).
, onKeyDown
onMouseDown. . onMouseDown
. ,
, .
onKeyDown
, . onKeyDown 30 10
.
, ,
onKeyDown onKeyUp .
onKeyDown onKeyUp, , -
. ,
getCode() getAscii() Key. .
12.3.3. . getCode()
, . ,
. , ,
. . , ? ,
? ,
? ?
, .
.
.
Windows , . , 0 9 48 57, <Enter> 13, <b> 9, <Ctrl> 17. , Z 0 9 ASCII. .
ActionScript , getCode()
Key. :
Key.addListener(this);
//
<Enter>
Output
this.onKeyDown = function():Void {
if (Key.getCode() == 13) {
trace(" <Enter> ");
}
};
, getCode() 0.
getCode() onKeyDown onKeyUp. ,
, , .
getCode() , .
, F, 70.
,
, getAscii().
getAscii(), getCode() . , , . ,
. getCode() :
,
. -;
Macintosh Windows.
Windows ( 1 2). getCode() . (, ), isDown(),
,
Key , .
. , (. 12.1).
12.1
BACKSPACE
CAPSLOCK
CONTROL
DELETEK.EY
DOWN
Key
8
INSERT
20
LEFT
17
PGDN
46
PGUP
40
RIGHT
45
37
34
33
39
END
ENTER
ESCAPE
HOME
35
13
27
36
SHIFT
SPACE
TAB
UP
12.1
16
32
9
38
Key , <Esc>:
fscommand("trapallkeys", "true");
//
// <Esc>
Key.addListener(this);
this.onKeyDown = functiont):Void {
if (Key.getCode() == Key.ESCAPE) {
fscommand("quit");
}
};
12.3.4. . getAscii()
, , .
getCode() . , 4
, , . ,
getAscii() Key:
// '' Output
Key. addListener(this);
this.onKeyDown = function():Void {
if (Key.getAscii() == "A".charCodeAt(0)) {
}
};
. , , ,
: getAscii() .
. , .
, , getAscii(). getCode().
,
onKeyDown , getAscii(), .
? , , charCodeAt() String, . , Unicode, .
:
Key.addListener(this);
this.onKeyDown = function():Void { // ,
trace(Key.getAscii());
};
12.3.5. . isDown()
isDown() , .
. isDown() : true
, false . :
this.onEnterFrame = function():Void {
// <Enter> Output
//
if (Key.isDown(Key.ENTER)) {
trace(" !");
}
};
, isDown() . ,
, getCode() getAscii(). , isDown() . , , , getCode() gctAscii().
isDown() , .
. , ,
. , isDown(), .
:
// ball
this.onEnterFrame = function():Void {
if (Key.isDown(Key.LEFT)) {
//
ball._x -= 3;
}
if (Key.isDown(Key.RIGHT)) {
//
ball._x += 3;
}
if (Key.isDown(Key.UP)) {
//
ball._y -= 3;
}
if (Key.isDown(Key.DOWN)) {
ball._y += 3;
}
//
};
isDown() , ,
, , , onKeyDown getCode(). , (, ).
isDown() . , ,
, .
onEnterFrame setInterval(), 2
ActionScript (. 12.1.4).
12.3.6. . isToggled()
3 , , Caps Lock ( ), Num Lock ( ), Scroll Lock
( ). , . , , getCode() isDown(), (
). isToggled().
isToggled() .
: Caps Lock 20, Num Lock 144, Scroll Lock 145. Caps Lock
, Key.CAPSLOCK. isToggled() : true , false .
isToggled() , true
( ).
, . , Caps Lock getAscii(),
Num Lock getCode(). , , ,
.
12:
, ActionScript, ,
( ), .
, .
, . . , , . ,
.
, , ,
elastic.swf 12 . ,
, .
, . - 20 . ball.
.
. . , onPress,
onRelease onMouseMove. .
ball , MovieClip,
. Object.registerClass():
// ,
//
// ball Balls
Object.registerClass("ball", Balls);
Balls.prototype = new MovieClip();
// Balls MovieClip
function Balls():Void {
, . , . . ,
,
. , :
var cords:Array= [[200, 200], [400, 200], [400, 400], [200, 400]];
var sv:Array = [[1, 2], [2, 3], [3, 4], [4, 1]];
createElastik(), :
function createElastik(coord:Array, sv:Array):Void {}
createElastik() .
, Balls, ,
, arr_ball, ( ):
arr_ball = [];
//
this.clear();
//
// ,
for (var inst in this) {
// Balls,
if (this[inst] instanceof Balls) {
this[inst].removeMovieClip();
}
}
, coord,
ball. :
for (var i = 0; i<coord.length; i++) {
this.attachMovie("ball", "ball"+i, i, {_x:coord[i][0], _y:coord[i][1]});
}
,
, . ,
, . , ,
, ,
, .
, sv :
var b1:MovieClip=null, b2:MovieClip=null, normal:Number=null;
:
drawLines();
drawLines(), , , . :
function drawLines():Void {
this.clear();
// ""
//
for (var i = 0; i<arr_ball.length; i++) {
//
this.lineStyle(5, 0x000039);
//
this.moveTo(arr_ball[i][0]._, arr_ball[i][0]._y);
this.lineTo(arr_ball[i][1]._x, arr_ball[i][1]._y);
}
}
, , ,
. , , , ,
. .
. : ,
. . , .
, .
. .
, . (L) , (k):
F = Lk.
,
( , )
(. 12.2).
. 12.2.
( L 0 , L d )
, , ,
. , . , :
Fx = F x / L;
Fy = F y / L,
x y X Y; L
.
.
. ,
, , . :
, . , .
, ,
+, . , , ,
+. :
zn _ x = ( x1 x 2) /(| x1 x 2 |)
zn _ y = ( y1 y2) /(| y1 y2 |)
V1x = V1x + zn _ xVx
V1y = V1y + zn _ yVy
V 2 x = V 2 x + (zn _ xVx )
V 2 y = V 2 y + (zn _ yVy ).
zn_x zn_y ; x1 y1
; 2 2 ; V1x V1y
; V2x V2y .
, .
, , , .
,
:
V = V V kof t (kof - ).
. , ( ). t 1:
var kof:Number = 0.97; //
var upr:Number = 0.05; //
var m:Number=50;
//
function elast():Void {
//
var delta_x:Number = null, delta_y:Number = null, r:Number = null,
rast:Number = null, ax:Number = null, ay:Number = null, zn_x:Number = null,
zn_y:Number = null, b1:MovieClip = null, b2:MovieClip = null, normal:Number = null;
//
for (var i = 0; i<arr_ball.length; i++) {
// b1 , b2 , normal
//
b1=arr_ball[i][0], b2=arr_ball[i][1], normal=arr_ball[i][2];
// delta_x delta_y - X Y
delta_x=b1._-b2._, delta_y=b1._-b2._;
//r -
r = Math.sqrt(delta_x*delta_x+delta_y*delta_y);
// ( L )
rast = -normal+r;
// X
fx = upr*rast*Math.abs(delta_x/r);
// no Y
fy = upr*rast*Math.abs(delta_y/r);
//
// . ,
// 0.
// X
rn_ = (delta_x+1)/Math.abs[delta_x+1);
// Y
zn_y = (delta_y+1)/Math.abs(delta_y+1);
//
b1.vx -= zn_x*fx/m,
b2.vx += zn_x*fx/m;
b1.vy ~= zn_y*fy/m,
b2.vy += zn_y*fy/m;
//
b1.vx *= kof, b1.vy *= kof, b2.vx *= kof, b2.vx = kof;
// , ,
// ( flag).
if (b1!- flag) {
b1._ += b1.vx, b1._ += b1.vy;
}
if (b2!= flag) {
b2._x += b2.vx, b2._y += b2.vy;
}
}
drawLines();
// ""
}
onEnterFrame ( ,
):
this.onEnterFrame = function():Void {
elast();
}
.
. elast()
, flag:
//
Balls.prototype.onPress = function() {
flag=this;
// ,
this.startDrag (false);
//
};
startDrag.
.
flag:
Balls.prototype.onRelease = function():Void {
flag = false;
this.vx = this.vy=0;
this.stopDrag();
};
// onReleaseOutside onRelease
Balls.prototype.onReleaseOutside = function():Void {
flag = null;
this.vx = this.vy=0;
this.stopDrag();
};
.
,
:
this.onMouseMove = function():Void {
if (flag) {
// ,
elast();
//
updateAfterEvent();
//
}
};
, .
, . ,
, fla- 12 .
13
Flash , , , . . , , .
web-, 10 , , .
, . , Flash . .
Flash , .
3 :
Static, . ,
, .
. .
Dynamic. . , ,
, ,
(, ).
Input. . .
(, ).
. , ,
. Dynamic Input
. ,
, . , , ,
Dynamic Input ,
, .
Static ActionScript. -
MovieClip Graph. , Flash MX 2004
(, , ), TextSnapshot. , .
. . ActionScript 13.15.
. , (. 13.1). ,
, .
.
. 13.1. () (b)
.
ActionScript. , , , .
ActionScript, , . . , Dynamic Input
. Static .
.
Dynamic Input .
TextFicld.
,
. , .
Text Field. .
ActionScript. ,
TextFormat.
(CSS) StyleSheet. , ,
Selection. , ,
, .
Textsnapshoi. .
13.1.
Flash MX ,
Text, , ActionScript. ,
, . .
.
13.1.1. Text
, :
Tools Text ( <>).
.
. , :
o ,
(. 13.1, 1)
o ,
, ( Text). , Dynamic Input .
Free Transform. , ;
o , ,
Arrow;
o , , , ,
TextField TextFormat.
.
13.1.2.
Flash 5 ,
. Input Dynamic , , , .
, .
, . .
Var (. 3.1, 3)
, . ,
. , , . , . , . : . []
Var .
. ,
, scroll :
// , pole_var,
pole_var.scroll+=5;
, ,
, .
Flash MX ,
. .
,
. . .
: , ,
.
, Var,
, . , ,
. , ( ).
. variable TextField. , .
:
// : ""
this.createTextField("pole",0,200,200,50,30);
//
//
var per:String = "";
// ,
//
pole.variable="per";
//
Flash MX
text TextField.
13.1.3.
Flash MX Flash 5 , ,
. . createTextField() MovieClip.
:
clip.createTextField(name, depth, x, , width, height)
:
clip , ;
name ;
;
width height .
, MovieClip, TextField, . . . ,
(. 13.3).
createTextField() . , type TextField,
. : dynamic ( )
input ( ). :
this.createTextField("pole", 0, 200, 200, 80, 30); //
trace(pole.type);
// : dynamic
pole.type = "input";
//
pole.text=" "; //
//
. , .
, , Dynamic Input.
.
. , .
variable.
Text . , , , .
, TextField, StyleSheet TextFormat.
. (. 13.2):
//
//
pole.text = " ";
//
pole.textcolor = 0x000099;
//
pole.background = true;
//
pole.backgroundColor = 0x188189;
//
pole.border=true;
//
pole.wordWrap = true;
//
var format:tFormat = new TextFormat(); //
format.size = 20;
//
format.font = "Times New Roman Cyr";//
format.align = "center";
//
pole.setTextFormat(format);
//
this.createTextField("pole", 0, 200, 200, 10, 80);
. 13.2.
TextField TextFormat. ,
, .
13.2.
, removeTextField() TextField.
:
this.createTextField("pole", 0, 200, 200, 180, 80);
pole.removeTextField();
//
trace(pole);
// : undefined ( )
removeTextField() removeMovieClip(). :
ActionScript , removeTextField() . . , ,
. , removeTextField() , . ,
, swapDepths()
. ,
, . , getDepth()
:
trace(pole);
// : _level0.pole ( )
this.createEmptyMovieClip("clip", 10000);
//
clip.swapDepths (pole. getDepth());
//
//
pole.removeTextField(); //
trace(pole);
// : undefined ( )
, ,
. :
this.createEmptyMovieClip("clip", pole.getDepth());
TextField MovieClip. , swapDepths():
trace(pole);
// : _level0.pole [ )
TextField.prototype.__proto__ = MovieClip.prototype; //
//
pole.swapDepths(10000);
//
//
pole.removeTextField();
//
trace(pole);
// : undefined ( )
removeTextField() , ,
1048575 (0xFFFFF). :
this.createTextField("pole",0xFFFFF+1,200,200,40,50); //
//
pole.removeTextField();
// trace(0xFFFFF);
// : _level0.pole ( )
13.3.
, Input Dynamic . Flash MX 2004 Flash 5,
,
. 9 ; , , .
. , _ _. :
this.createTextField("pole", 0, 0, 0, 80, 40);
// ,
this.onEnterFrame = function():Void {
pole._x+=2, pole._y+=3;
pole.text = "="+pole._x+", "+"y="+pole._y;
};
_rotation.
. , :
this.createTextField("pole", 0, 0, 0, 80, 40);
// ,
this.onEnterFrame = function():Void {
pole=_rotation+=4;
pole.text = "rotation="+pole._rotation;
};
, , ,
. .
, ,
, , . , . , , ,
.
swf- 20-30 , . . ,
. , Arial Cyr, :
New Font.
Font Font Symbol Properties .
,
Bold Italic.
, ,
-. ar_font.
Arial Cyr ,
, :
this.createTextField(pole", 0, 200, 200, 150, 40);
pole.embedFonts = true;
//
this.onEnterFrame = function():Void {
pole._rotation += 4;
pole.text = "rotation="+pole._rotation;
// 20-
pole.setTextFormat(new TextFormat("ar_font",20));
};
, _xscale _yscale. :
this.createTextField(pole", 0, 50, 50, 350, 40);
// 5%
this.onEnterFrame = function():Void {
pole._xseale=pole._yscale+=5;
pole.text= "="+pole._width + ", " + "=" + pole._height;
};
, . , , ,
. __xscalc _yscale, . , .
:
// Arial Cyr
// "ar_font"
this.createTextField("pole", 0, 50, 50, 350, 40);
pole.embedFonts = true;
//
//
this.onEnterFrame = function():Void {
pole._xscale += 1;
pole._yscale += 50;
pole.text = "="+l._width+", "+"="+pole._height;
//
pole.setTextFormat(new TextFormat{"ar_font", 20));
};
,
, Free Transform. .
, _xscale, _yscale _width, height
. _xscale _yscale ,
. _width
_height ,
. ,
, width _height , , . :
this.createTextField("pole", 0, 50, 50, 350, 40);
pole.border=true;
//
this.onEnterFrame = function():Void {
//
pole._width += 10, pole._height += 5;
pole.text = "="+pole._width+", " + "="+l._height;
};
_alpha. ,
:
// "font"
this.createTextField("pole", 0, 50, 50, 350, 40);
pole.embedFonts=true;
//
this.onEnterFrame = function():Void {
pole._alpha-=3;
// 3 %
pole.text="="+le._alpha;
pole.setTextFormat(new TextFormat("ar_font",20));
};
, _visible. :
this.createTextField("pole", 0, 50, 50, 350, 40);
pole.text = " ";
pole._visible = false;
//
_xmouse _ymouse.
. , ,
, :
this.createTextField("pole", 0, 50, 50, 350, 40);
pole-border=true;
//
this.onMouseMove = function():Void {
// ,
//
if (pole._xmouse>0 && pole._xmouse<pole._width && pole._ymouse>0 &&
pole._ymouse<pole._height) {
pole.text = " ";
} else {
pole.text=" ";
}
updateAfterEvent();
};
, ,
,
MovieClip. , ,
. ,
TextField. MovieClip
:
this.createTextField(pole", 0, 50, 50, 350, 40);
pole.text=" "; //
TextField.prototype.__proto__=MovieClip.prototype;
pole.startDrag(true);
//
, ,
, .
, - . , :
//
// "ball"
this.createTextField(pole", 0, 50, 50, 350, 40);
pole.text=", ";
TextField.prototype.__proto__=MovieClip.prototype;
pole.attachMovie("ball","ball",0,{_x:100,_y:100});
//
//
, , .
, , . ,
- . .
,
typeof object:
this.createTextField("pole",0, 0, 0, 10, 10);
trace(typeof pole);
// : object
, .
. . ,
movieclip, object (, , ), , .
13.4.
3 , :
, ( , ,
0:0), .
, , , . . :
this.createTextField("pole", 0, 200, 200, 100, 30);
var info:String = null;
pole.variable = "info";
this.onMouseMove = function():Void {
//
info = "X="+_xmouse+", "+"Y="+_ymouse;
updateAfterEvent();
};
//
//
//
//
, text, .
, , , .
, String. , ,
2. :
this.createTextField("pole", 0, 200, 200, 200, 30);
pole.text=new Dated;
// : Fri Nov 28 05:28:13 GMT+0200 2003
, , ,
text. :
this.createTextField("pole", 0, 200, 100, 200, 30);
pole.type = "input";
pole.text = " ";
// Output
pole.onChanged = function():Void {
trace(pole.text);
};
//
//
//
//
text. .
, . ,
, number, Number().
: text
. . , text . , , .
.
, .
13.5.
(.
13.1). , . , . ( ) -
. : .
, , ,
. , , , . . 13.6.
13.5.1.
, . , , , . createTextField().
. , . ActionScript
.
-, _width _height. -
, (
autoSize) . , ,
. , _width _height,
- , . ,
, . TextField textHeight ( ) textWidth ( ). , ( ) :
//
//
pole.type = "input";
//
pole.text = " ";
//
pole.multiline = true;
//
pole.border = true;
//
pole._width=pole.textWidth, pole._height=pole.textHeight;
//
//
//
pole.onChanged = function():Void {
this._width=this.textWidth, this._height=this.textHeight;
};
this.createTextField(pole", 0, 200, 200, 100, 30);
-, . autoSize TextField, :
none . ;
left .
.
. ;
center , ,
, . ,
. ,
, ;
right , left. .
. .
autoSize none left.
.
autoSize, : true
left, false .
, autoSize:
this.createTextField(pole", , 200, 200, 100, 30);
pole.type = "input", pole.text = " ", pole.multiline = true,
pole.border = true;
pole.autoSize="left";
, , , autoSize, _width
_height textWidth textHight.
13.5.2.
. ,
,
.
, true
border. false, .
. .
borderColor, ,
. :
this.createTextField{"pole", 0, 200, 200, 130, 25);
pole.text = " ";
pole.border=true;
//
pole.borderColor=0xFF0000;
//
.
, .
, true background. false.
.
, backgroundColor;
this.createTextField("pole", 0, 200, 200, 200, 25);
pole.text="oe ";
pole.border=true,pole.borderColor=0xFF0000;
pole.background=true;
//
pole.backgroundColor=0x009FF7;
// -
. ,
. 13.! 13. . -, . , ,
( ) ( ).
, , . , , .
13.5.3.
, , , ,
. . , .
, , . ,
, . , .
, , ,
. , . , escape \n (\u000a) newline (. 2).
, <Enter>.
, , \r (\u000d).
. ,
. ,
( <Enter>).
, - , ,
. , ,
, -. :
, ( . 13.1
17) Single Line ( ) Multiline no
wrap ( , ).
,
multiline TextField. : true ,
false .
,
. , ,
Single Line. -
, .
Input Multiline no wrap, , <Enter> <Backspace>. Single Line, : <Enter>.
. , , ,
. ,
, <Up>, <Down> .
Multiline no wrap .
Multiline, .
. , , . , ,
<Enter>. Multiline
Flash .
Multiline :
, . , . , .
Multiline , :
, multiline true.
. ,
true TextField wordWrap.
wordWrap false.
:
this.createTextField("pole",0,150,150,150,120);
pole.text=" Multiline .
,
.";
pole.border=true;
//
pole.multiline=true;
//
pole.wordWrap=true;
//
. 13.3.
. 13.3 .
, , .
ActionScript Text Format. 13.6.
13.5.4.
, , , , . , , 2
( , ),
3 ..
, . ,
, .
. Maximum Characters
(. 13.1, 20). 0.
, .
, , 1 , 65535 (0xFFFF).
, Input, . TextField maxChars. ( 1 65535). maxChars
0 ( null), (
). :
this.createTextField("pole", 0, 100, 100, 30, 20);
pole.type="input", pole.border=true;
//
//
pole.maxChars=3;
//
, -
, text .
. ,
, ,
. , , , .
, , , length String. , length TextField.
, :
this.createTextField{"pole", 0, 200, 200, 100, 30);
pole.text = "\t!", pole.border=true;
trace(pole.text.length);
// : 8
trace(pole.length);
// : 8
, , , . ,
.
13.5.5.
, ,
. ,
, , .
*.
Flash Macromedia, , .
, . , , . 13.1
17, Password. ( ) *.
. true TextField password:
this.createTextField("pole", 0, 200, 200, 100, 30);
pole.type="input",pole.border=true;
pole.password=true;
//
. , , multiline.
.
13.5.6.
.
, , . , , . ,
, ,
, , , ,
, . . -
NaN, .
,
. ,
, , . , . ActionScript,
, .
.
TextField restrict.
restrict ,
, . , ,
%:
this.createTextField("pole", 0, 200, 200, 100, 30);
pole.type="input", pole.border=true;
pole.restrict="0123456789 %"; //
//
, , , , . .
, .
, 0
9, . , ,
. restrict -, , . , 0 9
, :
pole.restrict="0-9a-aA-";
//
//
, restrict
. : Unicode- , .
Unicode , , . , . , , Unicode ,
, , :
pole, restrict="A-";
, restrict, ,
:
pole.restrict="a-z012345";
// z
// 0 5
, .
, (
), restrict,
. :
pole.restrict=""0-9 %"; // , 0 9
, .
, restrict, , , . , , , :
pole.restrict="A-z^rR"; // ,
// r
, restrict
. ,
, .
restrict Unicode-.
, ,
. :
pole.restrict="\u0030-\u0039";
// 0 9
restrict ^ - .
( ),
\.
\:
pole.restrict="\\^\\-\\\\";
restrict null. , .
text
restrict . .
, restrict, .
ActionScript. , Character Options,
Character (. 13.1,11), .
, ,
. swf- 13,7.
13.5.7.
. ,
I-. , , ,
.
() Select All ( ).
,
usability ( ). .
, L- , Flash-
. (, ), . ,
, ,
, I. onPress . .
, .
(. 13.1, 15). ,
. , .
. false selectable TextField. true . :
this.createTextField("pole",0,100,100,10,10);
pole.text=" ", pole.autoSize=true;
pole.selectable=false;
//
. .
selectable Input ( , ).
ActionScript , Selection. 13.13.
13.6. . TextFormat
. ,
, .
. , ActionScript ,
.
TextFormat. , new:
var format:TextFormat = new TextFormat(); //
TextFormat. 16 . . - ,
.
TextFormat .
, : Arial Cyr, 20 , .
var format:TextFormat = new TextFormat();
format.font="Arial Cyr", format.size=20, format.align="center";
TextFormat.
, TextFormat() 13(!) , . , , :
new TextFormat(font, size, color, bold, italic, underline, url, target, align, leftMargin, rightMargin, indent,
leading)
, , TextFormat(), . , , .
, , , , , . -
, ,
, .
TextFormat . , ,
,
. ,
null:
// Arial Cyr
var format:TextFormat = new TextFormat("Arial Cyr", null, null, null, true);
TextFormat , 16 , . ,
setTextFormat() TextField.
. :
this.createTextField("pole",0,200,200,0,0);
pole.autoSize=pole.border=true;
pole.text="
var format:TextFormat=new TextFormat();
//
format.font="Times New Roman Cyr";
//
format.size=15;
//
format.color=0xFF0000;
//
pole.setTextFormat (format);
//
";
, , setTextFormat(), ,
. , setTextFormat()
, .
, . ,
, .
,
setTextFormat() .
, , .
setTextFormat() , (
). , , setNewTextFormat() ( ).
TextFormat .
.
Flash 5 ,
. ,
HTML- (. 13.10). Flash MX 2004
, setTextFormat() ,
. :
pole.setTextFormat(startIndex, endIndex, textFormat)
:
startIndex , , ;
endIndex , ;
textFormat .
, (
, textFormat):
//
this.createTextField("pole", 0, 200, 200, 450, 30);
//
pole.text = " : http://site.com";
// HTML ( )
pole.html = true;
//
var formatSimpleText:TextFormat = new TextFormat();
with (formatSimpleText) {
font="Arial Cyr", size=15, bold=true, color=0x000067
;
//
var formatHyperlink:TextFormat = new TextForinat();
with (formatHyperlink) {
font="Tahoma", size=15, target="_blank", url="http://wnk.biz",
italic=true, underline=true, color=0x0000FF;
}
// formatSimpleText ,
// ":"
pole.setTextFormat(0, pole.text.indexOf(":")+1, formatSimpleText);
// formatHyperlink , ":"
pole.setTextFormat(pole.text.indexOf(":")+2, pole.text.length,
formatHyperlink);
. 13.4.
setTextFormat() ,
:
pole.setTextFormat(index, textFormat)
index .
, ,
- ,
( 1
, ).
, TextFormat setTextFormat()
, . , .
- (,
).
13.7.
.
. . . , , , (. 13.5):
// Arial Cyr ( Bold
// + Italic). "font".
this.createTextField{"pole", 0, 0, 100, 550, 300);
//
//
//
pole.text = " - ,\n , \n TextField TextFormat";
//
// ,
//
this.onEnterFrame = function():Void {
var format:TextFormat = null, size:Number = null;
//
//
for (var j = 0; j<pole.text.length; j++) {
size = 30*Math.abs(Math.sin(i+Math.PI/10*j));
format = new TextFormat("font", size, null, true, true, null, null,
null, "center");
pole.setTextFormat(j, format);
}
i += Math.PI/10; // ( "")
};
pole.embedFonts = true;
var i:Number = 0;
. 13.5.
TextFormat , .
, , , .
: ,
. , , , .
, .
getTextFormat() TextField. TextFormat, ( ) . setTextFormat().
getTextFormat() :
pole.getTextFormat();
pole.getTextFormat(startIndex, endIndex);
pole.getTextFormat(index);
//
//
//
getTextFormat()
. , , TextFormat ,
. null.
getTextFormat() , ,
startIndex
endIndex. ,
TextFormat .
, , ,
index.
getTextFormat() ,
, ,
getTextFormat()
TextFormat .
setTextFormat() , , .
.
. :
Times New Roman, 12, , ,
, .
, ,
. , . , . , setTextFormat()
.
setNewTextFormat().
setNewTextFormat() , ,
setTextFormat(). TextFormat. :
this.createTextField("pole", 0, 100, 100, 200, 30);
pole.type="input", pole.border=true;
//
pole.setNewTextFormat(new TextFormat("Arial Cyr", 20, 0xFF0000, null, true,
null, null, null, "center"));
//
this.onMouseMove = function():Void {
pole.text = "X="+ xmouse+", "+"Y="+ ymouse;
};
. ,
getNewTextFormat(). , ,
:
this.createTextField("pole", 0, 100, 100, 200, 30);
var style:TextFormat = pole.getNewTextFormat();
for (var i in style) {
trace(i+"="+style[i]);
// : font=Times New Roman, size=12,
// bold=false . .
13.6.1.
( ).
, Arial, Garamond, Times New Roman . .
, . . , , . .
0 ,
, . 13.1 5.
Windows , , -
.
, ,
( ).
, , .
. ,
.
font TextFormat. . :
( ) .
, , :
, embedFonts true.
font .
font TextFormat().
.
, (. 13.6):
this.createTextField("pole",0, 100, 100, 320, 120);
pole.text="Times New Roman\nLucida Handwriting\nSymbol", pole.border=true;
pole.setTextFormat(0,15, new TextFormat("Times New Roman", 25, null, true,
null, null, null, null, "center"));
pole.setTextFormat(15,34, new TextFormat("Lucida Handwriting", 25, null,
true, null, null, null, null, "center"));
pole.setTextFormat(34,41, new TextFormat ("Symbol", 25, null, true, null,
null, null, null, "center"));
Puc. 13.6.
, , , . ,
, . . ,
, .
, , , swf- 2030 .
. , ,
. , ,
(, , ). ,
, .
, ,
TextField.getFontList(). ,
. ,
, :
// , , font
TextField.isFont=function(font:String):Boolean {
var list:Array = TextField.getFontList();
for (var i = 0; i<list.length; i++) {
if (list[i] == font)
return true;
}
return false;
}
trace(TextField.isFont("Times New Roman Cyr")); // : true (
// )
trace(TextField.isFont("?font"));
// : false ( )
swf- getFontList() . ,
.
, , ,
, . , font
. ,
. ,
, . ,
, - .
, (
Windows Times New Roman).
, . .
: . :
format.font="Symbol,Licida Handwriting,Helvetica, Times New Roman";
(indirect) Flash.
13.7.
,
, , . , Times New Roman, Arial, Courier New, Tahoma , .
13.6.2.
,
,
, -.
.
, . , , 1/72 .
, .13.1
6, 8 96 . ,
, , ,
, Free Transform.
size TextFormat. , TextFormat(), .
size 96 . 8 . ,
_xscale _yscale.
. ,
size , , .
, .
, (. 13.7):
// Arial Cyr "font"
this.createTextField("pole", 0, 100, 100, 0, 0);
pole.text="Te-", pole.autoSize=pole.embedFonts=true;
for (var i = 0; i<pole.length; i++) {
pole.setTextFormat(i, new TextFormat("font", 50-i*3));
}
Puc. 13.7.
13.6.3.
, , ,
, . 13.1 7.
.
color TextFormat.
( , , Color Mixer). color ,
TextFormat() .
, ,
TextFormat. TextField textColor.
color textColor . , _alpha (
).
, .
, (, 13.8).
, :
// "font"
this.createTextField("pole", 0, 100, 100, 0, 0);
pole.text=" - ";
pole.autoSize=pole.embedFonts=true;
for (var i = 0; i<pole.length; i++) {
. 13.8.
13.6.4.
. . ,
Times New Roman 4 : Regular (), Bold (), Italic (),
Italic Bold ( ).
Text , . 13.1 8. , bold italic
TextFormat. : true
, false .
bold italic .
bold , italic TextFormat(). :
this.createTextField("pole", 0, 100, 100, 0, 0);
pole. text="\noyp\nKypc\noyp ", pole.autoSize =
true;
pole.setTextFormat(0, 8, new TextFormat(null, 30, null, null, null, null,
null, null, "center"));
pole.setTextFormat(8, 19, new TextFormat(null, 30, null, true, null, null,
null, null, "center"));
pole.setTextFormat(19, 26, new TextFormat(null, 30, null, null, true, null,
null, null, "center"));
pole.setTextFormat(26, pole.length, new TextFormat(null, 30, null, true,
true, null, null, null, "center"));
.
swf- . , , , .
(. 13.9),
.
13.6.5.
. - .
, ( ).
Flash 4 :
. .
. (),
.
. .
, .
.
.
.
, .
, ,
, . 13.1 9.
. 3.10.
align TextFormat.
:
left . . ,
align null;
center ;
right .
- .
- .
, , "".
- .
- .
, , "".
- .
- .
, , "".
- .
- .
, , "".
. 13.10. : a ; b ; ; d
, , . , , , , .
13.6.6.
(. 13. ).
Flash ,
.
underline TextFormat. : true , false . underline null, false. :
this.createTextField("pole", 0, 100, 100, 0, 0);
pole.autoSize=true, pole.text="http://www.flasher.ru";
var format:TextFormat = new TextFormat();
format.size=25, format.italic = format.bold = format.underline=true;
pole.setTextFormat(format);
, . , .
, Flash- L- (, ). , HTML ( , . 13.1 14),
, , <U>. ,
, . 13.11, :
pole.htmlText="<I><B><U>http://www.flasher.ru</U></B></I>";
Puc. 13.11.
13.6.7.
: , .
, . , Flash
.
, :
HTML. Render Text As HTML (. 13.1,
14).
HTML , ,
(. 13.1, 18). , . www.flasher.ru HTTP ,
Word,
, , .
Target (. 13.1, 12). :
o _blank ;
o __self ;
o _parent ,
;
o _top ,
.
Target ,
.
, , .
. , .
, swf-,
HTML-. , . . , Flash . , Flash- usability. .
, , , .
TextFormat url target.
url , . , - . ,
url null ( ).
target , , . Target, 4 :
_blank, _self, _top, _parent. _self ( ). target DHTML- , .
, , HTML. , true html .
(. 13.12):
this.createTextField("pole", 0, 100, 100, 0, 0);
pole.autoSize=pole.html=true, pole.text="a Flash
";
var format:TextFormat = new TextFormat();
with (format) {
size=15, color=0x00C0FF, font="Arial", italic=bold=underline=true;
url="http: //www.flasher.ru/forum", target=" blank";
}
pole.setTextFormat(format);
. 13.12.
TextFormat:
this.createTextField("pole", 0, 50, 50, 0, 0);
pole.autoSize = pole.html=true;
pole.htmlText = "<A HREF='http://www.flasher.ru' TARGET='_blank'> <b><i><u>
<F0NT SIZE='20' FACE='Arial Cyr' COLOR='#0Q00FF'>
Flash </F0NT></U></I></B></A>";
, HTML
TextFormat:
. , , <>,
url .
HTML web-. , , JavaScript-
. Flash.
, .
JavaScript alert():
this.createTextField("pole", 0, 150, 150, 0, 0);
pole.autoSize = pole.html=true, pole.text="";
var format:TextFormat=new TextFormat() ;
format.url = "javascript:alert('')", format.underline=true;
pole.setTextFormat(format);
. ,
0,5 , ,
.
(. 13.13):
this.createEmptyMovieClip("clip", 0);
// -
clip.createTextField("pole", 0, 150, 150, 0, 0);
//
clip.pole.autoSize=clip.pole.html=true, clip.pole.text="
Flash\nHa ";
var format:TextFormat = new TextFormat();
//
with (format) {
size=15, color=0x0000FF, font="Arial", underline=true, align="center",
url="http://www.flasher.ru/forum", target="_blank";
}
lip.pole.setTextFormat(format);
var time:Number = null;
// setInterval()
// ,
//
clip.onMouseMove = function():Void {
if (this.hitTest(_xmouse, _ymouse, true)) {
clearInterval(time);
//
// 0,5 , ,
//
time = setInterval(help, 500, this.pole);
} else if (help_field) {
// ""
help_field.removeTextField();
}
};
function help(pole:TextField):Void {
clearInterval(time);
// setInterval
// ,
if (pole._parent.hitTest(_xmouse, _ymouse, true)) {
//
_root.createTextField("help_field", 100000, _xmouse+15, _ymouse+15, 80, 40);
//
help_field.autoSize=true;
// url
help_field.text = pole.getTextFormat().url;
help_field.border = help_field.background=true;
//
help_field.backgroundColor = 0xFFFFDD;
//
var format:TextFormat = new TextFormat();
with (format) {
size=12, leftMargin=rightMargin=3, align="center";
}
help_field.setTextFormat(format);
}
}
. 13.13.
Flash- URL
.
JavaScript swf- getURL() ( fscommand()).
status window JavaScript.
, . ,
status . ActionScript
, .
JavaScript ActionScript ,
:
<SCRIPT>
// HTML- ,
//
function help(par) {
window.status=par;
}
</SCRIPT>
URL , . (
status ). ,
onMouseMove :
//
// , ,
// URL
clip.onMouseMove = function():Void {
if (this.hitTest(_xmouse, _ymouse, true)) {
clearInterval(time);
time = setInterval(help, 500, this.pole);
/* URL , help() JavaScript getURL(). , help() . */
if (!link} {
getURL("javascript:help('"+clip.pole.getTextFormat().url+"');");
link = true;
}
} else if (help_field) {
help_field.removeTextField();
//
getURL("javascript:help('');");
link = false;
//
//
} else if (link) {
getURL("javascript:help('');");
link = false;
}
};
var time:Number = null;
var link:Boolean = false;
(. 13.14), , Flash-
. ,
. 16,
SharedObject ( ).
Flash MX 2004 CSS (Cascading
Style Sheets ). Flash- 3 (): hover ( ,
), active ( ) link ( ). .
13.12.
13.6.8.
, , , . Flash , .
Format Options (. 13.15),
Format (. 13.1, 10).
Puc. 13.15.
Format Options
:
Indent .
. , 0 ( ,
);
Line Spacing .
. , , 0, . Line Spacing
;
Left Margin Right Margin . Left
Margin : Indent.
Format Options TextFormat, . :
intend.
, . intend
0 ( ),
leading.
2 (
).
leftMargin rightMargin. 0 .
, ,
. , . true TextFormat
bullet. , ,
.
.
,
, blokIndent.
( indent ). blokIndent 0
.
(. 13.16):
this.createTextField("pole", 0, 150, 150, 130, 100);
pole.text = " :\n \n
\n- \n";
with (pole){
border= autoSize= background=true, backgroundColor=0xFFFFDD;
}
var simple_format:TextFormat = new TextFormat();
//
with (simple_format) {
size=20, color=0x0000DD, font="Times New Roman";
indent=20, leftMargin=rightMargin=20, leading=l5;
}
var bullet_format: TextFormat = new TextFormat(); //
with (bullet_format) {
size=15, color=0x0000FF, font="Times New Roman", italic=true;
indent=20, leading=10, leftMargin=30, rightMargin=20, bullet=true;
}
//
pole.setTextFormat(0, pole.text.indexOf(":")+1, simple_format);
//
pole.setTextFormat(pole.text.indexOf(":")+1, pole.length, bullet_format);
. 13.16.
, ,
Text Format. , . . -, , , ( 4 ). -, , .
escape- \u0009 ( :
TAB 9), \ \t.
:
this.createTextField("pole",0,150,150,80,30);
pole.border=pole.autoSize=true;
pole.text="\t
:
\n\t\t\u25CF\t
\n\t\t\u25CF\t \n\t\t\u25CF\t- \n\t\t\u25CF\t";
pole.setTextFormat(new TextFormat(null, 15, null, true));
. 13.17. , TextFormat
bullet:
escape- (\u25CF),
, .
, .
, (, ). , , , . ,
. ,
TextFormat, . , , ( HTML CSS- (. 13.11 13.12)).
.
, . ,
? ActionScript
, .
tabStops TextFormat. ,
.
, [4, 10, 15] , \t 4 , \t\t
10 , \t\t\t 15 . (. 13.18):
this.createTextField("pole", 0, 150, 150, 80, 30), pole.border = pole.autoSize=true;
pole.text = "0 ao\n\t1 \n\t\t2 \n\t\t\t3 \n\t\t\t\t4 \n\t\t\t\t\t5
";
var format:TextFormat = new TextFormat();
format.size=15, format.tabStops=[10, 15, 25, 37, 75];
pole.setTextFormat(format);
tabStops , , .
. 13.18.
13.6.9.
, . , , . Text Format getTextExtent().
getTexlExtent() Flash MX.
,
, :
. (, , , ).
, ,
.
46 . .
, ( , , , ).
Flash MX 2004 getTextExtent()
.
getTextExtent() :
format_object.getTextExtent(string, wrap_width),
:
format_object TextFormat, ,
;
string , ,
;
wrap_width , , . .
,
.
getTextFormat() 6 , width, height, textFieldWidth,
textWidthHeight, ascent, descent. , .
13.19,
. 13.19. ,
.
:
. , 2 .
.
. width
getTextExtent() . ( left Margin
rightMargin ), , .
.
height getTextExtent() .
,
. 4 ( 2 ). , .
, ,
textFieldWidth textFieldHeight getTextExtent() .
, ,
(baseline). ,
(q, j, p .) .
, , . (ascent).
ascent getTextExtent() .
.
. , ,
, (descent).
descent getTextExtent() .
. , leading TextFormat.
ascent, descent leading, .
, ,
, .
getTextExtent() , Flash MX 2004
. , (, ). , , , . , ,
, .
.
: , ,
.
this.createTextField("pole", 0, 150, 150, 0, 0), pole.border=true;
// tx
var tx:String = " ActionScript ,
:\r\u25CF TextFormat\r\u25CF HTML\r\u25CF
SS-\r\r
CSS.";
pole.text = tx;
//
var style:TextFormat new TextFormat();
with (style) {
font="Courier Cyr", size=l4, leading=4;
bold-true, italic=true;
}
pole.setTextFormat(style);
//
//
var size_object:Object = style.getTextExtent(tx);
pole._width=size_object.textFieldWidth;
pole._height=size_object.textFieldHeight;
// , .
// , ,
// , .
this.onMouseDown = function():Void {
if (pole._ymouse>2 && pole._ymouse<size_object.height+2 && pole._xmouse>2
&& pole._ymouse<size_object.width) {
var line_height:Number = style.leading + size_object.ascent +
size_object.descent;
var line_number:Number = Math.ceil(pole._ymouse/line height);
trace(" "+line number);
}
};
13.7.
Flash
.
. , , , , ,
, , ,
, , .
Flash, .
, .
Flash MX 2004.
13.7.1.
swf- : (glyph text) (device text).
( ).
.
.
:
(antialiasing). . , , . (, 13.20).
. 13.20. () ()
, ,
, . , , , . , , , .
. , , , . , (, Unicode), ,
, , , . , .
, 1530 . , web-
. ,
, . .
. : , , . TextFormat,
, . , , .
, , , , .
.
, TextFormat. . . , .
,
. . , ,
. , ,
Flash . , Flash-, ,
. , , ,
.
, , . 100 .
, . , . ,
. Use Device Fonts . ,
(1015 ) ( )
.
, swf- HTML- <OBJECT> devicefont( <EMBED>), , . HTML Publish Settings, Device Font
Playback.
,
. . , , , , 200 , 2030 .
. ? 100 ,
web-. .
13.7.2.
, .
, .
- , (
).
(indirect) ( web- ). , -
. ,
. , , . , , .
Flash MX 2004 3 (
):
_sans. Arial ( Macintosh
Helvetica) , ,
.
, . ,
, ;
_serif. , Times New Roman.
. , ,
. , ;
_typewriter, Courier New. . , . : , W
, , , I.
. . ,
, , , . ,
, (. 13.21).
Flash , .
.
, ,
.
, , .
.
13.7.3.
, ,
. - , .
, Dynamic Input
. ,
(, ), .
.
, ?
Flash- ( -). ,
, Graph. ,
, ,
(. 13.22). , ,
.
. , . -, PostScript. Flash
TrueType ( ).
,
, (
View / Antialias Text ). , . Flash
.
. 13.22.
. , , . ,
, , 12 , . , ,
( ,
13,7.6). .
. , , Arial.
,
Times New Roman. . , Arial Cyr
18 . Times New Roman Cyr
27 . .
, , Arial. , , . ,
.
, , Flash .
, Generate Size Report Flash
Publish Settings. , ,
swf- , , , - -, , . ,
, Times New Roman Cyr - 27 .
, . ,
swf- , .
13.7.4.
, :
(<F11>) , ,
, New Font.
New Font Symbol Font Properties,
:
o Name. . .
.
o Font. , .
o Style. , .
. , , ,
,
.
o Alias Text. ( 12 ),
. . ,
Size. Size , Alias Text
, .
13.7.6.
, ActionScript. :
o .
linkage;
o Linkage Linkage Properties
Export for ActionScript. Identifier,
.
, ,
. ActionScript:
, . true embedFonts TextField.
font .
( setTextFormat()) ( setNewTextFormat()).
.
:
// "font"
this.createTextField("pole",0,150,150,0,0);
pole.border=pole.autoSize=pole.embedFonts=true;
pole.text="e ";
pole.setTextFormat(new TextFormat("font",2 0));
, Text Format
. ,
bold italic. : , . , .
.
embedFonts true, .
, .
13.7.5.
. ,
,
. 10 :. , . ,
, ,
,
, .
: , ?
, .
Character Options (.
13.23), Character
(. 13.1, 11).
Embed font outlines for
:
No Characters. .
.
Specify Ranges.
. (,
).
:
13.23.
o Uppercase (AZ).
.
o Lowercase (az). .
o Numerals (09). 0 9.
o Punctuation. , , , , ( , : !"#$
%&'()*+,-./:;<=>?@[\]^_`{|}~). ,
, .
o Basic Latin. ASCII. ,
.
o Cyrillic. ( ). , . , ,
, Cyrillic
Basic Latin.
. ,
<Ctrl>, Specify Ranges.
, , ,
. ,
. , , , Arial Cyr, . ,
Cyrillic: 500 ,
.
swf- . - , ,
Unicode- (, Arial Unicode MS).
Specify Ranges ,
. XML- UnicodeTable.xml.
FontEmbedding Configuration. , , Flash.
, - ( Classes,
ActionScript). Configurations ,
. Windows 2000 : C:\Documents and Settings\user\Local Settings\Application Data\ Macromedia\Flash MX 2004\en\Configuration.
UnicodeTable.xml, , . XML-
<fontEmbeddingTable>. , , .
<glyphRange>.
. name .
Specify Ranges. id . B <glyphRange>
<range>, , Unicode- . <range> : min ,
, max , .
Unicode- (, ),
<range>. , ( -
) <range>.
UnicodeTable.xml, . . , 6
. ,
. <glyphRange> UnicodeTable.xml . , .
Specify Ranges , (
Cyrillic ). . , , Unicode
0x0410 0x04FF:
<glyphRange name="Russian" id="8">
<range min="0x0410" max ="0x044F"/>
</glyphRange>
, , , , :
<glyphRange name="Rus-Eng-Num-Punct"
<range min="0x0410" max ="0xO44F"
<range min="0x0020" max ="0x002F"
<range min="0x0030" max ="0x0039"
<range min="0x003A" max ="0x0040"
<range min="0x0041" max ="0xO05A"
<range min="0x005B" max ="0x0060"
<range min="0x0061" max ="0x007A"
<range min="Ox007B" max ="0x007E"
</glyphRange>
id="9">
/>
/>
/>
/>
/>
/>
/>
/>
, , .
UnicodeTable.xml, .
Specify Ranges Flash.
Include these characters. ,
. ( Punctuation ) (, :). And these characters , restrict, .
. , .
, . ,
, ,
, , <Space> .
, Include these characters, .
,
. , , Include these characters ,
. .
, , , . ( ) Auto Fill
Character Options. , , -
13.7.6.
Flash ,
( 12 ) , . ,
, Word, .
Flash . ,
, . , , . Flash MX
2004 , ,
. Flash 7.
Flash ? , , . ,
,
. , ,
, , , , .
. Flash- , .
(hinting) .
.
. .
( ) - .
, -
, . ,
, . ,
, .
, ,
. . -
.
.
. (Arial, Times New Roman, Tahoma . .) , (8 6
). hinting, 8- ,
.
swf- . ,
. , , swf-.
Flash, .
, - Flash ? .
, . . 13.24 , ( 8pt)
.
. 13.24. () (b)
. , ,
. , ,
, , .
( )
Verdana ( Arial).
,
.
. , , .
(, . ).
, , ,
, (.
13.25). , , . ,
.
. 13.25. () ()
, .
. -, . ,
, . (. 13.26) (
). ,
. ,
. ,
, . , ,
, , . - .
. 13.26.
-, , , .
. ,
. .
, , , ,
, .
. , 12 , 14
24, 36, 48 . . (,
). ,
.
. , Flash . Flash Flash- TrueType .
, . TrueType? . .
, . .
(pseudopixel).
, , : , .
Flash 5 Flash MX Flash-
( http://www.miniml.com
http://www.fontsforflash.com). ( )
. ,
.
Flash MX 2004 Macromedia ,
. , . , , Alias Text (. 13.1, 18). , :
. , . ,
;
Alias Text Character. .
.
Properties.
Alias Text. , ,
Size.
, , . 13.27.
. 13.27. () (b) ( )
. ,
. : , .
,
, . , -
, , *
. , Times New Roman Cyr 27 ,
8- 9 , 12- 14 , 32- 18 .
, Flash .
8 pt ,
. Flash,
.
- ,
.
, .
.
13.8. onChanged
onChanged
. ( text ), . ,
. :
this.createTextField("pole", 0, 200, 200, 0, 0);
pole.border=pole.autoSize=true, pole.type="input", pole.text=" ";
pole.onChanged = function():Void {
// Output
trace(this.text);
};
Ha onChanged , .
. ,
listeners:
this.createTextField("pole", 0, 200, 200, 0, 0);
trace(pole._listeners); // : _level0.pole
, onChanged - ,
addListener(). removeListener (. 8).
this.createTextField("pole", 0, 200, 200, 0, 0);
pole.addListener(this); //
//
trace(pole._listeners); // : _level0.pole _level0
Flash 4 5 onChanged
changed. Flash- . , , .
, .
_changed ,
Flash 4. ,
:
( pole_var).
, . : pole_var_changed.
pole_var_changed , ,
.
Flash 4, onChanged
. , ActionScript . ,
. call(), ,
. _changed.
, . ,
.
13.9.
, , ( ) . . , .
: . :
;
,
;
<Page Up> <Page Down> ( );
. Flash, Flash MX 2004 , , . ;
o ,
. , . -, , ,
.
o 1 3 .
, .
ActionScript . , ,
,
.
o
(,
,
, ).
mouseWheelEnabled, : true ,
false . ,
,
. , , -
, Windows-. , ActionScript , , .
TextField. : scroll, maxscroll, bottomScroll.
, :
scroll. , .
1. , scroll
. ,
. scroll , , .
bottomScroll. , scroll,
, . , scroll
bottomScroll. .
maxscroll. scroll .
, maxscroll , . ,
, ( 1).
,
. ( down) . (
up) . :
up.onPress = function():Void {
if (pole.scroll>1) {
pole.scroll -= 1;
}
};
down.onPress = function():Void {
if (pole.scroll<pole.maxscroll) {
pole.scroll += 1;
}
};
, . , .
, (, ,
).
hscroll maxhscroll
TextField:
hscroll. ,
. . hscroll 0
.
, hscroll . , 1. hscroll
.
( hscroll , 0,5, 0).
maxhscroll. hscroll,
,
:
, . ,
, , . .
ActionScript
onScroller, TextField. , , . onScroller:
this.reateTextField("pole", 0, 150, 150, 80, 30);
pole.border=true, pole.type="input", pole.text=" ";
pole.onScroller = function():Void {
trace(" !!!");
};
onScrollor .
, _listeners .
addListener() ( 8).
, ,
. Flash MX 2004
. ,
ScrollPane. Flash 19.
13.10.
, web- , .
. , . , ,
. ,
<Enter>. , .
. -, <b>.
. <Shift> + <Tab>. -, <b> . ,
. -, , JavaScript.
Flash . ,
HTML-, . , . , swf- .
flash- HTML-.
, , .
, .
11. .
Tab-, , .
.
, Selection.setFocus().
, , , . , ( _focusrect ). ,
, . <BackSpace>,
. ,
.
, . , false tabEnabled. .
pole.tabEnabled = false;
//
, , . . , , , . . , tabIndex.
tabIndex , Tab-. 1. , .
Tab- tabIndex , , .
. ActionScript, Selection.setFocus(pole), pole
. , , ,
<b> (
).
,
:
onSetFocus , . - , ;
onKillFocus , . , .
onSetFocus on KillFous ,
Selection.setFocus(). , , , ( .
) .
Tab- flash- L- ,
.
<b> , , . , , .
13.11. HTML
, ,
TextFormat. Flash , HTML. , HTML 4. , .
Flash 5 HTML ,
.
TextFormat CSS. . HTML- :
, , ,
,
.
HTML , . ,
( , ActionScript).
HTML, :
, Render Text As HTML
(. 13.1, 14);
HTML , true html .
HTML-, .
- .
, HTML- text .
HTML,
, htmlText. :
this.createTextField("pole",0,200,200,0,0);
pole.autoSize=pole.html=true;
// 20 -
pole.htmlText= "<B> <I> <FONT SIZE='20'> HTML-
</FONT> </I> </B>";
htmlText
. . ,
htmlText. text . . TextFormat . , , pole, .
trace(pole.text);
trace(pole.getTextFormat().size);
// : HTML-
// : 20
, . :
HTML text TextFormat.
. , , ,
font,
FACE <FONT>. ,
, HTML. , TextFormat.
HTML,
htmlText ( ) . HTML, text TextFormat. :
this.createTextField("pole", 0, 100, 200, 0, 0);
pole.text = " : http://www.piter.com";
pole.html = pole.autoSize=true;
pole.setTextFormat(0, 30, new TextFormat("Arial Cyr", 20, 0, null, true, null,
null, null, "center", 20));
pole.setTextFormat(30, 45, new TextFormat("Tahoma", 20, 0x0000FF, false, true,
true, "http://www.piter.com", "_self"));
trace(pole.htmlText);
/* : <TEXTFORMAT LEFTMARGIN="20"><P ALIGN = "CENTER">
<FONT FACE="Arial Cyr" SIZE="20" COLOR="#000000"<I> no :
</I><FONT FACE="Tahoma" COLOR="#0000FF" <A HREF=http://www.piter.com TARGET="_self">
<I> <U> http://www.piter.com/ </U> </I> </A> </FONT> </FONT> </P> </TEXTFORMAT> */
, HTML
Text Format .
, .
HTML . HTML , ,
text. , HTML, htmlText. :
this.createTextField("pole",0,150,150, 30, 30) ;
var pole_text:String=null;
//
pole.variable="pole_text";
pole.text="";
//
trace(pole_text);
// :
pole.html=true;
// HTML
pole.text="Ho ";
//
trace(pole text);
// : < ALIGN="LEFT"><FONT FACE="Times New Roman"
// SIZE="12" COLOR="#000000"></FONT></P>
HTML- Flash , . , , , . ,
, . , , Flash-:
<FONT SI2E=20>!</FONT>
, SIZE :
<FONT SIZE='20'>!</FONT>
, . ,
, HTML-.
HTML ( XML).
, .
:
HTML.
HTML Flash- , . , ,
:
<TAG><b>Te</b></TAG>
// :
HTML,
( , ).
, (< >),
(&). , -
HTML ( ): > <, < - >, "
, & . :
<> "⁢U>" </>
:
"<U>"
HTML - (,
&;). Flash .
HTML- , escape- ( ,
):
pole.htmlText="<B> \"<U>\"</B> </B>";
. . ,
escape- Unicode- ( ,
). :
//
pole.htmlText="<FONT COLOR>'#FF0000'>\u5674\u7865\u6745\u8767</FONT>";
ASCII, HTML-,
&#number;, number . :
pole.htmlText="<B>© Macromedia</B>";
// : Macromedia
, <>, ,
. , <>
( Flash MX 2004).
, Flash- <> . , , .
<> Flash
, , . , ,
, , .
htmlText ,
<>. , :
pole.htmlText="<B></B>";
pole.htmlText+="<B> !!!</>";
:
!!!
, htmlText
, .
Flash.
ALIGN align TextFormat.
13.11.2. <BR>
. esc- \n. :
" : <r>\t\n\t"
:
:
<BR> escape- \n :
, . \r \n .
<> :
HREF URL-, , , . , . HREF .
TextFormat url;
TARGET , , .
: _self ( ), _ ( ), _top ( ),
_parent ( ). _ self. TARGET DHTML
, .
target TextFormat.
<> Flash-
, . ,
<U>. :
this.createTextField("pole",0,150,150,0,0);
pole.autoSize=pole.html=true;
pole.htmlText="<A HREF = 'http://www.flash-ripper.com/' TARGET = '_blank' >
<U> </U> </A>";
Flash , . -, swf-
URL. -, . , 13.6.7.
<>, HTML-
ftp. JavaScript .
HREF javascript:
this.createTextField("pole",0,150,150,0,0);
pole.autoSize=pole.html=true;
pole.htmlText="<A HREF='javascript:alert(999)'>
</A>
<U>
JavaScript
</U>
JavaScript . , , . , ,
":
// : ""
pole.htmlText="<A HREF = 'javascript:window.status =""'>
<U> </U></>";
ActionScript. asfunction:
"<A HREF='asfunction: functionName, parameter'> </>"
:
functionName . ().
, ,
( , );
parameter , .
// Output : " func "
pole.htmlText = "< HREF='asfunction:_root.func, func '>
<U> func</U></A>";
function func (par:String):Void {
trace(par);
}
, asfunction
.
, HREF.
, .
, .
- , , .
:
this.createTextField("pole", 0, 150, 150, 0, 0);
pole.autoSize = pole.html=true;
pole.htmlText = "< HREF='asfunction:sum,1^2^3^4^5^6^7^8^9'><U> 0
9</U></A>";
function sum(par:String):Void {
// , "^"
var arr:Array=par.split("^");
var summa:Number=0;
for(var i=0; i<arr.length; i++) {
//
summa+=Number(arr[i]);
//
}
pole.text=" "+summa;
}
asfunction . , , ,
javascript, .
. ,
, . .
<> Flash-
. http, ftp, javascript, asfunction,
event ( Macromedia Director,
Flash-), file ( ), lingo ( Lingo Macromedia Director), vbscript (
VBscript), print ( ), mailto ( )
. , , Flash MX 2004:
pole.htmlText = "< HREF='file:///:/Program Files/Macromedia/Flash MX 2004/
Flash.exe'><U> !</U></A>";
:
pole.htmlText = "<A HREF='print:_root'><U></U></A>";
e-mail :
pole.htmlText="<A HREF= 'mailto:diis_ignotis@tut.by' ><U>Ha '
</U></>";
getURL() fscommand().
CSS-
, , ,
. A hover, link active.
: HTML-, TextFormat .
13.12.
<> CLASS,
CSS.
FONT . :
pole.htmlText="<FONT FACE='Lucida handwriting' SIZE='20' COLOR='#FF66GG'>
Macromedia Flash </FONT>"
. 13.29.
13.11.9. <>
<> . escape /t.
1<TAB>2<TAB><TAB>3\t\t\t4
:
1 2
3
, ,
. TABSTOPS <TEXTFORMAT>.
<> HTML. Flash
, .
<TEXTFORMAT> HTML. ,
Text Format.
13.11.12. <IMG>
Flash
, . swf , . ( ) Flash , , , , . - Flash- .
Flash MX 2004
<IMG>.
L <IMG> . Flash
. jpeg-,
. , , Flash MX Flash MX 2004 . ,
, Flash 5. MovieClip, createEmptyMovieClip(), loadMovie() attachMovie(), - . ,
, <IMG>
- (
). <IMG> ,
ActionScript .
<IMG> :
SRC. JPEG- , . , . , SRC . .
SRC . <IMG> .
ID. JPEG- swf-, ,
. , , .
.
. ID. ,
instance1, instance2 . .
, - . ,
. :
// image, pole, //
www.mysite.ru pole.image.onPress = function():Void {
getURL("http://www.mysite.ru", "_blank");
WIDTH. . , .
HEIGHT. .
- , ,
, <IMG>, .
, . , ,
. , 16384- (
).
. 13.30.
Flash- JPEG-. , , . , . .
, .
. , .
, . ,
, , ,
. , , . ,
MovieClip.
WIDTH HEIGHT <IMG> ,
. ,
. , . , . WIDTH
HEIGHT , , .
, , , . . .
, , .
, , .
<IMG> <>.
:
pole.htmlText = " \"\", : <
HREF'='http://www.piter.com" TARGET'_blank'><IMG SRC='banner.jpg' WIDTH='70'
HEIGHT='30'></A>";
, , . - ,
, .
13.11.13. . condenseWhite
HTML- . , , :
<> <>
</>
HTML- Flash :
pole.htmlText="<B><P>Bce </><>
</></>";
HTML- -
. Flash
. .
condenseWhite TextField. :
true , false .
pole.condenceWhite=true; //
pole.htmlText="<B><P>Bce </><>
</></>";
:
condenseWhite HTML-.
, text , .
13.12.
(CSS)
Flash 5 , , , HTML. , .
(, , Flash ), . , ,
,
. , :
<FONT COLOR='#FF0000' FACE= 'Tahoma Cyr' SIZE='25'><B><U><I> _ </I></U>
</B> </F0NT>
?
. , , ,
(, , . .).
. ,
, , . , ,
, ,
? Flash MX Text Format,
, - . ,
,
.
, Text Format :
, TextFormat, ,
. ,
, , . , .
, , , , ,
.
TextFormat . .
, , . Flash MX , , HTML-, -
.
, HTML,
TextFormat . , , . , , HTML, TextFormat, . . - . web- 1996 , CSS (Cascading Style
Sheets ). Flash MX 2004
CSS , StyleSheets, ,
, , Flash , .
CSS? , : , , . , .
, HTML, , .
CSS.
, .
CSS .
, Flash- CSSI.
, CSS,
HTML. , - .
13.12.1. CSS
CSS-. HTML- ( Flash- ). CSS Flash .
, CSS , ,
( ). , , 50
, :
A:{color:#00FF00; font-style:italic; font-size:50}
</BODY>
</HTML>
HTML- , , ,
. !
, CSS. :
. , ,
, . , , . , . CSS 100. BCSS, Flash, .
(, SIZE FONT font size). (
HTML). .
, STYLE CSS-, .
. - HTML. ,
:
{text-decoration:underline}
, :
1, 2, {color:#00FF00; font-style:italic}
- ,
. *. ,
:
<STYLE>
H1 {color:#0000FF; font-size:22}
{color:#FF0000; font-size:24}
* {font-style:italic}
</STYLE>
<BODY>
<1> <B> </></1>
</BODY>
, X, Y, X Y. ,
- :
<1> - <> </B></1>
. , , . , 20 , 22 ,
22- . ,
, .
, .
HTML , <BODY>, ActionScript
.
.
. ,
.
CSS Y, X. :
X Y {property:value...}
, , H1 , .
1, :
1
H1
{color:#0000FF}
{color:#0000FF}
{color:#FF0000}
,
:
* {property:value...}
,
. CSS :
H1 [atr='value']{property:value...},
:
H ;
atr ;
value , .
HTML .
class. :
<1 class-'myClass'> myClass </1>
X, myClass,
:
X.myClass {property:value...}
, :
*.myClass {property:value...}
:
.myClass {property:value...}
,
( ). ,
, :
<STYLE>
A {color:#00COFF; font-size=25}
,
A.myClass {color:#FF0000}
</STYLE>
<BODY>
<P><A CLASS='myClass' HREF='http://wnk.biz'>
" "</>
<>< CLASS= 'myClass' HREF='http://www.piter.com'>
"" </>
<P>< HREF='http://www.bhv.ru'> BHV </>
</BODY>
, . ,
. ID-.
ID , . :
<1 ID='special'> </1>
H1 ID 'special', :
H1#special {property:value...}
, :
<STYLE>
A {color:#0000FF; font-size=30}
A#special_link {color:#FF0000}
</STYLE>
<BODY>
<P><A ID='special_link' HREF= 'http://wnk.biz'>
" "</>
<>< HREF='http://www.piter.com'> "" </>
</BODY>
CSS .
.
< href> ().
link. .
visited. , .
hover. .
active. .
,
:
<STYLE>
A:link
{color:#0000FF; font-size=20}
A:visited {color:#AA00DD; font-size=20; font-style:italic}
A:hover
{color:#990000; font-size=22}
A:active {color:#FF0000; font-size=20}
</STYLE>
<BODY>
<A HREF='http://www.piter.com'> ""</>
</BODY>
CSS , ,
, XML (extensible Markup Language). XML , HTML-,
, . XML- , CSS ( ). , XML-, CSS-. .
XML CSS. XML:
<BOOK>
<HEADLINE>War and Peace</HEADLINE>
<AUTHOR> L.N.Tolstoy </AUTHOR>
<VOLUME> Third Volume </VOLUME>
<part>First Part</Part>
<TEXT>
Since the end of 1811th...
</TEXT>
</BOOK>
. ess- ( styles) :
BOOK
{font-family:sans-serif}
HEADLINE
{display:block; font-size:30; font-weight:bold; text-align:center}
AUTHOR
{display:block; font-size:25; font-style:italic; text-align:center}
VOLUME
{display:block; font-size:23; color:#000055; text-align:center}
PART
{display:block; font-size:23; text-align:center;
text-decoration:underline}
TEXT
{text-indent:10; font-size:18; text-align:left; margin-left:5}
XML- , :
<?XML:stylesheet type="text/css" href="styles.css"?>
XML- .
.
L-, . Flash- ,
.
CSS, , .
HTML-, <STYLE>. ,
HTML-,
*.css. , . ,
. HTML
<LINK>. :
<LINK REL='STYLESHEET' TYPE='TEXT/CSS' href='Styles.ess'>
CSS. ,
Flash-.
13.12.2.
ActionScript CSS- StyleSheet.
StyleSheets()
TextField. :
var styles:TextField.StyleSheet=new TextField.StyieSheet();
TextField , StyleSheet. ,
ActionScript, .
StyleSheet , CSS, . 3 .
ActionScript .
, , , :
var css_rules:String="A {color:#FF0000; text-size:12px; font-style:italic;
text-decoration:underline}";
, , parseCSS()
StyleSheet. CSS. , ,
, parseCSS() true. - CSS
, false. , :
trace(styles.parseCSS(css_rulesM)); // : true
CSS- . , .
,
parseCSS(), styles. forin:
ASSetPropFlags(styles, null, null, 1);
for (var i in styles) {
trace(i);
// : _styles _css __proto__ __constructor__
}
, 2 : _styles _css.
, Object. ,
, . ,
, <>.
. _css:
ASSetPropFlags(styles["_css"][""], null, null, 1};
for (var i in styles["_css"]["A"]) {
trace(i);
// : color textSize fontStyle textDecoration
}
, ,
getStyle(name), name .
, _css StyleSheet. :
var styles:TextField.StyleSheet = new TextField.StyleSheet();
var css rules:String = "A {color:#0000FF; text-size:12px; font-style:italic}";
styles.parseCSS(css_rules);
var st_obj:Object = styles.getStyle{"A");
for (var i in st_obj) {
trace(i+" = "+st_obj[i]); // : fontStyle = italic
// textSize = 12px color = #0000FF
}
getStyle() ,
StyleSheet . , .
, StyleSheet ?
. CSS Flash-
. , CSS
, . , ,
. ,
, :
(,
CSS- , ). , CSS- , .
, ;
, CSS-, ,
. . ,
, ;
. ,
, CSS-;
CSS- . , XML-.
, CSS Flash- . , CSS, , . , .
StyleSheet setStyle().
:
setStyle ("name", style_obj).
:
name . CSS- ;
style_obj , .
, CSS-. (
), ,
(, text-decration
textDecoration). , CSS,
().
12.
setStyle() . _css name ,
, ,
style_obj .
setStyle() . ,
, .
setStyle():
// , <new_style>
var styles:TextField.StyleSheet = new TextField.StyleSheet();
var st_obj:Object={textSize:'12px', textDecoration:"underline", color:'#FF0000',
'marginLeft:45'};
styles.setStyle("new_style", st_obj);
delete_styles;
,
css-. , . , swf-,
HTML - , .
, load(url), url ess-.
, swf-.
Flash. , 18.
, StyleSheet, load.
. , ,
ess-. , , - , load().
onLoad StyleSheet. css-, (
). onLoad : true , false .
:
// ,
// hyperlink.css ,
//
A:link {text-decoration:underline; color:#0000FF; font-style:italic-text-size:12}
, clear():
hyp_st.clear();
trace(hyp_st.getStyleNames());
// StyleSheet
// Output
StyleSheet(), , . ,
CSS Flash.
13.12.3.
, StyleSheet, , styleSheet TextField. . :
// ,
this.createTextField("pole", 0, 200, 200, 100, 30);
var styie:TextField.Stylesheet = new TextField.StyleSheet();
style.parseCSS("GREEN {color:#00FF00}");
pole.styleSheet = style;
pole.text = "<GREEN> </GREEN>";
StyleSheet, , CSS-. :
htmlText text.
CSS , ( ), htmlText. ,
htmlText, text , .
. , .
, CSS-, setTextFormat() . ,
CSS-. , setNewTextFormat()
.
, replaceSel(). , text htmlText, .
CSS - .
CSS
, HTML TextFormat. ,
- ,
, . , ,
. , .
13.1
text-align
text-decoration
text-indent
color
margin-left
CSS1, Flash-
. : left (
), right ( ), center (
). (justify)
.
( ) underline ( )
.
. , #, 0x. (red, silver
. .) rgb(R, G, )
margin-right
font-style
font-weight
font-size
font-family
13.1
. margin-bottom margin-top
. Flash : normal ( ) italic ( )
. : normal ( )
bold ( )
.
.
, . ,
, . ,
. : ,
, :
MyStyle {font-family: Garamond Cyr, Symbol, _serif}
display
CSS- Flash, :
CSS : (), (pt), ( %), (cm) . . Flash-
. , font-size left-margin,
. ,
, . CSS-
( parseFloat()). , . .
//
A {margin-left:40}
{margin-left:40pt}
{margin-left:40cm}
CSS- ( HTML
).
.
Flash CSS (Color
color). CSS .
, CSS Flash-
, ,
:
, , {property1:value1; property2:value2...}
o *:
*{property:value...}
o ,
:
A[par='val'] {property:value...}
o ID-:
H1#special {property:value...}
,
. Flash
(. ).
CSS . ,
, <>, :
<STYLE>
{font-style:italic}
<STYLE>
HTML
. , , <>,
( ) <>.
Flash- , CSS. link ( ), hover (
), active ( ). visited (
) , ,
ActionScript , , , , . , , SharedObject. , ,
, .
, , , :
this.createTextField("pole", 0, 200, 200, 100, 30);
pole.autoSize=true;
var style:TextField.Stylesheet = new TextField.Stylesheet();
style.parseCSS("A:link {color:#0000FF} A:hover {color:#00FF00} A:active
{color:#FF0000}");
pole.stylesheet = style;
pole.html=true;
pole.text = "<A HREF= 'http://wnk.biz' TARGET= '_blank' > </>";
.
, ,
.
. 13.31.
13.13. . Selection
, , . (selection) . .
<BackSpace>,
, , .
Flash .
.
Flash-, , HTML-. , . , , ,
, . , ,
. , , Flash
.
:
, ,
, , . .
, .
, <Ctrl> + <A>
Select All .
, , , <Shift>.
<Shift> + <End>,
. , , <Shift> + <Home>.
<Shift> + <Ctrl> + <End> .
,
<Shift> + <Ctrl> + <Home>,
Selection.setSelection().
.
Word , Flash
, <Ctrl>.
.
Flash , , ,
Word :
, <Ctrl> + <>.
.
<Ctrl> + <>. -
Cut . . .
, <BackSpace> <Delete>. ,
Delete .
, .
,
<Ctrl> + <V> Paste . replaceSel()
TextField.
, .
. , , 13.5.7.
. ,
. , , .
, , ,
. , .
. ActionScript
Selection.
, , ,
, . .
getFocus() ,
, Tab-
setFocus() , , .
, getFocus() . ,
,
.
, .
Selection.setFocus().
, Selection.setFocus() null.
, . , ,
:
Selection.setSelection(null,null);
13.13.2. (onSetFocus)
onSetFocus onKillFocus,
, , b- .
, - .
, .
onSetFocus Selection.
onSetFocus Selection , .
2 . , . , .
, onSetFocus
null.
onSetFocus . , _listeners Selection.
addListener():
var obj:Object =();
Selection.addListener(obj);
obj.onSetFocus = function(f1:TextField, f2:TextField):Void {
trace(" "+f1+", "+f2);
};
removeListener
( . 8).
13.13.3. .
getBeginlndex() getEndIndex()
ActionScript , .
Selection.getBeginIndex() Selection.getEndIndex().
Selection.getBeginIndex() , . . , 1. ,
, Selection.getBeginIndex() (
Selection.getCaretIndex()).
Selection.getEndIndex() ,
. getEndIndex()
getBeginIndex() . :
this.createTextField("pole", 0, 150, 150, 0, 0);
pole.border=pole.autoSize=true, pole.type="input";
pole.text="Bee ";
//
Selection.setFocus(pole);
trace([Selection.getBeginIndex(), Selection.getEndIndex()]];
// : 0, 16
13.13.4.
,
(caret). ,
Paste. ,
. , , <BackSpace>
, .
. Windows- , . Flash , .
Input.
: .
, ,
Dynamic . : getCaretIndex()
, .
ActionScript, ,
. Selection.getCaretIndex().
, . , 1. , 0.
, Selection.setSelection(),
,
. :
this.createTextField("pole", 0, 150, 150, 0, 0);
pole.border=pole.autoSize=true, pole.type="input";
pole.text="Ty \"\" . = ";
Selection.setFocus(pole);
//
Selection.setSelection (5,5);
//
pole.text+=Selection.getCaretIndex();
//
13.13.5. . setSelection()
, Selection,
.
setSelection(). 2 : , , ,
.
setSelection() ,
. , , , .
getFocus(). ,
( ), ,
setFocus().
.
, ,
, . .
setSelection() . Flash-
, .
, ,
Flash- .
, .
. :
1.
2.
(5001000 ).
3.
Input, , .
str.
4.
, . but.
5.
:
o
toLowerCase() toUpperCase(). ,
, .
o , ,
. indexOf() String.
o , . , . , .
o , ,
. , .
:
var index:Number = 0;
// ,
//
// ,
var stroke:String="";
function poisk():Void {
//
var big_text:String = pole.text.toLowerCase();
var stroke:String = stroka.toLowerCase();
// stroka index
var search_res = big_text.indexOf(stroka, index);
// , index
if (search_res!= -1) {
index = search_res+stroka.length;
Selection.setFocus(pole);
Selection.setSelection(search_res, search_res+stroka.length);
} else {
// , index = 0;
index = 0;
}
6.
but.onRelease = function{):Void {
stroka=str.text;
poisk();
};
. . , .
.
13.13.6. . replaceSel()
, , , .
. , , , . ,
, . , Actions.
.
, , ,
.
Flash MX, replaceSel() TextField.
, .
, replaceSel(),
, , ,
setTextFormat() HTML-,
. ,
setNewTextFormat(). , HTML, , replaceSel() ,
replaceSel() ,
CSS.
repaceSel()
, .
:
Input.
, . zam;
zambut. ;
, ,
:
zam_but.onPress = function():Void {
pole.replaceSel(zam.next);
};
, , ,
. ,
. , , . replaceSel(), .
- , . , . : zam_but . , (
index) (
stroka), .
, zam_but ,
. , ,
, stroka.
:
zam_but.onPress = function(): Void {
if (pole.text.substring(index-stroka.length, index).toLowerCase() ==
str.text.toLowerCase()) {
Selection,setFocus(pole);
Selection.setSelection(index-stroka.length, index);
pole.replaceSel(zam.text);
}
};
. , __ 13 .
13.14. . TextSnapshot
Flash MX 2004 ActionScript ,
. . ,
. .
, Static . , , ,
swf-.
( , ), . , . Static
. ,
, Dynamic Input. ,
,
.
, . READ ONLY ,
. :
, Internet Explorer.
,
.
, .
Flash
.
, swf-. Flash MX 2004
READ ONLY . TextSnapshot.
13.14.1. TextSnapshot
TextSnapshot .
new .
, . :
// st_text clip
var st_text:TextSnapshot=new TextSnapshot(clip);
TextSnapshot .
-. getTextSnapshot() MovieClip. , . getTextSnapshot()
TextSnapshot, . :
var st_text:TextSnapshot = clip.getTextSnapshot();
trace(st_text);
// : [object Object]
trace(st_text.__proto__ == TextSnapshot .prototype); // : true
// ( TextSnapshot)
TextSnapshot . ,
, ActionScript getTextSnapshot()(
. , Macromedia TextSnapshot ,
. getTextSnapshot() .
TextSnapshot, . ,
, getTextSnapshot().
TextSnapshot , . ( , ), TextSnapshot . ,
.
TextSnapshot.
TextSnapshot . , , .
13.14.2.
, ,
TextSnapshot . , , , . TextSnapshot , , -
, . , getText(). :
t_sn_obj.getText(begin, end, line_endings),
:
t_sn_obj TextSnapshot,
;
begin , , . 0;
end , . , begin 0,
end t_sn_obj.getCount() ( getCount() ). end begin:
bcgin+1;
line_endings , , ,
,
. ,
getText()
TextSnapshot. line_endings false:
.
getText():
// ,
// 1, 2, 3
var st_text:TextSnapshot = _root.getTextSnapshot();
trace(st_text.getText(0,3)); // : 123
, ,
. , , TextSnapshot . ,
, , getText() .
Macromedia (, Flash Paper Flash MX2004) -.
,
.
, , .
: , . , ,
getText() .
getText() , Use Device Fonts.
getText() getCount().
.
length String.
13.14.3.
, TextSnapshot,
. , ,
getText() indexOf() String.
, findText()
TextSnapshot.
:
t_sn_obj.findText(begin, text_to_find, caseSens),
:
t_sn_obj TextSnapshot, , ;
begin , , ;
text_to_find , ;
caseSens , , (true) (false).
findText() ,
. , begin, ,
-1. :
// ", !"
var st_text:TextSnapshot = _root.getTextSnapshot();
var index:Number=st_text.findText(0,"", false);
trace(index);
// : 8
trace(st_text.getText(index,index+6));
// :
findText() , , .
13.14.4.
,
setSelected() TextSnapshot. , ,
. :
.
, .
.
.
Selectable.
, .
.
.
.
.
.
, ,
. ,
. .
-j
setSelected(). , . :
t_sn_obj.setSelected(begin, end, select),
:
t_sn_obj TextSnapshot, , ;
begin , . 0 t_sn_obj.getCount() 1. begin ,
0. , t_sn_obj.getCount() 1;
end , .
begin+1 t_sn_obj.getCount().
end , begin+1, begin+1. end
, t_sn_obj.getCount();
select , , (true) (false).
, setSelected().
setSelected() .
, setSelected(), . .
, setSelected(), . . , ,
, . , . setSelectColor(rgb), rgb
.
Flash Player 7 setSelected(). ,
. (
getSelectedText()), . , ( , ), , , . ,
Flash Player 7.
:
// clip .
//
// .
var st_text: TextSnapshot = clip.getTextSnapshot();
st_text.setSelectColor(0x30000);
st_text.setSelected(0, 1, true);
st_text.setSelected(st_text.getCount()-1, st_text.qetCount(), true);
,
getSelectedText(). , .
, . ,
TextSnapshot, , .
getSelectedText() . , , \n , . false:
.
getSelectedText() , setSelected().
.
getSelectedText() , ,
<Ctrl> + <C> . ActionScript,
.
, . getSelected(begin, end), begin , ,
, end , . , getSelected()
true. false. , , begin 0, end , getCount().
, , Static.
,
Flash-. .
:
/* , . , .
search_string. . but. .
clear. . */
var st_text:TextSnapshot = _root.getTextSnapshot();
st_text.setSelectColor(0xFF0000);
but.onPress = function():Void {
// ,
if (st_text.getSelected(0, st_text.getCount())) {
st_text.setSelected(0, st_text.getCount(), false);
}
// n ,
//
var n:Number = 0;
//
while (n<st_text.getCount()) {
// , ,
//
n = st_text.findText(n, search_string.text, false);
// n
// ,
if (n == -1) {
return;
// , n
} else {
st_text.setSelected(n, n+search_string.text.length, true);
n += search_string.text.length;
}
}
};
// ,
clear.onPress = function():Void {
if (st_text.getSelected(0, st_text.getCount())) {
st_text.setSelected(0, st_text.getCount() , false);
}
};
13.14.5.
,
( ).
hitTestTextNearPos() TextSnapshot. :
hitTestTextNearPos(x, , maxDistance),
:
, .
, ;
maxDistance , , hitTestTextNearPos() . 0. , , .
hitTestTextNearPos() ,
. , , TextSnapshot.
maxDistance,
1.
hitTestTextNearPos() . , , ,
. , , . :
//
var st_text:TextSnapshot = this.getTextSnapshot();
var index:Number = -1;
// ,
//
this.onMouseDown = function():Void {
st_text.setSelected(0, st_text.getCount(), false);
index = st_text.hitTestTextNearPos(_xmouse, _ymouse);
};
// ,
// ( index). ,
// , , ,
// .
this.onMouseMove = function():Void {
if (index!= -1) {
st_text.setSelected(0, st_text.getCount(), false);
var index_2:Number = st_text.hitTestTextNearPos(_xmouse, _ymouse.1000);
if (index_2>index) {
st_text.setSelected(index, index_2, true);
} else {
st_text.setSelected(index_2, index, true);
}
}
};
// ,
this.onMouseUp = function():Void {
index = -1;
};
Selectable , . TextSnapshot, .
, , , , <Ctrl>. Flash MX 2004
ActionScript (. ).
13.15.
, . , <Ctrl> + <C> ( ). . , ActionScript System.setClipboard(), . . , .
setClipboard() true.
, false.
setClipboard()
13.14.5 , <Ctrl> + <> :
// , <Ctrl> + <C>
fscommand("trapallkeys", "true");
//
Key.addListener(this);
this.onKeyDown = function():Void {
if (Key.isDown(17) && Key.isDown(67) && st_text.getSelected(0,
st_text.getCount())) {
System.setClipboard(st_text.getSelectedText());
}
};
//
var cont_menu:ContextMenu = new ContextMenu(activ);
this.menu = cont_menu;
var copy_command:ContextMenuItem = new ContextMenuItem(" ", copy);
function copy():Void {
System.setClipboard(st_text.getSelectedText());
}
// ,
function activ():Void {
if (!st_text.getSelected(0, st_text.getCount())) {
copy_command.enabled = false;
} else {
copy_command.enabled = true;
}
}
cont_menu.customItems.push(copy_command);
, .
<Ctrl> + <C>, . <Ctrl> ActionScript. trapallkeys fscommand(). , , , .
13.16. . Strings
, , . - , , .
, , . :
, ? , .
. (, http://www.macromedia.com http://www.google.com)
. ,
, , ,
.
ActionScript, Flash- . , . Flash MX 2004 ,
( -
). , , ( language System.capabilities). :
var language:String = System.capabilities.language;
switch (language) {
case "ru":
//
pole.text = "";
break;
case "de":
//
pole.text = "hallo";
break;
default:
// ( )
pole.text = "hi";
}
. ,
swf-. , . , .
,
. XML-. ,
, , , . XML XMLNode, ,
17. , ,
XML- , . , Flash MX 2004
, , .
XML-
, ActionScript. Strings.
Strings ( Window/Other Panels/Strings <Ctrl> + <F11>)
. , , .
Strings
:
1. Strings . Settings. Settings :
o Select languages. , . , Add.
(en , de . .)
Available languages. ,
.
Available languages ,
Remove.
Select languages .
, , . . OR, Select languages.
ISO 6391 ( , ,
http://www.loc.gov/standards/iso639-2/englangn.html).
( ). ISO 639-1
100 ( ISO 6392 ). ActionScript , .
System.capabilities.language.
() : xx_YY. YY , .
ISO 3166-1.
, ( (en_US) (en_GB) ).
.
o Select default language. , ,
, (, , ).
o URL. ,
XML- .
, swf-, .
o Insert ActionScript for automatic language detection. ,
ActionScript, ,
XML-,
. ,
Strings.
, ,
2. Settings , Strings.
, , -
. , ,
ID Strings . , ID,
Apply ( <Enter>). Strings . IDS_,
ActionScript ( , ).
.
, ID Strings . Apply, .
ActionScript, ID-
. Input
Dynamic.
3. , Strings, ID,
, ,
, Settings. , ( ). , , , de , en , ru .
, .
, Strings, . CSS-,
Strings.
TextFormat. HTML (
text, htmlText ).
Strings, ,
. -,
, Strings XML- (. ).
, .
4. .
, ,
. , Stage language Strings.
, ID-,
. ( ). Stage language,
. ,
.
, , String Strings.
Apply, .
5. , Flash,
.
Strings . XML- , ,
. , , XML-
.
, , .
Strings. :
o Import XML Strings.
o Language of file Import XML ,
. , Strings.
o Windows XML.
, XML-
.
, . ,
fla-, , ,
en, de, . . XML, Strings .
:
Name_lang.xml,
:
Name swf-, ,
lang , .
, movie.swf movie_ru.xml ru. swf-, XML-, . XML- , swf- .
XML-, ,
, . . URL, XML, URL Settings, Settings
Strings. URL , . ,
, Flash MX 2004 (
17).
, , ,
,
. XML-. , ,
, . ,
ID-, ,
text . ,
, , ,
swf-. , pole ID=IDS_1, -
:
if (mx.lang.Locale.checkXMLStatus() == true) {
pole.text = mx.lang.Locale.loadString("IDS_1");
} else {
mx.lang.Locale.addDelayedInstance(pole, "IDS_1");
}
, XLIFF, -
. , , . <trans-unk>. ,
ID . <source>. , XLIFF,
. <source>, ,
.
13:
,
. . , , , . ,
,
.
13
. , ,
.
, . ,
, . , , . , .
, .
MovieClip:
MovieClip.prototype.roundText = function (eff:String, depth:Number,
text_p: String, x:Number, :Number, format:Text.Format, N:Number) {}
roundText 7 :
eff , . ;
depth , ;
text_p , ;
;
format TextFormat, ;
n , .
roundText - :
var effect:MovieClip = this.CreateEmptyMovieClip(eff, depth);
, , , , . , , ,
.
,
, .
. , , W ( ). ,
, getTextExtent():
var text_width:Number = format.getTextExtent("W").width*text_p.length;
, ,
( I = 2R ):
var radius:Number=text_width/(2*Math.PI);
, . char_numb ,
char_numb :
var char_numb:Number = text_p.length;
for (var i = 0; i<char_numb; i++) {}
.
( , ):
X = X0 + R cos( )
Y = Y0 + R cos( )
X Y ; 0 Y0 ; R ;
, (X, Y) .
, , . n- , n:
phi = 2*Math.PI/char_numb*i;
_ = x+radius*Math.cos(phi);
y_p = y+radius*Math.sin(phi);
, ,
:
effect.createTextField("pole"+i, i, x_p, y_p, 0, 0);
with (effect["pole"+i]) {
text=text_p.substring(i, i+1), autoSize=true, setTextFormat(format);
}
, , , (,
. , .
. - , ,
. :
effect.n=0, effect.x=x, effect.y=y, effect.radius=radius, effect.fr=N,
effect.step=2*Math.PI/char_numb;
effeet.onEnterFrame = function():Void {
var I:Number = 0;
:
. effect ,
onEnterFrame. ,
, roundText()
, , .
n , . onEnterFrame , , ,
.
(. 13.32). . , ,
.
. 13.32.
, . , , ,
, .
, .
, . , ,
. ,
, . ? , . , ,
. , .
, . ? , ? ( , , )?
, .
, , , .
:
1. . .
, , .
2. , , .
, , , .
, .
3. . ,
.
4. . ,
.
5. , . , , .
6. 25 , . , .
, .
, , .
.
, , createMain(), ,
:
function createMain(x:Number, :Number):Void {}
createMain() ,
. text_p:
this.createTextField("pole1", 0, , , 0, 0);
pole1.text = text_p;
pole1.autoSize="left", pole1.embedFonts=pole1.border-true, pole1.selectable=false;
.
. , ,
, .
. - (, Courier New).
. , -, , -, - ,
.
, font.
(2030 ). . .
pole1.setTextFormat(new TextFormat("font", 20, 0xFFFFFF, null, null, null,
null, null, "center"));
, . ,
, , ,
:
var char:String = null, n:Number = 0;
for (var i = 0; i<text_p.length; i++) {
char = text_p.length.charAt(i);
if (char!= " " && char!= "\r" && char!= "\t" && char!= "\n") {
// arr
arr[n++] = i;
}
. createSymbol(), :
createSymb();
createSymb(), :
function.createSymb():Void {}
createSymb() , createMain(). .
, :
this.createTextField{"pole2", 1, -100 + 700*Math.random(), -100 +
600*Math.random(), 0, 0);
pole2.autoSize = pole2.embedFonts=true, pole2.selectable=false;
pole2 pole1.
, .
, ,
arr
:
var index:Number = Math.round(arr.length*Math.random());
n = arr[index];
. ,
arr ,
createSymb():
arr.splice(index, 1);
pole2. , index, . ,
. ,
, , (
, ):
var pole2_text:String = text_p, char:String = null;
for (var i = 0; i<pole2_text.length; i++} {
char = pole2_text.charAt(i);
if (i!= n && char!= " " && char!= "\r" && char!= "\t" && char!= "\n") {
pole2_text = pole2_text.slice(0, i)+" "+ pole2_text.slice(I +1);
}
}
, , pole1:
pole2.text = pole2_text;
pole2.setTextFormat(new TextFormat("font", 20, 0, null, null, null, null, null,
"center"));
pole2 pole1 . , ,
( 20-30). . pole2 ,
.
step_x step_y:
var delta_x:Number = (pole2._x-pole1._x);
var delta_y:Number = (pole2._y-pole1._y);
step_x = delta_x/20;
// 20
step_y = delta_y/20;
setInterval , loop.
charMover(),
:
function charMover():Void {}
, , .
pole1 pole2. (35 ), , pole1, , .
setInterval.
var rast:Number = Math.sqrt((pole2._x-pole1._x)*(pole2._x-pole1._x)+
(pole2._y-pole1._y)*(pole2._y-pole1._y));
if (rast<3) {
pole2.removeTextField();
pole1.setTextFormat(n, new TextFormat(null, null, 0));
clearInterval(loop);
}
, pole1 pole2.
, 1/20 , 20
charMover() .
. . , _ _
0,05 .
. ,
. ,
20 pole1 pole2 , ,
: 1 , , .
_ _, , ,
3 .
, ,
. ,
createChar(), , ,
:
if (arr.length!= 0) {
createSymb();
}
, ,
:
pole2._x -= step_x;
pole2._y -= step_y;
,
pole2 :
updateAfterEvent();
. . .
:
. user_text.
,
speed. .
. ( 0 99) ,
.
start.
onPress. :
but.onPress = function():Void {
//
n=null, text_p=user_text.text, arr=[], speed_t=speed.text;
// setInterval
clearInterval(loop);
createMain(100, 100);
//
};
random.fla
13.
14
? , , . , , ,
, . ,
.
, - .
, . .
.
ActionScript. . , ,
, , ,
.
,
.
ActionScript .
ActionScript Date.
. ,
getTimer(), , .
Date , 14.1 14.2.
14.1.
, , .
. 24 . ,
12 .
,
. , XIX . , . XIX
.
1884 , (UT),
, ,
.
24 ( 15 ),
. .
, , ,
. , 23 21 , 2
22 , - 9 21 .
GMT (Greenwich Mean Time).
+/ N , GMT +/ N (, GMT+03:00).
, 24 , -
, . , , .
. ,
, ,
, . ,
.
,
. , . ,
, .
Windows .
.
,
. , , , , . . , , .
UT0. - .
UT1. .
LT2. .
, .
1960- , .
. 100 ,
, , (TAI). 40
.
.
, .
.
, UTC (Universal Time
Coordinated), . UTI - UTC 0,7-0,9 .
.
UTC ,
1972 .
, UTC-, (GMT),
UTC. UTC-
ActionScript (, , ).
14.2.
: , ?. ,
. , , .
1/1000 ( , ),
.
,
. , . .
, Windows . , . , , , . , - .
UTC- .
, , , , , . , 1 1970
. , , , , , . . .
, , , 86 400 000
. , , -
, , UTC-.
, , - .
.
, , . , . ActionScript,
, (. ).
ActionScript 64- .
, . 1 1970 1 072 062 073 017 . 64 -9 007 199 254 740 991 9 007 199 254 740 991. , , 1970 200 000 .
14.3. Date
, , , , , , ,
. , , , . ,
, ( ).
.
Date, Macromedia. ,
,
-262, .
14.3.1. Date
Date ActionScript .
, I 1970 (. . , ). Date()
,
.
Date() , , - new.
Date(). ,
:
var time:Date=new Date();
trace(time);
// "Mon Dec 22 07:46:16 GMT+0300 2003"
Date -
, ,
. :
var date:Date=new Date(year, month, date, hour, minute, second, millisecond};
year , .
(1970 2004). 1900 1999 ,
year . , 80 1980 ( 80 ).
1900 (, ,
2000 ). , 1900, . , 1899 1, 1500
500,1 1899. , ,
(, 1784). , 1900 ;
month , ( ) . . , , 1, 0. , , 2, ;
date . , 1, 0,
Date();
hour , . 0
23;
minute . 0 59;
second , . 0;
millisecond , . 0 999.
. ,
Date() (, , , , ). , year month, .
, 0 ( 1 date).
:
var time:Date=new Date(2003,2,5,6);
trace(time); // "Wed Mar 5 06:00:00 GMT+0300 2003"
Date() ,
. ,
setUTC...() (. ).
Date(),
Macromedia, -262. Date ,
. :
var time:Dace=new Date(-1046833200000);
trace(time);
// "Fri Oct 30 00:00:00 GMT+0300 1936"
Date() . ,
, ,
.
14.3.2. Date
Date 37 (
ActionScript MovieClip 30). : Date . , UTC() toString(),
Date() .
Get-. , . , getHours() ( ),
, Date. getYear() ,
getMilliseconds() . . get- ,
.
Set-.
, Date, , setDate() ,
setSeconds() , setMonth() . set- ( ).
set- , ,
. ,
Date , , . , setUTC.
Date ,
.
. , , ,
. ,
.
,
. , , ( ) . , , ,
, . - ,
. - , , ( 50 %). , .
// ,
// , ,
//
var time:Date=new Date();
trace(time.getHours());
// "11"
time.setMonth(6);
// ""
trace(time.getHours()); // "11"
Bo Flash 5 , .
, ,
Flash 6. .
. ,
, UTC-. , UTC- , UTC. . ,
.
, . , , , .
, , UTC.
UTC (, getUTCTime()).
Date, UTCQ, . LTC()
(. . Date()).
, Date ,
. , (, getMonth(), month)?
, . , ,
, 1 1970 . 1970 ,
. .
, . , , .
Date :
getTime() ;
setTime() , Date;
UTC() .
getTime() , . , , :
var time1:Number=(new Date()).getTime();
for (var i=0; i<1000000; i++) {
}
trace((new Date()).getTime()-time1);
// "5147"
.
Date(), ,
, , , (, ):
var begin_time:Number={new Date()).getTime();
for (var i=0; i<1000000; i++) {
}
var delta_time:Number=(new Date()).getTime()-begin_time;
var time:Date-new Date(delta_time);
trace(" :\r"+(time.getUTCFullYear()-1970)+" \r" +
time.getUTCMonth() + " \r" + (time.getUTCDate()-1) + " \r" +
time.getUTCHours() + " \r" + time.getUTCMinutes() + " \r" +
time.getUTCSeconds() + " \r" + time.getUTCMilliseconds() + "
");
/* :
" :
0 0 0 0 0 5 307 " */
Date.
,
, .
, getTime(), 10 . , :
var time1:Number=(new Date()).getTime();
var time2:Number=null;
for (var i=0; i<10000; i++) {
time2=(new Date()).getTime();
trace(time2-time1);
time1-=time2;
}
// "0 0 0 0 0 10 0 0 0 0..."
, getTime() . ,
, 100 . (18 ).
ActionScript Date ,
. setTime():
var date:Date=new Date();
date.setTime(565436745768);
trace(date.getFullYear());
// "4987"
. , , Date
getTime(). , :
trace((new Date(2004, 0)).getTime()-(new Date()).getTime()); // "711372224"
, Date.
Date UTC(). , Date() (.
14.3.1). :
trace(((Date.UTC(2005,0))-Date.UTC(2004,0))/(1000*60*60*24));
// "366" (2004 - )
Date , , .
.
getYear() setYear(). . , 1900. , 1999 99-, 2003-103. 1900 (,
1798 -102).
getYear() setYear() . UTC ActionScript ,
getFullYear(), setFullYear() ( ) getUTCFullYear(), setUTCFuilYear() ( ), . .
.
, ActionScript - ,
. :
var date:Date=new Date(0,0);
trace(date.getFullYear());
trace(date.getYear());
// "1900"
// "0"
, Date ,
getMonth() ( ) getUTCMonth() (
). setMonth() setUTCMonth(). . , . . 0, 1 . . :
// , 100
var date:Date=new Date();
date.setTime(date.getTime()+100*1000*60*60*24);
function month(numb:Number):String {
var arr:Array=["", "", "", "", "", "", "",
"", "", "", "", ""];
return arr[numb];
}
trace(month(date.getMonth())); // :
, , -
, , ,
. getDay() ( ) getUTCDay() ( ). , 0 () 6 ().
, , . , (
).
// , 100
var date:Date=new Date();
date.setTime(date.getTime()+100*1000*60*60*24);
function day(numb:Number):String {
var arr:Array=["", "", "", "", "",
"", ""];
return arr[numb];
}
trace(day(date.getDay())); // :
, ,
, ,
, , , , UTC. Date , .
, , , :
getHours(), setHours() ( ) getUTCHours(), setUTCHours() ( )
. ( );
getMinutes(), setMinutes() ( ) getUTCMinutes(), setUTCMinutes() ( ) , . 0 59;
getSeconds(), setSeconds() ( ) getUTCSeconds(), setUTCSeconds() ( ) , , Date. 0 59;
getMilliseconds(), setMilliseconds() ( ) getUTCMilliseconds(), setUTCMilliseconds() ( ) , . 0 999.
, , Date, 10 , , getMilliseconds() getUTCMilliseconds() . , .
set ,
(0-23 , 0-59 , 0-999 ),
. , , . . , setMinutes() 100 , getHours() ( getDate() getMonth()). set .
. :
var date:Date=new Date();
trace(date.getDate()); // : 23
trace(date.setHours(-100);
trace(date.getDate()); // : 18
,
:
// ,
this.createTextField("timer", 0, 100, 150, 145, 27), timer.border=true;
timer.setNewTextFormat(new TextFormat("Lucida Console", 20, 0, true));
// ,
function time():Void {
var tm:Date=new Date();
timer.text=tm.getHours() + ":" + tm.getMinutes() + ":" + tm.getSeconds()
+ ":" + Math.round(tm.getMilliseconds()/10);
// ,
updateAfterEvent();
}
setInterval(time, 10); // 100
( ) . ,
. 12 12 ( , 4 30 ). ActionScript getTimezoneOffset(). :
var date:Date=new Date();
trace(dats.getHours()==(date.getUTCHours()-date.getTimezoneOffset()/60) %24);
// : true
Date, . ActionScript.
Date
object String , , :
[object Object]
( , , _global
),
[type Object]
Date , toString().
, Date String, . , , SWF . ,
Date. -262 parse(), , , ActionScript .
.
Number Date .
( Boolean, Number String, ) NaN,
Date , (. .
, 1 !970 ). :
trace(Number(new Date()));
// : 1072217134319
, Date
getTime().
. ,
, ,
getTime() :
// , "-"
var begin_time:Date=new Date();
for (var i=0; i<2000000; i++) {};
trace((new Date())-begin_time);
// : 10164
// : true
14.4. ,
, onMouseMove 100 . ,
.
14:
Flash
, ActionScript.
, . ,
. ,
, , . .
, , . , .
,
- ActionScript 2.0.
, .
, . AS- Clock.
Flash ( ) .
Clock ,
class Clock {}
, , . -. Clock,
:
function Clock(clip:MovieClip, name_clock:String, depth:Number, coords:Object,
linesCol:Array, fillCol:Array, textCol:Number) {}
clip , ;
name_clock . ,
(, ),
;
depth , ;
coords : ,
Y, size ( );
linesCol fillCol ,
. ;
textCol , .
Clock,
:
x=coords., y=coords., size=coords.size;
:
private var :Number=null, :Nuraber=null, size:Number=null;
, .
Clock, clock:
clock=clip.createEmptyMovieClip(name_clock, depth);
clock :
private var clock:MovieClip=null;
, lineCol fillCol.
, . beginFill()
lineStyle(), fillCol:
if (fillCol==undefined || fillCol==null) {
var fillCol:Array=[0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF,
0xFFFfFF];
}
, , . . ( , ), ( ).
, , :
private function drawBox(clip:MovieClip, coords :Object, lineStrObject,
fillSt:Object):Void {
clip.lineStyle(lineSt.thickness, lineSt.rgb, linest.alpha);
clip.moveTo(coords.xMin, coords.yMin);
clip.beginFill(fillSt.rgb, filist.alpha);
clip.lineTo(coords.xMax, coords.yMin);
clip.lineTo(coords.xMax, coords.);
clip.lineTo(coords.xMin, coords.yMax);
clip.endFill();
}
drawBox() :
clip , ;
coords .
; xMin, yMin ; , ;
lineSt , ,
. : thickness
, rgb alpha ;
fillSt , : rgb ,
alpha .
, , . ,
10:
private function drawCircle(clip:MovieClip, xCenter:Number, yCenter:Number,
radius:Number, N:Number, lineSt:Object, fillSt:Object):Void {
var phi:Number=2*Math.PI/N;
clip.lineStyle(lineSt.thickness, lineSt.rgb, lineSt.alpha);
clip.moveTo(xCenter+radius, yCenter);
clip.beginFill(fillSt.rgb, fillSt.alpha);
for (var i=phi; i<2*Math.PI; i+=phi) {
clip.lineTo(xCenter+radius*Math.cos(i), Center+radius*Math.sin(i));
}
clip.endFill();
}
drawCircle():
clip , ;
xCenter, yCenter, radius ;
N , . ,
, N;
lineSt fillSt , drawBox().
, , -, . . . linesCol fillCol.
( ). 100 (
alpha , clock).
var lineSt1:Object={thickness:Math.round(size/150), rgb:linesCol[0], alpha:100};
var fillSt1:Object={rgb:fillCol[0], alpha:100};
var coords1:Object={xMin:x-size*0.05, yMin:y-size*0.05, :+1.05*size,
yMax:y+l.05*size);
drawBox(clock, coords1, lineSt1, fillSt1);
.
60 , . , ,
. , .
,
:
private function createNumbers(sm_rounds_lines_col:Number, sm_rounds_fill_col:Number,
big_rounds_lines_col:Number, big_rounds_fill_col:Number, textCol:Number):Void {}
createNumbers() :
sm_rounds_lines_col sm_rounds_fill_col
;
big_rounds_lines_col big_rounds_fill_col ,
;
textCol .
createNumbers() , drawCircle().
, .
, :
var linest_small:Object={thickness:Math.round(size/300), rgb:
sm_rounds_lines_col, alpha:100};
var fillSt_small:0bject={rgb:sm_rounds_fill_col, alpha:100};
var lineSt_big:Object={thickness:Math.round(size/300), rgb:
big_rounds_lines_col, alpha:100};
var fillSt_big:Object={rgb:big_rounds_fill_col, alpha:100};
, , , , . , :
//
var radius:Number=null, xCenter:Number=null, yCenter:Number-null,
t_x:Number=null, t_y:Number=null;
// ,
var phi:Number=Math.PI/30;
// C 60
for (var i=l; i<=60; i++) {
// ( // , )
radius = i %5 == 0? size/50: size/90;
// . ,
// , ,
//
xCenter=x+size/2+0.37*size*Math.cos(i*phi);
yCenter=y+size/2+0.37*size*Math.sin(i*phi);
// . .
drawCirele(clock, xCenter, yCenter, radius.Math.round(size/30), i %5==0?
lineSt_big: lineSt_small, i %5==0? fillSt_big: fillst_small);
}
, . ,
, , , .
:
//
//
clock.createTextField("pole"+i, 10+i/5, 0, 0, 0, 0);
clock["pole"+i].text=i/5, clock["pole"+i].autoSize=true;
clock["pole"+i].setTextFormat(format);
//
t_x=x+size/2+0.45*size*Math.cos(i*phi-Math.PI/2);
t_y=y+size/2+0.45*size*Math.sin(i*phi-Math.PI/2);
//
clock["pole"+i]._x=t_x-clock["pole"+i]._width/2;
clock["pole"+i]._y=t_y-clock["pole"+i]._height/2;
}
if (i %5==0) {
.
, . , (. . ). , / 2 . ,
, . , .
. , , -
t_x t_y .
, X t_x , . , Y t_y .
format, , :
//
var format:TextFormat=new TextFormat(null, Math.round(size/15), textCol, true);
createNumbers() . :
createNumbers(linesCol[3], fillCol[3], linesCol[4], fillCol[4], textCol);
,
fillCol linesCol, .
. ,
.
. , , 12. , , ;
Y (. . X-
width/2, width/2, width
);
X 9:1 (. . Y- , , -height*0.9, ,
, height*0.1, height ). , , .
createArrow():
private function create Arrow(name:String, depth:Number, width:Number, height:Number,
lineSt:Object, fillSt:Object):MovieClip {
var arrow:MovieClip=clock.createEmptyMovieClip(name, depth);
arrow._x=x+size/2, arrow._y=y+size/2;
drawBox(arrow, {xMin:-0.5*width, yMin:-0.9*height, xHax:0.5*width,
:0.1*height}, lineSt, fillSt);
return arrow;
}
createArrow() :
name . , . , createArrow(), ;
depth , .
;
width height ;
lineSt fillSt .
.
,
. , .
fillCol linesCol:
var lineSt4:Object={thickness:Math.round(size/250), rgb:linesCol[5], alpha:100};
var fillSt4:Object=(rgb:fillCol[5], alpha:100};
hour_arrow=createArrow("arr_1", 0, size*0.045, size*0.3, lineSt4, fillSt4);
minute_arrow=createArrow("arr_2", 1, size*0.025, size*0.33, lineSt4, fillSt4);
. ,
.
fillCol linesCol:
var lineSt5:Object={thickness:Math.round(size/250), rgb:linesCol[6], alpha:100};
var fillSt5:Object{rgb:fillCol[6], alpha:100};
second_arrow=createArrow{"arr_3", 2, size*0.015, size*0.43, lineSt5, fillst5);
time() :
var date:Date=new Date();
hour_arrow._rotation=((date.getHours()+date.getMinutes()/60) %12)/12*360;
minute_arrow._rotation=(date.getMinutes()+date.getSeconds()/60)/60*360;
second_arrow._rotation=date.getSeconds()/60*360;
6 .
. time() 1000 .
setInterval(this, "time", 1000);
time();
//
, time() setInterval() .
, , .
Clock . ,
.
getter/setter-:
public function get hour():Number {
return (new Date ()).getHours();
}
public function get minutes():Number {
return (new Date()).getMinutes();
}
public function get seconds{):Number {
return (new Date()).getSeconds();
}
//
//
//
. 14.1. ,
. . FLA-, , Clock.as,
var linesCol: Arrays[0x000033, 0x000066, 0x0000DD, 0x000033, 0x330000, 0, 0];
var fillCol:Array=[0x000088, 0x0099FF, 0x00DDFF, 0x0000BB, 0xFF0000, 0x7700DD,
0xDD0033];
var clock:Clock=new Clock(this, "c1", 0, 1x:100, y:100, size:300}, linesCol, fillCol,
0x000088);
. , , . 14.1.
15
Flash-, ,
( , Flash, ).
ActionScript, . , .
ActionScript, 100 %.
, ,
, ActionScript.
, Flash,
. ,
. , , , .
15.1.
, , . ( , .),
. ( ) . , . 20 20 . .
, .
. , . .
( ) , .
,
. , , . .
, , .
(
) (. . , ). , ,
.
.
. . , -
(), ( 0,001-0,0001 ) , ,
. ,
( . sample ). ,
.
(
, - ()). () . , .
.
1. ;
2. .
3. .
4. / ().
5. .
, .
15.1.1.
, . , ( ).
, (, ,
).
, ,
. 20 ,
40 .
, -, 44.1 ( CD-). , ,
.
44.1 .
,
,
44.1 :
22.05 -. FM. Flash
. ;
11.025 . , . 1-;
5,5 .
, (,
).
Flash- 44,1: 22,05; 11,025; 5,5 .
, ,
SWF-. , . , -
15.1.2.
, . 4 ,
16 . , .
, ( ).
8 256 . FM-. . 16- .
65 536 ,
.
16 -. .
Flash- 8- 16- (,
WAV) 16- ( 3).
.
15.1.3.
, . , .
, , .
.
Flash-. ActionScript, ,
, . , .
3-, .
Dual Channel. . ,
, , .
Stereo. , , . .
Joint Stereo. .
, . , .
, Flash , .
, , 3- .
, ,
Convert Stereo to Mono ( ). .
, Flash, ,
. Nellymoser,
.
15.1.4.
, , CD-. , size = F B K t ,
F , , , t .
44,1 , = 2 , = 2 t = 300 , ,
50 .
, - 10 .
, CD-, 200 ,
, .
11,05 8 ,
11 .
, , : - .
.
Flash- .
ADPCM (Adaptive Differential Pulse Code Modulation ). . -, ,
. ,
(, ).
, ,
, , ,
. -, , ( ).
ADPCM IP-.
- (, , ,
). ADPCM
8:1 3:1. ADPCM Flash-
2, 3,4 5 .
(bitrate, . . ) 16 .
ADPCM , . 3- .
:
Flash 4. ADPCM, , , . , ADPCM
IP-, ,
, , .
3. ,
.
:
o , . ;
o ,
, . ;
o , ,
, ;
o , , .
3 . , (frames),
.
. . ,
.
3 20-30 . ,
CD- 160 / ( 3-).
. Flash- 3, 16-32 /.
Flash- 16 160 /,
. 3- , (
Use imported mp3 quality). , , .
, .
, , Flash- , MPEG1 Layer 3, (MPEG2 MPEG2.5),
. , 3- , ( ).
3- Rash-.
. , 3- ,
ID3- .
Nellymoser. , Nellymoser
Inc. . , .
.
. , 3-,
. Nellymoser
http://www.nellymoser.com/.
Nellymoser Flash MX.
Flash Nellymoser Speech ().
/ Nellymoser ,
.
SWF- . Raw.
.
, (,
, ).
3- ( 120 /) .
15.1.5.
. Flash .
WAV. Windows.
- , . WAV
,
. WAV- , . , WAV , SoundForge.
3. , .
Flash , . , , WAV-,
loadSound() Sound.
QuickTime 4 , AIFF, QuickTime, Sun AU.
Wave MIDI. , ,
Wave-. MIDI , . .
MIDl- , . . MIDI- , , ,
.
Flash- MIDI-. , . , ,
IDI-. Flash MX 2004 Professional , , MIDI-. Macromedia.
. ,
. , ( ) .
.
Sync .
o Event. ,
.
o Start. , , - , hi; .
, , , .
, . ,
. ,
.
, . , , . .
(stream).
. ,
.
.
:
o . -
, ,
. , , .
, . .
: ,
;
o - ,
. ,
- ;
o , . , ;
o
.
, -
, ;
o
( ).
,
, 5 .
, ,
, 5 .
. , ,
,
. .
_soundbuftime.
, .
, , . .
. , . , . , , .
, . , , , .
15.3.
. Flash, , ,
. ,
Flash-.
Flash .
, , , . SoundForge,
.
Flash . , . WAV- 3- ,
. ,
. , ,
Stop Sync (
, ). Sound
. ,
.
Flash MX 2004 . ( ) , -
- . , Fade In . Effect
. ,
. , , . Edit Envelope, Edit .
, Edit Envelope,
, .
{ ,
), . , , 3- , , , .
, . . ,
, Event. ,
Sync, Loop. .
, ( ).
, . ,
.
usability ( ).
.
, Set
Audio stream ( ) Audio event ( ) Flash Publish Settings.
, .
Sound Properties, Properties . , ,
. ,
Override sound settings Flash Publish Settings.
, ( ), .
15.4. Sound
ActionScript Sound. , ,
MovieClip, Sound . Sound , .
, Flash (
). Sound . , : Sound .
, ( ),
.
: , ,
? Sound
, , -
. , :
,
( , , attachSound() loadSound()). , , , , .
Sound. -
. Sound() .
:
var sound:Sound=new Sound(clip);
// sound clip
, , Sound
. ,
, . , , X % , . , , , . , , _root.
, , : Sound()
. , . Sound , -.
Sound,
. ,
( Sound ).
(,
).
Sound, . , Sound() :
//
var global_sound:Sound=new Sound();
global_sound.stop();
, :
var sound:Sound=new Sound();
var sound:Sound=new Sound(this);
. Sound,
, ,
, . (
) , .
Sound, ,
, , . . , , _root,
stop().
Sound ,
( ),
. .
Sound
. , , , ,
.
15.5. . attachSound()
attachMovie() .
attachSound() Sound.
.
attachSound(),
. , .
1.
(F11),
. Linkage.
Linkage Properties.
2.
3.
,
. Export in first frame (
10).
attachSound() , attachMovie():
snd.attachSound("Id"),
snd Sound,
. Sound . attachSound() ( ,
);
"Id" .
, :
var sound:Sound=new Sound(_root);
sound.attachSound("snd");
sound.start();
attachSound() () ,
Sound. Sound
( ), , .
, Sound ,
attachSound(), . , , , duration (
) start() ( ).
. Sound
,
. ,
Sound ,
. ,
.
, Sound ( attachSound(), loadSound(), getBytesLoaded(), getBytesTotal() onLoad) . , , . , setVolume()
( ,
Sound , ), ( ) , ( attachSound() loadSound()) . , position ,
. , .
Sound, , .
, attachSound(), , ,
, . , , , .
. - . ,
, attachSound().
,
Sound, . stop().
,
Sound, . ,
attachSound() .
15.6. 3-
Flash, . Flash-
, , .
, .
, 3- .
.
, .
, , . ,
, . SWF- .
Flash 5.
, loadMovie(). ,
- (,
, ). , , SWF-, . ,
, Flash, . Flash MX Sound loadSound(),
3- , .
getBytesLoaded() getBytesTotal(), onLoad.
.
15.6.1. loadSound()
loadSound() 3- . :
snd.loadSound(URL, isStreaming);
:
snd Sound, . , loadSound(), ,
attachSound(). , , ,
loadSound(). , Sound
, , loadSound()
attachSound();
url 3-, . ( ), . Flash 7 ( ).
, SWF-.
3- HTTP.
http://. ,
FTP. ftp://. ( ) FTP
;
ioStreaming , . :
1.
(isStreaming=faise). Flash- ,
, . ,
-
,
. ( , ,
)
, ( ).
, , , , attachSound(). To ,
Sound loadSound()
attachSound(). ,
( , ).
Sound.
2.
(isStreaming=true). ,
.
, 5 .
,
. ,
. . , , . ,
.
, 3- (8-24 /),
, .
3-, ,
(, 3- ). , mp3-, . .
, , . , ,
start().
.
, , , . ,
duration position, getBytesLoaded()
getBytesTotal(). stop(),
. (
). ,
ActionScript . , -
, .
,
, loadSound() B , . - .
, , ,
, , . , . , ,
( , - ), 5 . ,
, _soundbuftime.
, -. ,
. , ,
_soundbuftime=60;
, Flash- , , . , ,
. , , , , , .
loadSound(), . , 3-. ,
. , . , ,
:
var sound:Sound=new Sound(this);
sound.loadSound("http://harms.mtu.ru:9000/", true);
15.6.2. . onLoad
onLoad Sound MovieClip. 3- loadSound() ,
. onLoad : , true,
- ( ,
), false.
, , , ,
onLoad false:
var sound:Sound=new Sound(this);
sound.loadSound("music.mp3", false};
sound.onLoad=function(succ:Boolean):Void {
if (succ) {
sound.start();
} else {
trace(" 3- ");
}
};
15.6.3.
Flash- , . -
( ), . , . , , , , , 100 %.
, , MovieClipLoader.
. Sound , MovieClip: getBytesLoaded() getBytesTotal(). , 3- .
. , . ,
(
). .
:
, , is . , , .
15.7.
, Sound. start() stop() . .
onSoundComplete, .
15.7.1. . start()
start () , attachSound() loadSound(). , , , , .
, . start() ,
. ,
, _soundbuftime. ,
, , start() , .
start() :
snd.start(offset, loop)
:
snd Sound, , ;
offset , , (
). , 3 ( ),
3. offset
. ,
( position). ,
, , start(), offset ;
loop , , .
. , , loop (, 100 000).
start() . , , . .
, stop()
position.
15.7.2. .
stop() stopAllSounds()
stop() . .
. stop() , , Sound. To ,
start(), ,
attachSound() loadMovie(), , , Sound, .
stop() Sound (
, Sound() ),
.
stop(), Sound,
, ,
, .
.
stop() Sound,
. *
.
stop() , . ,
. start() ,
, .
. stop() ,
attachSound(). . stop()
.
stop() Sound, , , . stop()
Sound, , ,
, .
, , .
Flash 3 (
Sound). stopAllSounds().
ActionScript. , :
stopAllSounds();
(new Sound()).stop();
// ""
// ""
. .
, . :
(new Sound()).setVolume(0);
15.7.3. onSoundComplete
onSoundComplete , attachSound() loadSound() ( , ). , , onSoundComplete .
onSoundComplete , ,
:
var sound:Sound=new Sound(this);
sound.attachSound("snd");
sound.start();
sound.onSoundComplete=function():Void {
sound.start();
}
15.9.
(). Sound
, . ,
, , . , ,
, , ,
. , .
15.9.1.
setVolume(percent), percent
(0 , 100
). percent 100. , . percenl=300 , . , percent 100 %
( Macromedia ).
, . percent>1000
, .
, setVolume() , ( , ,
) ( Windows
).
. , , setVolume() 100 000, .
setVolume() ( , ), , Sound,
. , ,
, .
setVolume() Sound(), . . , setVolume(), : ,
, .
. , ,
( ).
, . , , . , , .
, , ,
Sound, getVolume(). setVolume(). getVolume() ,
, ,
.
, :
function fadeIn(sound:Sound):Void {
fade.sound=sound, fade.i=0;
function fade():Void {
var snd:Sound=fade.sound;
if (snd.getVolume()>0) {
var proc:Number=(200/snd.duration)*100;
snd.setVolume(100-proc*fade.i);
fade.i++;
} else {
clearInterval(fade.time);
delete fade;
}
}
fade.time=setInterval(fade, 200);
sound.start();
}
. , :
snd.setVolume(snd.getVolume()-proc);
15.9.2.
, .
(,
).
Winamp. ActionScript setPan() Sound.
setPan() 100 100. 100 , .
. , -70 30 % . setPan() 100 %. , , ( ). setPan()
. 100 .
setPan() , , . , Convert Stereo to Mono.
, setPan() . ,
, . , , ,
, -100 100. (panning).
setPan(), setVolume(), , , Sound. setPan()
Sound(), .
, . , setVolume().
getPan(). -100
100, , setPan(). ,
getPan() setPan() , . .
setPan() , X, Y.
.
var sound:Sound=new Sound(this);
sound.attachSound("snd");
sound.start();
this.onMouseMove=function():Void {
var pan:Number=Math.round(-100+2*(_xmouse/Stage.width)*100);
var volume:Number=Math.round((_ymouse/Stage.height)*l00);
sound.setPan(pan);
sound.setVolume(volume);
};
15.9.3. . setTransform()
, Flash- , . ,
, . , ,
( ).
.
, , , .
ActionScript
setTransform(). setTransform() Color,
Object ,
. :
11 . 0 (
) 100 (
). 100, ,
;
1r ,
. 1r
100, 0, ;
r1 , ;
rr .
.
30 %, , 70 %, , .
ll rr 100, 1r r1 0 ( ). ,
. ,
. , . , .
setTransform(), setVolume() setPat(), ,
, Sound, . setTransform() Sound . , .
setTransform() ,
, :
// -
this.createEmptyMovieClip("clip1", 0);
this.createEmptyMovieClip("clip2", 0);
// Sound
var sound1:Sound=new Sound(clip1);
var sound2:Sound=new Sound(clip2);
sound1.attachSound("snd1");
sound2.attachSound("snd2");
// , -
sound1.setTransform({rr:0, 1r:100});
sound2.setTransform({11:0, 1r:100});
//
sound1.start(), sound2.start();
15.10. ID3- 3-
, 3-, Winamp, 3- .
. , ,
: , , ,
. , 3-, WAV- MlDl, , .
- (ID3 tags).
ActionScript ID3- Flash 6.
id3 Sound, , ,
Flash MX 2004. ID3-, onID3, ID3-.
Flash- 7 ID3- 1.0,1.1,2.3 2.4. , 2.2 , .
ID3- ID3- .
album
1
TOAL
2
artist
1
TOFN
2
TOLY
2
comment
1
2
genre
1
( - TORY
2
)
songname
1
TOWN
2
TALB
2
1
2
TBPM
2
2
2
TCOM
2
TCON
2
- 4
2
TCOP
2
- TPOS
2
TDAT
2
TPUB
2
TDLY
2
- track
1
TENC
2
TRCK
2
TEXT
2
RTDA
2
TFLT
2
TRSN
2
-
TIME
2
TRSO
2
-
TIT1
2
TSIZ
2
TIT2
2
TSRC
2
ISRC (
)
TIT3
2
TSRC
2
TKEY
2
TYER
2
TLAN
2
WXXX
2
TLEN
TMED
2
2
year
, ID3- .
. - .
3- ( ) ID3-.
ID3-, , 3- . - , . , ID3-. , Winamp ( File Info ( )
).
3- ID3-,
, id3,
Sound. , year id3.year, TLAN
id3.TLAN . . id3 , :
var sound:Sound=new Sound(this);
sound.attachSound("snd");
for (var i in sound.id3) {
trace(i + " = " + sound.id3[i]);
}
// : genre=13 comment=Elton John - Bernie Taupin year=1995
// album=Made In England artist=Elton John songname=Believe
ID3- ,
attachSound() loadSound().
ID3- , , ,
ID3-, UTF-8 (
3- ID3- ).
ID3- . . : ,
. , , ,
. , ID3- ,
, ID3vl- id3
, ID3v2-. , TYER,
TYER, year.
, ID3- , . , , ID3- 3-.
D3-TeroB loadSound()
, ID3- 3-, .
, . -
, ID3- .
, , Sound onID3, -. , 3- ID3-
, onID3 ( ).
15: 3-
, ActionScript .
, - . - Flash
. ,
Sound, , Winamp. Flash- . , .
, . ,
. SwiftMP3. 3- SWF-, . ,
.
, .
,
, ,
.
Flash, , , (. 15.1). skin.fla,
15 .
. 15.1.
, . , . , . , .
playlist .
. ,
. , ActionScript
,
XML-. 17.
,
. .
( snd).
.
, Actions.
Sound :
Play ( ). , , play_button.
, play_button, :
. ;
.
, .
, , - play_flag. , , ,
stop_position:
var stop_position:Number=null;
var play_flag:Boolean="false"; //
onRelease play_button :
play_button.onRelease-function():Void {
if (play_flag) {
sound.stop(); // ,
//
sound.start();
} else {
sound.start(stop_position);
play_flag=true;
//
}
};
. , , ( . ).
. , ( skala).
, . ,
, . , ( begunok).
.
,
. , , , :
begunok._x=skala._x, begunok._y=skala._y;
onEnterFrame. ,
. , :
begunok.onEnterFrame=function():Void {
if (play_flag) {
this._x=skala._x+(sound.position/sound.duration)*skala._width;
}
};
, , , .
.
,
. X
. :
begunok.onPress=function():Void {
if (play_flag) {
this.startDrag(true, skala._x, skala._y, skala._x + skala._width, skala._y);
sound.stop();
play_flag=false;
}
};
. , ,
:
begunok.onRelease=function():Void {
this.stopDrag();
var pos:Number=((this._x-skala._x)/skala._width)*sound.duration;
sound.start(pos/1000);
play_flag=true;
);
begunok.onReleaseOutside=begunok.onRelease;
. ,
, . , , loop:
var loop:Boolean=false; //
, ( loop_button). , , ,
loop_button ( 1).
. ,
. loop .
, , :
loop_button.onRelease=function():Void {
if (loop==false) {
lp.gotoAndStop(2);
loop_true;
} else {
loop=false;
lp.gotoAndStop(1);
}
};
loop_button.onReleaseOutside=loop_button.onPelease;
loop . ,
. .
stop_position play_flag, :
sound.onSoundComplete=function():Void {
if (loop) {
sound.start();
} else {
begunok._x=skala._x;
stop_position=0;
play_flag=false;
}
};
.15.10. 3- .
, . , , . tablo,
info.
, , setInfo().
, , .
ID3- songname. artist.
id3
. , ID3- (
id3 ).
., ..
, info ,
. position, (
).
setInfo() :
function setInfo():Void {
var title:String=null, singer:String=null;
if (sound.id3.songname!= undefined) {
title=sound.id3.songname;
} else {
title=".";
}
if (sound.id3.artist!= undefined) {
songer=sound.id3.artist;
} else {
songer=".";
}
//
var pos:Number=(begunok._x-skala._x)/skala._width*sound.duration/1000;
//
var time:String="<"+Math.round(pos/60)+":"+Math.round(pos %60)+">";
//
tablo.info.text=title+"-"+songer+"\t"+time;
}
setInfo() begunok.onEnterFrame
sound.onSoundComplete.
. ( ). fast_forward fast_back.
, , :
fastback , . , ;
clip.
onEnterFrame ( ) ;
onEnterFrame clip ,
.
, . onEnterFrame 1 % , .
, .
, 1 .
, , .
, ;
info. clip.onEnterFrame
setInfo();
fastback , (
clip). , clip ,
, .
, , :
fast_back.onPress=function():Void {
if (play_flag) {
sound.stop();
play_flag=false;
begunok.i=0; // ""
begunok.createEmptyMovieClip("clip",10000);
begunok.clip.onEnterFrame=function():Void {
var x:Number=(1000/sound.duration+begunok.i]* skala._width;
begunok.i += 0.01;
if (begunok._x-x>skala._x) {
begunok._x=begunok._x-x;
} else {
begunok._x=skala._x;
setInfo();
};
}
};
fast_back.onRelease=function():Void {
if (begunok.lip) {
play_flag=true;
begunok.clip.removeMovieClip();
sound.start((begunok._x-skala._x)/skala._width*sound.duration/1000);
}
};
fast_back.onReleaseOutside=fast_back.onRelease;
, , .
( ,
player.fla, 15 ).
.
. . ,
. . ,
. , ,
. ,
, .
.
. vol. skala, begunok,
val.
. ,
X . Y
. ( onMouseMove)
val.
0 200 ( 100):
vol.begunok.onPress= function():Void {
this.startDrag(true, vol.skala._x, vol.skala._y, vol.skala._x+vol.skala._width,
vol.skala._y);
this.onMouseMove-function():Void {
var percent:Number=Math.round((this-_x-vol.skala._x)/ vol.skala._width*200);
sound.setVolume(percent);
vol.val.text_percent;
};
};
. onMouseMove:
vol.begunok.onRelease=function():Void {
this.stopDrag();
delete this.onMouseMove;
};
vol.begunok.onReleaseOutside=vol.begunok.onRelease;
100, 0, . val:
vol.begunok._x=vol.skala._x+vol.skala._width/2;
vol.val.text=100;
, , ,
. . .
. .
, , . 16 , . . ,
, , .
, . ,
.
amplitudes. . c_N, N . .
, ActionScript .
. .
. onEnterFrame.
onEnterFrame , .
,
.
, . . , stop_flag, , .
, , :
var stop_flag:Boolean=true;
this.onEnterFrame=function():Void {
if (play_flag) {
for (var i=1; i<=16; i++) {
amplitudes["c_"+i].gotoAndStop(1+Math.round(Math.random()*7));
stop_flag=false;
}
) else if (stop_flag=false) {
for (var i=1; i<=16; i++) {
amplitudes["c_"+i].gotoAndStop(1);
stop_flag=true;
}
}
};
. (. 15.2). . , 17.
. 15.2.
16
, , .
, , , . ,
, , , , , ?
. , , , , , . .
. , , , Flash-
, .
, , , . SWF- ,
. Flash- . ,
, . ,
.
.
17, . , , ( 18).
12.
16.1.
SWF- SWF-,
. ,
, . ,
, . . , ,
_root (
_lockroot),
, , .
, ,
. (. 10). , , , clip , ,
_level2.clip._visible=false;
, . .
, , -
_lockroot. false, ,
. _lockroot true,
.
.
, loadMovie() ,
.
, .
Flash MX 2004 .
Flash- ( , , ).
, ,
, .
, . , , .
allowDomain() System.security, . , ,
www.mysite.ru, , :
System.security.allowDomane("www.mysite.ru");
, , ,
getSWFVersion() -3.
, JPEG-.
getSWFVersion() ,
. , , :
, . , . , , , , . getSWFVersion().
, ,
.
, . , _url
, .
, , . , , :
System.security.allowDomane(_level0._url};
_url .
ActionScript, , , loadMovie() MovieClip
loadSound() Sound. , , , ,
. ,
. , _url,
Flash 7.
_url, , , .
, SWF-, , HTML-.
base <Object> ( < Embed >). base ., , (
). , ,
SWF-.
SWF-, , SWF , ActionScript.
, . , (, ).
, , .
, , ,
. ,
.
16.2.
Flash-
. ,
, , , .
, .
.
-, , HTML-. -,
, HTML- ( , SWF-). -, ( - ). -, Flash, ( ).
, , .
(, ).
, , . 16.3.
16.2.1.
, ,
. , SWF-,
. Macromedia, .
SWF-, Flash, , , , .
, , . . Flash- ,
. . , Flash Player 6
, . . , , . , , , . , .
, ( (build))
, getVersion(). , :
, ( 0), ,
( 0)
:
trace(getVersion()); // : WIN 7, 0, 14, 0
, Flash MX 2004,
, 7.0 14, Windows.
: . , , Flash 8,
( ). , Flash Player 6 65...
getVersion(), , ,
version System.capabilities. ,
getVersion():
trace(System.capabilities.version); // : WIN 7,0,14,0
, , $version:
trace(version);
// : WIN 7, 0, 14, 0
, ,
, . ,
. , ,
. ,
Flash-. : Flash-
. ,
. ,
, , Flash- . HTML-, Flash- .
, , Flash-, .
Flash Player 6 98 % , . , .
. , .
Macromedia Flash-.
: , ,
. ,
Flash, . . , , Flash-, . Macromedia .
, .
, .
( Install Now), .
, Remind Me Later. Settings, Global Notifications Settings. ,
,
.
,
. 0,5 , ,
. Flash Player 7 .
, .
Flash-. , Flash, Netscape
Navigator ActiveX- Internet Explorer.
, , . System.capabilities.playerType
(. 16.9). , JavaScript ,
:
if (System.capabilities.playerType=="ActiveX" ||
System.capabilities.playerType=="PlugIn") {
getURL("javascript:alert('')");
}
. ,
, , , :
trace(System.capabilities.manufacturer); // : Macromedia Windows
16.2.2.
. , . ,
. ,
. HTML-, , -
, <Object> (
<Embed>, ).
HTML- JavaScript (
).
, . , , . -, . -,
, . ,
, . -, ,
. - .
Flash-? .
Flash. , , HTML-.
, <Object> <Embed>, ,
Flash- scale (, <Embed> scale ), . :
showAll , .
, .
, ,
.
, ,
. , - ,
(. . 16.2.3).
.
(. 16,1).
. 16.1. showAll:
; b ;
showAll , , .
, ;
exactFit , (. 16.2). , exactFit (
);
noBorder , showAll. ,
(. . ). , - (.
16.3).
. 16.2. exactFit:
; b
, , .
,
(, , , ).
;
noScale . , , . , , . ,
. ,
. , , (. 16.4).
, , HTML, , <Object> ( <Embed>) width height ( SWF- JavaScript). , Flash-, .
. 16.4. noScale:
; b ;
scaleMode
. () scale <Object>
<Embed>, scaleMode
.
HTML-, scale. scaleMode
,
.
16.2.3.
showAll, ,
.
, . ?
, . ,
noScale. , . .
, , ,
. ,
(. . ).
,
, , . , -
,
, . ,
,
. .
, .
( !! , ). ,
, Flash. ,
, HTML-. salign, <Object> ( <Embed> ). ,
.
, , . 16.5. salign , .
LT
LB
RT
RB
. 16.5. ,
. , , align . , , , (
align ).
, ( . center ).
, , . . 16.6 , noScale
.
HTML-, , ,
salign <Object> (
<Embed>). Stage.align , .
. 16.6.
16.2.4.
.
550x400 . Document Properties, Size
. .
, ,
,
. , , .
,
, , HTML- SWF- .
,
. , showAll noScale
, , , . ,
noBorder noScale, , .
. SWF-. . Flash MX . -
, , . ( showAll), , .
, noBorder,
.
, . -
? , .
, , .
, .
. - -
, . , noScale.
noScale width height Stage . , , . , .
, ,
, . . , ,
( ). ,
, .
, , , ( , , ) () . ,
, noScale width
height Stage ,
.
. showAll, noScale.
:
var mov_width:Number=Stage.width;
//
var mov_height:Number=Stage.height;
Stage.scaleMode="noScale";
//
var xSpeed:Number=5*Math.random(); // X Y
var ySpeed:Number=5*Math.random();
this.onEnterFrame=function() {
// ,
if (ball._x-ball._width/2<mov_width/2-Stage.width/2 ||
ball._x+ball._width/2>mov_width/2+Stage.width/2) {
xSpeed*=-l;
}
// ,
if (ball._y-ball._height/2<mov_height/2-Stage.height/2 ||
ball._y+ball._height/2>mov_beight/2+Stage.height/2) {
ySpeed*=-1;
}
//
ball._x+=xSpeed, ball._y+=ySpeed;
};
. ,
, . , ,
. ( ). , , onResize.
, ,
ActionScript? , . .
,
, . , ,
.
, , :
, . , . . , , , , . -
, . .
, . , , .
, , 16 (window.swf).
16.2.5. onResize
, ,
, . , ,
,
. ,
.
, ? onResize Stage.
onResize ,
noScale. , , (,
showAll), .
onResize . , addListener() Stage. onResize() removeListener() (
ActionScript 8).
onResize ,
, :
// ,
Stage.addListener(this);
this.onResize=function():Void {
ball._x=mov_width/2, ball._y=mov_height/2;
};
16 border2.swf. , ?
16.2.6.
(background) SWF-.
. , .
Background,
, SWF-.
, , SWF-,
, , (, ).
, . , .
SWF- . ,
. , . ,
, .
, . , , . , .
HTML-, ,
. , ?
, HTML-
bgcolor <Object> (
<Embed>).
.
: background
? , . , HTML-. wmode <Object> ( <Embed>)
transparent. Flash-
.
Netscape Opera.
, , .
HTML- Flash, ,
Transparent Windowless Window Mode HTML Publish Settings.
, ( )
HTML-. - ( , ).
16.2.7.
. , ,
SWF- - , . . . - ,
,
, . ,
. , , . .
.
, ( antialiasing). Flash ,
, ,
(. 13). , , , (
), .
. quality,
:
LOW . ,
, ;
MEDIUM . ( ) 2x2 .
1 , . ;
HIGH . , , 44 ,
. ,
( );
BEST . HIGH :,
,
. BEST , .
,
,
. BEST , .
. 16.7.
. 16. 7.
. 16.8.
_quality , ,
, .
, .
(device), BEST
( ).
Quality, (,
BEST). , , .
Flash 2.
toggleHighQuality(), LOW HIGH.
toggleHighQuality(), Flash 4 _highquality, 0 2 (0 LOW, 1 HIGH, 2 BEST). Flash 5, _quality, toggleHighQuality() _highquality ( ).
HTML-, ,
, quality <Object> ( <Embed>). , ,
LOW,MEDIUM, (HIGH BEST, quality
:
Autolow ,
. , ,
;
Autohigh , .
. ,
, , .
HTML- Flash,
Quality HTML Publish Settings.
16.2.8.
, ,
ActionScript - c . , Flash 6
SharedObject. ,
, (10 ).
(,
).
ActionScript , , , .
, , , , ,
.
. Flash 7
ActionScript ,
.
, -. , , , , , -, .
, ( ),
, . Flash-
Macromedia Flash Player Settings, Settings
. , , ActionScript.
.
(. 16.9) , , . ,
1. Privacy (). , (
Allow) ( Deny) . .
, Remember.
Advanced, Macromedia, Settings Manager. . , , , , . ,
, . Settings
Manager . ,
Flash 7.
2. Local Storage ( ). , , ( 10 ). : 0 ( ), I0K6, 100 , I ,
10 , . ,
( ), Never
Ask Again.
3. Microphone (). -
. ,
. Record Volume, . Record Echo,
( ), , .
4. Camera (). , , ,
.
c. 16. 9.
, 6 ,
, - , . , ,
. , Macromedia Flash Player Settings .
showSettings() System. , (0 Privacy, 1 Local Storage, 2
Microphone, 3 Camera). showSettings() , , . :
// Settings
//
this.onMouseDown = function():Void {
System.showSettings(2);
};
, ,
215x138 ( ).
, ,
, ,
SharedObject, Microphone, Camera NetStream.
16.3.
Flash . 1996 , L-.
Flash , .
SWF-, ,
16.3.1.
( ) Macromedia Flash Player.
SWF-,
-, , .
SWF-. -, SWF-
Flash- (*.e) .
, . , , , , ( , ,
). (projector -, SWF-)
, Flash- .
. ( ),
, Create Projector File. , Flash.
Windows ( Macintosh ), Windows Projector Formats Publish Settings,
Publish.
, -. ,
Windows SWF-, Macintosh ( ). , Flash MX 2004 Windows Macintosh ( ,
, ).
, Macintosh Projector Formats Publish Settings.
*.hqx, .
Macintosh
.
SWF-.
950 ( ). Macintosh ( 1,2 ). Flash- . -,
.
, SWF-, , Flash-
, . -
.
, . . ,
{
). (
). SWF- PDF.
, ,
. Jtools Flash Jester Swiff Canvas SwiffTools.
, . -,
. -, -. , - , . , . ,
Windows .
16.3.2. fscommandf()
fscommand() ActionScript. Flash 3
. Flash: fs
FutureSplash ( , Flash). , fscommand(). . , JavaScript,
Macromedia Director, Visual Basic Visual C++ .
Flash 5 fscommand() getURL(),
.
fscommand() - ,
.
fscommand() :
fscommand("command", "parameters");
command , parameters ( , ), , .
, , (. 16.1).
.
allowscale
fullscreen
quit
trapallkeys
16.1
fscommand(),
true "false
,
true false
true false
,
showmenu
true false
exec
16.1
,
allowscale Flash- (
Windows-) . . . , ,
,
( , (,
), , ). ,
(
), . , . j- .
, , , ;
fscommand("allowscale", "true");
ActionScript . , Esc.
, -,
Windows, , ,
*. . ,
.
, ,
, ( ,
). ( , ) , ,
, . 4:3 ( 640x480,
800x600, 1024x768, 160(3x1200 ).
, ,
.
,
.
,
. ;
quit , Flash- ,
File Exit . , ? ,
. , ,
. , 6 Exit.
, :
fscommand("quit");
trappalkeys Flash-, , .
, Esc, , Ctrl + Enter , Ctrl + . (
Ctrl) .
, , Ctrl
Esc . ,
.
fscommand("trapallkeys", "true");
showmenu Flash-
. , ,
( , ).
. - . , . , , , .
, . :
fscommand("showmenu", "false");
,
: Settings About Macromedia Flash Player. .
fscommand() ,
. ,
, HTML-, showMenu Stage.
ContextMenu (,
, , ) (. 12);
exec Flash .
. , , , ActionScript. Flash
e-. fscommand()
e.
- , exec
:
o . SWF-
Flash-, exec ;
o fscommand
, .
Word , exec, .
fscommand() exec :
fscommand("exec", "someApplication.exe");
"someAppllcation.exe" fscommand. To
fscommand() , .
fscommand() , , , , , .
Flash MX exec .
, fscommand() (
) -. ,
exec ,
.
, exec , .
, , ,
fscommand("exec", "info.txt");
, bat-. , ;
save save Flash 5, -
, , Flash MX, . , , . , ,
, save
. SharedObject, .
fscommand() . , , :
JavaScript ( VBScript), , ( getURL(), ). , ;
SWF- Macromedia Director (
, Lingo ( Macromedia
Director)),
Director . Macromedia;
Visual Basic Visual C++ ActiveX.
16.4. ,
Flash MX LocalConnection, , ,
.
. -, . , ,
. -, LocalConnection ,
SWF- ( Flash- ).
, . , ,
.
, HTML-, Flash. , ActionScript ( fscommand() getURL()) JavaScript, . , JavaScript Rash-. , JavaScript , SWF-.
Flash MX 2004 , , .
LocalConnection . , , HTML-,
, . ,
, Flash. , JavaScript ,
LocalConnection .
, , - . . -
ActionScript LocalConnection.
- - ,
LocalConnection :
var tel_out:LocalConnection=new LocalConnection();
***********************
var tel_in:LocalConnection=new LocalConnection();
//
//
(). ,
- LocalConnection.
send(), .
-, ,
.
send(), . ,
radio, - info,
tel_out.send("radio", "info", "");
- .
connect(), ,
:
tel_in.connect{"radio");
- , :
tel_in["info"]=function(par:String):Void {
trace(par);
}
, , tel_in. Flash,
, tel_out, , , Output ,
, LocalConnection . ,
.
,
. ,
,
LocalConnection. .
16.4.1.
, ,
send() LocalConnection. :
lc.send("cana1", "method", par1, par2, par3...);
:
lc LocalConnection.
. ;
"canal" . , connect() LocalConnection , ;
"method" LocalConnection,
. ,
LocalConnection (send,
connect, onStatus . .);
par1, par2, par3... , , . method. , , ( ).
, send() true.
false.
, , , . ,
LocalConnection, connect() . .
, send(), . 40 .
send() false. , send().
. ,
.
.
, . , ,
.
.
, .
. , , , , send(). , ,
:. , www.mysite.ru,
new connect, :
"www.mysite.ru:new_connect"
SWF- ,
- localhost. :
"localhost:new_connect"
, ,
. , -
( - , -,
- LocalConnection ,
), -
.
, , . . -
Flash. ( LocalConnection, ) ,
. , , , - , , , -. ,
, .
.
, . ,
, . , ,
. , .
, , ,
, _ :
.
, ,
. . ,
allowDomain. , , ,
, , ,
, .
. ,
, .
_,
. send()
LocalConnection, connect() , .
. send() , , -. ,
can1, - www.mysite.ru, send() www.mysite.ru:can1. :,
-.
mysite.ru:can1, - ,
- .
, - - , .
LocalConnection, , . , , .
, . -, , - , . -, . -,
- .
, , - -. , - -
16.4.2.
LocalConnection , . connect(). ,
canall,
var lc:LocalConnection=new LocalConnection();
lc.connect("canall");
LocalConnection .
, . , . ,
, ,
connect() (true , false ).
, connect(), , ,
(. . 16.4.1). -
, , (
send() -). , . , ,
. . , .
,
LocalConnection, send(). -
,
send().
- LocalConnection . , , -,
: There is no property with the name 'methodName' (
''). . , dynamic LocalConnection (. 9). , .
-, [], .. . , meth, ,
lc["meth"]=function(str:String):Void {
trace(str);
};
, . LocalConnection .
- , .
, close().
LocalConnection , close() :
lc.close();
close() true, , .
false, .
. 16.4.1 , send() connect(),
, . , , -, -. , , , . ,
LocalConnection, . , , , , . , allowDomain.
allowDomain , , ,
LocalConnection .
, ,
allowDomain , . , . , true. ( , ), false. , allowDomain,
, .
, ,
www.mysite.ru friend.narod.ru, allowDomain :
l.allowDomain=function(domain:String):Boolean {
return (domain=="www.mysite.ru" || domain=="friend.narod.ru");
};
, -
. ,
, ,
.
lc.allowDomain=function():Boolean {
return true;
};
allowDomain, ,
, , , . , , , ,
-, . allowDomain
, .
false .
, LocalConnection domain(),
, . . , . allowDomain,
, ,
-, friend.narod.ru:
lc.allowDomain-function(domain:String):Boolean {
return (domain==lc.domain() || domain="friend.narod.ru");
};
Flash 7, , , HTTP, ,
, HTTPS ( , HTTP, ).
.
, LocalConnection allowInsecureDomain, , , HTTP, , HTTPS. , , .
, true. false.
allowInsecureDomain
.
, allowDomain allowInsecureDomain , allowInsecureDomain .
16.4.3. LocalConnection
LocalConnection , , .
, ,
. .
, , , , .
, .
1. . 250 250 .
2. .
.
.
3. , .
( , _root , ). but.
4. . :
pen.swapDepths(10000);
5. .
:
Mouse.hide();
pen.startDrag(true);
6. , X
. , . :
this._x=-Stage.width/2, this._y=Stage.width/2;
7. LocalConnection, :
var lc.out:LocalConection=new LocalConnection();
8. . ,
, moveTo().
, , , ,
- draw_flag.
true.
, (, ) -, -. start() -.
var draw_flag:Boolean=false;
pen.onMouseDown=function():Void {
draw_flag=true;
_root.lineStyle(1);
_root.moveTo(this,_x, this._y);
lc_out.send("mirrow", "start", this._x, this._y);
};
9. . (
onMouseMove) , (
draw_flag). ,
.
-, draw.
pen.onMouseMove=function():Void {
if (draw_flag) {
_root.lineTo(this._x, this._y);
lc_out.send("mirrow", "draw", this._x, this, );
updateAfterEvent(); //
}
};
10. :
pen.onMouseUp=function():Void {
draw_flag=false;
};
11. but .
-,
clear():
but.onRelease=function():Void {
_root.clear();
lc_out.send("mirrow", "clear");
};
12. but , .
, , , :
but.onRollOver=f unction():Void {
Mouse.show();
pen._visible=false;
draw_flag-false;
};
but.onRollOut=function():Void {
Mouse.hide();
pen._x=_xmouse, pen._y=_ymouse;
pen._visible=true;
};
but.onDragOut=but.onRollOut;
- . -.
13. 250x250 .
14. , - ,
, X . , _xscale
-1:
this._x=Stage.width/2, this._y=Stage.width/2;
this._xscale*=-1;
15. LocalConnection :
var lc_in:LocalConnection=new LocalConnection();
lc_in.connect("mirrow");
16. start() - :
lc_in["start"]=function(x:Number, :Number):Void {
_root.linestyle(1);
_root .moveTo(x, y);
};
17. draw() , :
lc_in["draw"]=function(x:Number, :Number):Void {
_root.lineTo(x, y);
};
18. clear(), , -
:
lc_in["clear"]=function():Void {
_root.clear();
};
(. 16.10). . LocalConnection, 16 .
. 16.10.
16.5.
Flash- ,
. , . , SWF-
HTML-. Flash-, ,
, , - . , .
, SWF- ,
HTML-. , , ,
( ) . : HTML- ?
ActionScript ? JavaScript?
SWF-? . ,
, . , , , Flash- .
, , . , HTML JavaScript.
, align , quality
. . , , HTML- , <OBJECT> <EMBED> .
:
, width
height;
SWF- , , . movie id <OBJECT>, src
<EMBED>.
, HTML-, SWF-,
, , ,
. ,
<EMBED>, , <OBJECT>, , . : HTML-,
Flash, . , <HMBED> . , SWF-
:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550"
height="400">
<param name="movie" value="mov.swf"/>
</object>
Microsoft.
Netscape Opera ( , , ),
classid type ( I- ):
<object type="application/x-shockwave-flash" width="550" height="400">
<param name="movie" value="mov.swf"/>
</object>
Flash, , Flash-.
, , .
ActiveX
, SWF-, , . , ,
. HTML- <OBJECT>. 1 ( Flash-,
) , .
<EMBED> alt.
<OBJECT> <EMBED> .
, .
. ,
.
. ,
, . , , SWF, , ,
Flash- . . , ,
. , , ,
, .
20. Flash- . . 16.2.
16.2
<OBJECT> <EMBED>
classid
Flash- ActiveX- (
<OBJECT>)
type
MIME- . , .
<OBJECT>, <EMBED>. Internet Explorer classid. <OBJECT> Netscape
codebase
, Flash-,
( <OBJECT>)
movie
SWF- ( <OBJECT>)
data
( movie, ).
<Objcct>
src
, movie, <EMBED>
pluginspage , Flash-
, ( <EMBED>)
width
height
-
id
Flash- HTML-. .
<OBJECT>
name
, id, <EMBED>
align
, .
, .
, align : L { ), R ( ), ( ), ( ).
swliveconnect , LiveConnect ( Java , Netscape
JavaScript ) .
true, JavaScript fscommand(). swliveconnect false. <EMBED>
, .
, . , .
<EMBED> ( ). <OBJECT>,
. <PARAM>.
: name value . ,
,
,
, . (. 16.3).
16.3
/
play
true, false
loop
menu
quality
scale
salign
wmode
, (true) (false).
- true
true, false
, (true)
(false).
true
true, false
, (true) (false).
true
low, autolow, high, .
autohigh, medium, .
best
16.2.6. high
showall,
, noborder,
. exactfit, noscale
. 16.2.2. showall
l, t, r, b, tl, tr, bl, br ,
(. . 16.2.3).
window,
opaque,
, :
transparent
window ( );
opaque ,
;
bgcolor
transparent
#RRGGBB ( . , -
- , .
)
HTML- ()
base
. ()
URL
flashvars
HTML-
-
. . 16.5.2.
devicefont
true, false
. , SWF- (..16.1)
16.3
/
HTML- Flash, ,
HTML Publish Settings. , HTML-, , .
. ,
.
16.5.2. HTML-
Flash-.
, , ,
. , L-,
. flashvars
<OBJECT> ( <EMBED>).
flashvars ,
-, (&). , , ,
<param name="flashvars" value="name=Bob&age=25&location=USA"/>
flashvars="name=Bob&age=25&location=USA"
( <OBJECT>)
( <EMBED>)
- . , ActionScript
. , HTML-,
: name, age location, Bob, 25
USA. , , HTML-, .
ActionScript.
() flashvars, 64 .
, () flashvars, ,
( L ), < < %, . , Unicode, .
US-ASCII ( 128 Unicode ). %, XX
. , ,
%20, %2F. Unicode, , 255, % %YY. , %D0
%B0. +.
URL .
, , , URL-.
URL-, ()
flashvars, -.
, Flash- Unicode. , , US-ASCII, Unicode (HTML-
).
, , :
<ram name="flashvars" value="text=Bce !"/>
text,
:
trace(text); // : 6 !
, , , . . ,
URL-;
<param name="flashvars" value=
"text=%D0%92%Dl%81%D0%B5%D0%BC%20%D0%BF%D1%80%DO%B8%DO%B2%DO%B5%D1%82%21"/>
:
trace(text);
// : !
URL- , ,
, , .
ActionScript JavaScript URL- escape():
trace(escape("")); // : %DO%9F%D1%30%DO%B8%DO%32%DO%B5%D1%82
, unescape():
trace(unescaper("%D0%9F*D1%80%D0%B8%D0%B2%D0%B5%D1%82");
// :
-, GET,
, () flashvars.
GET
, flashvars, -, GET 256 ( flashvars 64 ). -, ,
URL , .
GET ,
Flash- .
, GET ,
load.Movie() loadMovieNum(). ,
.
16.5.3.
2001 , Web-
Flash. usability ( ) Flash is bad on 99 % (Flash
99 %). Flash , . , Flash . 0,5 , , , ,
( ) Flash-. usability
. ,
Flash-, HTML-.
:
. , Flash-
SWF-, HTML-. , . ! Flash- .
,
(Back). , Flash-, SWF, HTML-. , Flash- HTML-.
. ;
Flash-.
, ,
Macromedia ;
Flash-,
, HTML-.
. 2003 Google SWF-.
Flash MX
( ). , Flash-, (Back) (Forward)
. , .
Flash- SWF-.
, , . (Frame Anchor). ,
Frame ,
Label type Anchor.
,
, ?
? , Flash-.
1.
. .
.
Flash-.
2.
. frame_1,
fraine_2, frame_3.
3.
, .
forward .
:
forward.onPress=function():Void {
nextFrame();
};
4.
, HTML-
. , Flash-. , ,
, (Back) . ,
. (Forward), . Flash- , HTML. !
HTML, , , . , , , , . ,
, :
http://www.flash-sitc.ru/ ( );
http://www.flash-site.ru#frame_2 ( ).
:
Flash- Microsoft Internet Explorer ( );
Flash- frame2 - Microsoft Internet Explorer ( ).
#frame_2, URL , . .
U RL, , ,
.
. <> name. , ,
HTML-, :
<h3><a name="part_4" > </a></h3>
. -
<
name="label_1"></a>
, , LRL ,
? , , , , . , . <OBJECT> :
< name="frame_1"></a>
< name="frame_2"></a>
< name="frame_3"></a>
, URL. Flash-, ,
HTML- .
? , . ,
( , JavaScript ). , , . ,
( URL, ,
).
(Back) (Forward), ,
. ,
. , .
... !
HTML- Flash- Publish
, , ,
, .
<OBJECT>, .
, , main, photo job,
L- :
< name="main"></a>
< name="photo"></a>
< name="job"></a>
Netscape JavaScript .
. ,
Netscape, JavaScript,
LJRL , . :
<script language="JavaScript">
function flashGetHref() { return Location.href; }
// URL
function flashPutHref(href) { location.href - href; } // URL
function flashGetTitle() { return document.title; }
//
//
function flashPutTitle(title) { document.title = title; } //
//
</script>
, . Flash-,
(Back) (Forward), ,
, . , .
16.5.4. . getURL()
getURL() , , ActionScript. Flash 2, ,
ActionScript. Flash 5
MovieClip. getURL() ,
.
, Macromedia Director,
, , (
host environment).
getURL() no . HTML-, , , JavaScript VBScript, . . ,
.
getURL() :
getURL("URL");
url , , URL.
: scheme:scheme_specific_part, :
scheme () - ,
scheme_specific_part URL.
(hup, ftp, https) (javascript, mailto, file, asfunction). ( URL)
(, javascript JavaScript). ( HTML-);
scheme_specific_part - URL, ,
. (http,
ftp), JavaScript (javascript), ActionScript (asfunction), E-mail (mailto) . .
getURL() . ,
.
getURL() , .
, ,
.
. 16.4 , get
URL(). , ,
.
16.4
, getURL()
/
http://www.flasher.ru
http
HTML- HTTP
https : //mysite.ru/mov.swf
https
HTTPS (HTTP )
ftp://server.com/file
ftp
FTP- (ftp
)
nntp://news.com/comp/132
nntp
Usenet
file://C:\\book.doc
file
mailto:diis_ignotis@tut.by
mailto
javascript javascript:alert(""); JavaScript
vbscript vbscript:alert("")
VBScript
asfunction asfunction:func name
ActionScript (. 13)
event:
event_name
event
Macromedia Director,
SWF-
lingo:command_name
lingo
Lingo (
Macromedia Director). , SWF- Director
getURM("print:", "this");
print
. Flash 4,
ActionScript
, getURL(), <>. , , , :
this.createTextField("pole",0,200,200,0,0);
pole.border=pole.html=pole.autoSize=true;
pale.htmlText="ee <B><A HREF='javascript:alert (\"\")'>
</A></B>";
<> J3.
HTML-
. ,
. , . ,
getURL(), . , .
HTML-, getURL()
:
getURL("URL", window);
:
"url" L-. http, https.
( http, URL ,
);
window , , HTML-. window:
o _blank .
. , , SWF JavaScript. :
getURL("http://wnk.biz", _blank);
o _self , HTML . ;
o _parent ,
, HTML- . ( ), _parent
_self ;
o _top HTML- ,
Flash-, .
, ,
window _parent, _self, _top ;
o name name.
, ,
name . :
getURL("http://wnk.biz","left -_frame");
_, window. ,; .
, ! (, ).
L- , . , , ,
. . , ( URL HTML-,
, , SWF-). , base
<OBJECT> ( <BED>). ,
SWF- HTML-, , .
, HTML-
www.mysite.server.ru/main, () base :
, () base ! ( URL ). .
getURL()
, :
getURL(location, window, method);
location URL,
window , , ;
method . Flash
HTTP, : GET POST. :
o GET , URL,
. -
(&),
URL ?. , , GET, 256-1024 ( ).
, POST.
URL GET:
http://www .mysite.ru/cgi-bin/search?book=ActionScript&author=Gurski
URL, search,
cgi-bin. , ?, .
o POST GET , , HTTP-. POST , , GET,
. ,
, Java-
, (, Netscape Navigator).
getURL() , , .
. ,
String. :
var a:String="ActicnScript", b:Object{}, :Array=[1,2,3];
getURL("http://www.mysite.ru/cgi-bin/execute", "_blank", "GET");
/* :
http://www.mysite.ru/cgibin/execute?a=ActionScript&b=%5Bobject+Object%5D&c-1%22%23
*/
, getURL() , , . .
getURL() , -
. ,
loadVariables() LoadVars,
.
, \ , ActionScript escape.
URL
file. ,
-. ,
exec fscommand().
URL file . . , - PDF, , , URL file.
, E-mail , .
mailto, getURL().
URL mailto :
mailto:?
:
URL, , . ,
;
IJRL, . :
o subject ;
o ,
;
o bcc , E-mail,
.
,
subject .
URL mailto:
getURL("mailto:diis_ignotis@tut-by");
getURL("mailto:diis_ignotis@tut.by,dct@omen.ru");
getURL("mailto;diis_ignotis@tut.by?subject=&cc=dagi@tut.by&bcc=gurski@
tut.by");
URL mailto ,
. . , URL.
JavaScript
SWF- JavaScript
Flash 2 ( 1996 ). :
ActionScript JavaScript, JavaScript SWF-. , getURL() Flash- .
JavaScript ActionScript .
ActionScript JavaScript -
, fscommand() getURL(). getURL()
, , -,
HTML-, -, . fscommand() ,
JavaScript . 16.5.5.
getURL() , JavaScript, URL:
getURL(javascript:script);
:
javascript , , URL JavaScript;
script JavaScript, .
, <SCRIPT>. .
, URL javascript , !
:
// , , "!"
getURL("javascript:alert('')");
// , ""
getURL("javascript:window.location='http://www.piter.com'");
// , ,
getURL("javascript:function func(par) {return par};
alert(func(''));");
JavaScript ,
.
SWF- JavaScript . (, Internet Explorer 4 Macintosh) JavaScript
getURL() . ( ) ActionScript JavaScript .
getURL() ,
, SWF-. , always allowscriptaccess <OBJECT> ( -
<EMBED>).
JavaScript, ,
. , JavaScript ActionScript
-262. . ,
, - . JavaScript ActionScript . , -262,
Flash-, .
JavaScript . ,
Flash-, HTML-. JavaScript , ,
Flash Web-. , , , :
// ban
// , ,
//
getURL ("javascript:function setStatus(par) {window.status=par;}");
// ,
//
ban.onRollOver=function():Void {
getURL("javascript:setStatus('http://www.flasher.ru');");
};
//
//
ban.onRollOut=function():Void {
getURL("javascript:setStatus(window.defaultStatus);");
};
, , :
getURL("javascript:window.close();");
HTML- getURL() , , . , . ,
SWF-, ,
(
Flash-
). , , HTML- window.open() JavaScript. , HTML 300 300 .
getURL("javascript:void window.open('http://www.flasher.ru', null,
'width=300, height=300, menubar, status')");
Internet Explorer, ( ):
getURL("javascript:void window.open('http://www.flasher.ru/forum', null,
'fullscreen')");
JavaScript ,
ActionScript . ,
. but , , 100 50 :
but.onRelease=function():Void {
getURL("javascript:window.resizeBy(100, 50)");
};
JavaScript ,
. ,
HTML- SWF-;
var i:Number=0;
this.onEnterFrame=function():Void {
var x:Number=300+200*Math.cos(i*Math.PI/30);
var y:Number=300+200*Math.sin(i*Math.PI/30);
getURL("javascript:window.moveTo("+x+","+y+");");
i++;
};
JavaScript, ,
SWF- HTML- . , . <OBJECT> id, <EMBED> name. , ,
JavaScript. , but
, w () h
():
// , name
getURL("javascript:function setSize(name, n_w, n_h) { this[name).width=n_w,
this[name].height=n_h}");
// ( mov)
but.onPress=function():Void {
getURL("javascript:setSize('mov',"+w.text+", "+h.text+");");
};
ActionScript JavaScript .
, , . ,
JavaScript . , , .
fscommand() Netscape
Navigator 6.2 Internet Explorer Macintosh,
Opera.
, fscommand() JavaScript , getURL(). ,
fscommand() , . ,
, , ,
fscommand() .
fscommand() JavaScript.
: moviename_DoFSCommand, moviename SWF HTML- ( id name <EMBED>
<OBJECT>), _DoFSCommand , fscommand(). , mov, ,
fscommand() ,
function mov_DoFSCommand(cammand, args) {}
moviename_DoFSCommand() , fscommand(). ,
, , , . , . JavaScript getURL(),
fscommand() . fscommand(), mov, mov_DoFSCornmand()
JavaScript, .
_DoFSCommand, : trace (
, ) close ( ):
<SCRIPT language="JavaScript">
function mov_DoFSComraand(command, args){
switch(command){
case "trace": alert(args), break;
case "close": window, close();
</SCRIPT>
trace, , mov
fscommand("trace", "");
close :
Fscommand("close");
JavaScript, , fscommand()
. , - , .
JavaScript getURL(),
_DoFSCommand() . .
, fscommand() JavaScript, Internet Explorer. VBScript,
JavaScript. , moviename_FSCommand, moviename ,
VBScript .
Internet Explorer, . , VBScript , Microsoft. , document JavaScript write(), HTML-:
// , Internet Explorer Windows.
// , VBScript
if (navigator.appName && navigator.appName.indexOf("Microsoft")!=-1 &&
navigator.userAgent.indexOf("Windows")!=-1 {
document.write('<script language=\"VBScript\"\>\n');
document.write('On Error Resume Next\n');
document.write('Sub mov_FSCommand(ByVal command, ByVal args)\n');
document.write('\tCall mov_DoFSCommand(command, args)\n');
document.write('End Sub\n') ;
document.write('</script\>\n');
}
, .
Flash- JavaScript - ActionScript
. , ,
- JavaScript , Flash
SWF- JavaScript . Flash , . ,
SetVariable() ,
HTML-.
Flash-, , .
JavaScript SWF-, HTML-,
Object. .
, :
getURL("javascript: for(var i in mov){alert(i+'='+mov[i]);}");
, JavaScript. , ,
mov.StopPlay();
Flash- JavaScript ,
(. . ). , , . , , JavaScript ,
ActionScript, .
Flash- Netscape 6.2,
, LiveConnect.
true swliveconnect <EMBED>.
Flash- Flash 4. /-. , /. ., :.
_level0, /. :
_root.clip.intro.var=1; //
/clip/intro:var=1;
// /-
Flash- . .
( ), , . ( TellTarget-) . Flash-
. 16.5.
16.5
Flash-
GetVariable(vur)
, var.
, null. :
var numb=mov.GetVariable(/movie:number_of_copies);
PercentLoaded()
Play()
Rewind()
SetVariable(var,
value)
,
value , ,
var.
,
:
mov.SetVariable('"/movie:number_of_copies", "100");
SetZoomRect(left,
right, top, bottom)
StopPlay()
TotalFrames()
Zoom(percent)
.
left, right, top, bottom
. percent ,
. , percent 50,
16.6
TCallFrame(clip,
number)
TCallLabel(clip,label)
TCurrentFrame(clip)
flash- TellTarget
, number
clip, ( Flash 4 ). ll() ActionScript
TCallFrame() , ,
clip.
, _currentframe ActionScript, 1, 0. :
alert(mov.TCurrentFrame("/clip/clip_intro"); // : 0
TCurrentLabel(clip)
TGetProperty(clip,
property)
,
clip
property clip. (,
Flash 4).
, . ,
, . 16.7. :
// _current_frame - 4
alert(mov.TGetProperty("/clip/clip_intro", 4); //
:0
TGelPropertyAsNumber TGetProperty() ,
property ( ) ,
(clip, property)
clip
TGotoFrame(clip,
number
number)
TGotoLabel(clip, label)
clip label
l(clip)
clip
property clip value. TSetProperty(clip,
, Flash 4. property, value)
, . , , . 16.7. :
// name - 13
mov.TSetProperty("/mov/mov_intro", 13, "new_clip_name");
TStopPlay(clip)
clip
16.7
,
JavaScript
Get/Set
Get/Set
_x
0
+/+
_height
9
+/_y
1
+/+
_rotation
10
+/+
_xscale
2
+/+
_target
11
+/+
_yscale
3
+/+
_framesloaded
12
+/_current_frame
4
+/_name
13
+/+
_totalframes
5
+/_droptarget
14
+/_alpha
6
+/+
_url
15
+/_visible
7
+/+
_highquality
16
+/+
_width
8
+/+
_focusrect
17
+/+
16.8
OnProgress(proc)
Flash-
, Flash- . ,
proc . ;
Mov.OnProgress=function(proc) {
alert(" "+proc+"%
}
")
OnReadyStateChange(state) , Flash-. 0 ,
, state . : 0 , 1 , 2 - , 3 -
, 4
, fscommand(). FSCommand(command,
fscommand()
args)
Flash- JavaScript SetVariable(),
HTML-
. , , SetVariable()H ActionScript.
Microsoft : JavaScript VBScript,
, , ( VBScript ,
ActiveX). , SWF- VBScript. Flash- JavaScript, .
VBScript JavaScript.
SWF- VBScript
Macromedia.
16.5.7. Flash-
Flash , .
, , Flash, , . . Flash , . , , Flash Player 6
98 % , !
, ,
. . -,
,
, Flash, . ,
, . -, HTML , Flash-, , . , 2 % , .
Flash- ,
, , . -
, ( ).
, , . .
, Flash-
, .
, , 98 % . , ,
.
... , ,
, .
. . HTML , , .
Flash-. , , , .
. . -, Internet Explorer, ActiveX.
Netscape ,
, . -, -
.
Flash- . -, ,
Flash, , ,
Flash-.
: Flash HTML. , . , . ,
Flash- , SWF (, ). ,
Flash- .
. .
.
. , Flash , HTML. ,
, , Flash- .
, .
undefined, Flash- , , :
Shockwave Flash 7.0 r14
IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"));
, ,
HTML-, . ,
, . HTML- , , ,
, Flash-.
. ,
Flash. , .
. , , . . , , (, Internet Explorer 4.5 Macintosh) , Flash-.
, HTML- .
Flash 4. $version . , Flash 4, 99 % , . Flash 4 , ,
, ,
. , getURL() . ,
HTML- ,
.
. ,
.
. , Flash-
. , getURL() .
,
. ,
. 16.11.
. 16.1. Flash-
. Flash-
HTML-, , . , Flash
. SWF- ,
, . , . , , Flash- ,
. , Flash-. Macromedia. Internet Explorer, . Flash- , , . HTML-,
. , -
Flash-.
,
-. ,
. , Macromedia ,
Flash- . Flash Deployment Kit ( Flash). JavaScript VBScript, SWF-
.
http://www.macromedia.com/software/flash/download/deployment_kit/
Flash MX 2004 . , Detect Flash Version HTML Publish Settings. HTML-. , SWF. .
, . , , . ,
, , , Settings Detect Flash Version.
16.6.
, ActionScript , Flash. CustomActions
. ,
Actions, ,
, .
, .
MMExecute() Flash- JSFL
Flash. JSFL,
.
ActionScript .
, , JSFL
Actions.
16.6.1. Actions
Actions, Flash MX 2004, , , , . , , , .
.
. Classes
, , %.
( Show Code Hint)
text. . ;
text="loadMovie(% url, target, method %);\n"
, ,
text, text2, text3 , . , .
:
text = "gotoAndPlay (% frame %);\n" text2= "gotoAndPlay (% scene, frame %);\n"
(
.):
text="array_name.sortOn(% key %)"
o quickey . , ,
ab, , <>
<b> Esc;
o codehint , ;
<ifdef>...</ifdef> , , Actions
, , mode.
.
ActionsPanel.xml, Actions
. Cat.
1.
ActionsPanel.xml .
2.
,
. <folder>.
3.
4.
ActionsPanel.xml ( UTF-8).
5.
Flash ( , Actions ).
, Actions
myclasses, , Cat(PHC. 16.12).
Cat. ,
. setColor.
, , . 16.13.
Puc. 16.13.
, Cat , . , . , AsColorSyntax.xml.
ActionsPanel.xml, AsColorSyntax.xml .
:
<colorsyntax>...</colorsyntax;> - .
;
<keyword text="name"/> , .
text;
<identifier text="name"/> , <keyword>,
(. . , , , , );
<property text="name"/> , ( , _: _xscale, _totalframes);
<ifdef>...</ifdef> , ActionsPanel.xml.
Cat ,
<colorsyntax> AsColorSyntax.xml :
<identifier text="Cat"/>
<identifier text =".color"/>
<identifier text=".setColor"/>
,
..
Flash. ,
, sctColor() Cat. , ,
.
Actions
AsCodeHints.xmt. .
<codehints></codehints> ;
<codehint/> ,
Flash 5 on() onClipEvent().
tiptext <action> ActionsPanel.xml . pattern <codehint>.
<codehint>, ;
<typeinfo/> . ,
, ,
, , ., ,
.
, . , , <typeinfo>. :
o object , ,
pattern .
:
<"typeinfo pattern="*_xmlsocket" object="XMLSocket"/>
<typeinfo> , :
<typeinfo pattern"_level*" object="MovieClip"/>
Flash MX.
Flash MX 2004 . ,
AsCodeHints.xml, . ,
Cat , _cat,
AsCodeHints.xml :
<typeinfo pattern="*_cat" object="Cat"/>
. 16.14.
16.6.2. CustomActions
Macromedia
ActionsPanel.xml, AsCodeHints.xml AsColorSyntax.xml. -,
, Actions. -, ( ). -,
-
ActionsPanel.xml. Actions
ActionScript CustomActions.
, L-
ActionsPanel Configuration ( ) Flash.
CustomActions .
Actions undocumented,
. Functions
ASSetPropFlags(). . ,
, .
1.
<customactions>
<!-- undocumented, Global Functions ASSetPropFlags-->
<actionspanel>
<folder name="undocumented" id="und" version= "6"
tiptext=" ">
<folder name="Global functions" id="undf" version="6"
tiptext=" ">
<action name="ASSetPropFlags" tiptext=" "
text="ASSetPropFlags(%object,properties,flag1,flag2 %);"/>
</folder>
</folder>
</actionspanel>
<!-- -->
<colorsyntax>
<identifier text="ASSetPropFlags"/>
</colorsyntax>
</customactions>
XML- Actions
. .
,
undocumented.xml. Flash
Unicode, UTF-8.
, , .
3.
FLA- .
:
CustomActions.install("undocum",inst.toString());
}
. L, load() undocumented.xml.
( onLoad), undocum.xml
CustomActions ActionsPanel.
CustomActions.install(name, text), name , XML-
CustomActions, text . , install() true. ( ,
\ :) false. L name , .
4.
Ctrl + Enter, . ,
, . , Actions.
undocumented (. 16.15).
Puc. 16.15.
5.
,
CustomActions . , instaU() , XML CustomActions. CustomActions . -, Flash. -,
CustomActions , , Actions, . , .
install() CustomActions :
list() , L-,
CustomActions. , .
undefined. :
list() ,
, , ;
trace(CustomActions.get("undocum"));
// Output
// undocum.xml
undocumented , ,
:
CustomActions.uninstall("undocum");
, , undocumented .
undocum.xml CustomActions.
16.6.3. JSFL
JSFL (JavaScript Flash Language) Flash MX 2004. , , , . , ,
JSFL. , JSFL
ActionScript. , , , , ActionScript
JavaScript. JSFL Macromedia Flash MX 2004, a
ActionScript Macromedia Flash Player. JSFL ActionScript
, JSFL ( , , ).
JavaScript Flash Language. , JSFL , .
JSFL, ActionScript JavaScript, -262. . JSFL , , , ,
, Array, String, Math. JSFL JavaScript
( ). , Flash
(DOM), Netscape
. JavaScript, JSFL .
JSFL , ActionScript, ,
*.jsfl. (. 16.16).
.16.16.
JSFL- . Flash, . JSFL
, JSFL.
, Flash JavaScript File Create New , . , ,
JSFL Actions,
.
JSFL
Flash. , , , , , . , Tools
ToolObj. , ,
. , , JSFL. -V N - 1.
. 16.17 JSFL, -
, , , . JSFL,
, Macromedia.
JSFL ( )
flash ( ). flash
. Flash,
flash JSFL,
flash , File
. , ,
. flash
JSFL . ,
Document flash, documents.
. 16.17. JSFL
, ,
example.fla, Flash:
flash.createDocument();
flash.saveDocument(flash.documents[0],"file:///C|/example.fla");
flash.quit(false);
, JSFL-,
. Flash, . JSFL , Run Command
Commands.
JSFL 10 ,
Tools Document. Tools
. Document -
.
Document . , JSFL, , FLA . 90 % JSFL , Document.
Document . , (. . 16.17)!
Document, FLA-,
documents flash. ,
. , , , . Document
getDocumentDOM() flash.
Document . ,
JSFL! Document ,
.
, :
var doc=flash.getDocumentDOM();
doc.width=200, doc.height=200;
doc.frameRate=24;
,
flash.getDocumentDOM().testMovie();
:
flash.getDocumentDOM().addNewOval({left:100,top:100,right:200,bottom:200});
(
Break Apart):
flash.getDocumentDOM().breakApart();
flash.getDocumentDOM().breakApart();
//
//
,
flash.getDocumentDOM().selectAll();
(100, 100), :
var item=flash.getDocumentDOM().library.items[0];
flash.getDocumentDOM(),addItem({x:100,y:100},item);
File Save :
flash.getDocumentDOM().save();
SWF- , FLA-, ,
flash.getDocumentDOM().exportSWF(" ", true);
, Publish File:
flash.getDocumentDOM().publish();
, FLA-, Document. ,
FLA- , , .
Document,
, get. ,
Timeline, , getTimeline() Document:
var timeline= flash.getDocument.Dem().getTimeline();
JSFL , *.
, ,
flash.getDocumentDOM().getTimeline().insertKeyframe(10);
:
flash.getDocumentDOM().getTimeline().addNewLayer("_","guide",false);
Timeline. Layer.
. layers Timeline.
, Layer. :
flash.getDocumentDOM().getTimeline().addNewLayer <"_","guide",false);
flash.trace(flash.getDocumentDOM().getTimeline().layers[1].name);
// : _
Layer , . , , , visible:
//
flash.getDocumentDOM().getTimeline().layers[0].visible=false;
,
. . Frame. Frame, ,
frames Layer. , , ,
,
flash.getDocumentDOM().getTimeline().layers[0].frames[0].soundEffect='fade in';
, , , . JSFL ,
. ,
Element . ,
, ,
flash ( , ).
, JSFL , :
flash.getDocumentDOM().getTimeiine().layers[0].frames.elements[0].edges[0].
getHalfEdge(0).getVertex();
Element , .
, Document selection, , .
:
//
var sel_objs=flash.getDocumentDOM().selection;
for (var i=0; i<sel_objs.length; i++) {
sel_objs[i],width*=2, sel_objs[i].height*=2;
}
, Timeline, .
.
Timeline Document .
Library, .
library Document.
, Library , . , Clip (100, 100),
:
ilash.getDocuinentDOM().library.addItemToDocument({x:100, :100}, "Clip"};
Clip:
flash.getDocumentDOM().library.editItem("Clip");
, , ,
Element, ( SymbolItem
, FontItem , BitmapItem . .).
Item. , , items Library. , -
Library. :
flash.trace(flash, getDocumentDOM().library, items[0].name];
// : Clip
Item . ,
clip:
flash.getDocumentDOM().library.items[0].linkageExportForAS=true;
flash.getDocumentDOM().library.items[0].linkageIdentifier="clip";
Item . . , SoundItem
. , 16
/, JSFL-:
var library_items=flash.getDocumentDOM().library.items;
for(var i=0; i<library_items.length; i++) {
if(library_items[i].itemType=="sound") {
library_items[i].compressionType="MP3";
library_items[i].bitRate="16 kbps";
}
}
Tools tools
flash. , . ,
,
var tool_active=flash.tools.activeTool;
Tools ToolObj.
. toolObjs
Tools.
ToolObj , ;
componentsPanel Components;
outputPanel Output;
Math ( ), Math;
Effect , ;
drawing Layer , , .
, ;
, XML-,
XMLUI ( XML User Interface).
, flash, ,
-262: escape(), Array, String, Math . . ,
JSFL Flash .
, mouseDown(),
mouseClick(), keyUp() .. JSFL Tool.
.
JSFL , ActionScript. , . -
. JSFL , , ( 13 ActionScript).
1.
JSFL- WaveText.
2.
, ,
, .
Element selection, , . , , , :
var doc=flash.getDocuraentDOM();
if (doc.selection.length !=1 && doc.selection[0].element Type !=" text" ) {
alert (" "};
} else {
3.
? ,
, Break Apart. , .
, . -
15-20 . , ( ?).
JSFL , , . , .
Document convertTo Symbol (type, name, centerLock), type ( : movie clip, button, graphic), name , centerLock (top left, center, bottom right . .). , . :
sinText+i, i . ,
( itemExists()
Library), .
var name="sinText", n=0;
while(doc.library.itemExists(name+n)) {
n++;
}
doc.convertToSymbol("movie clip",name+n,"center")
4. :
doc.enterEditMode();
5. , Break Apart:
doc.breakApart();
6. 16 .
:
var timln=doc.getTimeline();
for (var k=1; k<16; k++) {
timIn.insertKeyframe(i+1);
}
7. 16 , ,
.
Timeline setSelectedFrames(begin, end), begin , , end , . .
, .
, selection, , , (
). .
15 .
;V N + 1 15 .
: , (. . , ).
var phi=Math.PI/8;
//
var mat=null;
//
for(var i=0; i<15; i*+){ //
timIn.setSelectedFrames(i, i+1); // i
for(var j=0; j<doc.selection.lenqth; j++){
//
//
mat=doc.selection[j].matrix;
// ,
mat.a=mat.d=Math.abs[Math.sin(phi*(i+j)));
//
doc.selection[j].matrix=mat;
}
}
JSFL , , , , .
Matrix, matrix Element. , (0, 0) (
) (1,1) ( d), .
, , ,
10, . .
, :
doc.exitEditMode();
. JSFL-, FLA-.
. , sinText , Run
Command Commands. , Flash . , .
. , 16 . . ! !
. , . ,
, .
JSFL XMLUI. , ,
, XML, , JSFL-.
JSFL, . Commands Configuration ( Windows
98/XP C:\Documents and Settings\user\Local Settings\ Application Data\Macromedia\Flash MX
2004\en\Configuration).
Commands. JSFL-
Commands , Manage Saved Commands
. Macromedia , Get More Commands Commands.
.
Tools Configuration.
JSFL, . Flash
MX 2004 History, . , , History
Save As Command . ,
Command Name . ., Commands , Commands
JSFL-. , , , Flash JSFL-:
fl.getDocumentDOM().addNewLine({x:40,y:148}, {x:84,y:216});
fl.getDocumentDOM().addNewLine({x:83,y:213), {x:107,y:124});
fl.getDocumentDOM().addNewLine({x:107,y:124}, {x:40,:146});
, JSFL,
, .
, Macromedia Macromedia Extension
Manager, *.mxp. XML-. Macromedia
Extension Manager - &1 (
Extensions Configuration). --, Extension Manager
Macromedia. , (, , ), , *.mxp. Extension Manager
19, .
,
JSFL. (Insert
Timeline Effects). JSFL SWF- -
. . , SWF-
. Flash MX . Flash MX 2004 , , , SWF-, JSFL. : ActionScript JSFL?.
MMExecute(). JSFL. :
MMSxecute("alert('');"); //
MMExecute()
, , . ,
Flash.
, MMExecute() getURL(). .
16.7.
. ,
, . , , .
,
. . 1998
508 , , , , , ( . http://www.section508.gov). . W3C, , , , (.
htlp://www.w3.org/WAI/).
Flash , ,
, . , , , Tab. , Flash-
. , Macromedia , Flash .
, .
Flash MX . Flash- .
(Screen Readers) , ( ) .
,
, . , , (, , . .) . .
,
Flash. Window-Eyes GW Micro JAWS,
. , Flash.
, Flash- MSAA, .
SAA (icrosoft Active Accessibility) , icrosoft ,
Tab- ,
. tabEnabled
tabIndex ( . 12);
, ( ).
:
if (Accessibility.isActive{}) {
stopAllSounds();
}
// : false
.
. ,
, , , . , (
Dynamic Input, ), , .
Accessibility, Tab Index.
;
. . ,
. Name ( ) Description
( ) Accessibility;
,
. ,
. Shortcut Accessibility;
(,
).
Make Object Accessible Accessibility. ,
Make Child Objects Accessible;
, , . . , , . -, Name
Accessibility. .
Auto Label Accessibility, .
silent - , (false)
(true);
forceSirnple , (false)
(true);
name ;
description ;
shortcut ,
.
, updateProperties()
Accessibility. ActionScript, . , .
,
,
_accProps={silent:true, forcesimple:false);
Accessibility.updateProperties();
Flash
, ,
. ,
Macromedia
(http://www.macromedia.com/accessibility/).
16.8.
Flash- , , , ,
. ,
Macintosh. , .
. : ,
? , ,
.
ActionScript,
, .
System.capabilities, Co . , 13
, , language, .
. - URL, . capabilities.
, . , .
serverString capabilities:
trace(System.capabilities.serverString);
/* :
A=t&SA=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=f&PR=t&SP=t&SB=f&DEB=t&V=WIN%207%2C0%2C19%2C0&
M=Macromedia%20Windows&R=1024x768&DP=72&COL=color&AR=1.0&OS=Windows%202000&L=ru&PT=Ex
ternal&AVD=f&LFD=f&WD=f
System.capabilities .
. 16.9.
avHardwareDisable
hasAccessibility
hasAudio
hasAudioEncoder
16.9
System.capabilities
AVD
true, , false,
( )
ACC
, ,
(true) (false)
A
,
(true) (false). false ,
AE
false,
( , , ).
16.9
hasEmbeddedVideo EV
, , ,
hasMP3
MP3
, 3-
hasPrinting
PR
true,
hasScreenBroadcast SB
true, , Flash Communication Server
hasScreenPlayback SP
true, , Flash Comminicaiion Server
hasStreamingAudio SA
, ,
hasStreamingVideo SV
, ,
hasVidcoEncoder
VE
, ,
isDebugger
DEB
language
localFileReadDisable LFD
manufacturer
Os
OS
pixelAspectRatio
AR
playerType
PI
screenColor
COL
screenDPI
DP
, Flash-
(false) , (true). Flash
,
. , . , en, ru,
de. ISO
639-1.
, . ,
en-US. ISO 3166
,
, , .
Macromedia OSname, OSnamc ; Windows, Macintosh, Linux, Other OS Name
. : Windows XP,
Windows 2000. Windows 98/ME, Windows NT, Windows
95, Windows , Linux, Mac OS
(
). 1
, . : StandAlonc ( ), External
(, Flash), Plugln (
Netscape), ActiveX (ActiveX-
Internet Explorer)
, (color), (grayscale)
(bw)
16.9
screenResolutionX
screenResolutionY
serverString
version
R
R
,
System.capabilities
, . :
trace(System.capabilities.version);
// : WIN 7,0,14,0
, System.capabilities
windowlessDisable ( WD). .
System.capabilities
, ,
. .
, , :
if (System.capabilities.playerType="StandAlone") {
fscommand("fullscreen","true");
};
16.9.
. . , .
, ,
. , .
, . , . , , . : N . ,
. . , , , .
ActionScript Flash 5.
save fscommand(). ,
fscommand(). save
, ,
. ( ), , .
( SWF-).
Macromedia, Flash MX save
.
Flash 5 -
JavaScript. cookie- ,
JavaScript- setVariable().
Flash MX SharedObject.
, , save. -, , , . -, , A, , . , ActionScript. SharedObject .
SharedObjcct ,
. JavaScript, cookies. Cookies SharedObject , . cookies SharedObject
. , cookies , .
SharedObject . cookies *.txt. SharedObject *.sol.
cookies . SharedObject number,
string, boolean, object.
SharedObject. , , Flash-usability,
.
16.9.1. SharedObject
cookies Cookies, Documents
And Settings. ,
SharedObject. ( Windows 2000/XP) C:\Documents and Settings\user\Application Data\Macromedia\Flash Player. ,
. Flash- Flash-,
. ,
SharedObject . ,
http://www.bit-101.com, SharedObject
www.bit-101.com
, .
, . ,
http://www.bit-101.com/main/films/1.swf, www.bit-101.com
main, films. ,
(, 1.swf). SharedObject,
.
, sol- localhost.
, , . , , , , , sol .
ActionScript sol- SharedObject.
getLocal(). sol- (
~, %, &, \, ;, :, ", ', ,, <, >, ?, #). :
var sh_obj:SharedObject=SharedObject.getLocal("user_name");
getLocal() ,
SharedObject. ( , )
null.
: SharedObject ,
new, getLocal()?. ,
getLocal() . SharedObject,
, sol- .
, , ,
. getLocal() SharedObject, , sol-.
sol- .
(, sol- ). getLocal() sol-, . - ,
, , . ,
user_name.sol main Data ,
var sh_obj:Shared0bject=Snared0bject.getLocal("mainData/user_name");
, ,
localhost Flash Player.
SharedObject use rename, sol. . , sol-.
, , ? sol
SharedObject, .
flush(), , ,
www.xyz.com , X Y .
Allow, sol- . Deny, (. 16.18).
Puc. 16.18.
,
, flush() . pending.
, flush() true ( ), false ( ).
,
Currently Used, Local Storage.
, onStatus. Allow
Deny . , ,
level onStatus .
Allow , , , level
Status. Deny Error. level
code.
SharedObjecl.Flush.Success, SharedObject.Flush.Failed. :
sh_obj.onStatus=function(info:Object):Void {
if (info, level=="Error") {
getURL("alert(' !')");
}
}
// 1
var sh_obj:SharedObject=SharedObject.getLocal("data");
for (var i=0; i<10000; i++) {
sh_obj.data["prop"+i]=i*i;
}
trace(sh_obj.getSize());
// : 198916
getSize() ,
. sol-.
, sol- , . -,
. -,
. -, sol- . ,
.
Never Ask Again Local Storage. ,
.
, . , Local Storage ? , sol-, , , , , ,
. , sol, , , .
Cancel, (. 16.19).
Puc. 16.19.
, , . , SharedObject, .
,
, Local Storage.
Advanced Privacy. Macromedia,
, .
.
16.9.2. SharedObject
sol- :
SharedObject, getLocal(). , . sol-
, SharedObject. sol- ,
SharedObject.
, sol-.
var new_sol:SharedObject=SharedObject.getLocal("new");
new_sol.data.date=(new Date()).toString();
new_sol.flush();
var read_obj:SharedObject=SharedObject.getLocal("new");
trace(read_obj.data.date);
// : Fri Mar 5 21:34:33 GMT+0300 2004
, www.xyz.com, ,
www.xyz.com Flash Player shared.sol.
(. ).
, sol-,
, sol- ( , ). ,
www.xyz.com/swf/new/anim/multl.swf,
www.xyz.com/swf/new/efTects/blur.swf, swf
www.xyz.com:
var sol:SharedObject=SharedObject.getlocal("base", "/swf");
, , sol- ,
, , .
, sol- ( LocalConnection).
16.9.3. sol-
sol- ,
SharedObject clear(). . data ( sol- ). :
var read_scl:SharedObjt=SharedObjt.getLocal("shared", "/");
read_sol.clear();
for (var i in read_sol.data) {
trace(i);
// Output
}
sol- .
16.9.4. SharedObject
SharedObject .
, for-in
ASSetPropFlags():
ASSetPropFlags(SharedObject, null, null, 1);
for (var i in SharedObject) {
trace(i);
// : getDiskUsage deleteAll getRemote getLocal
}
ASSetPropFlags(SharedObject.prototype, null, null, 1);
for (var i in SharedObject.prototype) {
trace(i);
// : clear setFps getSize close flush send connect
}
16.9.5.
, Flash-,
Web- usability . HTML- ,
, , ,
. , , . Flash- , , . ,
, , , JavaScript. , SharedObject, . , .
, .
-, , ? .
: CSS (
s1,s2,s3, ...,sN). ,
( ).
, , , , . , .
, <>.
-, ,
? asfunction, ActionScript (. 13).
CSS , , _. :
"< class='s2'
href='asfunction:press, s2-http://www.flash-ripper.com'>
</a>"
, . , :
var text_arr:Array=null, cookies:SharedObject=null;
funtion init():Void {
// , ,
text_arr=[];
// links-sol
cookies=SharedObject.getLocal("links");
// , base, .
// ( ), .
if (cookies.data.base==undefined) {
cookies.data.base=();
cookies.flush();
}
}
init();
, . CSS- .
, CSS:
function press(par:String):Void {
//
var name:String=par.substring(0, par.indexOf("-"));
var link:String=par.substring(par.indexOf("-")+1);
// , name (
// , ). , .
if (cookies.data.base[name]==undefined) {
cookies.data.base[name]=true;
cookies.flush();
}
getURL(link, "_blank"); // ,
setStyle(text_arr);
// (
// )
var style_string:String="";
//
// 14
style_string+="p {font-size:14}";
//
style_string+="a {color:#0000FF; text-decoration; underline;
font-style:italic; margin-left:20)";
// CSS-,
var base:Object=cookies.data.base;
for (var i in base) {
style_string+="\r."+i+"{color:#FF0000; display:inline)\r";
}
//
var style:TextField.StyleSheet=new TextField.Stylesheet();
style.parseCSS(style_string);
for (var j=0; j<arr.length; j++) {
arr[j].styleSheet=style;
}
}
. ,
. :
this.createTextField("links", 0, 100, 100, 350, 200);
links.htm1=links.border=true;
text_arr[0]=links;
setStyle(text_arr);
// CSS-
var text:String = "<> :\n";
text+="<a class='s1' href='asfunction:press,
s1-http://www.flasher.ru/forum'> \n</>";
text+="<a class='s2' href='asfunctionipress,
s2-http://www.flash-ripper.com'> \n</>";
text+="<a class='s3' href='asfunction:press,
s3-http://www.macromedia.com'> Macromedia\n</a>";
text+="<a class='s4' href='asfunction:press,
s4-http://www.actionscript.org' , ActionScript\n</a>";
text+="<a class='s5' href='asfunction:press,
5-http://www.piter.'> \"\"</>";
text+="</p>";
links.text=text;
, .
, . , . . !
, , .
:
but.onPress=function():Void {
cookies.data.base={};
cookies.flush();
setStyle(text_arr); //
};
but.
.
16.10.
, , Flash-
SWF- . , , , ,
. ,
( , ,
, ).
, SWF- -
.
Print File . , , -,
HTML-. -, SWF- ( ). -,
, . .
Print . , , , , .
Print (
). !#. ,
ContextMenu.
ActionScript ( )
Flash 7 PrintJob. , . , ,
, .
ActionScript,
. , Flash MX 2004. PrintJob, Flash 7.
16.10.1.
Flash 4 : print(), printAsBitmap(), printNum(), printAsBitmapNum(). ,
.
print() printNurnO . ,
, , Flash ,
. , ,
, Color
Color. print()
printNum() .
printAsBitmap() printAsBitmapNum() .
. , , print{)
printNum().
, .
printAsBitmap().
:
printFunction(target, bounding_box);
, . print() printAsBitmap()
, printNum() printAsBitmapNum() , . ,
. ,
#. , ;
target
, , .
:
bounding_box
o , (bounding_box="bmovie").
. ,
#b. .
bmovie . ,
#b , .
, ( );
o , ,
(boundirig_box="bmax").
, ;
o ,
(bounding_box="bframe").
.
, Flash- print,
getURL().
print():
getURL("print:#bmovie", "_root");
,
.
, _visible. (,
).
Flash- PostScript- (PostScript , Adobe ), , . PostScript,
print() printAsBitmap() ,
.
16.10.2. PrintJob
Flash MX 2004. , , . , Print Job
,
(
). . PrintJob , .
Flash 7
PrintJob. ,
, .
PrintJob :
var printing:PrintJob=new PrintJob();
. start():
printing.start();
target
ares
, . , ;
, ,
. (
) xMin, xMax, yMin,
yMax . area , , ;
, . addPage()
. N , N
addPage().
frameNumber
, addPage() true. (,
addPage() start()), false.
. ( ).
, , , pageWidth pageHeignt ( , ).
, ( ).
,
. send().
:
var printing:PrintJob=new PrintJob();
if (printing.start()) {
//
_root._xscale=_root._yscale=printing.pageWidth/Stage.width;
// _root
printing.addPage(0, {xMin:0, yMin:0, x:Stage.width, yMax:Stage.height),
null, 0);
printing.addPage(0, {xMin:0, yMin:0, xMax:Stags.width, yMax:Stage.height},
null, 1);
printing.send();
//
//
_root._xscale=_root._yscale=1;
}
16:
, JSFL, Tools. , JSFL ActionScript . , JSFL
, . ,
, ,
Flash MX 2004, .
JSFL .
Macromedia .
, .
, ,
. ,
. , ,
.
, , Spirals JSFL 16 Tools Configurations ( . ). Flash, Tools ,
Edit Customize Tools Panel, . , Options .
,
, JSFL. . , Macromedia JSFL. , - .
. 16.20.
PolyStar
Tools 17 . 16
Flash MX 2004, JSFL,
, PolyStar (.
16.20). . - Tools, Rectangle, .
PolyStar Toolbar.
PolyStar . () , Options .
Tool Settings PolyStar
. 16.21.
PolyStar
. <properties> . <property> :
type
, . -
:
o Number ;
o Double , ( double 64-
);
o Boolean /. ;
o String ;
o Strings .
;
o color , Tools;
variable , ToolObj, .
(Number, Double, Color , Boolean , String Strings ).
;
defaultValue
min, max
. , , defaultValue="true";
. ;
name ,
list
,
. ,
, . . , .
. , , . , .
.
( ), . Tool Settings.
,
. , ,
, . Flash ,
, SWF-. , , ,
, , .
, : Double Number (,
, , ).
,
. . , XML- UTF-8.
<properties>
<property name=" " variable="r0" min="0" max="500"
defaultValue="0" type="Double"/>
<property name=" " variable="step" min="1" max="500"
defaultValue="5" type="Double"/>
<property name="" variable="a" min="-100" max="100"
defaultValue="0" type="Double"/>
<property name=" , /" variable="number__of_curves"
defaultValue="50" min="5" max="300"
type="Number"/>
</properties>
, . 16.22 (
, ).
Puc. 16.22.
. JSFL.
spirals.jsfl Tools Configuration. JSFL Flash ( ) ,
Unicode.
JSFL. ,
)' . JSFL , . , . { ),
,
, . . , , . , , .
. , . .
. . , , ,
. .
, ,
. , JSFL- . , Flash. (
, , ..)
. , . , ,
.
JSFL . , flash,
.
:
, Flash Tools.
, . ,
Flash ,
. configureTool() , ,
, .
configureTool
Flash , Tools. ,
JSFL- Toots;
activate , . ,
configureTooi. , activate , Tool Settings;
deactivate
, ;
, Tool Settings.
;
setCursor , .
. , +. JSFL , setCursor() Tools
( );
notifySettingsChanged
keyUp, keyDown
configureTool.
. , , mouseDown.
JSFL- . , :
,
configureTool. ToolObj ( , , ):
setlcon(name.png) PNG-,
. Tools Configuration;
setOptionsFile(name.xml) ,
L-. Configuration\Tools;
showPIControI(controi, bShow) , . PI
( JSFL).
. ,
tool.showPIControl("fill", false);
setMenuString(name) , , ,
Tools;
setToolName(name) , Tools
, XML- toolConfig.xml
Configuration/Tools. setToolName() ,
.
;
setToolTip(text) ,
.
. : JSFL- UTF8;
freeTransformHandles(bShow) , Free
Transform , .
. ,
.
.
configureTool, . ToolObj ,
activeTool Tool ( tools flash):
function configureTool() {
var tool=flash.tools.activeTool;
tool.setToolNarce("");
tool.setIcon("spirals.png");
tool.setPI("Shape");
tool.showPlControl("fill", false);
tool.setMenuString("spirals");
tool.setToolTip(" ");
tool.setOptionsFile("spirals.xml");
tool.showTransformHandles(false);
}
function activate() {
var t1=flash.tools.activeTool;
step=t1.step, a=t1.a, r0=t1.r0, number_of_curves=t1.number_of_curves;
}
. ToolObj (
spirais.xml ) . .
, , , Tool Settings:
function notifySettingsChanged() {
var t1=flash.tools.activeTool;
step=t1.step, a=t1.a, r0=t1.r0, number_of_curves=t1.number_of_curves;
}
,
+. ,
function setCursor() {
Flash.tools.setCursor(0);
}
setCursor(index) Tools .
: 0 +, 1 , 2 , 3
, 4 , 5 , 6
X, 7 .
.
,
. JSFL
drawingLayer. ,
. drawingLayer ,
. , drawingLayer,
.
drawingLayer,
beginDraw(). , ,
,
(true), (false). , , true:
function mouseDown() {
flash.drawingLayer.beginDraw();
}
. , . , , mouseIsDown Tools
function mouseMove() {
if (flash.tools.mouseIsDown){}
}
drawingLayer , .
. drawingLayer (Frame) , :
flash.drawingLayer.beginFrame();
//
flash.drawingLayer.endFrame();
,
. drawingLayer ,
.
mouseMove. , , .
, . -, , . , , ,
(
number_of_curves):
var phi=2*Math.PI/number_of_curves;
-, , ,
( ).
, penDownLoc Tools:
var center_x=flash.tools.penDownLoc.x, center_y=flash.tools.penDownLoc.y;
-,
( , ). penLoc Tools:
var cursor_pos_x=flash.tools.penLoc.x, cursor_pos_y=flash.tools.penLoc.y;
-, ,
. ,
penDownLoc penLoc .
,
. , , , tx ty .
viewMatrix Document:
var delta_x=flash.getDocumentDOM().viewMatrix.tx;
var delta_y=flash.getDocumentDOM().viewMatrix.ty;
-, , . ,
:
var radius=Math.sqrt((cursor_pos_x-center_x)*(cursor_pos_x-center_x) +
cursor_pos_y-center_y)*(cursor_pos_y-center_y));
-, , X ,
, . ,
, .
var alpha=Math.atan2(cursor_pos_y-center_y,cursor_pos_x-center_x);
, :
y = centerY R sin( );
x = centerX + R cos( );
; centerX centerY ; R
; , X, .
( , R ) . ,
10, . , , .
.
r0, Tool Settings. ,
, , , :
var begin_anchor_x=center_x+r0*Math.cos(-alpha);
var begin_anchor_y=center_y-r0*Math.sin(-alpha);
drawingLayer
moveTo, , MovieClip
ActionScript:
flash.drawingLayer.moveTo(begin_anchor_x+delta_x,begin_anchor_y+delta_y);
, . , :
while(r<radius && step+a*i/number_of_curves>0) {
r=r0+i/number_of_curves*(step+a"i/number_of_curves/2);
anchor_x=center_x+r*Math.cos(phi*i-alpha);
anchor_y=center_y-r*Math.sin(phi*i-alpha);
r_control=r/Math.cos(phi/2);
control_x=center_x+r_ccntrol*Math.cos((i-1/2)*phi-alpha);
control_y=center_y-r_control*Math.sin((i-1/2)*phi-lpha);
flash.drawingLayer.curveTo(control_x+delta_x, control_y + delta_y,
anchor_x+delta_x, anchor_y+delta_y);
i++;
}
, 10
. , , . : ( ), . , , . , .
,
( ),
, :
S r = r0 + t +
at 2
.
2
,
. r0,
. , ( step). () :
r=r0+i/number_of_curves*(step+a*i/number_of_curves/2 ) ;
.
, . while ,
. , while ,
:
. Tools ,
. ,
Tools. ,
, Output. , .
, drawingLayer
. Path,
. mouseMove()
path = flash.drawingLayer.newPath();
, . Path
addCurve():
// while
path.addCurve(begin_anchor_x, begin_anchor_y, control_x, control_y, anchor_x,
anchor_y);
begin_anchor_x=anchor_x, begin_anchor_y=anchor_y;
. . . , , 16.23.
. 16.23.
, *.m.
, Macromedia Exchange Manager.
17
ActionScript .
, . -, SWF-. , loadVariables()
LoadVars.
- XML. ActionScript, Flash, L. c XML
XML LNode.
, , . getURL() LoadVars. , ,
TCP,
XMLSocket.
. , SWF-, 11. 3 14. ,
, 18.
.
, , . ActionScript, , , . , .
Flash- , ;
SharedObject, cookies . , ,
100 . . ,
, SharedObject, -, , , , , ;
,
. , Local Connection ,
;
JavaScript , ,
HTML-;
HTTPS, SSL;
, HTTP, ,
HTTPS ( );
, , , . , ,
. , ,
, . , , .
Flash.
. , .
Flash, , .
Flash , SharedObject,
LocaiConnection, Camera Microphone.
17.1.1.
Flash- -. ,
, . ,
. .
,
ActionScript Web-. ?
, , , ,
, , .
, .
, , ,
.
, , ,
, .
? , , URL.
www.data.mysite.ru
www.info.mysite.ru. .
, www.mysite.ru www,
, mysite.ru ( www.mysitc.ru mysite.ru).
(www.mySite.ru www.mysite.ru
).
Flash 6 , .
n- . , ,
data.mysite.ru, , info.mysite.ru.
. , , narod.ru, . , , .
. , Flash 7 , , .
, Flash 6, , Flash 7, . , , ,
. ,
Flash Player 7. ,
. , . ? Flash 7? ActionScript ... , . :
System.exactSettings=false;
exactScttings System .
true, Flash 7,
false Flash 6. exactSettings true Flash
7 false Flash 6.
exactSettings . ,
, . , exactSettings ,
.
exactSettings ,
. , ,
.
17.1.2.
1990- , ,
, . -, , , .
,
, ,
. 1995 Netscape
, SSL (Secure Sockets Layer ).
,
. SSL HTTP,
HTTPS. SSL .
HTML-, HTTPS.
, , , SSL. , , , , .
, , , HTTPS.
, SSL. , , HTTPS,
, ,
, SSL-.
, , URL http://www.mysite.m/filml.swf,
XML- https://www.mysite.ru/data.xml. ,
URL https://www.mysite.ru/film2.swf.
Flash 6 .
: .
17.1.3.
, ,
.
. ,
.
. LocalConnection (. 16).
JavaScript, HTML-
. GetVariable() SetVariable().
,
LocalConnection() .
, ,
loadMovie(), loadMovieNum() loadClip() MovieClipLoader.
, , ,
. , HTTPS,
HTTP. , . HTTPS -. . , . ,
HTTP ( ). .
, . ,
. , , .
.
Flash Player 7 Flash 6. ,
, ( ; ,
HTTP, , HTTPS).
Flash 7, , .
, ,
, .
, , , , ,
. , _global. Flash 6 (, ). Flash Player 7 global
,
( ). ,
, Flash MX 2004, , Flash 6.
, www.zzz.com
www.yyy.com, , www.zzz.com
.
System.security.allowDomain():
System.security.allowDomain("www.zzz.com");
System.security.allowDomain("");
allowDomain() , .
http://www.zzz.com, https://www.yyy.com, ,
,
System.security.allowDomain("www.zzz.com");
, , ,
HTTPS, System.security.allowInsecureDomain().
,
allowDomain():
System.security.allowInsecureDcmain("www.zzz.com");
, aIlowInsecureDomain() ,
HTTPS. ,
, Flash 6, ,
Flash 7.
, , LocalConnection,
allowDomain allowlnsecureDomain .
, 16.
JavaScript , HTML-, .
, . , SetVariable()
, background
. . , . , , . , key
, ,
. L-, . , , GetVariable(),
key.
, Flash- JavaScript , , HTML-.
.
17.1.4.
Flash 6 ,
, , . Flash 7
. , ActionScript,
loadVariables() loadVariablesNum(), load() sendAndLoad() LoadVars,
load() sendAndLoad() XML, Flash Remoting, , ,
, . ,
HTTP, , .
,
,
. Flash 6
( Flash 7), , .
17.1.
, , , www.mysite.com , store.mysite.com. , , HTTP
www.mysite.com, HTTPS. Allow,
. Deny . Never Ask Again,
. .
Puc. 17.1.
, Security ,
Never Ask Again. , , (215138 ).
, Deny.
Security Flash Player, , Flash
6 , , ( ). . Flash 7 , Security . ,
. Flash 7
HTTPS, HTTP.
, Flash- ,
, ( HTTPS ,
). ? , , ,
- , , .
, ,
. .
, , XML-
crossdomain.xml. .
<crossdomain-policy> . domain <allowaccessfrom> . ,
www.data.mysite.com, www.info.mysite.com www.macromedia.com,
crossdomain.xml :
<crossdomain-policy>
<allow-access-from domain="www.data.mysite.com"/>
<allow-access-from domain="www.info.mysice.com'/>
<allow-access-from domain="www.macromedia.com"/>
</cross-domain-policy>
crossdomain.xml , , , , domain, .
, http://mysite.com/movie.swf, , domain
www.mysite.com, .
, domain
:
<allow-access-from domain-"*"/>
,
, domain, . , Flash- www.narod.ru ,
<allow-access-from domain="*.narod.ru"/>
IP-. ,
Flash- (. . I7.1J),
, , , IP. :
<allow-access-from domain="34.67.98.56"/>
, HTTP, HTTPS,
false secure <allow-access-from>.
, , . , HTTPS-
, , . secure:
<allow-access-from domain= "mysite.da.ru" secure-"false"/>
crossdomain.xml <allow-access-from>, . -,
. Flash 6 ,
Security .
crossdomain.xml ( ,
):
<?xml version="l.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.macromedia.com/xmi/dtds/cross-domain-policy.dtd">
, XML-,
:
<!-- -->
crossdomain.xml, ,
. ( HTTPS , HTTP)
. ,
. , ,
. .
, , .
, .
System.security.loadPolicyFile(), 19- Flash Player 7. XML :
System.security.loadPolicyFile("http://www.mysite.ru/data/secur_file.xml");
loadVariables("http://www.mysite.ru/data/news.txt", this);
loadPolicyFile(),
. , , , ,
. ,
. , , www.mysite.ru/data/, www.mysite.ru/data/news.txt ( )
www.mysite.ru/data/info/last_news.txt ( ).
www.macromedia.com/news.txt ( ) www.mysite.ru/news.txt
( ).
, , ,
. , loadPolicyFile() , .
:
loadPolicyFile()? ,
, ?
, Flash Player ,
. . .
loadPolicyFile() , , .
loadPolicyFile() , crossdomain.xml .
, ( Security
).
loadPolicyFile() .
19- . .
, ,
. , , .
.
, . Flash,
, ?
, -,
, .
(PHP, ColdFusion, Perl . .).
17.1.5.
Flash- TCP,
HTTP, . XMLSocket, , . , ,
Flash MX 2004.
Flash 5, XMLSocket, 1024.
( 0 1024). Flash MX 2004 ,
, . , . , , HTTP. - , crossdomain.xml 80 (. . HTTP-),
, .
,
HTTP. , to-ports <allow-access-from>,
, , domain. ,
. , beginend, begin , end - ,
. to-ports *,
1024.
1024. :
<?xml version="l.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.mysite.ru" to-ports="2020"/>
<allow-access-from domain="*.narod.ru" to-ports="1024-65535"/>
<allow-access-from domain="*" to-ports="1025,1026"/>
</cross-domain-policy>
HTTP. . , , -, HTTP- (
80 ). - . -.
loadPolicyFile() System.security. URL, : xmlsockct://domain:port, xmlsocket:// ,
, HTTP; domain , ; port - . :
var connection:XMLSocket=new XMLSocket();
System.security.loadPolicyFile("xmlsocket://www.mysite.ru:2045");
connection.connect("www.mysite.ru", 2045);
, , , , , , <cross-domain-request/>, .
, .
, .
loadPolicyFile() ,
, HTTP-. loadPolicyFileO, 1024 (
). ,
1024 ( , , ). , , 1024, HTTP,
.
Flash 7
-t, , , .
17.1.6. ,
Flash MX 2004
. , , . , , ,
. , -
. .
- HTML JavaScript, ,
(, )
. . HTML-.
HTML HTML-. ,
JavaScript if(password:="12345"){}, , , . SWF-, ,
ActionScript . SWF- 1998 ,
, Flash ( ASV, - http://www.buraks.com). -
ActionScript. , SWF-. ,
. - ? _bytecode() -
Flexm ( ).
. ,
.
, : .
. , ,
, ,
.
, (,
- ).
,
. ,
? , . , , , . . , , . . , . , , SWF- HTML-, HTTP . ,
SSL. http://, https://, . ,
. ,
HTTPS-.
SSL . , ,
.
, .
. .
SSL ,
HTTP. . :
. (, RSA) .
(, Rijndael
Twofish) ( ,
).
. .
, ,
. , . , .
,
, .
, . , :
, , . . , - ,
, , ,
. : MD5
SHA-1 ( ). SHA-I ActionScript
http://www.waxpraxis.org/archives/000035.html, MD5
http://flashexperiments.insh-allah.com/ffMD5.
.
1.
, , SWF-.
2.
, , . ,
, .
3.
4.
, , , . , . , , .
, ,
.
17.2.
, .
, .
, , , . Flash 7 HTML CSS,
. , Flash, , . ,
, , . ,
FLA- , .
, , ActionScript.
17.2.1.
( )
-, &.
. , Flash .
-:
name=Jonh&surname==Smith&age=25
, .
- HTML-
. HTML, , .
.
+ ( ) %20 ( ). :
txt=3apa+++
, escape() URL-,
Unicode-. Flash
name= name%3D.
. , .
. , :
per=++:
HTML XML- (
escape- \n \r ). , Windows
. Flash
. .
, - , Flash-. Unicode, UTF-8. ,
, Unicode :
System.useCodePage=true;
17.2.2. loadVariables()
loadVariables() ActionScript.
Flash 4, .
LoadVars. .
, loadVariables() :
loadVariables(URL, target);
. , , . ;
, - .
URL
target
ActionScript, loadVariables() . ,
target , ,
, , per.txt ,
,
message=Hello&from=Moscow
loadVariables("per.txt", _root);
message from,
Hello Moscow. , :
_root.OnData=function():Void {
trace (message);
// : Hello
trace(from);
// : Moscow
}
onData ,
. ,
, , loadVariables() .
.
onData.
onData
loadMovie(). .
loadVariables() MovieClip. . , ActionScript loadVariabiesNum(), , .
17.2.3. LoadVars
LoadVars loadVariables().
, .
- ActionScript, loadVariables().
LoadVars, -, ,
, .
, .
(, ).
LoadVars , , .
LoadVars URL-.
, , , per.txt,
:
Message=Hello&from=Moscow
, LoadVars,
:
var loader:LoadVurs=new LoadVars();
Ioad(), ( , loadVariables()):
loader.load("per.txt");
-, load() message
from loader, Hello Moscow:
loader.onLoad=function():Void {
trace(this.message); // : Hello
trace(this.from}; // : Moscow
}
onLoad LoadVars . , ,
onLoad. , : load() onLoad .
, : , . c, , load().
onLoad , -
. true,
false:
loader.onLoad=function(success:Boolean):Void {
if(!success) {
trace("He ");
}
}
LoadVars .
. , .
onLoad loaded. . LoadVars ,
false. , loaded true.
, loaded false.
loaded . ,
LoadVars , .
getBytesLoaded() getBytesTotal(), , , . LoadVars ,
(
MovieClipLoader onLoadProgress). ,
onEnterFrame setInterval().
, - , .
loaded. , :
var loader:LoadVars=new LoadVars();
loader.load("http://www.mysite.com/info.txt");
this.createTextField("preloader", 0, 200, 200, 40, 30);
preloader.text="0%";
this.onEnterFrame=function():Void {
if (!loader.leaded && loader.getBytesTotal()>0) {
var proc:String=Math.round(loader.getBytesLoaded()/
loader.getBytesTotal()*100)+"%";
preloader.text=proc;
} else if (loader.getBytesTotal()>0) {
preloder.removeTextField();
delete this.onEnterFrame;
}
};
,
. , , , X%
, , . , .
, . - . , . , LoadVars , . -
, -. onData,
, , , - LoadVars.
, .
, , , ,
info.txt, ;
<> <b>XML</b> <b>HTML</b> ,
<b>XML</b>
<b><i><!DOCTYPE...></i></b>
(DTD).</>
pole, c :
var loader:LoadVars=new LoadVars();
loader.load("info.txt");
loader.onData=function(str:String):Void {
pole.htmlText=str; // HTML
delete loader;
};
LoadVars, .
HTML-, , SWF-
.
. ,
. , . , , .
news.txt, LoadVars.
, , , , , ,
. . . :
URL, , .
URL ,
. :
var loader:LoadVars=new LoadVars();
loader.load("http://www.mysite.ru/info.txt?rand="+Math.random());
Unicode , .
, .
Unicode :
System=useCodepage=true;
,
,
split String. , , . :
var str:String="l,2,3,4,5";
var arr:Array=str.split(",");
trace(arr[2]);
// : 3
17.3.
Flash ,
.
, -, . , ,
, ,
.
,
. : ASP, ColdFusion, JSP, Perl,
PHP. , .
Flash .
. -,
. -, ActionScript,
, . -,
, - ,
. -, , ,
.
ActionScript ,
HTTP-. getURL() loadVariables(),
send() sendAndLoad() LoadVars ( send() sendAndLoad() XML
17.3.1.
HTML-. , , Google Yahoo. , Flash- . HTML-,
, . , SWF . .
HTML-
,
getURLQ send() LoadVars. getURLQ :
getURL(URL, target, method)
, . URL
;
URL
target
method
, ,
. : _blank, _self, _top, _parent, name (
. getURL() 16). target . , ;
HTTP-, .
: GET POST ( ).
method , POST.
,
Flash-. , , , ,
. getURL() , . - getURL() , . , , , -, , URL-.
getURL() . ,
.
. www.mysite.ru - message.php
:
<?php
$message=$_GET['mess'];
echo "<h2>Your message is: $message</h2>";
?>
this.createEmptyMovieClip {"clip",0);
clip.mess="Hello!";
clip.getURL("http://www.mysite.ru/message.php", "_blank", "GET");
, ,
HTTP . , GET, $_GET.
, POST,
SPOST. HTTP- ?
, .
http://www.mysite.ru/message.php?mess=Hello %21
POST GET. - , .
GET, POST .
, , URL-. ,
POST, XML-, .
POST .
, , .
POST .
, ,
, . GET -
, POST , . POST
( GET, ,
POST).
getURL() Flash 7
. , , , ActionScript Flash. , , getURL(). send()
LoadVars. :
getURL() -,
, . , ,
, .
send() -
LoadVars, . ;
LoadVars
. , addRequestHeader(), .
send() , getURL():
sender.send(URL, target, method);
send().
www.mysite.ru IP.php, :
<?php
$name=$_POST['name'];
$ip=getservbyname($name);
echo "<b> $name IP $ip</b>";
?>
-, ,
, :
www.flasher.ru IP 81.113.73. 11
17.3.2.
getURL() send() LoadVars HTML-.
, .
, ,
, , loadVariables() sendAndLoad()
LoadVars.
loadVariables() :
loadVariables(URL, target, method);
URL
target
, -
method
. . . ( pass), , ( but). ,
( info). :
this.createEmptyMovieClip("clip", 1);
// -
but.onRolease=function():Void {
// password
clip.password=pass.text;
};
loadVariables("http://www.mysite.ru/password.php",clip,"POST");
// message, , TRUE,
// . , .
clip.onData=function():Void {
if (this.message=="TRUE"} {
_root.gotoAndPlay(2);
} else {
info.text=" ";
, pass 12345
. info .
, Flash 7
loadVariables() . AclionScript , , sendAndLoad() LoadVars.
loadVariables() :
loadVariables() ,
. ,
, . sendAndLoad()
LoadVars, - ;
sendAndLoad() :
sender.sendAndLoad(URL, loader, method);
URL ,
loader
LoadVars, ;
method HTTP-, .
loadVariables(), sendAndLoad() .
, send() LoadVars,
-, URL- .
sendAndLoad() ,
load LoadVars.
sendAndLoad()
LoadVars , .
, , , onLoad onData LoadVars.
,
onData onLoad . ,
, .
for-in sendAndLoad() LoadVars - . . ,
onLoad onData ASSetPropFlags().
.
send() load() LoadVars , sendAndLoad() . .
ActionScript , ,
, The Bat! Outlook Express.
, .
, , , .
9.
.
. ( sender_name) . (sender_mail) . (receiver_mail) . (subject) .
letter_text, .
. , . send. ,
, . info.
, HTML,
TextArea ( )
Text Input ( ).
, .
9.
ActionScript. Unicode,
:
System.useCodepage=true;
9.
- - LoadVars:
9.
send.onPress=function():Void {
s_and_1_obj.sender name=sender_name.text;
s_and_1_obj.sender_mail=sender_mail.text;
s_and_1_obj.receiver_mail=receiver_mail.text;
s_and_1_obj.subject=subject.text;
s_and_1_obj.letter_text=letter_text.text;
s_and_1_obj.sendAndLoad("http://www.mysite.ru/mail.php", rec_obj, "POST"
};
info.text=" ...";
};
9.
.
:
rec_obj.onData=function(text:String):Void {
info.text=" :"+text;
};
9.
Flash- . .
. POST,
$_POST:
$receiver=$_POST['receiver_mail'];
$subject=$_POST['subject'];
$text=$_POST['letter_text'];
$from='From:'.$_POST['sender_name'].'<'.$_POST['sender_mail'].'>';
, $from, . . (, : <diis_ignotis@tut.by>).
, ..
8. mail(), :
mail(receiver, subject, text, sender)
receiver
subject
text
sender
,
( ).
mail() :
$success=mail($receiver, $subject, $text, $from);
9.
mail() TRUE.
FALSE. mail() , , :
if($success) {
echo ' ';
} else {
echo ' . , .';
}
. PHP- ,
sendAndLoad() . , ,
, mail() ( ).
, . .
17.3.3.
LoadVars getURL() getVariables() ,
HTTP-. , .
HTTP : .
, . . HTTP 1.1 . , . .
Content-Type. . LoadVars
URL- -,
application/x-www-form-urlencoded. text/html ( HTML), text/plain ( ), text/xml ( L).
Accept-Language. ( ), .
(en , ru . .).
Host. , .
Date. .
. ,
. . addRequestHeader()
LoadVars. . , :
sender.addRequestHeader(headerName, headerVaiue);
headerName
headerValue
,
.
, addRequestHeader() :
sender.addRequestHeader([neaderName1,headerValue1,...,headerNameN, headerValueN]);
addRequestHeader() ,
POST. GET .
HTTP- . , , . ,
, Accept-Language,
.
, , , (, , , -). ,
, . , .
, Accept-Language.
:
var sender:LoadVars=new LoadVars();
sender.addRequestHeader("Accept-Language", "ru");
sender.send("http://www.news.com/last.php","_blank","POST");
HTTP-
addRequeslHeader(). : Accept-Ranges, Age, Allow,
Allowed, Connection, Content-Length, Content-Location, Content-Range, ETag, Host, Last-Modified,
Locations, Max-Forwards, Proxy-Authenticate, Proxy-Authorization, Public, Range, Retry-After, Server,
, Trailer, Transfer-Encoding, Upgrade, URI, Vary, Via, Warning, WWW-Authenticate.
Content-Type, ,
. , , - URL-, Content-Type application/x-www-form-urlencoded
text/plain ( ). , addRequestHeader().
contentType LoadVars:
var sender:LoadVars=new LoadVars();
trace(sender.contentType); // : application/x-www-form-urlencoded
sender.cententType="text/plain";
17.4.
, .
? ,
( )?
HTTP. , HTTP. , ,
. .
.
HTTP HTML, ,
. HTTP
. , , . , , ? !
HTTP- , IP-. HTTP
: , (
). , ,
.
, , . , . , .
HTTP, ,
(polling method). ,
. Quake, ,
. , HTTP 0,1 .
( ),
.
HTTP , .
. , . . HTTP . - ? , .
, HTTP,
, TCP, .
, TCP. HTTP TCP, ,
, . ,
TCP, , .
TCP . . ,
, . IP- .
.
IP- - . IP, 32- , 0 255, (,
171.34.78.14). , IP-. , , , , IP
. , IP IP
. .
, , . HTTP DNS. , IP , IP
(
; , IP ). IP,
.
, IP-,
. IP (127.0.0.1) ,
- . IP
, - , .
, ,
IP-. IP- , ( 12
). (DNS), IP, . ,
www.macromedia.com , 204.87.25.56. IP
DNS-, IP ,
. IP- DNS-
. Flash- ,
DNS-.
IP, IP- . .
, URL , IP (,
http://223.78.56.12/index.html). .
I- . ,
. ,
, , , . ,
? , . , , , , .
, . , , (
- , LPT).
, , . , , , , . , IP , .
16- -. , 65 536 . , - , . U RL (
: hitp://www.mysite.ru:8080). , -
. , HTTP 80 , FTP 12, -110, Telnet
23 . . 0 1023. , HTTP-
80 , , http://.
,
. 5001 65 535 ( 01023 ,
10245000 ).
. , TCP- ,
. , - TCP
HTTP:
80- .
, TCP ,
IP . ?
, . , . -.
- .
. - , , .
, - - - . , .
(. . TCP- ). TCP HTTP. HTTP
,
.
HTTP- . TCP . ,
( ).
ActionScript, -. XMLSocket,
. 17.4.1. -, ( Java) . . - ,
. - -, (
. 17.4.2), -
.
, TCP HTTP.
, (, TCP ).
, ,
HTTP.
-, , .
, , , . HTTP,
,
. , , .
5-10 .
. , Flash 7 , ( - , . 17.3.2).
, , . , , HTTP.
- .
(
), . ,
- . ,
. , - . ,
gethostbyname(), IP . ,
!
-,
. .
17.4.1. XMLSocket
XMLSocket() -.
,
XML. XMLSocket() , L ( XMLSocket Socket).
TCP- XMLSocket;
var socket:XMLSocket=new XMLSocket();
-.
connect(), :
socket.connect(server, port);
-, -,
-. IP-, .
-, , . , . 17.1.5;
server
- ,
, .
connect() null ;
, , -.
1024.
.
, ,
. , . 17.1.5.
port
connect() true,
. , connect() false.
- , . ,
. -, - Flash- onConnect. , , , .
, onConnect. true, TCP- (
). false, ( ).
var socket:XMLSocket=new XMLSocket();
if (!socket.connect("www.mysite.ru",9875)) {
trace("He ");
}
socket.onConnect=function(success:Boolean):Void {
if (!success) {
trace("He ");
} else {
trace(" ");
}
};
onConnect ,
, .
-, send(). .
( , ASCII) . :
socket.send(" !");
, , - ,
. , ( ,
TCP- ). , onData
, . , onData (. . , ).
, , ,
onData , .
XML, -. , XMLSocket XML- XML. XML- , on Data
( , ). , onXML,
XML.
, .
LSocket.
. close():
socket.close();
close() XMLSocket. .
-, -. , , . ,
(, , ). , , onClose.. :
//
socket.onClose=function():Void {
this.connect("www.mysite.com",8080);
};
onClose , -
- - , close() onClose.
17.4.2. -
- , -. , , ActionScript. , Perl . -
Java, , , , , .
- .
,
. , , ,
( escape \0).
<?php
//
// ( - -, )
set_time_limit (0);
// IP- ,
$address=gethostbyname($_SERVER['SERVER_NAME']);
$port=10000; // , -
//
$sock=socket_create(AF_INET,SOCK__STRSAM, 0);
// IP
socket_bind($sock,$address,$port);
// - -
socket_listen($sock,5);
// , ,
// -
while (1) {
$acc=socket_accept($sock);
// ,
if (!$acc) {
continue 1;
}
// , ,
// , $buf
$buf='';
while(1) {
$buf.=socket_read[$acc,204S); //
// close,
if {$buf=='close\0") {
socket_close($acc);
break 2;
}
// quit,
//
if ($buf=='quit\0') {
break 1;
}
// ,
// . ,
// .
if(substr($buf,strlen($buf)-1,1)=='\0')){
socket_write($acc,$buf);
$buf='';
}
}
}
send() LoadVars. ,
, , ,
. , , .
,
set_time_limit(). .
- . ,
. -. ,
.
, -. ,
. -,
, , ,
, . , , Flash.
. -.
17.5. XML
XML ,
. 30 L . .
XML Flash-?
L , .
. , L .
, , L, -. , :
var capitals:Object=[England: "London", USA: "Washington", Russia: "Moscow"};
:
England=London&USA=Washington&Russia=Moscow
( ,
).
, ?
, -, . ... , ,
. XML. ,
var peoples:Object={Jonh:{age:24, phones:[34563459, 845677563]}, Bob:{age:31,
phones:[28965745]}},
XML-:
<peoples>
<person name='Jonh'>
<age value='24'/>
<phones>
<number>3456459</number>
<number>845677563</number>
</phones>
</person>
<person name='Bob'>
<age value='31'/>
<phones>
<number>28965754</number>
</phones>
</person>
</peoples>
XML
. XML-
XML . , . , - , XML. ActionScript
XML XMLNode, L-
.
, L , , -
. . ,
, L . XML . , ,
XML-, , Java- .
. , . XML ,
, ,
.
, , XML ActionScript,
,
, . XML . XML .
, XML ActionScript-,
, XML.
, Flash-, Windows, , . , ,
.
, :
? , .
L.
XML . ,
, ?
. XML-,
. ,
loadMovie() MovieClipLoader.
XML- . , ,
. ,
. , ,
XML- , .
, , .
- ElectroServer
XML-. , , .
XML .
. ActionScript- XML, , , .
, ActionScript XML-. XML, . XML Flash
, XML
.
17.5.1. L
, XML
, . , . .
, . , .
. , , , .
, .
SWF-. . . , . , _root, .
. . ( ), ( ).
_parent, , ,
. .
XML . ,
XML-.
L . XML- :
<name>Jonh Smith</name>
, , , .
: ( ). , . , , , .
( XML Flash-). , .
, XML- . , . , ( SWF-).
XML-, :
<person>
<name>Jonh Smith</name>
<age>44</age>
<profession>manager</profession>
<family>
<wife>
<name>Mary</name>
<age>39</age>
<profession>teacher</profession>
</wife>
<child>
<name>Bob</name>
<age>18</age>
<profession>student</profession>
</child>
</family>
</person>
, , . 17.2. ?
. 17.2. XML-
, .
, . , . ,
. 17.2 .
XML- . , Flash- XML
XMLNode. L,
.
XML- . , . , , .
, ( ).
, < />.
:
<person>
<name/>
<age/>
</person>
(. ).
. : _ (), - (), . () (
_). ,
. . .
XML- , . -, .
. ,
. , person, name age:
<person name= 'Jonh' age='23'></person>
, . . -, .
, .
-, ,
. , , . , ,
-.
, , , XML-, ,
, .
, .
XML, . , , . Flash-
, , . : , . , ,
.
, : < ( ) & ( ),
, escape-
ActionScript. < <, & &. >
>. :
<info> "<" ">"</info>
" ', , ,
. , .
, , .
&#N;, N . ,
: &#xN;. , , 3.
XML- HTML- XML-.
< & > < . , CDATA.
.
CDATA <! [CDDATA[. ]].
, . :
<text>
<![CDATA[
<> <i>XML<i>- <i>HTML<i>-</h>
]]>
</text>
XML- 32
( ). , , .
, ,
, .
. . ActionScript .
? .
, , .
XML. , .
, XML- ,
( ) , , . :
<new:text></new:text>
. , , , xml ( ).
.
, URL . URL, , ,
XML-. : ,
URL .
U RI , ,
, xmlns :
xmlns:prefix="URL". :
<doc xmlns:new="http://www.rnysite.ru/my_xml_format.html">
<new:text></new:text>
</doc>
, , URL. , URL ,
XML . , URI
, .
XML , ActionScript.
, , ,
. XML <!-- -->.
. :
<!-- -->
XML-
XML- ( ) XML-. , , ,
<?xml ?>.
XML-:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
XML- .
, . XML-:
version L, .
XML 1.0;
standalone
DTD.
. DTD
XML .
. , SVG ( , L),
. ,
.
XML , ?
,
?
DTD (Document Type Definition ). DTD ,
. XML- DTD, , , ( ).
DTD .
, MathML, SVG, XHTML, DTD ,
. DTD
, XML-.
( DTD XHTML):
<!DOCTYPE xhtml SYSTEM
"http://www.w3.org/TH/xhtml1/DTD/xhtml1-transitional.dtd">
, DTD XML-.
XML HTML
HTML , XML .
( ).
HTML . XML .
L . HTML .
. DOM Flash-.
DOM (Document Object Model ) W3C
.
SAX . DOM . ActionScript
DOM, . .
, DOM , XML-
. ( , ).
,
XML. , , . , . , , .
ActionScript , DOM,
LNode. , .
XMLNode, ActionScript , L.
XML, . ,
, . , , XML- DDT-, , XML- DOM . .
XML DOM, . ,
. L , D0M. , XML XMLNode. LNode , . XML ,
.
XML XMLNode, . ,
XMLNode, .
XML ,
XML- DOM.
L LNode.
, L, . , , ,
XMLNode. XML,
, DOM, .
DOM, Flash-,
, ,
. ,
. , , , ,
; ELEMENT TEXT.
, nodeType.
DOM W3C XML . -
. , ,
ELEMENT. , , ,
TEXT. , , . . DOM 12.
(ELEMENT TEXT) DOM, Flash-.
, XML , ,
DOM, ActionScript, (,
).
, ( TEXT ). ,
DOM, ( ELEM ENT
TEXT):
<text>
<tab/> XML <link addr="http://w3c.org"/> SGML
</text>
, Flash- , . 17.3.
. 17.3. DOM,
XML-
DOM W3C,
( Attr addr link).
DOM . ,
, . . XML- D0M
. DOM, XML-
, SAX (Simple API for XM L). : SAX , . ,
ActionScript SAX.
XML- XML. ,
( LNode,
D0M), . XML XML-,
XML:
var xml_doc:String="<doc><link>http://www.piter.com</link></doc>";
var xml_data:XML=new XML(xml_doc);
L DOM.
XML .
var xml_doc:Strings"<doc><link>http://www.piter.com</link></doc>";
var xml_data:XML=new XML("<doc0></doc0>"s);
// DOM
xml_data.parseXML(xml_doc);
L- DOM ,
. XML-, , . .
load() XML. , , DOM
load() . . , XML-, load()
onData ( ) onLoad (
XML-). load(), onData onXML
LoadVars.
, L- , . .
XML, HTML, . , , . , ,
XML- D0M, . L,
XML Flash-. , XML-
, , , status XML. ,
XML- DOM . status
-1 10.
. . 17.1 , .
0
-2
-3
-4
-5
-6
-7
-8
-9
-10
17.1
:
CDATA ( , ] )
XML- (,
< >, <? ?>)
XML-
DOM,
( , )
,
,
. 17.1 : XML- -
, status? :
. , ,
. , , .
( ) DOM ,
.
. Flash- ,
:
var xml_data:XML=new XML("<doc><data type=xml></data></doc>");
trace(xml_data.status);
// : -6
, , . ,
. status, 8.
status, XML-, ,
. .
XML- Flash- ,
. DTD, , DTD .
DTD. .
docTypeDecl . :
var docTDecl:String="<!DOCTYPE data SYSTEM 'dtd/data.dtd'>";
var xml_body:String=docTDecl+"<data></data>";
var xml_doc:XML=new XML(xml_body);
trace(xml_doc.docTypeDecl);
// : <!DOCTYPE data SYSTEM 'dtd/data.dtd'>
L- Flash, XML ;
XML-
DOM, , xmlDecl . :
var doc:String="<?xml version='1.0' encoding='UTF-8'?>";
doc+="<data></data>"
var xml__doc:XML=new XML(doc);
trace(xml_doc.xmlDecl>; // : <?xml version='1.0' enogding='UTF-8'?>
,
XML- DOM:
<data> </data>
, . . DOM, Flash-, , , ,
. <data> , . ,
. . , . ,
. ,
, .
, , , ,
. , XML- , . DOM , .
, true ignoreWhite. , . , .
ignoreWhite false. :
var xml_obj:XML=new XML("<text> </text>");
trace(xml_obj.firstChild.firstChild.nodeValue == " ");
// : true
// ( )
xml obj.ignoreWhite=true;
xml_obj.parseXML("<text> </text>");
trace(xml_obj.firstChild.firstChild);
// : null ( )
17.5.4. DOM
XML-,
DOM. ,
.
LNode, .
DOM,
. L, . :
var xml_doc:XML=new XML("<text></text>");
var root_node_1:XMLNode=xml_doc.firstChild;
var root_node_2:XMLNode=xml_doc.lastChild;
var root_node_3:XMLNode=xml_doc.childNodes[0];
trace(root_node_1==root_node_2 && root_node_1==root_node_3);
// : true
,
L . ,
DOM .
( ), , .
hasChildNodes() XMLNode, true,
, false, . :
var xml_doc:XML=new XML("<text></text>");
trace(xml_doc.firstChild.hasChildNodes());
// : true
, . ,
attributes . , , -
, .
. .
LNode childNodes, ,
. , . , ,
childNodes:
XML- , childNodes .
, , . DOM, ActionScript, & previousSibling nextSibling, firstNode lastNode.
DOM , , .
, , .
, , nextSibling.
, , ,
previousSimbling.
nextSimbling previousSimbling,
.
firstChild ( ) lastChild ( ).
DOM obhod(),
. .
- . , . ,
. , , . , obhod().
var xml_doc:XML=new XML("<text><t1/><data></data><t3/></text>");
var col:Number=0; // -
function obhod(node:XMLNode):Void {
col++;
if (node.hasChildNodes()) {
obhod(node.firstChild);
}
if (node.nextSibling!=null) {
obhod(node.nextSibling);
}
}
obhod(xml_doc.firstChild);
trace(col);
//
// : 5
XML. ,
.
, .
, .
XML-
, 255 . , , scriptLimits SWF- Flasm. , 20.
, , ,
. XMLNode parentNode, . :
var xml_doc:XML=new XML("<text></text>");
trace(xml_doc.firstChild.firstChiId.parentNode.nodeName);
// : text
, . ,
DOM, ActionScript, : ELEMENT TEXT. ,
, nodeType. 1,
, 3, . ;
var xml_doc:XML=new XML("<text></text>");
trace(xml_doc.firstChild.firstChild.nodeType); // : 3
, , ,
. nodeValue XMLNode. ELEMENT, TEXT, nodeValue
null. :
var xml_doc:XML=new XML("<text></text>");
trace(xml_doc.firstChild.firstChild.nodeValue); // :
XMLNode XML.
for-in ,
, , , . ,
. ( ):
namespaceURI , UR1 , .
, URI xmlns , ;
prefix , ;
localName ( nodeName
);
getPrefixForNamespace() , URI;
getNamespaceForPrefix() URI .
,
. ., [].
:
var xml_text:String="<text xmlns:new='http://www.mysite.ru'><new:node/> </text>"
var xml_obj:XML=new XML(xml_text);
var ch_node:XMLNode=xml_obj.firstChild.firstChild;
trace(ch_node["namespaceURI"]); // : http://www.mysite.ru
trace(ch_node["prefix"]);
// : new
trace(ch_node.nodeName);
// : new:node
trace(ch_node["localName"]);
// : node
trace(ch_node["getPrefixForNamespace"]("http://www.mysite.ru");
// : new
trace (ch_node["getNarnespaceForPrefix"]("new"));
// : http://www.mysite.ru
17.5.5. XML-
ActionScript XML-,
DOM. .
XML, DOM:
var doc:XML=new XML();
DOM.
XMLNode . ,
.
, ,
createTextNode() XML. :
XML- ,
.
. ,
. cloneNode() XMLNode.
cloneNode() , .
( true) . ( false) , .
.
var doc:XML=new XML("<doc><text></text></doc>");
var cloned_node:XMLNode=doc.childNodes[0].childNodes[0].cloneNode(true);
trace(cloned_node);
// : <text></text>
, , attributes:
var doc:XML=new XML();
var new_node:XMLNode=doc.createElement("text");
new_node.attributes.author="Pushkin", new_node.attributes.title="Onegin";
, .
appendChild() insertBefore() XMLNode. appendChild() ,
,
. appendChild() , . appendChild()
XMLNode. :
var doc:XML=new XML();
var node_1:XMLNode=doc.createElement("doc");
var node_2:XMLNode=doc.createElement("text");
var text_node_3:XMLNode=doc.createTextNode("");
node_2.appendChild(text_node_3);
node_1.appendChild(node_2);
doc.appendChild(node_1);
trace(doc);
// : <doc><text></text></doc>
, DOM appendChild()
XML. XMLNode.
, appendChild()
insertBefore(newChild, beforeChild), newChild
XMLNode, beforeChild ,
. :
var doc:XML=new XML("<doc><tag1/><tag2/><tag3/></doc>");
var new_child:XMLNode=doc.createElement("tag4");
doc.firstChild.insertBefore(new_cnild, doc.firstChild.childNodes[2]);
trace(doc); // : <doc><tag1/><tag2/><tag4/><tag3/></doc>
17.5.6. XML-
XML- . ( ) - XML.
LoadVars : send(),
load(), sendAndLoad(), getBytesTotal(), gctBytesLoaded(), addRequestHeader(); contentType,
loaded; onData onLoad. ,
LoadVars XML , . ,
XML-.
XML-, Flash- .
onLoad. XML- . on Data,
, .
onData . onData, L-
DOM.
Flash- application/xwww-form-urlencoded. . ,
XML-,
text/xml. contentType.
17:
Flash.
, SWF.
; , , (
, ). , , Flash-,
, , - .
. -, ,
. ActionScript,
. -, , , , , .
. : .
:
, .
. 1010 .
. ,
. ( ), . ,
, , ,
( , . . ). ( , , , (reverse
. )). ,
, .
, . , Flash .
? ( ).
1.
: Flash-,
.
2.
, ,
. .
, , .
3.
, .
, -
. .
, .
, -
. , .
4.
.
, , . ,
. , . , ,
. .
,
.
? , : , ,
. , , . , . ,
. ,
. , , , , . , , , (
). , , , , ,
, ,
.
, , FLA- 17 .
, , .
.
. ?
,
.
C++ Java ColdFusion . ? -
, HTTP .
, ,
. -, . , .
: -. HTTP-,
. ? , . , ?
? . ActionScript, , .
, . .
: . , . , HTTP- , .
ActionScript, , - ,
SWF-. . (, )
.
? : -
SWF- . , ,
. ,
, . , .
SWF-, :
, .
, HTTP- .
:
, ,
, . , ,
.
.
. ,
stop();
Unicode, :
System.useCodepage=true;
, :
Stage.showMenu=false;
, .
: , (
nick); , ( send); (info).
, .
send , nick. , . , , . :
var sender:LoadVars=new LoadVars();
// -
var receiver:LoadVars=new LoadVars();
// -
send.onPress=function():Void {
if (nick.text.length>=3) {
sender.nick=nick.text;
sender.sendAndLoad("registration.php",receiver,"GET");
} else {
inf.text=" ";
}
};
, , registration.php, ,
, .
nicks.txt.
: fopen() PHP, , . ,
\n.
, , :
( fwrite()), ,
\n, . ,
, .
nicks.txt ( fwrite()), , .
registration.php :
<?php
$nickname=$_GET['nick'];
// ,
$basa=fopen('nicks.txt','+');
//
$basa_string=fread($basa, 10000);
//
$i=0;
//
// ,
while(1) {
$pos=strpos($basa_string,"\n",$i);
if ($pos==FALSE) {
break 1;
}
if (substr($basa_string,$i,$pos-$i)==$nickname) {
$i='err';
break 1;
} else {
$i=$pos+1;
}
}
// ,
// " "
if($i==='err') {
echo " ";
// , nicks.txt,
// " ".
} else {
fwrite($basa, Snickname."\n");
fclose($basa);
echo ' ';
}
?>
: nicks.txt? , ,
. , , , (
,
). , ,
, .
ActionScript. ,
. , onData
undefined, , , .
info . onData ,
info. , name
:
var name:String=null;
receiver.onData=function (text:String):Void {
if(text==undefined) {
info.text="Co ";
return;
}
if (text=="\r\n ") {
info.text=" ";
} else {
name=nick.text;
gotoAndStop(2);
}
};
, ,
, . -, ,
- . -, .
, ,
. , ,
. ,
( pass act), ,
:
pass.nPress=function():Void {
gotoAndStop(3);
};
act.onPress=function():Void {
gotoAndStop(4);
};
.
exit ( , , ).
unreg.php
. setInterval.
, , ,
, setInterval().
( ).
exit.onPress=function():Void {
var sender:LoadVars=new LoadVars();
sender.nik=name;
sender.sendAndLoad("unreg.php",snd,"GET");
for (var i=0; i<100; i++) {
clearInterval(i);
}
gotoAndStop(1);
};
exit , .
: , .
, nicks.txt, .
.
, , .
nicks.txt , unreg.php , , ( ,
):
<?php
$nick=$_GET['nick');
//
$data_base=fopen{'nicks.txt','+'); //
$text=fread($data_base,10000);
//
fclose($data base);
//
$pos=strpos($text,$nick);
//
//
$new_data_base_text=substr($text,0,$pos).substr($text,3pos+strlen($nick)+1);
// nicks.txt
$file = fopen('nicks.txt','w+');
fwrite($file,$new_data_base_text);
fclose($file);
unlink($nick."_messages");
// " "
?>
, , - , .
. : ( info) ( block, yes no).
, , . . block :
blok._visible=false;
,
. . ,
. ,
, name_messages.txt, name
.
,
createMcssageBox.php:
<?php
$nick=$_GET['nick'];
$text=$_GET['text'];
$file_name=$nick."_messages.txt";
$file=fopen($file_name, 'w');
fwrite($file,$text);
fclose($file);
echo $text;
?>
//
//
//
//
//
//
//
,
,
,
, .
, . , ,
var sender:LoadVars = new LoadVars();
// -
var receiver_l: LoadVars=new LoadVars();
// -
sender.nick=name, sender.text=" ";
sender.sendAndLoad("createMessageBox ,php", receiver_1, "GET");
delete sender.nick, sender.text;
, info
info.text=" . ...";
, , , . , (
10-20 ) . ,
, :
<?php
$nick=$_GET['nick'];
//
$messages_box=$nick."_messages.txt";
//
$file=fopen($messages_box,'a+'];
//
echo fread($file,10000);
//
fclose($file);
//
?>
polling.php.
, :
var time:Number=null;
receiver_1.onData=function(text:String):Void {
if (text==" ") {
// 20
time=setInterval(polling,20000);
} else {
info.text=" ";
}
};
//
var receiver_2:LoadVars=new LoadVars();
function polling():Void {
sender.nick=name;
sender.sendAndLoad("polling.php",receiver_2,"GET");
delete sender.nick;
}
, , ,
- . , block,
, -
. , , .
var guest:String=null; // ,
receiver_2.onData=function(text:String):Void {
if (text!=' ') {
clearInterval(time);
blok._visible=true;
guest=text;
info.text="C "+guest+". ?";
}
};
yes block,
,
, :
blok.yes.onPress=function():Void {
sender.nick=guest, sender.text=" ";
sender.sendAndLoad("createMessageBox.php",sender,"GET");
delete sender.nick, delete sender.text;
gotoAndStop(5);
};
, block, .
. block , info
:
blok.no.onPress=function():Void {
// ,
sender.nik=guest, sender.text=" ";
sender.sendAndLoad("createMessageBox.php",sender,"GET");
//
sender.nick=name, sender.text=" ";
sender.sendAndLoad("createMessageBox.php",receiver_1,"GET");
blok._visible=false;
info.text="oe . ";
};
, , , , ,
. . -,
, ( users). -, ,
, ( choise). -, ,
(send). -, info,
.
.
, nicks.txt
:
<?php
$file=fopen("nicks.txt","r"); // nicks.txt
echo fread($file,1000);
//
fclose($file);
//
users_list.php.
,
:
info.text=" ";
var sender:LoadVars=new LoadVars();
var receiver_1:LoadVars=new LoadVars();
sender.sendAndLoad("users_list.php", receiver_1, "GET");
, . ,
users. , , , .
split() String, , nicks.txt \n. ,
, , - info.
var users_arr:Array=null;
receiver_1.onData=function(text:String):Void {
if (text!=undefined) {
users_arr=text.split("\n");
info.text = " ";
} else {
inf.text='' ";
}
};
choise,
send. invitation.php, , , , . , invitation.php, , .
users_arr.
, . info
.
send , , .
var guest:String=null; //
var receiver_2:LoadVars=new LoadVars();
send.onPress=function():Void {
for (var i=0; i<users_arr.length; i++) {
if (choise.text==users_arr[i]) {
sender.nick=name, sender.guest=choise.text;
sendee.sendAndLoad("invitation.php",receiver_2, "GET");
delete sender.nick, delete sender.guest;
guest=choise.text;
//
this.enabled=false; //
return;
}
}
info.text=" ";
};
.
. , ,
. , .
<?php
$nick=$_GET['nick'];
//
$guest=$ GET['guest'];
//
$file_name=$guest."_messages.txt"; // " "
$file=fopen(Sfile_name,'at');
// " "
$status=fread($file,10000);
//
fclose($file);
//
if ($status' ') { // , ...
$new_file=fopen($file_name,'w+');
// " "
fwrite($new_file,Snick);
//
fclose(Snew file);
//
echo " ";
//
} else {
// ,
echo " ";
}
?>
ActionScript. , .
. ,
info, send, .
var time:Number=0;
receiver_2.onData=function(text:String):Void {
if (text==" ") {
info.text=text+". .";
time=setInterval(polling, 20000);// - 20
} else {
send.enabled=true;
info.text=" .
}
};
var receiver_3:LoadVars=new LoadVars();
function polling():Void { //
sender.nick=name;
sender.sendAndLoad("polling.php",receiver_3, "GET");
delete sender.nick;
}
, , ,
. :
, setInterval;
,
. .
, .
( ), , , ActionScript.
. 0,5,
. .
, ,
1 ( ) 0 ( );
,
, .
, . :
, polling() setInterval:
info , , ;
, ;
send.
:
receiver_3.onData=function(text:String):Void {
if (text=="Ha ") {
clearInterval(time);
var color_own:Number=Math.random()>0.5? 1: 0;
var color_guest:Number=clor_own;
sender.nick=name, sender.text=color_own;
sender.sendAndLoad("createMessageBox.php",sender,"GET");
sender.nick=choise.text, sender.text=color_guest;
sender.sendAndLoad("createMessageBox.php",sender,"GET");
delete sender.nick, delete sender.text;
gotoAndStop(5);
} else if (text==" ") {
clearInterval(time);
info.text=" . '
sender.nick=name, sender.text="";
sender.sendAndLoad("createMessageBox.php",sender,"GET");
delete sender.nick, delete sender.text;
send.enabled=true;
}
};
.
. 250x250 ,
25x25 . , . ( ). pole.
ActionScript 10
10 .
. ,
. , .
, .
20 (
). black ( ) white ( ).
, . , , . 0,
. 1, .
, , ,
. . ,
, ; 1 0. , beginGame(),
. color_own color_guest, black white, , . .
var sender:LoadVars=new LoadVars();
//
var receiver_1:LoadVars=new LoadVars();
//
var time:Nurnber=setInterval(getColor,10000);
// - 10
function getColor():Void {
//
sender.nick=name;
sender.sendAndLoad("polling.php",receiver_1,"GET");
delete sender.nick;
}
// color_own - , color_guest
var color_own:String=null, color_guest:String=null;
receiver_1.onData=function(text:String):Void {
if (text=="1" || text=="0") {
color_own=text=="0"? "black": "white";
color_guest=text=="1"? "black": "white";
clearInterval(time);
//
sender.nick=name, sender.text=" " ;
sender.sendAndLoad("createMessageBox.php",sender,"GET");
delete sender.nick, delete sender.text;
beginGame();
}
, ,
. , onMouseDown game(), . , .
info , .
, , . (
: 3-5 , ) sellnterval waiting(). info , . .
, ,
, initialize(), .
function beginGame():Void {
initialize();
if (color own=="black") {
info.text-" . , .";
time=setInterval(waiting,5000);
} else if (color_own=="white") {
info.text=" . ";
this.onMouseDown=game;
}
}
, . : . -
. , , . (
) initialize():
var pole_arr:Array=null, n:Number=null, users_rounds:Number=null,
guests_rounds:Number=null;
function initialize():Void {
// 10 10
pole_arr=[];
for (var i=0; i<10; i++) {
pole_arr[i]=[];
for (var j=0; j<10; j++) {
pole_arr[i][j]="";
}
}
//
pole_arr[4][4]=pole.attachMovie('black', 'black44', 44, {_:4*25+12.5,
_:4*25+12.5});
pole_arr[5][5]=pole.attachMovie('black', 'black55', 55, {_x:5*25+12.5,
_y:5*25+12.5});
pole_arr[4][5]=pole.attachMovie('white', 'white45', 45, {_x:4*25+12.5,
_y:5*25+12.5});
pole_arr[5][4]=pole.attachMcvie('white', 'white54', 54, {_x:5*25+12.5,
_y:4*25+12.5});
n = 96; //
users_rounds=2, guests_rounds=2; //
}
, . 'colorN', color
(black white), N , .
. . , ,
, bla34. , , , .
,
.
,
, . ,
beginGame()
this.onMouseDown=game;
game(), . :
function game():Void {}
- , , . , info
game():
if (pole._xmouse<0 || pole._xmouse>250 || pole._ymouse<0 || pole._ymouse>250) {
info.text=" ";
return;
}
, ,
. , .
game():
var i:Number=Math.round(Math. abs{(pole._xmouse-l2.5)/25));
.
, . ,
, ,
. : , , , ? :
,
, .
. .
1 1, ,
, . ,
, , 1 ( ) -1 (
). . . ,
, . ,
, ;
,
. . ,
,
.
,
.
:
var k:Number=null;
//
var win_number:Number=null;
//
var flag:Boolean=false;
// , ,
// , ,
var hod_info_for_guest:Strings="";
for (var m=-1; m<2; m++) {
//
for (var z=-1; z<2; z++) {
//
k=1;
//
win_number=0;
while (1) {
//
// ,
//
if (pole=arr[i+m*k][j+z*k] ==
pole[color_guest+(i+m*k)+(j+z*k)] && pole_arr[i+m*k][j+z*k]!= undefined) {
k++;
win_number++;
continue;
}
/* ,
, changer(), . hod_info_for_guest. . */
if (pole_arr[i+m*k][j+z*k] ==
pole[color_own+(i+m*k)+(j+z*k)] && win_number!= 0) {
flag=true;
hod_info_for_guest+=changer(i,j,m,z,win_number);
}
// ,
break;
}
}
changer(), , ,
, game(), , ,
, (
). change() , . *. changer() :
function changer(row_numb:Number, col_numb:Number, delta_x:Number, delta_y:Number,
numb:Number):String {
var i:Number=null, j:Number=null;
var res:String="";
for (var k=1; k<=numb; k++) {
users_rounds++, guests_rounds--;
i=row_numb+delta_x*k, j=col_numb+delta y*k;
pole_arr[i][j] = pole.attachMovie(color_own, color_own+i+j, i*10+j,
{_:25*i+12.5, _y :25*j+12.5});
res+=i+","+j+"*";
}
return res;
}
, , , . hod_info_for_guest.
game() onMouseDown,
. , , , hod_info_for_guest
. ,
( users_rounds guests_rounds)
( n). , end(). , , setInterval waiting().
:
else {
pole_arr[i][j] = pole.attachMovie(color_own, color_own+i+j, i+10+j,
{_x:25"i+12.5, _y:25*3+12.5});
hod_info_for_guest+=i+","+j+"*";
users_rounds+=1, n--;
info.text="Xo . ";
delete this.onMouseDown;
sender.nick=name, sender.text=hod_info_for_guest;
sender.sendAndLoad("createMessageBox.php",sender,"GET");
delete sender.nick, delete sender.text;
if (users_rounds==0 || guests_rounds-=0 || n==0) {
end();
return;
}
time=setInterval(waiting, 5000);
}
waiting(), , :
var receiver_2:LoadVars=new LoadVars();
function waiting():Void {
sender.nik=guest;
sender.sendAndLoad("polling.php",receiver_2, "GET");
delete sender.nick;
}
, , , ,
, (
onData undefined, , ):
receiver_2.onData=function(text:String) {
if (text!=undefined && text!=" ") {
, :
clearInterval(time);
. , ,
, , *. . split()
String, .
//
var arr_of_index_pairs:Array=text.split("*");
var numb:Number=arr_of_index_pairs.length;
var indexes:Array=null;
var z:Number=null, m:Number=nul1;
for (var i=0; i<numb-1; i++) {
//
//
indexes=arr_of_index_pairs[i].split(",");
z=Number(indexes[0]), m=Number(indexes[1]);
//
pole_arr[z][m]=pole.attachMovie(color_guest, color_guest+z+m, z*10+m,
{_x:z*25+12.5,_y:m*25+12.5});
}
, :
users_rounds-=numb-2, guests_rounds+=numb-1, n--;
, . end():
if (users_rounds==0 || guests_rounds==0 || n==0) {
end();
return;
}
, onMouseDown game().
. ,
. info , :
_root.onMouseDown=game;
. end(),
. , :
function end():Void {
if (users_rounds==0) {
info.text==" ";
return;
}
if (guests_rounds==0) {
info.text=='' ";
return;
}
if (n==0 && users_rounds-guests_rounds>0) {
info.text=" . .";
} else {
" . ";
}
(. 17.4) . ,
, . . ,
,
. 17.4.
. . .
,
.
Flash-. , ,
.
,
. *.pdf (http://www.piter.com).
ActionScript 2.0.
, . ,
. -, .
17 , 1100 . ,
? , - 1300 . , . -, . , , 100 ? , .
-, . , , . , ,
- , , . . , Flash MX 2004
Macromedia . . -,
, , ,
. , ,
, .
- . 99 %
. ,
ActionScript , .
. ,
17 .
,
. ,
ActionScript, , .
18.
17 . , , .
. , .
LoadVars XMLSocket .
Media ActionScript Flash Communication
Server. Flash Communication Server , Macromedia , Flash . , ,
( ), . . Flash Communication Server . , .
, 18
ActionScript , XML. Flash MX ActionScript, , ActionScript.
Flash Remounting. 2004 Macromedia
19.
. , Flash MX 2004
, , , , Flash-. , .
ActionScript . , . , ,
. ,
. 18
, .
20.
,
, ActionScript, . , , . .
. , , , 20.1.
. ActionScript, , .
. , , .
20.2. , ,
, .
.