.


:




:

































 

 

 

 


8. ' Flash




( 12 )

 

.

 

1. Key

: . . ' , , , , , . . Ctrl . , .

 

:

: . .

' 1.

:

 

' Movie Clip ' 1.

' Movie Clip .

 

: , ' :

onClipEvent (keyDown) {

trace(Key.getCode());

trace(Key.isDown(Key.CONTROL));

trace(Key.isDown(Key.SHIFT));

trace(Key.isDown(Key.ALT));

}

 

, .

, . keyDown , , , . enterFrame, Key.isDown , , _x _y .

v, load ( 3 ).

: :

onClipEvent (load) {

v = 3;

}

onClipEvent (enterFrame) {

if (Key.isDown(Key.RIGHT)) {

_x += v;

} else if (Key.isDown(Key.LEFT)) {

_x -= v;

}

}

- ( Key.UP Key.DOWN).

, , , .

, Home ( ). 䳿 load ' x0 y0, Home _x _y.

: load:

x0 = _x;

y0 = _y;

䳿 keyDown :

onClipEvent (keyDown) {

if (Key.isDown(Key.HOME)) {

_x = x0;

_y = y0;

}

}

, , .

trace("-");

keyDown, , Home .

, , , , Enter Home. Flash- .

.

: Disable Keyboard Shortcuts Control . , Home.

 

, Ctrl 3 . v0.

: 䳿 enterFrame

if (Key.isDown(Key.CONTROL)) {

v = v0*3;

} else {

v = v0;

}

load

v0 = 3;

: , , , . , .

, . 7.11 ' . .

: ϳ

// '

on (press) {

startDrag(this);

}

on (release, releaseOutside) {

stopDrag();

}

 

2. (String, Selection)

: , 쳺 , .

:

' String

' String ().

  • length ,

,

  • charAt(n) n ( );
  • charCodeAt(n) n ( );
  • substring(from, to) , from to (, to ); , ;
  • indexOf(sub) sub, ; , -1;
  • toLowerCase() () ;
  • toUpperCase() () .

, ' , +, , :

s = "123";t = s + 45 + "6789";trace (t); // "123456789"

45 .

, 쳺 , .

:

: , . /, /, /, /. .

 

: . Input Text ( ), ' main Multiline ( ), .

, , ' String. ' text, , main main.text.

, / / ( ).

:

on (release){

main.text = main.text.toUpperCase();

}

/ -

on (release){

main.text = main.text.toLowerCase();

}

.

( ) , main.text.

: (Dynamic Text, Single line) ' info. / 䳿

on (release){

info.text = ": " + main.text.length;

}

' Selection

' Selection . ³ ' , , .

' Selection:

  • setFocus("") , ;
  • getBeginIndex() ;
  • getEndIndex() , ( );
  • setSelection(start,end) start end.

.

: ( ) (Input Text, Single line) ' find.

/.

: 䳿

on (release) {

if (find.text == "") return;

n = main.text.indexOf (find.text);

if (n < 0)

info.text = "ͳ .";

else {

info.text = " " + n;

Selection.setFocus ("main");

Selection.setSelection (n, n + find.text.length);

}

}

, ( , , ).

, indexOf . , . , main .

' Selection, : , .

nStart nEnd. , . , : main.text 3 substring, toUpperCase.

: Flash Player 9 , .

: :

on (release) {

nStart = Selection.getBeginIndex();

nEnd = Selection.getEndIndex();

if (nStart == nEnd) {

main.text = main.text.toUpperCase();

} else {

s = main.text;

s = s.substring (0, nStart) +

s.substring (nStart, nEnd).toUpperCase() +

s.substring (nEnd);

main.text = s;

}

}

/.

, substring(nEnd) , nEnd .

, , main ( getBeginIndex getEndIndex -1).

 

3. Color

 

: , ' Movie Clip ' logo. Bevel Glow. ' . ' .

 

' Color . ' ', ' :

col = new Color ( );

, '. :

  • setRGB() ;
  • getRGB() , setRGB.

RGB (R= red, ; G= green, ; B= blue, ) , R, G B, 0 255.

, , B, G, R. , 0x660000 R=6616=102, G=B=0.

:

' :

 

: , ' Movie Clip ' logo. Bevel Glow. ' .

 

: Properties. Color Tint ( ), #000033 100% ( ).

: , :

on (release) {

cLogo = new Color(_root.logo);

cLogo.setRGB(0x000033);

}

0x000066. .

, , , .

, '. , . .

: , ( , JavaScript, Java, ActionScript).

, : , , , .

:

A = new Array(3);

A[0] = 12;

A[1] = 4.56;

A[2] = "-!";

:

A = new Array (12, 4.56, "-!");

:

A = [12, 4.56, "-!"];

, ' ( , ), . :

A = [1, 2, 3];

B = A;

B[1] = 99;

trace (A);

A, B. B[1] A Output. A , Output :

1,99,3

A? , B=A , B A, A B '. , B, A. , B=A

B = new Array();

for(i=0; i<A.length; i++) B[i] = A[i];

length ' Array .

, .

: . , :

colors = [0x000033, 0x000066, 0x000099,

0x003300, 0x006600, 0x009900,

0x330000, 0x660000, 0x990000];

, 䳿 release . , .

: , . ActionScript, .

: , , :

function changeColor() {

c = new Color(this);

col = c.getRGB();

cLogo = new Color(_root.logo);

cLogo.setRGB(col);

}

 

