7. ActionScript
( 14 )
.
- ActionScript?
- .
: 6 , . . . . . , , .. .
:
: ³ .
: , , F9, Actions. :
stop();
.
, , - .
Button (). , 4 :
- Up ;
- Over , ;
- Down ;
- Hit .
- . , .
: ( Ctrl+F8) Button () _. : Over -. Down .
Hit, , Down.
: . , 1, .
䳿
, . F9, ' Actions (䳿), , ' . :
on (release) { play();}on 䳿, release () . , : - .
ActionScript , . .
( Ctrl+T), ( ActionScript). "The script contains no errors.", . Compiler Errors ( ' Alt+F2).
. , (, , ). , Actions. , :
|
|
, ' , .
: Actions
on (release) { play(); }
/, , - / .
Actions (Toolbox). ( ), ', ' ActionScript. , ( Scene 1). (Current Selection). .
Toolbox, .
: 1
stop();
Actions .
2 : . , -. , , Duplicate , ' .
: ' _ . , ' (Up, Over, Down). , .
: , ( 1)
on (release) { gotoAndPlay(1); }
.
: , ' ,
gotoAndStop(1);
, .
, . , . .
: ( Ctrl) Move to New Folder ( ) . ' .
, , . Align (, Ctrl+K). , To Stage ( ).
: Align. ( Match Size). ( Align) ( Distribute).
, , , ( Filters).
: Bevel .
̳
, . ( !) ' () , . .
|
|
: ̳ 1. Properties , .
, ' ,
gotoAndStop ("start");
.
, 1 ̳ ' start:
- : ,
- :
: - , , . , , . .
:
, . , stop() , () .
? -. , ' , : .
: Properties ' car. ³ wheel1 wheel2.
, 4 :
- () , _root;
- ;
- .
' :
car _root, wheel1 wheel2 car.
_root (parent) car.
car (child) _root wheel1 wheel2.
wheel1 wheel2 car, .
' , - . , :
, , . , . 5, . 25
, - ..
' Flash- _root, , , :
_root
_root.car
_root.car.wheel1
_root.car.wheel2
, .
, .
, stop() :
_root.stop();_root.car.stop();_root.car.wheel1.stop();_root.car.wheel2.stop();, ', , , ( ).
³
³ , ', . , 2 .
_parent. , wheel1 car,
_parent.stop();wheel2, car.
_parent, . ,
_parent._parent.stop();wheel1 wheel2.
. ,
car.stop();_root. , this ( ):
this.car.stop();wheel1 _root
|
|
, . . wheel1,
_parent.wheel2.stop();
- 䳿
: .
:
- _x, _y ( );
- _width, _height ;
- _xscale, _yscale X Y ( 100 );
- _rotation ( 0 );
- _alpha ( 0 100).
:
, , .
- . .
, . , .
:
- _x, _y ( );
- _width, _height ;
- _xscale, _yscale X Y ( 100 );
- _rotation ( 0 );
- _alpha ( 0 100).
: ³ space.fla PRACTICE\7. ( , ).
: 1 0 4 . Transform ( WindowsTransform Ctrl+T) 90, 180 270 . , .
, ( _rotation), ( _xscale _yscale).
ActionScript ( , Java) :
a = a - 5;
b = b + 10;
,
a -= 5;
b += 10;
: . :
on (release) {
rocket._alpha = 100;
}
:
on (release) {
rocket._rotation -= 10;
}
- , .
on (release) {
rocket._xscale += 5;
rocket._yscale += 5;
}
- , . .
: _x: _x. Properties Dynamic Text, ' x W=50.
䳿
( Movie Clip) 䳿, , on (...). , , . :
- load ;
- enterFrame ;
- mouseDown ;
- mouseMove ;
- mouseUp ;
- keyDown ;
- keyUp .
onClipEvent (...), Actions, .
|
|
12, enterFrame 12 , . , x- .
' x text, ( ). ' , x.text. , x- rocket x :
x.text = rocket._x;
: Actions ( F9). 䳿 enterFrame:
onClipEvent (enterFrame) {
x.text = rocket._x;
}
.
, x- , , x- .
, ( ) , , .
:
trace (x);
' Output ( WindowOutput F2), ' undefined.
³ : , x , , x (undefined, ). , x . ' 12 , , enterFrame. ,
trace (rocket);
, .
. . , x, , , _root.x ( ) _parent.x ( ).
_x ', this._x ( ) _root.rocket._x ( ). , _x , this._x.
: ', '. , ( Relative) ( Absolute).
: Actions ( F9). 䳿 enterFrame:
onClipEvent (enterFrame) {
_root.x.text = _x;
}
/.
: ( ) 䳿 , . .
: , _x . .
, . ϳ 䳿 load.
: 䳿 load ( ):
onClipEvent (load) {
_x = 100;
_y = 100;
}
- 䳿
: , , ( 5 ). , , , . - .
:
. :
- press ' ;
- release ' ;
- releaseOutside ';
- rollOver ' ( );
- rollOut ' ( );
- dragOut ' ;
- dragOver ', ( ).
, 䳿 rollOut ( 5 ). _alpha.
|
|
: 䳿 :
on (rollOut){
_alpha -= 5;
}
, _alpha . , , if.
: ' ( press) ' :
startDrag (this);' (this ', ).
( release) :
stopDrag();
: :
on (press){
startDrag(this);
}
on (release){
stopDrag();
}
on , . Script Assist ( ).
: on(release) Script Assist Actions. ³ releaseOutside Script Assist.
.
䳿
, , 䳿 mouseDown, mouseUp mouseMove. , , , - . _xmouse _ymouse _root.
, , , , , . 䳿 mouseMove, _rotation . , x- , _root._width/2.
: :
onClipEvent (mouseMove) {
if (_root._xmouse < _root._width/2)
_rotation -= 0.5;
else _rotation += 0.5;
}
: , mouseMove . , ', . dragging, true (, ) false (, ). true, , false.
: :
on (press){
startDrag(this);
dragging = true;
}
on (release, releaseOutside){
stopDrag();
dragging = false;
}
mouseMove , dragging=false.
: 䳿:
onClipEvent (mouseMove) {
if (! dragging) {
if (_root._xmouse < _root._width/2)
_rotation -= 0.5;
else _rotation += 0.5;
}
}
, if(!dragging) . ҳ _rotation.
³
, 䳿 on (...). onClipEvent (...), .
: , ( Button) , , (Movie Clip) .
, play() stop().
stop(); this.stop(); 䳿 , ( _root).
, ( ).
_rotation += 45;
, 45 , _root. 45 .
? , , . Properties ' . , , ' btn _root. _root.btn ( _root) btn.
btn._rotation += 45;
( - !)
_root.btn._rotation += 45;
䳿 keyPress. keypress , :
on (keyPress "A") {... }, , "<Left>" (), "<Right>" (), "<Up>" (), "<Down>" ().
: . :
on (keyPress "<Left>"){
_x -= 2;
}
-.
, . keyDown keyUp, .
.
1. ActionScript?
2. ' ?
3. ?
4. () ActionScript
5. Up, Over, Down .