, getRGB. .

, , . , 䳿 release ,

. onRelease = changeColor;

, i ( ) 0 8, : 䳿.

, _root[ ' ]. , _root["color0"] , _root.color0, , ' , , , :

_root["color"+chr(48+i)]

chr . , 0-9 48-57, i=2 _root["color2"].

, color0, color1 ..

: color0, color1 .., . Properties, - .

: 1 :

for (i=0; i<9; i++){

obj = _root["color"+chr(48+i)];

c = new Color(obj);

c.setRGB(colors[i]);

obj.onRelease = changeColor;

}

.

obj i.

 

 

4. Sound

 

' Sound .

  • ;
  • , ;
  • , .

.

.

: . Linkage... ('), , ', Export for ActionScript Export in frame frame, ' - hey Identifier.

Export for ActionScript , hey. Export in first frame , , .

  • ' Sound new Sound();
  • attachSound;
  • ( start)
  • stop.

' , 䳿 mouseDown keyDown , . ' Sound load, mouseDown 䳿 keyDown.

: Actions :

onClipEvent (load) {

snd = new Sound();

}

onClipEvent (mouseDown) {

snd.attachSound ("hey");

snd.start(0, 1);

}

onClipEvent (keyDown) {

snd.stop();

}

start (0 ), .

: , .

: stopAllSounds(); .

, ' Sound. , this:

bounce = new Sound(this);

setVolume, .

setPan (set panoram ), -100 ( , ) 100 ( , ).

 

 

5.

 

: , , , .

 

' Date

:

  • ' Date ();
  • getTimer() ( ).

' Date :

d = new Date(2013, 4, 09);

, , . 09 2013 . , , 4 Flash .

:

today = new Date();

' .

' Date , , :

  • today.getFullYear() ;
  • today.getMonth() ;
  • today.getDate() ;
  • today.getDay() ;
  • today.getHours() ;
  • today.getMinutes() ;
  • today.getSeconds() .

, , , , ( 0), 1 ..

:

: .

: (Dynamic Text) , , , . day, date, month year, , .

:

stop();

today = new Date();

weekDays = ["", "", "",

"", "", "'", ""];

months = ["", "", "", "",

"", "", "", "", "",

"", "", ""];

day.text = weekDays[today.getDay()];

date.text = today.getDate();

month.text = months[today.getMonth()];

year.text = today.getFullYear();

.

, . weekDays months ( , ).

, .

, . , .

: ' time. 1

function showTime() {

function str2 (n) {

var s = String(n);

if (n < 10) s = "0" + s;

return s;

}

today = new Date();

h = today.getHours();

m = today.getMinutes();

s = today.getSeconds();

time.text = str2(h) + ":" + str2(m) + ":" + str2(s);

}

str2, n String. , 10, . , , , 5 3 2 05:03:02, 5:3:2.

' Date, . getHours, getMinutes getSeconds , . str2 ' text time.

, showTime 1 . , Flash .

: 1

setInterval (showTime, 200);

.

setInterval , , .

 

.

: (Static Text): , , , , (Input Text) alarmTime ( ) loops (). . .

: 1 :

alarmTime.text = "10";

loops.text = "1";

.

t = getTimer();

t , . , ' startTime.

, alarmOn ' ( ). : ' .

: :

on (release) {

clock.alarmOn = true;

clock.startTime = getTimer();

}

clock: , .

: ' Movie Clip ' clock. 0, 15, 30 45 .

: ' Movie Clip ' hand. .

: .

: .

 

: 7 ship click.wav. tick. 6 kuranty.mp3. alarm.

: Linkage... ('), , ', Export for ActionScript Export in frame frame, ' tick alarm Identifier.

: - enterFrame:

onClipEvent (enterFrame) {

if (!alarmOn) return;

t = Number(_root.alarmTime.text);

diff = Math.round((getTimer()-startTime)/1000);

if (hand._rotation!= diff*6) {

hand._rotation = diff*6;

tick = new Sound();

tick.attachSound("tick");

tick.start(0,1);

}

if (diff == t) Alarm();

}

, .

t , Number.

г ( 1000) Math.round, ' Math ().

, 1 6(=360/60) , diff*6. , _rotation 1 tick .

diff t, Alarm, . , alarm .

: load -:

onClipEvent (load) {

function Alarm() {

alarmOn = false;

hand._rotation = 0;

snd = new Sound();

snd.attachSound("alarm");

snd.start(0,_root.loops.text);

}

}

.

, load, .

!, 2 .

: ! ' wakeup. .

.

: 1

wakeup._visible = false;

, , _visible true.

, , . , qq :

function rot() {

qq._rotation += 10;

}

setInterval (rot, 1000);

1000 ( 1 ) rot, 10 .

' :

i = setInterval (rot, 1000);

clearInterval:

clearInterval (i);

' :

delete i;

.

: Alarm

_root.wakeup._visible = true;

i = setInterval (removeText, 2000);

ϳ ( 䳿 load) :

function removeText() {

_root.wakeup._visible = false;

delete i;

}

.

.

  1. length ' String ?
  2. setRGB() getRGB()?
  3. ' Sound?
  4. ActionScript?

 





:


: 2017-02-11; !; : 305 |


:

:

80% - .
==> ...

1829 - | 1691 -


© 2015-2024 lektsii.org - -

: 0.218 .