6 Komentar

Macromedia Flash ( Fungsi Global )


Langsung Ja……. Nih Fungsi Global macromedia Flash Lengkap n Gratis (^_^)

Fungsi global

Bagian ini berisi satu set built-in fungsi yang tersedia dalam setiap bagian dari file SWF mana ActionScript digunakan. Fungsi-fungsi global yang mencakup berbagai macam tugas pemrograman umum seperti bekerja dengan tipe data ( Boolean() , int() , dan sebagainya), menghasilkan informasi debug ( trace() ), dan berkomunikasi dengan Flash Player atau browser (

fscommand() ).

 

Fungsi
       Array ([numElements: Number ], [elementN: Object ]) : Array
Menciptakan sebuah array, baru kosong atau mengkonversi elemen tertentu untuk array.
       asfunction
Sebuah protokol khusus untuk URL dalam bidang teks HTML yang memungkinkan link HREF untuk memanggil fungsi ActionScript.
       Boolean (expression: Object ) : Boolean
Mengubah parameter expression ke nilai Boolean dan mengembalikan true atau false .
       call (frame: Object ) : Void
Usang pada Flash Player 5 – Tindakan ini usang dalam mendukung function pernyataan.
       chr (number: Number ) : String
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung String.fromCharCode() .
       clearInterval (intervalID: Number ) : Void
Menghentikan setInterval() panggilan.
       clearTimeout (id: Number ) : Void
Membatalkan ditentukan setTimeout() panggilan.
       duplicateMovieClip (target: Object , newname: String , depth: Number ) : Void
Menciptakan sebuah instance dari klip video sedangkan file SWF diputar.
       escape (expression: String ) : String
Mengkonversi parameter untuk string dan encode dalam format URL-encoded, di mana semua karakter nonalphanumeric diganti dengan urutan heksadesimal%.
       eval (expression: Object ) : Object
Mengakses variabel, properti, benda, atau klip video dengan nama.
       fscommand (command: String , parameters: String ) : Void
Mari berkomunikasi dengan baik file SWF Flash Player atau program hosting yang Flash Player, seperti browser web.
       getProperty (my_mc: Object , property) : Object
Mengembalikan nilai properti yang ditentukan untuk klip video my_mc .
       getTimer () : Number
Mengembalikan jumlah milidetik yang telah berlalu sejak file SWF mulai bermain.
       getURL (url: String , [window: String ], [method: String ]) : Void
Beban dokumen dari URL tertentu ke dalam jendela atau melewati variabel ke aplikasi lain pada URL didefinisikan.
       getVersion () : String
Mengembalikan string yang berisi Flash Player versi dan platform informasi.
       gotoAndPlay ([scene: String ], frame: Object ) : Void
Mengirim playhead ke frame yang ditentukan dalam sebuah adegan dan memainkan dari frame itu.
       gotoAndStop ([scene: String ], frame: Object ) : Void
Mengirim playhead ke frame yang ditentukan dalam sebuah adegan dan berhenti itu.
       ifFrameLoaded ([scene: String ], frame: Object ) : Void
Usang pada Flash Player 5 – Fungsi ini telah usang. Macromedia menganjurkan agar Anda menggunakan MovieClip._framesloaded properti.
       int (value: Number ) : Number
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung Math.round() .
       isFinite (expression: Object ) : Boolean
Mengevaluasi expression dan mengembalikan true jika itu adalah jumlah terbatas atau false jika tak terhingga atau tak terhingga negatif.
       isNaN (expression: Object ) : Boolean
Mengevaluasi parameter dan mengembalikan true jika nilai NaN (bukan angka).
       length (expression: String , variable: Object ) : Number
Usang pada Flash Player 5 – Fungsi ini, bersama dengan semua fungsi string, telah usang. Macromedia menganjurkan agar Anda menggunakan metode dari kelas String dan String.length properti untuk melakukan operasi yang sama.
       loadMovie (url: String , target: Object , [method: String ]) : Void
Banyak file SWF atau JPEG ke Flash Player sedangkan SWF asli memainkan file.
       loadMovieNum (url: String , level: Number , [method: String ]) : Void
Banyak file SWF atau JPEG ke tingkat di Flash Player sementara awalnya dimuat SWF memainkan file.
       loadVariables (url: String , target: Object , [method: String ]) : Void
Membaca data dari file eksternal, seperti file teks atau teks yang dihasilkan oleh ColdFusion, script CGI, Active Server Pages (ASP), PHP, atau Perl script, dan menetapkan nilai-nilai untuk variabel dalam klip video target.
       loadVariablesNum (url: String , level: Number , [method: String ]) : Void
Membaca data dari file eksternal, seperti file teks atau teks yang dihasilkan oleh ColdFusion, CGI script, ASP, PHP, atau Perl script, dan menetapkan nilai-nilai untuk variabel di tingkat Flash Player.
       mbchr (number: Number ) : Void
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung String.fromCharCode() metode.
       mblength (string: String ) : Number
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung metode dan properti dari kelas String.
       mbord (character: String ) : Number
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung String.charCodeAt() .
       mbsubstring (value: String , index: Number , count: Number ) : String
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung String.substr() .
       MMExecute (command: String ) : String
Memungkinkan Anda mengeluarkan flash JavaScript API (jsapi) perintah dari ActionScript.
       nextFrame () : Void
Mengirim playhead ke frame berikutnya.
       nextScene () : Void
Mengirim playhead ke Frame 1 dari adegan berikutnya.
       Number (expression: Object ) : Number
Mengubah parameter expression ke nomor.
       Object ([value: Object ]) : Object
Membuat obyek kosong baru atau mengubah jumlah tertentu, string, atau nilai Boolean kepada suatu objek.
       on (mouseEvent: Object ) : Void
Menentukan peristiwa mouse atau menekan tombol yang memicu tindakan.
       onClipEvent (movieEvent: Object ) : Void
Pemicu tindakan yang ditetapkan untuk contoh spesifik dari klip video.
       ord (character: String ) : Number
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung metode dan properti dari kelas String.
       parseFloat (string: String ) : Number
Mengkonversi string menjadi nilai floating-point.
       parseInt (expression: String , [radix: Number ]) : Number
Mengkonversi string ke integer.
       play () : Void
Memindahkan maju playhead dalam Timeline.
       prevFrame () : Void
Mengirim playhead ke frame sebelumnya.
       prevScene () : Void
Mengirim playhead ke Frame 1 dari adegan sebelumnya.
       print (target: Object , boundingBox: String ) : Void
Mencetak target klip video sesuai dengan batas-batas yang ditentukan dalam parameter ( bmovie , bmax , atau bframe ).
       printAsBitmap (target: Object , boundingBox: String ) : Void
Mencetak target klip video sebagai bitmap sesuai dengan batas-batas yang ditentukan dalam parameter ( bmovie , bmax , atau bframe ).
       printAsBitmapNum (level: Number , boundingBox: String ) : Void
Mencetak tingkat dalam Flash Player sebagai bitmap sesuai dengan batas-batas yang ditentukan dalam parameter ( bmovie , bmax , atau bframe ).
       printNum (level: Number , boundingBox: String ) : Void
Mencetak tingkat di Flash Player sesuai dengan batas-batas yang ditentukan dalam boundingBox parameter ( bmovie , bmax , bframe ).
       random (value: Number ) : Number
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung Math.random() .
       removeMovieClip (target: Object ) : Void
Menghapus klip video yang ditentukan.
       setInterval (functionReference: Function , interval: Number , [param: Object ], objectReference: Object , methodName: String ) :Number
Memanggil fungsi atau metode objek secara berkala sementara file SWF bermain.
       setProperty (target: Object , property: Object , expression: Object ) : Void
Perubahan nilai properti dari klip video sebagai memainkan klip video.
       setTimeout (functionReference: Object , delay: Number , args: Object ) : Number
Menjalankan fungsi tertentu setelah penundaan yang ditentukan (dalam milidetik).
       showRedrawRegions (enable: Boolean , [color: Number ]) : Void
Menyediakan kemampuan untuk pemain debugger untuk menguraikan daerah layar yang sedang digambar ulang.
       startDrag (target: Object , [lock: Boolean ], [left,top,right,bottom: Number ]) : Void
Menjadikan target draggable klip sementara film drama.
       stop () : Void
Menghentikan file SWF yang sedang diputar.
       stopAllSounds () : Void
Berhenti semua suara saat bermain di sebuah file SWF tanpa berhenti playhead.
       stopDrag () : Void
Menghentikan operasi tarik saat ini.
       String (expression: Object ) : String
Mengembalikan sebuah representasi string parameter yang ditentukan.
       substring (string: String , index: Number , count: Number ) : String
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung String.substr() .
       targetPath (targetObject: Object ) : String
Mengembalikan string yang berisi jalur target movieClipObject .
       tellTarget (target: String , statement(s)) : Void
Usang pada Flash Player 5 – Macromedia menyarankan Anda menggunakan dot notasi dan (.) with pernyataan.
       toggleHighQuality () : Void
Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung _quality .
       trace (expression: Object ) : Void
Mengevaluasi ekspresi dan menampilkan hasilnya.
       unescape (string: String ) : String
Mengevaluasi parameter x sebagai string, decode string dari URL-encoded format (mengkonversi semua urutan heksadesimal untuk karakter ASCII), dan mengembalikan string.
       unloadMovie (target: Object ) : Void
Menghapus klip video yang dimuat dengan cara loadMovie() dari Flash Player.
       unloadMovieNum (level: Number ) : Void
Menghapus SWF atau gambar yang dimuat dengan cara loadMovieNum() dari Flash Player.
       updateAfterEvent () : Void
Update layar saat Anda menyebutnya dalam pengendali atau menggunakan setInterval() .
Fungsi rinci

Array Fungsi

  Array (): Array
 Array (numElements: Nomor ): Array
 Array (element0: Object , [element1, element2, ... elementN]): Array
Player versi: Flash Player 6

Membuat array baru dengan panjang 0 atau lebih, atau sebuah array dihuni oleh daftar elemen tertentu, mungkin dari jenis data yang berbeda.

Gunakan Array() untuk membuat salah satu dari berikut:

  • Sebuah array kosong
  • Sebuah array dengan panjang tertentu tetapi elemen yang memiliki nilai tidak terdefinisi
  • Sebuah array yang elemen memiliki nilai-nilai tertentu

Menggunakan fungsi ini mirip dengan menciptakan sebuah array dengan konstruktor Array (lihat “Konstruktor untuk kelas Array” ).

Anda dapat melewati sejumlah ( numElements ) atau daftar elemen yang mengandung satu atau lebih jenis ( element0, element1, ... elementN ).

Parameter yang dapat menerima lebih dari satu tipe data yang tercantum dalam tanda tangan sebagai tipe Object .

Parameter

numElements : Number [opsional] – Sebuah bilangan bulat positif yang menentukan jumlah elemen dalam array. Anda dapat menentukan baik numElements atau daftar elemen, tetapi tidak keduanya.
elementN : Object [opsional] – Satu atau lebih parameter, element0, element1, ... , elementN element0, element1, ... , elementN , nilai-nilai yang dapat dari jenis apa pun. Parameter yang dapat menerima lebih dari satu tipe data yang terdaftar sebagai jenis Object . Anda dapat menentukan baik numElements atau daftar elemen, tetapi tidak keduanya.

Pengembalian
Array – Array.

Contoh

 var myArray: Array = Array ();
 myArray.push (12);
 jejak (myArray); / / jejak 12
 myArray [4] = 7;
 jejak (myArray); / / jejak 12, undefined, undefined, undefined, 7

Penggunaan 2: Contoh berikut membuat sebuah array dengan panjang 4 tetapi dengan tidak ada unsur-unsur yang ditetapkan:

 var myArray: Array = Array (4);
 jejak (myArray.length); / / jejak 4
 jejak (myArray); / / jejak undefined, undefined, undefined, terdefinisi

Penggunaan 3: Contoh berikut membuat array dengan tiga elemen didefinisikan:

 var myArray: Array = Array ("firstElement", "secondElement", "thirdElement");
 jejak (myArray); / / jejak firstElement, secondElement, thirdElement
 Berbeda dengan konstruktor kelas Array, Array () fungsi tidak menggunakan kata kunci baru.

Lihat juga
Array kelas


asfunction Protocol

asfunction:function: Function , parameter: String
Player versi: Flash Player 5

Sebuah protokol khusus untuk URL dalam bidang teks HTML yang memungkinkan link HREF untuk memanggil fungsi ActionScript. Dalam bidang teks HTML, Anda dapat membuat link menggunakan HTML A tag. Atribut HREF dari A tag berisi URL yang menggunakan protokol standar seperti HTTP, HTTPS, FTP atau. The asfunction protokol adalah protokol tambahan yang khusus untuk Flash, yang menyebabkan link untuk memanggil fungsi ActionScript.

Parameter

function : String – Sebuah identifier untuk fungsi.
parameter : String – Sebuah string yang dilewatkan ke fungsi yang disebutkan dalam function parameter.

Contoh
Dalam contoh berikut, playMP3() fungsi didefinisikan. The list_txt objek TextField dibuat dan diatur sehingga teks HTML dapat diberikan. Track teks 1 dan Track 2 adalah link dalam kolom teks. The playMP3() fungsi dipanggil ketika pengguna mengklik link dan baik memainkan MP3 yang dilewatkan sebagai parameter panggilan asfunction.

 var myMP3: Suara = Suara baru ();
 Fungsi playMP3 (mp3: String) {
   myMP3.loadSound (mp3, true);
   myMP3.onLoad = function (success) {
     if (sukses!) {
       / / Kode untuk menangani kesalahan di sini
     }
   };
 }
 this.createTextField ("list_txt", this.getNextHighestDepth (), 0, 0, 200, 100);
 list_txt.autoSize = true;
 list_txt.html = true;
 list_txt.multiline = true;
 list_txt.htmlText = "<a href=\"asfunction:playMP3, track1.mp3\"> Track 1 </ a> <br>";
 list_txt.htmlText + = "<a href=\"asfunction:playMP3, track2.mp3\"> Track 2 </ a> <br>";

Ketika Anda mengklik link, aliran file MP3 suara dalam Flash Player.

Lihat juga
TextField.htmlText


Fungsi Boolean

Boolean(expression: Object ) : Boolean
Player versi: Flash Player 5 – Perilaku berubah di Flash Player 7.

Mengubah expression parameter untuk nilai Boolean dan mengembalikan nilai seperti yang dijelaskan dalam daftar berikut:

  • Jika expression adalah nilai Boolean, nilai kembalian adalah expression .
  • Jika expression adalah angka, nilai kembali adalah true jika nomor tidak 0, jika nilai kembali adalah false .

Jika expression adalah string, nilai kembali adalah sebagai berikut:

  • Dalam file dipublikasikan untuk Flash Player 6 dan sebelumnya, string pertama-tama diubah ke nomor. Nilai adalah true jika nomor tidak 0, jika nilai kembali adalah false.
  • Dalam file dipublikasikan untuk Flash Player 7 dan kemudian, hasilnya adalah true jika string memiliki panjang lebih besar dari 0, nilai adalah false untuk string kosong.

Jika expression adalah string, hasilnya adalah true jika string memiliki panjang lebih besar dari 0, nilai adalah false untuk string kosong.

  • Jika expression yang undefined atau NaN (bukan angka), nilai kembali adalah false .
  • Jika expression adalah klip video atau benda, nilai kembalian adalah true .

Berbeda dengan konstruktor kelas Boolean, yang Boolean() fungsi tidak menggunakan kata kunci baru. Selain itu, konstruktor kelas Boolean menginisialisasi objek Boolean untuk false jika tidak ada parameter yang ditentukan, sedangkan Boolean() mengembalikan fungsi undefined jika tidak ada parameter yang ditentukan.

Parameter

expression : Object – Sebuah ekspresi untuk mengkonversi ke nilai Boolean.

Pengembalian
Boolean – Sebuah nilai Boolean.

Contoh

  jejak (Boolean (-1)); / / Output: true
 jejak (Boolean (0)); / / Output: false
 jejak (Boolean (1)); / / Output: true

 jejak (Boolean (true)); / / Output: true
 jejak (Boolean (false)); / / Output: false

 jejak (Boolean ("true")); / / Output: true
 jejak (Boolean ("false")); / / Output: true

 jejak (Boolean ("Craiggers")); / / Output: true
 jejak (Boolean ("")); / / Output: false

Jika file yang dipublikasikan untuk Flash Player 6 dan sebelumnya, hasilnya berbeda untuk tiga contoh sebelumnya:

 jejak (Boolean ("true")); / / Output: false
 jejak (Boolean ("false")); / / Output: false
 jejak (Boolean ("Craiggers")); / / Output: false

Contoh ini menunjukkan perbedaan yang signifikan antara penggunaan Boolean() fungsi dan kelas Boolean. The Boolean() fungsi menciptakan nilai Boolean, dan kelas Boolean membuat objek Boolean. Nilai boolean dibandingkan dengan nilai, dan objek Boolean dibandingkan dengan referensi.

 / / Variabel yang mewakili nilai-nilai Boolean dibandingkan dengan nilai
 var a: Boolean = Boolean ("a"); / / a benar
 var b: Boolean = Boolean (1); / / b benar
 jejak (a == b); / / true

 / / Variabel yang mewakili objek Boolean dibandingkan dengan referensi
 var a: Boolean = new Boolean ("a"); / / a benar
 var b: Boolean = new Boolean (1); / / b benar
 jejak (a == b); / / false

Lihat juga
Boolean kelas


Fungsi panggilan

call(frame)

Usang pada Flash Player 5 – Tindakan ini usang dalam mendukung function pernyataan.

Player versi: Flash Player 4

Menjalankan script di frame disebut tanpa memindahkan playhead ke frame. Variabel lokal tidak ada setelah script dijalankan.

  • Jika variabel tidak dideklarasikan di dalam blok ( {} ) tapi daftar aksi dieksekusi dengan panggilan () tindakan, variabel lokal dan berakhir pada akhir dari daftar saat ini.
  • Jika variabel tidak dideklarasikan di dalam blok dan daftar tindakan saat ini tidak dieksekusi dengan panggilan () tindakan, variabel diinterpretasikan sebagai variabel Timeline.

Parameter

frame : Object – Label atau jumlah frame dalam Timeline.

Lihat juga
pernyataan fungsi , Function.call ()


Fungsi chr

chr(number: Number ) : String

Usang pada Flash Player 5 – Fungsi ini usang dalam mendukung String.fromCharCode() .

Player versi: Flash Player 4

Mengubah nomor kode ASCII untuk karakter.

Parameter

number : Number – Sebuah nomor kode ASCII.

Pengembalian
String – Nilai karakter kode ASCII tertentu.

Contoh
Contoh berikut mengubah nomor 65 untuk huruf A dan memberikan ke variabel myVar :
myVar = chr(65);

Lihat juga
String.fromCharCode ()


clearInterval Fungsi

clearInterval(intervalID: Number ) : Void
Player versi: Flash Player 6

Menghentikan setInterval () panggilan.

Parameter

intervalID : Number – Sebuah numerik (integer) identifier kembali dari panggilan untuk setInterval() .

Contoh
Contoh berikut set pertama dan kemudian membersihkan panggilan interval:

 fungsi callback () {
     trace ("interval disebut:" ". ms" + getTimer () +);
 }

 var intervalID: Nomor = setInterval (callback, 1000);

Anda harus menghapus interval ketika Anda selesai menggunakan fungsi. Buat tombol yang disebut clearInt_btn dan menggunakan ActionScript berikut untuk jelassetInterval() :

 clearInt_btn.onRelease = function () {
     clearInterval (intervalID);
     trace ("interval dibersihkan");
 };

Lihat juga
setInterval ()


clearTimeout Fungsi

clearTimeout(id:Number) : Void
Player versi: Flash Player 8

Membatalkan ditentukan setTimeout() panggilan.

Parameter

id : Number – nomor identifikasi dari setTimeout() panggilan untuk membatalkan.

Contoh
Silakan lihat contoh untuk setTimeout() fungsi.

Lihat juga
setTimeout () , setInterval ()


duplicateMovieClip Fungsi

  duplicateMovieClip (target: String , newname: String , kedalaman: Nomor ): Void
 duplicateMovieClip (target: MovieClip , newname: String , kedalaman: Nomor ): Void
Player versi: Flash Player 4

Menciptakan sebuah instance dari klip video sedangkan file SWF diputar. Playhead dalam klip video duplikat selalu dimulai dari Frame 1, terlepas dari mana playhead berada dalam klip film asli. Variabel dalam klip video asli tidak disalin ke dalam klip video duplikat. Gunakan removeMovieClip() fungsi atau metode untuk menghapus contoh film klip dibuat dengan duplicateMovieClip() .

Parameter

target : Object – Jalur target klip video untuk menduplikasi. Parameter ini dapat berupa String (misalnya “my_mc”) atau referensi langsung ke instance klip video (misalnya my_mc). Parameter yang dapat menerima lebih dari satu tipe data yang terdaftar sebagai jenis Object .
newname : String – Sebuah pengenal unik untuk klip video digandakan.
depth : Number – Tingkat kedalaman yang unik untuk klip video digandakan. Tingkat kedalaman urutan susun untuk klip video digandakan. Ini urutan menumpuk mirip dengan urutan layer dalam Timeline, film klip dengan tingkat kedalaman yang lebih rendah yang tersembunyi di bawah klip dengan pesanan menumpuk tinggi. Anda harus menetapkan setiap film yang digandakan klip tingkat kedalaman yang unik untuk mencegah dari mengganti file SWF pada kedalaman diduduki.

Contoh
Dalam contoh berikut, contoh film baru klip dibuat disebut img_mc. Sebuah gambar yang dimuat ke dalam klip video, dan kemudian img_mc klip diduplikasi. Klip digandakan disebut newImg_mc , dan ini klip baru dipindahkan pada Stage sehingga tidak tumpang tindih klip aslinya, dan gambar yang sama dimuat ke dalam klip kedua.

 this.createEmptyMovieClip ("img_mc", this.getNextHighestDepth ());
 img_mc.loadMovie ("http://www.helpexamples.com/flash/images/image1.jpg");
 duplicateMovieClip (img_mc, "newImg_mc", this.getNextHighestDepth ());
 newImg_mc._x = 200;
 newImg_mc.loadMovie ("http://www.helpexamples.com/flash/images/image1.jpg");

Untuk menghapus klip video duplikat, Anda bisa menambahkan kode ini untuk tombol yang disebut myButton_btn .

 this.myButton_btn.onRelease = function () {
     removeMovieClip (newImg_mc);
 };

Lihat juga
removeMovieClip () , MovieClip.duplicateMovieClip () , MovieClip.removeMovieClip ()


lolos Fungsi

escape(expression: String ) : String
Player versi: Flash Player 5

Mengkonversi parameter untuk string dan encode dalam format URL-encoded, di mana semua karakter nonalphanumeric diganti dengan urutan heksadesimal%. Ketika digunakan dalam string URL-encoded, simbol persentase (%) digunakan untuk memperkenalkan karakter melarikan diri, dan tidak setara dengan operator modulo (%).

Parameter

expression : String – Ekspresi untuk mengkonversi ke dalam string dan encode dalam format URL-encoded.

Pengembalian
String – URL-encoded string.

Contoh
Kode berikut menghasilkan hasil someuser%40somedomain%2Ecom :

 var email: String = "someuser@somedomain.com";
 jejak (escape (email));

Dalam contoh ini, di simbol ( @ ) diganti dengan %40 dan simbol titik ( . diganti dengan) %2E . Ini berguna jika Anda mencoba untuk menyampaikan informasi ke remote server dan data memiliki karakter khusus di dalamnya (misalnya, & atau ? ), seperti yang ditunjukkan dalam kode berikut:

 var redirectUrl: String = "http://www.somedomain.com?loggedin=true&username=Gus";
 getURL ("http://www.myothersite.com?returnurl =" + escape (redirectUrl));

Lihat juga
unescape ()


Fungsi eval

  eval (ekspresi: Object ): Obyek
 eval (ekspresi: String ): Obyek
Player versi: Flash Player 5 – Flash Player 5 atau yang lebih baru untuk fungsionalitas penuh. Anda dapat menggunakan eval() berfungsi bila mengekspor ke Flash Player 4, tetapi Anda harus menggunakan notasi garis miring dan dapat mengakses variabel saja, bukan sifat atau benda.

Mengakses variabel, properti, benda, atau klip video dengan nama. Jika ekspresi adalah variabel atau properti, nilai dari variabel atau properti dikembalikan. Jika ekspresi adalah klip objek atau film, referensi ke objek atau klip video dikembalikan. Jika elemen yang disebutkan dalam ekspresi tidak dapat ditemukan, tidak terdefinisi dikembalikan.

Dalam Flash 4, eval() digunakan untuk mensimulasikan array, di Flash 5 atau lambat, Anda harus menggunakan kelas Array untuk mensimulasikan array.

Dalam Flash 4, Anda juga dapat menggunakan eval() untuk secara dinamis mengatur dan mengambil nilai dari nama variabel atau contoh. Namun, Anda juga dapat melakukan hal ini dengan operator akses array ( [] ).

Dalam Flash 5 atau lambat, Anda tidak dapat menggunakan eval() untuk secara dinamis mengatur dan mengambil nilai dari nama variabel atau contoh, karena Anda tidak dapat menggunakan eval() di sisi kiri dari persamaan. Misalnya, mengganti kode

eval ("var" + i) = "first";

dengan ini:

this["var"+i] = "first"

atau ini:

set ("var" + i, "first");

Parameter

expression : Object – Nama properti, variabel, objek, atau klip video untuk mengambil. Parameter ini dapat berupa String atau referensi langsung ke instance objek (penggunaan yaitu tanda kutip (“”) adalah opsional.)

Pengembalian
Obyek – nilai A, referensi ke suatu objek atau klip video, atau undefined .

Contoh
Contoh berikut ini menggunakan eval() untuk mengatur properti untuk klip video secara dinamis bernama. ActionScript ini menetapkan _rotation properti selama tiga klip video, yang disebut square1_mc , square2_mc , dan square3_mc .

 for (var i = 1; i <= 3; i + +) {
     setProperty (eval ("persegi" + i + "_mc"), _rotation, 5);
 }

Anda juga dapat menggunakan ActionScript berikut:

 for (var i = 1; i <= 3; i + +) {
     ini ["persegi" + i + "_mc"] _rotation = -5.;
 }

Lihat juga
Array kelas , set variabel


fscommand Fungsi

fscommand(command: String , parameters: String ) : Void
Player versi: Flash Player 3

Mari berkomunikasi dengan baik file SWF Flash Player atau program yang menjadi tuan Flash Player, seperti browser web. Anda juga dapat menggunakan fscommand() fungsi untuk menyampaikan pesan ke Macromedia Director, atau Visual Basic (VB), Visual C + +, dan program lain yang dapat menjadi tuan rumah kontrol ActiveX.

The fscommand() fungsi memungkinkan sebuah file SWF berkomunikasi dengan script di halaman web. Namun, akses skrip dikendalikan oleh halaman Web allowScriptAccesspengaturan. (Anda menetapkan atribut ini dalam kode HTML yang embeds SWF file-misalnya, dalam PARAM tag untuk Internet Explorer atau EMBED tag untuk Netscape. KetikaallowScriptAccess diatur ke "never" , sebuah file SWF tidak dapat mengakses script halaman web. Dengan Flash Player 7 dan kemudian, ketika allowScriptAccess diatur ke "always" , sebuah file SWF selalu dapat mengakses script halaman web. Ketika allowScriptAccess diatur ke "sameDomain" , scripting diperbolehkan hanya dari file SWF yang berada dalam domain yang sama dengan web page, scripting selalu diizinkan dengan versi sebelumnya Flash Player Jika. allowScriptAccess tidak ditentukan dalam halaman HTML, atribut diatur secara default untuk "sameDomain" untuk file SWF versi 8 dan kemudian, dan "always" untuk SWF file dari versi 7 dan sebelumnya.

Penggunaan 1: Untuk menggunakan fscommand() untuk mengirim pesan ke Flash Player, Anda harus menggunakan perintah standar dan parameter. Tabel berikut menunjukkan nilai-nilai yang Anda dapat menentukan untuk fscommand() fungsi ini command dan parameters parameter. Nilai-nilai ini mengontrol file SWF yang bermain di Flash Player, termasuk proyektor. (Sebuah proyektor adalah file SWF disimpan dalam format yang dapat dijalankan sebagai aplikasi yang berdiri sendiri-yaitu, tanpa Flash Player.)

Perintah Parameter Tujuan
quit Tak satupun Menutup proyektor.
fullscreen true atau false Menentukan true set Lampu kilat Player untuk modus layar penuh. Menentukan false kembali pemain ke tampilan menu normal.
allowscale true atau false Menentukan false set pemain sehingga file SWF selalu digambar pada ukuran aslinya dan tidak pernah diskalakan.Menentukan true pasukan file SWF untuk skala sampai 100% dari pemain.
showmenu true atau false Menentukan true memungkinkan set lengkap item menu konteks. Menentukan false menyembunyikan semua item menu konteks kecuali Tentang Flash Player dan Pengaturan.
exec Path ke aplikasi Menjalankan aplikasi dari dalam proyektor.
trapallkeys true atau false Menentukan true mengirimkan semua peristiwa penting, termasuk kunci akselerator, ke onClipEvent(keyDown/keyUp)handler dalam Flash Player.

Ketersediaan:

  • Tak satu pun dari perintah dijelaskan dalam tabel yang tersedia di web pemain.
  • Semua perintah yang tersedia dalam aplikasi yang berdiri sendiri, seperti proyektor.
  • Hanya allowscale dan exec tersedia dalam uji-pemain film.

The exec perintah dapat hanya berisi karakter AZ, az, 0-9, titik (.), dan garis bawah (_). The exec Perintah berjalan di fscommand subdirektori saja. Dengan kata lain, jika Anda menggunakan exec perintah untuk memanggil aplikasi, aplikasi tersebut harus berada dalam subdirektori bernama fscommand. The exec perintah bekerja hanya dari dalam sebuah file proyektor Flash.

Penggunaan 2: Untuk menggunakan fscommand() untuk mengirim pesan ke bahasa scripting seperti JavaScript di browser web, Anda dapat melewati setiap dua parameter dalam command dan parameters parameter. Parameter ini bisa menjadi string atau ekspresi, dan mereka digunakan dalam fungsi JavaScript yang menangani, atau tangkapan,yang fscommand() fungsi.

Dalam web browser, fscommand() memanggil fungsi JavaScript moviename_DoFScommand , yang berada di halaman web yang berisi file SWF. Untuk moviename , memasok nama dari objek Flash yang Anda gunakan untuk NAME atribut EMBED tag atau properti ID dari OBJECT tag. Jika Anda menetapkan file SWF nama myMovie , fungsi JavaScriptmyMovie_DoFScommand disebut.

Pada halaman web yang berisi file SWF, mengatur allowScriptAccess atribut untuk mengizinkan atau menolak kemampuan file SWF untuk mengakses halaman web. (Anda menetapkan atribut ini dalam kode HTML yang embeds file-untuk SWF misalnya, dalam PARAM tag untuk Internet Explorer atau EMBED tag untuk Netscape.) KetikaallowScriptAccess diatur ke "never" , scripting keluar selalu gagal. Ketika allowScriptAccess diatur ke "always" , scripting keluar selalu berhasil. Ketika sudah diatur untuk "sameDomain" , scripting diperbolehkan hanya dari file SWF yang berada dalam domain yang sama dengan halaman web. Jika allowScriptAccess tidak ditentukan dalam halaman web, standarnya ke "sameDomain" untuk Flash Player 8, dan "always" untuk versi sebelumnya Flash Player.

Bila menggunakan fungsi ini, mempertimbangkan model flash keamanan pemain. Untuk Flash Player 8 yang fscommand() fungsi tidak diperbolehkan jika file SWF memanggil dalam sandbox-lokal dengan-file sistem atau lokal-dengan-jaringan dan halaman HTML yang mengandung berada dalam sandbox dipercaya. Untuk informasi lebih lanjut, lihat berikut:

Penggunaan 3: The fscommand() fungsi dapat mengirim pesan ke Macromedia Director. Pesan-pesan ini diinterpretasikan oleh Lingo (Direktur bahasa scripting) sebagai string, peristiwa, atau kode Lingo dieksekusi. Jika pesan adalah string atau suatu peristiwa, Anda harus menulis kode Lingo untuk menerima pesan dari fscommand() fungsi dan melaksanakan tindakan dalam Director. Untuk informasi lebih lanjut, lihat Pusat Dukungan Direktur www.macromedia.com / support / direktur .

Penggunaan 4: Dalam VisualBasic, Visual C + +, dan program lain yang dapat host kontrol ActiveX, fscommand() mengirimkan acara VB dengan dua string yang dapat ditangani dalam bahasa pemrograman lingkungan itu. Untuk informasi lebih lanjut, gunakan kata kunci “metode flash” untuk mencari Pusat Dukungan Flash di www.macromedia.com / support / flash .

Catatan: Jika Anda mempublikasikan untuk Flash Player 8 atau yang lebih baru, kelas ExternalInterface menyediakan fungsionalitas yang lebih baik untuk komunikasi antara JavaScript dan ActionScript (Penggunaan 2) dan antara ActionScript dan VisualBasic, Visual C + +, atau program lain yang dapat host kontrol ActiveX (Penggunaan 4) . Anda harus terus menggunakan fscommand() untuk mengirim pesan ke Flash Player (Penggunaan 1) dan Macromedia Director (Penggunaan 3).

Parameter

command : String – Sebuah string dilewatkan ke aplikasi host untuk penggunaan apapun, atau perintah diteruskan ke Flash Player.
parameters : String – Sebuah string dilewatkan ke aplikasi host untuk penggunaan apapun, atau nilai diteruskan ke Flash Player.

Contoh
Dalam contoh berikut, fscommand() set Flash Player untuk skala file SWF dengan ukuran layar monitor penuh ketika fullscreen_btn atau unfullscreen_btn tombol dilepaskan:

 this.fullscreen_btn.onRelease = function () {
     fscommand ("fullscreen", true);
 };

 this.unfullscreen_btn.onRelease = function () {
     fscommand ("fullscreen", false);
 };

Contoh berikut ini berlaku fscommand() ke tombol di Flash untuk tujuan membuka kotak pesan JavaScript dalam halaman HTML. Pesan itu sendiri dikirim ke JavaScript sebagaifscommand parameter.

Anda harus menambahkan fungsi ke halaman web yang berisi file SWF. Fungsi ini, myDocument _DoFSCommand() , menunggu untuk fscommand() panggilan. Ketikafscommand() dipicu di Flash (misalnya, ketika pengguna mengklik tombol), yang command dan parameter string yang dikirimkan ke myDocument _DoFSCommand() fungsi. Anda dapat menggunakan string berlalu dalam Anda JavaScript atau VBScript kode cara apapun yang Anda suka. Dalam contoh ini, fungsi berisi bersyarat if pernyataan yang memeriksa untuk melihat apakah string perintah "messagebox" . Jika ya, kotak JavaScript peringatan menampilkan isi fscommand() fungsi ini parameters string.

 Fungsi myDocument_DoFSCommand (perintah, args) {
     if (command == "MessageBox") {
         alert (args);
     }
 }

Dalam dokumen Flash, tambahkan fscommand() ke tombol:

 fscommand ("MessageBox", "Ini adalah sebuah kotak pesan yang disebut dari dalam Flash.")

Anda dapat menggunakan ekspresi untuk parameter fscommand() fungsi, seperti yang ditunjukkan dalam contoh berikut:

 fscommand ("MessageBox", "Halo," + nama + ", selamat datang di website kami!")

Untuk menguji file SWF, pilih File> Publish Preview> HTML. Jika Anda mempublikasikan file SWF menggunakan Flash dengan template FSCommand (dalam kotak dialog Pengaturan Publish, pilih tag HTML), Flash memasukkan myDocument_DoFSCommand() fungsi otomatis. File SWF yang NAME dan ID atribut akan menjadi nama file. Misalnya, untuk myDocument.fla file, atribut akan diatur ke myDocument .

Lihat juga
ExternalInterface Kelas


getProperty Fungsi

getProperty(my_mc: Object , property: Object ) : Object
Player versi: Flash Player 4

Mengembalikan nilai properti yang ditentukan untuk klip video my_mc .

Parameter

my_mc : Object – Nama contoh klip video yang properti sedang diambil atau referensi ke sebuah klip video yang properti sedang diambil.
property – Sebuah properti dari klip video.

Pengembalian
Obyek – Nilai dari properti tertentu.

Contoh
Contoh berikut membuat klip video baru someClip_mc dan menunjukkan nilai alpha ( _alpha ) untuk klip video someClip_mc di panel Output:

 this.createEmptyMovieClip ("someClip_mc", 999);
 trace ("The alpha" + getProperty (someClip_mc, _name) + "adalah:" + getProperty (someClip_mc, _alpha));

getTimer Fungsi

getTimer() : Number
Player versi: Flash Player 4

Mengembalikan jumlah milidetik yang telah berlalu sejak file SWF mulai bermain.

Pengembalian
Nomor – Jumlah milidetik yang telah berlalu sejak file SWF mulai bermain.

Contoh
Dalam contoh berikut, getTimer() dan setInterval() fungsi yang digunakan untuk membuat timer sederhana:

 this.createTextField ("timer_txt", this.getNextHighestDepth (), 0, 0, 100, 22);
 Fungsi updateTimer (): Void {
     timer_txt.text = getTimer ();
 }

 var intervalID: Nomor = setInterval (updateTimer, 100);

Fungsi getURL

getURL(url: String , [window: String , [method: String ]]) : Void
Player versi: Flash Player 4 – The GET dan POST Pilihan ini hanya tersedia dalam dan kemudian versi.

Beban dokumen dari URL tertentu ke dalam jendela atau melewati variabel ke aplikasi lain pada URL didefinisikan. Untuk menguji fungsi ini, pastikan file yang akan dimuat adalah di lokasi yang ditentukan. Untuk menggunakan URL absolut (misalnya, http://www.myserver.com ), Anda memerlukan koneksi jaringan.

Parameter

url : String – The URL dari mana untuk mendapatkan dokumen.
window : String [opsional] – Menentukan jendela atau frame HTML dimana dokumen harus memuat. Anda dapat memasukkan nama dari jendela tertentu atau pilih dari nama target berikut cadangan:

  • _self menentukan frame di jendela saat ini.
  • _blank menentukan jendela baru.
  • _parent menentukan induk dari frame.
  • _top menentukan kerangka top-level di jendela saat ini.
method : String [opsional] – Sebuah GET atau POST metode untuk mengirim variabel. Jika tidak ada variabel, mengabaikan parameter ini. The GET menambahkan metode variabel ke akhir URL, dan digunakan untuk sejumlah kecil variabel. The POST Metode mengirimkan variabel dalam header HTTP terpisah dan digunakan untuk mengirim string panjang variabel.

Contoh
Contoh ini memuat gambar ke dalam klip video. Ketika gambar diklik, URL baru dimuat di jendela browser baru.

 var listenerObject: Object = new Object ();
 listenerObject.onLoadInit = function (target_mc: MovieClip) {
     target_mc.onRelease = function () {
         getURL ("http://www.macromedia.com/software/flash/flashpro/", "_blank");
     };
 };
 var logo: MovieClipLoader = new MovieClipLoader ();
 logo.addListener (listenerObject);
 logo.loadClip ("http://www.helpexamples.com/flash/images/image1.jpg",
     this.createEmptyMovieClip ("macromedia_mc", this.getNextHighestDepth ()));

In the following example, getURL() is used to send an e-mail message:

myBtn_btn.onRelease = function(){
    getURL("mailto:you@somedomain.com");
 };

In the following ActionScript, JavaScript is used to open an alert window when the SWF file is embedded in a browser window (please note that when calling JavaScript with getURL(), the url parameter is limited to 508 characters):

myBtn_btn.onRelease = function(){
    getURL("javascript:alert('you clicked me')");
 };

You can also use GET or POST for sending variables. The following example uses GET to append variables to a URL:

var firstName:String = "Gus";
var lastName:String = "Richardson";
var age:Number = 92;
myBtn_btn.onRelease = function() {
    getURL("http://www.macromedia.com", "_blank", "GET");
 };

The following ActionScript uses POST to send variables in the HTTP header. Make sure you test your documents in a browser window, because otherwise your variables are sent using GET :

var firstName:String = "Gus";
var lastName:String = "Richardson";
var age:Number = 92;
getURL("http://www.macromedia.com", "_blank", "POST");

Lihat juga
loadVariables() , XML.send() , XML.sendAndLoad()


getVersion Function

getVersion() : String
Player version: Flash Player 5

Returns a string containing Flash Player version and platform information. The getVersion function returns information only for Flash Player 5 or later versions of Flash Player.

Pengembalian
String — A string containing Flash Player version and platform information.

Contoh
The following examples trace the version number of the Flash Player playing the SWF file:

var flashVersion:String = getVersion();
trace(flashVersion); // output: WIN 8,0,1,0
trace($version); // output: WIN 8,0,1,0
trace(System.capabilities.version); // output: WIN 8,0,1,0

The following string is returned by the getVersion function:

WIN 8,0,1,0

This returned string indicates that the platform is Microsoft Windows, and the version number of Flash Player is major version 8, minor version 1 (8.1).

Lihat juga
System.capabilities.os , System.capabilities.version


gotoAndPlay Function

gotoAndPlay([scene: String ], frame: Object ) : Void
Player version: Flash Player 2

Sends the playhead to the specified frame in a scene and plays from that frame. If no scene is specified, the playhead goes to the specified frame in the current scene. You can use the scene parameter only on the root Timeline, not within Timelines for movie clips or other objects in the document.

Parameter

scene : String [optional] — A string specifying the name of the scene to which the playhead is sent.
frame : Object — A number representing the frame number, or a string representing the label of the frame, to which the playhead is sent.

Contoh
In the following example, a document has two scenes: sceneOne and sceneTwo . Scene one contains a frame label on Frame 10 called newFrame and two buttons, myBtn_btnand myOtherBtn_btn . This ActionScript is placed on Frame 1, Scene 1 of the main Timeline.

 berhenti ();
myBtn_btn.onRelease = function(){
    gotoAndPlay("newFrame");
 };

myOtherBtn_btn.onRelease = function(){
    gotoAndPlay("sceneTwo", 1);
 };

When the user clicks the buttons, the playhead moves to the specified location and continues playing.

Lihat juga
MovieClip.goToAndPlay() , nextFrame() , play() , prevFrame()


gotoAndStop Function

gotoAndStop([scene: String ], frame: Object ) : Void
Player version: Flash Player 2

Sends the playhead to the specified frame in a scene and stops it. If no scene is specified, the playhead is sent to the frame in the current scene. You can use the sceneparameter only on the root Timeline, not within Timelines for movie clips or other objects in the document.

Parameter

scene : String [optional] — A string specifying the name of the scene to which the playhead is sent.
frame : Object — A number representing the frame number, or a string representing the label of the frame, to which the playhead is sent.

Contoh
In the following example, a document has two scenes: sceneOne and sceneTwo . Scene one contains a frame label on Frame 10 called newFrame , and two buttons,myBtn_btn and myOtherBtn_btn . This ActionScript is placed on Frame 1, Scene 1 of the main Timeline:

 berhenti ();

myBtn_btn.onRelease = function(){
    gotoAndStop("newFrame");
 };

myOtherBtn_btn.onRelease = function(){
    gotoAndStop("sceneTwo", 1);
 };

When the user clicks the buttons, the playhead moves to the specified location and stops.

Lihat juga
MovieClip.gotoAndStop() , stop() , play() , gotoAndPlay()


ifFrameLoaded Function

 ifFrameLoaded([scene: String ], frame) { 
     Pernyataan (s); 
 }

Deprecated as of Flash Player 5 — This function has been deprecated. Macromedia recommends that you use the MovieClip._framesloaded property.

Player version: Flash Player 4

Checks whether the contents of a specific frame are available locally. Use ifFrameLoaded to start playing a simple animation while the rest of the SWF file downloads to the local computer. The difference between using _framesloaded and ifFrameLoaded is that _framesloaded lets you add custom if or else statements.

Parameter

scene : String [optional] — A string that specifies the name of the scene that must be loaded.
frame : Object — The frame number or frame label that must be loaded before the next statement is executed.

Lihat juga
MovieClip._framesloaded , MovieClipLoader.addListener()


int Function

int(value: Number ) : Number

Deprecated as of Flash Player 5 — This function was deprecated in favor of Math.round() .

Player version: Flash Player 4

Converts a decimal number to an integer value by truncating the decimal value. This function is equivalent to Math.floor() if the value parameter is positive andMath.ceil() if the value parameter is negative.

Parameter

value : Number — A number to be rounded to an integer.

Pengembalian
Number — The truncated integer value.

Lihat juga
Math.round() , Math.floor() , Math.ceil()


isFinite Function

isFinite(expression: Object ) : Boolean
Player version: Flash Player 5

Evaluates expression and returns true if it is a finite number or false if it is infinity or negative infinity. The presence of infinity or negative infinity indicates a mathematical error condition such as division by 0.

Parameter

expression : Object — A Boolean value, variable, or other expression to be evaluated.

Pengembalian
Boolean — A Boolean value.

Contoh
The following example shows return values for isFinite :

isFinite(56)
// returns true

isFinite(Number.POSITIVE_INFINITY)
//returns false

isNaN Function

isNaN(expression: Object ) : Boolean
Player version: Flash Player 5

Evaluates the parameter and returns true if the value is NaN (not a number). This function is useful for checking whether a mathematical expression evaluates successfully to a number.

Parameter

expression : Object — A Boolean, variable, or other expression to be evaluated.

Pengembalian
Boolean — A Boolean value.

Contoh
The following code illustrates return values for the isNaN() function:

trace( isNaN("Tree") );
// returns true

trace( isNaN(56) );
// returns false

trace( isNaN(Number.POSITIVE_INFINITY) )
// returns false

The following example shows how you can use isNAN() to check whether a mathematical expression contains an error:

var dividend:Number;
var divisor:Number;
divisor = 1;
trace( isNaN(dividend/divisor) );
// output: true 
// The output is true because the variable dividend is undefined. 
// Do not use isNAN() to check for division by 0 because it will return false.
// A positive number divided by 0 equals Infinity (Number.POSITIVE_INFINITY).
// A negative number divided by 0 equals -Infinity (Number.NEGATIVE_INFINITY).

Lihat juga
NaN , Number.Nan


length Function

length(expression: String )
length(variable)

Deprecated as of Flash Player 5 — This function, along with all the string functions, has been deprecated. Macromedia recommends that you use the methods of the String class and the String.length property to perform the same operations.

Player version: Flash Player 4

Returns the length of the specified string or variable.

Parameter

expression : String — A string.
variable : Object — The name of a variable.

Pengembalian
Number — The length of the specified string or variable.

Contoh
The following example returns the length of the string “Hello”:
length("Hello");
The result is 5.

Lihat juga
” ” (string delimiter) , String class , String.length


loadMovie Function

 loadMovie(url: String , target: Object , [method: String ]) : Void
loadMovie(url: String , target: String , [method: String ]) : Void
Player version: Flash Player 3 — The ability to load JPEG files is available as of Flash Player 6. The ability to load unanimated GIF files, PNG files, or progressive JPEG files is available as of Flash Player 8.

Loads a SWF, JPEG, GIF, or PNG file into a movie clip in Flash Player while the original SWF file is playing. Support for unanimated GIF files, PNG files, and progressive JPEG files is added in Flash Player 8. If you load an animated GIF, only the first frame is displayed.

Tip : If you want to monitor the progress of the download, use MovieClipLoader.loadClip() instead of this function.

The loadMovie() function lets you display several SWF files at once and switch among SWF files without loading another HTML document. Without the loadMovie()function, Flash Player displays a single SWF file.

If you want to load a SWF or JPEG file into a specific level, use loadMovieNum() instead of loadMovie() .

When a SWF file is loaded into a target movie clip, you can use the target path of that movie clip to target the loaded SWF file. A SWF file or image loaded into a target inherits the position, rotation, and scale properties of the targeted movie clip. The upper left corner of the loaded image or SWF file aligns with the registration point of the targeted movie clip. Alternatively, if the target is the root Timeline, the upper left corner of the image or SWF file aligns with the upper left corner of the Stage.

Use unloadMovie() to remove SWF files that were loaded with loadMovie() .

When using this function, consider the Flash Player security model.

For Flash Player 8:

  • Loading is not allowed if the calling movie clip is in the local-with-file-system sandbox and the loaded movie clip is from a network sandbox.
  • Loading is not allowed if the calling SWF file is in a network sandbox and the movie clip to be loaded is local.
  • Network sandbox access from the local-trusted or local-with-networking sandbox requires permission from the website by means of a cross-domain policy file.
  • Movie clips in the local-with-file-system sandbox may not script movie clips in the local-with-networking sandbox (and the reverse is also prevented).

For Flash Player 7 and later:

  • Websites can permit cross-domain access to a resource by means of a cross-domain policy file.
  • Scripting between SWF files is restricted based on the origin domain of the SWF files. Use the System.security.allowDomain() method to adjust these restrictions.

Untuk informasi lebih lanjut, lihat berikut:

Parameter

url : String — The absolute or relative URL of the SWF or JPEG file to be loaded. A relative path must be relative to the SWF file at level 0. URL mutlak harus menyertakan referensi protokol, seperti http:// atau file :/ / /.
target : Object — A reference to a movie clip object or a string representing the path to a target movie clip. The target movie clip is replaced by the loaded SWF file or image.
method : String [optional] — Specifies an HTTP method for sending variables. The parameter must be the string GET or POST . If there are no variables to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables.

Contoh
Usage 1: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called mySquare that already exists on the Stage:

loadMovie("circle.swf", mySquare);
// equivalent statement (Usage 1): loadMovie("circle.swf", _level0.mySquare);
// equivalent statement (Usage 2): loadMovie("circle.swf", "mySquare");

The following example loads the SWF file circle.swf from the same directory, but replaces the main movie clip instead of the mySquare movie clip:

loadMovie("circle.swf", this);
// Note that using "this" as a string for the target parameter will not work
// equivalent statement (Usage 2): loadMovie("circle.swf", "_level0");

The following loadMovie() statement loads the SWF file sub.swf from the same directory into a new movie clip called logo_mc that’s created usingcreateEmptyMovieClip() :

this.createEmptyMovieClip("logo_mc", 999);
loadMovie("sub.swf", logo_mc);

You could add the following code to load a JPEG image called image1.jpg from the same directory as the SWF file loading sub.swf. The JPEG is loaded when you click a button called myBtn_btn . This code loads the JPEG into logo_mc . Therefore, it will replace sub.swf with the JPEG image.

myBtn_btn.onRelease = function(){
    loadMovie("image1.jpg", logo_mc);
 };

Usage 2: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called mySquare that already exists on the Stage:

loadMovie("circle.swf", "mySquare");

Lihat juga
_level , loadMovieNum() , MovieClip.loadMovie() , MovieClipLoader.loadClip() , unloadMovie()


loadMovieNum Function

loadMovieNum(url: String , level: Number , [method: String ]) : Void
Player version: Flash Player 4 — Flash 4 files opened in Flash 5 or later are converted to use the correct syntax. The ability to load JPEG files is available as of Flash Player 6. The ability to load unanimated GIF files, PNG files, or progressive JPEG files is available as of Flash Player 8.

Loads a SWF, JPEG, GIF, or PNG file into a level while the original SWF file is playing. Support for unanimated GIF files, PNG files, and progressive JPEG files is added in Flash Player 8. If you load an animated GIF, only the first frame is displayed.

Tip : If you want to monitor the progress of the download, use MovieClipLoader.loadClip() instead of this function.

Normally, Flash Player displays a single SWF file and then closes. The loadMovieNum() action lets you display several SWF files at once and switch among SWF files without loading another HTML document.

If you want to specify a target instead of a level, use loadMovie() instead of loadMovieNum() .

Flash Player has a stacking order of levels starting with level 0. These levels are like layers of acetate; they are transparent except for the objects on each level. When you useloadMovieNum() , you must specify a level in Flash Player into which the SWF file will load. When a SWF file is loaded into a level, you can use the syntax, _level N , where Nis the level number, to target the SWF file.

When you load a SWF file, you can specify any level number and you can load SWF files into a level that already has a SWF file loaded into it. If you do, the new SWF file will replace the existing SWF file. If you load a SWF file into level 0, every level in Flash Player is unloaded, and level 0 is replaced with the new file. The SWF file in level 0 sets the frame rate, background color, and frame size for all other loaded SWF files.

The loadMovieNum() action also lets you load JPEG files into a SWF file while it plays. For images and SWF files, the upper left corner of the image aligns with the upper left corner of the Stage when the file loads. Also in both cases, the loaded file inherits rotation and scaling, and the original content is overwritten in the specified level.

Note : JPEG files saved in progressive format are not supported.

Use unloadMovieNum() to remove SWF files or images that were loaded with loadMovieNum() .

When using this method, consider the Flash Player security model.

For Flash Player 8:

  • Loading is not allowed if the calling movie clip is in the local-with-file-system sandbox and the loaded movie clip is from a network sandbox.
  • Loading is not allowed if the calling SWF file is in a network sandbox and the movie clip to be loaded is local.
  • Network sandbox access from the local-trusted or local-with-networking sandbox requires permission from the website by means of a cross-domain policy file.
  • Movie clips in the local-with-file-system sandbox may not script movie clips in the local-with-networking sandbox (and the reverse is also prevented).

For Flash Player 7 and later:

  • Websites can permit cross-domain access to a resource by means of a cross-domain policy file.
  • Scripting between SWF files is restricted based on the origin domain of the SWF files. Use the System.security.allowDomain() method to adjust these restrictions.

Untuk informasi lebih lanjut, lihat berikut:

Parameter

url : String — The absolute or relative URL of the SWF or JPEG file to be loaded. A relative path must be relative to the SWF file at level 0. For use in the stand-alone Flash Player or for testing in test mode in the Flash authoring application, all SWF files must be stored in the same folder and the filenames cannot include folder or disk drive specifications.
level : Number — An integer specifying the level in Flash Player into which the SWF file will load.
method : String [optional] — Specifies an HTTP method for sending variables. The parameter must be the string GET or POST . If there are no variables to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables.

Contoh
The following example loads the JPEG image tim.jpg into level 2 of Flash Player:

loadMovieNum("http://www.helpexamples.com/flash/images/image1.jpg", 2);

Lihat juga
unloadMovieNum() , loadMovie() , MovieClipLoader.loadClip() , _level


loadVariables Function

loadVariables(url: String , target: Object , [method: String ]) : Void
Player version: Flash Player 4 — Behavior changed in Flash Player 7.

Reads data from an external file, such as a text file or text generated by ColdFusion, a CGI script, Active Server Pages (ASP), PHP, or Perl script, and sets the values for variables in a target movie clip. This action can also be used to update variables in the active SWF file with new values.

The text at the specified URL must be in the standard MIME format application/x-www-form-urlencoded (a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables:

company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103

In SWF files running in a version earlier than Flash Player 7, url must be in the same superdomain as the SWF file that is issuing this call. A superdomain is derived by removing the leftmost component of a file’s URL. For example, a SWF file at http://www.someDomain.com can load data from a source at store.someDomain.com because both files are in the same superdomain of someDomain.com.

In SWF files of any version running in Flash Player 7 or later, url must be in exactly the same domain as the SWF file that is issuing this call (see “Flash Player security features”in Using ActionScript in Flash ). For example, a SWF file at http://www.someDomain.com can load data only from sources that are also at http://www.someDomain.com. If you want to load data from a different domain, you can place a cross-domain policy file on the server hosting the SWF file that is being accessed. For more information, see “About allowing cross-domain data loading” in Using ActionScript in Flash .

If you want to load variables into a specific level, use loadVariablesNum() instead of loadVariables() .

Parameter

url : String — An absolute or relative URL where the variables are located. If the SWF file issuing this call is running in a web browser, url must be in the same domain as the SWF file; for details, see the Description section.
target : Object — The target path to a movie clip that receives the loaded variables.
method : String [optional] — Specifies an HTTP method for sending variables. The parameter must be the string GET or POST . If there are no variables to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables.

Contoh
The following example loads information from a text file called params.txt into the target_mc movie clip that is created using createEmptyMovieClip() . ThesetInterval() function is used to check the loading progress. The script checks for a variable in the params.txt file named done .

this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());
loadVariables("params.txt", target_mc);
function checkParamsLoaded() {
    if (target_mc.done == undefined) {
        trace("not yet.");
     } Else {
        trace("finished loading. killing interval.");
        trace("-------------");
        for (i in target_mc) {
            trace(i+": "+target_mc[i]);
         }
        trace("-------------");
        clearInterval(param_interval);
     }
 }
var param_interval:Number = setInterval(checkParamsLoaded, 100);

The external file, params.txt , includes the following text:

var1="hello"&var2="goodbye"&done="done"

Lihat juga


loadVariablesNum Function

loadVariablesNum(url: String , level: Number , [method: String ]) : Void
Player version: Flash Player 4 — Behavior changed in Flash Player 7. Flash 4 files opened in Flash 5 or later are converted to use the correct syntax.

Reads data from an external file, such as a text file or text generated by ColdFusion, a CGI script, ASP, PHP, or a Perl script, and sets the values for variables in a Flash Player level. You can also use this function to update variables in the active SWF file with new values.

The text at the specified URL must be in the standard MIME format application/x-www-form-urlencoded (a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables:

company=Macromedia&address=601+Townsend&city=San+Francisco&zip=94103

In SWF files running in a version of the player earlier than Flash Player 7, url must be in the same superdomain as the SWF file that is issuing this call. A superdomain is derived by removing the leftmost component of a file’s URL. For example, a SWF file at http://www.someDomain.com can load data from a source at store.someDomain.com, because both files are in the same superdomain of someDomain.com.

In SWF files of any version running in Flash Player 7 or later, url must be in exactly the same domain as the SWF file that is issuing this call (see “Flash Player security features”in Using ActionScript in Flash ). For example, a SWF file at http://www.someDomain.com can load data only from sources that are also at http://www.someDomain.com. If you want to load data from a different domain, you can place a cross-domain policy file on the server hosting the SWF file. For more information, see “About allowing cross-domain data loading”in Using ActionScript in Flash .

If you want to load variables into a target MovieClip, use loadVariables() instead of loadVariablesNum() .

Parameter

url : String — An absolute or relative URL where the variables are located. If the SWF file issuing this call is running in a web browser, url must be in the same domain as the SWF file; for details, see the Description section.
level : Number — An integer specifying the level in Flash Player to receive the variables.
method : String [optional] — Specifies an HTTP method for sending variables. The parameter must be the string GET or POST . If there are no variables to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables.

Contoh
The following example loads information from a text file called params.txt into the main Timeline of the SWF at level 2 in Flash Player. The variable names of the text fields must match the variable names in the params.txt file. The setInterval() function is used to check the progress of the data being loaded into the SWF. The script checks for a variable in the params.txt file named done .

loadVariablesNum("params.txt", 2);
function checkParamsLoaded() {
    if (_level2.done == undefined) {
        trace("not yet.");
     } Else {
        trace("finished loading. killing interval.");
        trace("-------------");
        for (i in _level2) {
            trace(i+": "+_level2[i]);
         }
        trace("-------------");
        clearInterval(param_interval);
     }
 }
var param_interval:Number = setInterval(checkParamsLoaded, 100);

// Params.txt includes the following text
var1="hello"&var2="goodbye"&done="done"

Lihat juga


mbchr Function

mbchr(number: Number )

Deprecated as of Flash Player 5 — This function was deprecated in favor of the String.fromCharCode() method.

Player version: Flash Player 4

Converts an ASCII code number to a multibyte character.

Parameter

number : Number — The number to convert to a multibyte character.

Lihat juga
String.fromCharCode()


mblength Function

mblength(string: String ) : Number

Deprecated as of Flash Player 5 — This function was deprecated in favor of the methods and properties of the String class.

Player version: Flash Player 4

Returns the length of the multibyte character string.

Parameter

string : String — The string to measure.

Pengembalian
Number — The length of the multibyte character string.

Lihat juga
String class , String.length


mbord Function

mbord(character: String ) : Number

Deprecated as of Flash Player 5 — This function was deprecated in favor of String.charCodeAt() .

Player version: Flash Player 4

Converts the specified character to a multibyte number.

Parameter

character : String — The character to convert to a multibyte number.

Pengembalian
Number — The converted character.

Lihat juga
String.charCodeAt()


mbsubstring Function

mbsubstring(value: String , index: Number , count: Number ) : String

Deprecated as of Flash Player 5 — This function was deprecated in favor of String.substr() .

Player version: Flash Player 4

Extracts a new multibyte character string from a multibyte character string.

Parameter

value : String — The multibyte string from which to extract a new multibyte string.
index : Number — The number of the first character to extract.
count : Number — The number of characters to include in the extracted string, not including the index character.

Pengembalian
String — The string extracted from the multibyte character string.

Lihat juga
String.substr()


MMExecute Function

MMExecute( "Flash JavaScript API command;": String ) : String
Player version: Flash Player 7

Lets you issue Flash JavaScript API (JSAPI) commands from ActionScript. In Flash MX2004 the MMExecute function can be called only by a movie that is used as a Flash Panel (file is stored in WindowSWF directory), by an XMLtoUI dialog box, or by the Custom UI of a component. JSAPI commands have no effect in the player, in test movie mode, or outside the authoring environment.

The Flash JSAPI provides several objects, methods, and properties to duplicate or emulate commands that a user can enter in the authoring environment. Using the JSAPI, you can write scripts that extend Flash in several ways: adding commands to menus, manipulating objects on the Stage, repeating sequences of commands, and so on.

In general, a user runs a JSAPI script by selecting Commands > Run Command. However, you can use this function in an ActionScript script to call a JSAPI command directly. If you use MMExecute() in a script on Frame 1 of your file, the command executes when the SWF file is loaded.

For more information on the JSAPI, see www.macromedia.com/go/jsapi_info_en .

Parameter

command : String — Any command that you can use in a Flash JavaScript (JSFL) file.

Pengembalian
String — A string representation of the result, if any, sent by the JavaScript statement.

Contoh
The following command will output the number of items in the library of the current document to the trace window. You must run this example as a Flash panel because Flash files can’t call MMExecute if they are run in either test movie or the browser.

  • Place the following code into frame 1 of the main Timeline of an empty Flash document:
    var numLibItems = MMExecute("fl.getDocumentDOM().library.items.length");
    var message = numLibItems + " items in library";
    MMExecute('fl.trace("' + message + '");');
  • Save the FLA file in the WindowSWF directory that is located in your Configuration directory, and then select File > Publish (or save it elsewhere and either publish the SWF file directly to that directory, or move the SWF file to that directory).
  • Quit and restart the application (you need to do this step the first time you add your file to the WindowSWF directory).

Now you can select your file from the bottom of the Window > Other Panels menu.

The ActionScript trace function does not work from a Flash panel; this example uses the JavaScript fl.trace version to get the output. It might be easier to copy the results of MMExecute to a text field that is part of your Flash Panel file.


nextFrame Function

nextFrame() : Void
Player version: Flash Player 2

Sends the playhead to the next frame.

Contoh
In the following example, when the user presses the Right or Down arrow key, the playhead goes to the next frame and stops. If the user presses the Left or Up arrow key, the playhead goes to the previous frame and stops. The listener is initialized to wait for the arrow key to be pressed, and the init variable is used to prevent the listener from being redefined if the playhead returns to Frame 1.

 berhenti ();

if (init == undefined) {
    someListener = new Object();
    someListener.onKeyDown = function() {
        if (Key.isDown(Key.LEFT) || Key.isDown(Key.UP)) {
            _level0.prevFrame();
        } else if (Key.isDown(Key.RIGHT) || Key.isDown(Key.DOWN)) {
            _level0.nextFrame();
         }
     };
    Key.addListener(someListener);
    init = 1;
 }

Lihat juga
prevFrame()


nextScene Function

nextScene() : Void
Player version: Flash Player 2

Sends the playhead to Frame 1 of the next scene.

Contoh
In the following example, when a user clicks the button that is created at runtime, the playhead is sent to Frame 1 of the next scene. Create two scenes, and enter the following ActionScript on Frame 1 of Scene 1.

 berhenti ();

if (init == undefined) {
    this.createEmptyMovieClip("nextscene_mc", this.getNextHighestDepth());
    nextscene_mc.createTextField("nextscene_txt", this.getNextHighestDepth(), 200, 0, 100, 22);
    nextscene_mc.nextscene_txt.autoSize = true;
    nextscene_mc.nextscene_txt.border = true;
    nextscene_mc.nextscene_txt.text = "Next Scene";
    this.createEmptyMovieClip("prevscene_mc", this.getNextHighestDepth());
    prevscene_mc.createTextField("prevscene_txt", this.getNextHighestDepth(), 00, 0, 100, 22);
    prevscene_mc.prevscene_txt.autoSize = true;
    prevscene_mc.prevscene_txt.border = true;
    prevscene_mc.prevscene_txt.text = "Prev Scene";
    nextscene_mc.onRelease = function() {
        nextScene();
     };

    prevscene_mc.onRelease = function() {
        prevScene();
     };

    init = true;
 }

Make sure you place a stop() action on Frame 1 of Scene 2.

Lihat juga
prevScene()


Number Function

Number(expression) : Number
Player version: Flash Player 4 — Behavior changed in Flash Player 7.

Converts the parameter expression to a number and returns a value as described in the following list:

  • If expression is a number, the return value is expression .
  • If expression is a Boolean value, the return value is 1 if expression is true , 0 if expression is false .
  • If expression is a string, the function attempts to parse expression as a decimal number with an optional trailing exponent (that is, 1.57505e-3).
  • If expression is NaN , the return value is NaN .
  • If expression is undefined , the return value is as follows:
    – In files published for Flash Player 6 or earlier, the result is 0.
    – In files published for Flash Player 7 or later, the result is NaN .

Parameter

expression : Object — An expression to convert to a number. Numbers or strings that begin with 0x are interpreted as hexadecimal values. Numbers or strings that begin with 0 are interpreted as octal values.

Pengembalian
Number — A number or NaN (not a number).

Contoh
In the following example, a text field is created on the Stage at runtime:

this.createTextField("counter_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
counter_txt.autoSize = true;
counter_txt.text = 0;
function incrementInterval():Void {
    var counter:Number = counter_txt.text;
    // Without the Number() function, Flash would concatenate the value instead 
    // of adding values. You could also use "counter_txt.text++;"
    counter_txt.text = Number(counter) + 1;
 }
var intervalID:Number = setInterval(incrementInterval, 1000);

Lihat juga
NaN , Number class , parseInt() , parseFloat()


Object Function

Object([value: Object ]) : Object
Player version: Flash Player 5

Creates a new empty object or converts the specified number, string, or Boolean value to an object. This command is equivalent to creating an object using the Object constructor (see “Constructor for the Object class” ).

Parameter

value : Object [optional] — A number, string, or Boolean value.

Pengembalian
Object — An object.

Contoh
In the following example, a new empty object is created, and then the object is populated with values:

var company:Object = new Object();
company.name = "Macromedia, Inc.";
company.address = "600 Townsend Street";
company.city = "San Francisco";
company.state = "CA";
company.postal = "94103";
for (var i in company) {
    trace("company."+i+" = "+company[i]);
 }

Lihat juga
Object Class


on Event Handler

 on( mouseEvent: Object ) {
    // your statements here
 }
Player version: Flash Player 2 — Flash 2. Not all events are supported in Flash 2.

Specifies the mouse event or keypress that triggers an action.

Parameter

mouseEvent : Object — A mouseEvent is a trigger called an event . When the event occurs, the statements following it within curly braces ({ }) execute. Any of the following values can be specified for the mouseEvent parameter:

  • press The mouse button is pressed while the pointer is over the button.
  • release The mouse button is released while the pointer is over the button.
  • releaseOutside While the pointer is over the button, the mouse button is pressed and then rolls outside the button area just before it is released. Both thepress and the dragOut events always precede a releaseOutside event.
  • rollOut The pointer rolls outside the button area.
  • rollOver The mouse pointer rolls over the button.
  • dragOut While the pointer is over the button, the mouse button is pressed and then rolls outside the button area.
  • dragOver While the pointer is over the button, the mouse button has been pressed, then rolled outside the button, and then rolled back over the button.
  • keyPress ” key > ” The specified keyboard key is pressed. For the key portion of the parameter, specify a key constant, as shown in the code hinting in the Actions Panel. You can use this parameter to intercept a key press, that is, to override any built-in behavior for the specified key. The button can be anywhere in your application, on or off the Stage. One limitation of this technique is that you can’t apply the on() handler at runtime; you must do it at authoring time. Make sure that you select Control > Disable Keyboard Shortcuts, or certain keys with built-in behavior won’t be overridden when you test the application using Control > Test Movie.

For a list of key constants, see the Key class.

Contoh
In the following script, the startDrag() function executes when the mouse is pressed, and the conditional script is executed when the mouse is released and the object is dropped:

on (press) {
    startDrag(this);
 }
 on (release) {
    trace("X:"+this._x);
    trace("Y:"+this._y);
     stopDrag ();
 }

Lihat juga
onClipEvent() , Key Class


onClipEvent Event Handler

 onClipEvent(movieEvent: Object ) {
    // your statements here
 }
Player version: Flash Player 5

Triggers actions defined for a specific instance of a movie clip.

Parameter

movieEvent : Object — The movieEvent is a trigger called an event . When the event occurs, the statements following it within curly braces ({}) are executed. Any of the following values can be specified for the movieEvent parameter:

  • load The action is initiated as soon as the movie clip is instantiated and appears in the Timeline.
  • unload The action is initiated in the first frame after the movie clip is removed from the Timeline. The actions associated with the Unload movie clip event are processed before any actions are attached to the affected frame.
  • enterFrame The action is triggered continually at the frame rate of the movie clip. The actions associated with the enterFrame clip event are processed before any frame actions that are attached to the affected frames.
  • mouseMove The action is initiated every time the mouse is moved. Use the _xmouse and _ymouse properties to determine the current mouse position.
  • mouseDown The action is initiated when the left mouse button is pressed.
  • mouseUp The action is initiated when the left mouse button is released.
  • keyDown The action is initiated when a key is pressed. Use Key.getCode() to retrieve information about the last key pressed.
  • keyUp The action is initiated when a key is released. Use the Key.getCode() method to retrieve information about the last key pressed.
  • data The action is initiated when data is received in a loadVariables() or loadMovie() action. When specified with a loadVariables() action, the dataevent occurs only once, when the last variable is loaded. When specified with a loadMovie() action, the data event occurs repeatedly, as each section of data is retrieved.

Contoh
The following example uses onClipEvent() with the keyDown movie event and is designed to be attached to a movie clip or button. The keyDown movie event is usually used with one or more methods and properties of the Key object. The following script uses Key.getCode() to find out which key the user has pressed; if the pressed key matches the Key.RIGHT property, the playhead is sent to the next frame; if the pressed key matches the Key.LEFT property, the playhead is sent to the previous frame.

onClipEvent (keyDown) {
    if (Key.getCode() == Key.RIGHT) {
        this._parent.nextFrame();
    } else if (Key.getCode() == Key.LEFT) {
        this._parent.prevFrame();
     }
 }

The following example uses onClipEvent() with the load and mouseMove movie events. The _ xmouse and _ ymouse properties track the position of the mouse each time the mouse moves, which appears in the text field that’s created at runtime.

 onClipEvent (beban) {
    this.createTextField("coords_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
    coords_txt.autoSize = true;
    coords_txt.selectable = false;
 }
onClipEvent (mouseMove) {
    coords_txt.text = "X:"+_root._xmouse+",Y:"+_root._ymouse;
 }

Lihat juga
Key class , MovieClip._xmouse , MovieClip._ymouse , on() , updateAfterEvent()


ord Function

ord(character: String ) : Number

Deprecated as of Flash Player 5 — This function was deprecated in favor of the methods and properties of the String class.

Player version: Flash Player 4

Converts characters to ASCII code numbers.

Parameter

character : String — The character to convert to an ASCII code number.

Pengembalian
Number — The ASCII code number of the specified character.

Lihat juga
String Class , String.charCodeAt()


parseFloat Function

parseFloat(string: String ) : Number
Player version: Flash Player 5

Mengkonversi string menjadi nilai floating-point. The function reads, or parses , and returns the numbers in a string until it reaches a character that is not a part of the initial number. If the string does not begin with a number that can be parsed, parseFloat() returns NaN . White space preceding valid integers is ignored, as are trailing nonnumeric characters.

Parameter

string : String — The string to read and convert to a floating-point number.

Pengembalian
Number — A number or NaN (not a number).

Contoh
The following examples use the parseFloat() function to evaluate various types of numbers:

trace(parseFloat("-2")); // output: -2
trace(parseFloat("2.5")); // output: 2.5
trace(parseFloat(" 2.5")); // output: 2.5
trace(parseFloat("3.5e6")); // output: 3500000
trace(parseFloat("foobar")); // output: NaN
trace(parseFloat("3.75math")); // output: 3.75
trace(parseFloat("0garbage")); // output: 0

Lihat juga
NaN , parseInt()


parseInt Function

parseInt(expression: String , [radix: Number ]) : Number
Player version: Flash Player 5

Mengkonversi string ke integer. If the specified string in the parameters cannot be converted to a number, the function returns NaN . Strings beginning with 0x are interpreted as hexadecimal numbers. Integers beginning with 0 or specifying a radix of 8 are interpreted as octal numbers. White space preceding valid integers is ignored, as are trailing nonnumeric characters.

Parameter

expression : String — A string to convert to an integer.
radix : Number [optional] — An integer representing the radix (base) of the number to parse. Legal values are from 2 to 36.

Pengembalian
Number — A number or NaN (not a number).

Contoh
The examples in this section use the parseInt() function to evaluate various types of numbers.

The following example returns 3:

 parseInt("3.5")

The following example returns NaN :

 parseInt("bar")

The following example returns 4:

 parseInt("4foo")

The following example shows a hexadecimal conversion that returns 1016:

 parseInt("0x3F8")

The following example shows a hexadecimal conversion using the optional radix parameter that returns 1000:

 parseInt("3E8", 16)

The following example shows a binary conversion and returns 10, which is the decimal representation of the binary 1010:

 parseInt("1010", 2)

The following examples show octal number parsing and return 511, which is the decimal representation of the octal 777:

 parseInt("0777") 
 parseInt("777", 8)

Lihat juga
NaN , parseFloat()


play Function

play() : Void
Player version: Flash Player 2

Moves the playhead forward in the Timeline.

Contoh
In the following example, there are two movie clip instances on the Stage with the instance names stop_mc and play_mc . The ActionScript stops the SWF file’s playback when the stop_mc movie clip instance is clicked. Playback resumes when the play_mc instance is clicked.

this.stop_mc.onRelease = function() {
     berhenti ();
 };
this.play_mc.onRelease = function() {
    play();
 };
trace("frame 1");

Lihat juga
gotoAndPlay() , MovieClip.gotoAndPlay()


prevFrame Function

prevFrame() : Void
Player version: Flash Player 2

Sends the playhead to the previous frame. If the current frame is Frame 1, the playhead does not move.

Contoh
When the user clicks a button called myBtn_btn and the following ActionScript is placed on a frame in the Timeline for that button, the playhead is sent to the previous frame:

 berhenti ();
this.myBtn_btn.onRelease = function(){
    prevFrame();
 };

Lihat juga
nextFrame() , MovieClip.prevFrame()


prevScene Function

prevScene() : Void
Player version: Flash Player 2

Sends the playhead to Frame 1 of the previous scene.

Lihat juga
nextScene()


print Function

print(target: Object , boundingBox: String ) : Void
Player version: Flash Player 4 — (4.0.20.0)

Prints the target movie clip according to the boundaries specified in the parameter ( bmovie , bmax , or bframe ). If you want to print specific frames in the target movie clip, attach a #p frame label to those frames. Although print() results in higher quality prints than printAsBitmap() it cannot be used to print movie clips that use alpha transparencies or special color effects.

If you use bmovie for the boundingBox parameter but do not assign a #b label to a frame, the print area is determined by the Stage size of the loaded movie clip. (The loaded movie clip does not inherit the main movie clip’s Stage size.)

All the printable elements in a movie clip must be fully loaded before printing can begin.

The Flash Player printing feature supports PostScript and non-PostScript printers. Non-PostScript printers convert vectors to bitmaps.

Parameter

target : Object — The instance name of a movie clip to print. By default, all of the frames in the target instance can be printed. If you want to print specific frames in the movie clip, assign a #p frame label to those frames.
boundingBox : String — A modifier that sets the print area of the movie clip. Enclose this parameter in quotation marks (” or ‘), and specify one of the following values:

  • bmovie Designates the bounding box of a specific frame in a movie clip as the print area for all printable frames in the movie clip. Assign a #b frame label to the frame whose bounding box you want to use as the print area.
  • bmax Designates a composite of all the bounding boxes of all the printable frames as the print area. Specify bmax if the printable frames in your movie clip vary in size.
  • bframe Indicates that the bounding box of each printable frame should be used as the print area for that frame, which changes the print area for each frame and scales the objects to fit the print area. Use bframe if you have objects of different sizes in each frame and want each object to fill the printed page.

 

Contoh
The following example prints all of the printable frames in holder_mc with a print area defined by the bounding box of each frame:

this.createEmptyMovieClip("holder_mc", 999);
holder_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");

this.myBtn_btn.onRelease = function() {
    print(this._parent.holder_mc, "bframe");
 };

In the previous ActionScript, you could replace bframe with bmovie so that the print area is defined by the bounding box of a frame with the #b frame label attached.

Lihat juga
printAsBitmap() , printAsBitmapNum() , PrintJob Class , printNum()


printAsBitmap Function

printAsBitmap(target: Object , boundingBox: String ) : Void
Player version: Flash Player 4 — (4.0.20.0) If you are authoring for Flash Player 7 or later, you can create a PrintJob object, which gives you (and the user) more control over the printing process. For more information, see the PrintJob class entry.

Prints the target movie clip as a bitmap according to the boundaries specified in the parameter ( bmovie , bmax , or bframe ). Use printAsBitmap() to print movie clips that contain frames with objects that use transparency or color effects. The printAsBitmap() action prints at the highest available resolution of the printer in order to maintain as much definition and quality as possible.

If your movie clip does not contain alpha transparencies or color effects, Macromedia recommends that you use print() for better quality results.

If you use bmovie for the boundingBox parameter but do not assign a #b label to a frame, the print area is determined by the Stage size of the loaded movie clip. (The loaded movie clip does not inherit the main movie clip’s Stage size.)

All the printable elements in a movie clip must be fully loaded before printing can begin.

The Flash Player printing feature supports PostScript and non-PostScript printers. Non-PostScript printers convert vectors to bitmaps.

Parameter

target : Object — The instance name of the movie clip to print. By default, all of the frames in the movie clip are printed. If you want to print specific frames in the movie clip, attach a #p frame label to those frames.
boundingBox : String — A modifier that sets the print area of the movie clip. Enclose this parameter in quotation marks (” or ‘), and specify one of the following values:

  • bmovie Designates the bounding box of a specific frame in a movie clip as the print area for all printable frames in the movie clip. Assign a #b frame label to the frame whose bounding box you want to use as the print area.
  • bmax Designates a composite of all the bounding boxes of all the printable frames as the print area. Specify the bmax parameter if the printable frames in your movie clip vary in size.
  • bframe Indicates that the bounding box of each printable frame should be used as the print area for that frame. This changes the print area for each frame and scales the objects to fit the print area. Use bframe if you have objects of different sizes in each frame and want each object to fill the printed page.

Contoh
The following example prints all of the printable frames in holder_mc with a print area defined by the bounding box of the frame:

this.createEmptyMovieClip("holder_mc", 999);
holder_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");

this.myBtn_btn.onRelease = function() {
    printAsBitmap(this._parent.holder_mc, "bframe");
 };

Lihat juga
print() , printAsBitmapNum() , printNum() , PrintJob Class


printAsBitmapNum Function

printAsBitmapNum(level: Number , boundingBox: String ) : Void
Player version: Flash Player 5 — If you are authoring for Flash Player 7 or later, you can create a PrintJob object, which gives you (and the user) more control over the printing process. For more information, see the PrintJob class entry.

Prints a level in Flash Player as a bitmap according to the boundaries specified in the parameter ( bmovie , bmax , or bframe ). Use printAsBitmapNum() to print movie clips that contain frames with objects that use transparency or color effects. The printAsBitmapNum() action prints at the highest available resolution of the printer in order to maintain the highest possible definition and quality. To calculate the printable file size of a frame designated to be printed as a bitmap, multiply pixel width by pixel height by printer resolution.

If your movie clip does not contain alpha transparencies or color effects, using printNum() will give you better quality results.

If you use bmovie for the boundingBox parameter but do not assign a #b label to a frame, the print area is determined by the Stage size of the loaded movie clip. (The loaded movie clip does not inherit the main movie’s Stage size.)

All the printable elements in a movie clip must be fully loaded before printing can start.

The Flash Player printing feature supports PostScript and non-PostScript printers. Non-PostScript printers convert vectors to bitmaps.

Parameter

level : Number — The level in Flash Player to print. By default, all of the frames in the level are printed. If you want to print specific frames in the level, assign a #pframe label to those frames.
boundingBox : String — A modifier that sets the print area of the movie clip. Enclose this parameter in quotation marks (” or ‘), and specify one of the following values:

  • bmovie Designates the bounding box of a specific frame in a movie clip as the print area for all of the printable frames in the movie clip. Assign a #b frame label to the frame whose bounding box you want to use as the print area.
  • bmax Designates a composite of all the bounding boxes of all the printable frames as the print area. Specify the bmax parameter if the printable frames in your movie clip vary in size.
  • bframe Indicates that the bounding box of each printable frame should be used as the print area for that frame. This changes the print area for each frame and scales the objects to fit the print area. Use bframe if you have objects of different sizes in each frame and you want each object to fill the printed page.

Contoh
The following example prints the contents of the Stage when the user clicks the button myBtn_btn . The area to print is defined by the bounding box of the frame.

myBtn_btn.onRelease = function(){
    printAsBitmapNum(0, "bframe")
 };

Lihat juga
print() , printAsBitmap() , PrintJob class , printNum()


printNum Function

printNum(level: Number , boundingBox: String ) : Void
Player version: Flash Player 5 — If you are authoring for Flash Player 7 or later, you can create a PrintJob object, which gives you (and the user) more control over the printing process. For more information, see the PrintJob class entry.

Prints the level in Flash Player according to the boundaries specified in the boundingBox parameter ( bmovie , bmax , bframe ). If you want to print specific frames in the target movie clip, attach a #p frame label to those frames. Although using printNum() results in higher quality prints than using printAsBitmapNum() , you cannot useprintNum() to print movies with alpha transparencies or special color effects.

If you use bmovie for the boundingBox parameter but do not assign a #b label to a frame, the print area is determined by the Stage size of the loaded movie clip. (The loaded movie clip does not inherit the main movie’s Stage size.)

All the printable elements in a movie clip must be fully loaded before printing can begin.

The Flash Player printing feature supports PostScript and non-PostScript printers. Non-PostScript printers convert vectors to bitmaps.

Parameter

level : Number — The level in Flash Player to print. By default, all of the frames in the level are printed. If you want to print specific frames in the level, assign a #pframe label to those frames.
boundingBox : String — A modifier that sets the print area of the movie clip. Enclose this parameter in quotation marks (” or ‘), and specify one of the following values:

  • bmovie Designates the bounding box of a specific frame in a movie clip as the print area for all printable frames in the movie clip. Assign a #b frame label to the frame whose bounding box you want to use as the print area.
  • bmax Designates a composite of all the bounding boxes of all the printable frames as the print area. Specify the bmax parameter if the printable frames in your movie clip vary in size.
  • bframe Indicates that the bounding box of each printable frame should be used as the print area for that frame. This changes the print area for each frame and scales the objects to fit the print area. Use bframe if you have objects of different sizes in each frame and want each object to fill the printed page.

Lihat juga
print() , printAsBitmap() , printAsBitmapNum() , PrintJob class


random Function

random(value: Number ) : Number

Deprecated as of Flash Player 5 — This function was deprecated in favor of Math.random() .

Player version: Flash Player 4

Returns a random integer between 0 and one less than the integer specified in the value parameter.

Parameter

value : Number — An integer.

Pengembalian
Number — A random integer.

Contoh
The following use of random() returns a value of 0, 1, 2, 3, or 4:
random(5);

Lihat juga
Math.random()


removeMovieClip Function

removeMovieClip(target: Object )
Player version: Flash Player 4

Deletes the specified movie clip.

Parameter

target : Object — The target path of a movie clip instance created with duplicateMovieClip() or the instance name of a movie clip created withMovieClip.attachMovie() , MovieClip.duplicateMovieClip() , or MovieClip.createEmptyMovieClip() .

Contoh
The following example creates a new movie clip called myClip_mc and duplicates the movie clip. The second movie clip is called newClip_mc . Images are loaded into both movie clips. When a button, button_mc , is clicked, the duplicated movie clip is removed from the Stage.

this.createEmptyMovieClip("myClip_mc", this.getNextHighestDepth());
myClip_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");
duplicateMovieClip(this.myClip_mc, "newClip_mc", this.getNextHighestDepth());
newClip_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");
newClip_mc._x = 200;
this.button_mc.onRelease = function() {
    removeMovieClip(this._parent.newClip_mc);
 };

Lihat juga


setInterval Function

 setInterval( functionReference: Function , interval: Number , [ param1: Object , param2 , ..., paramN ]) : Number
setInterval( objectReference: Object , methodName: String , interval: Number , [ param1: Object , param2 , ..., paramN ]) : Number
Player version: Flash Player 6

Calls a function or a method of an object at periodic intervals while a SWF file plays. You can use setInterval() to execute any function repetitively over time.

Use the following tips when working with setInterval() :

  1. Identify the scope of the function being called.
  2. Identify the scope where the interval ID (the return value of setInterval() ) was set.
  3. Clear previously set intervals before starting new ones.

These tips are discussed in further detail in the following paragraphs.

Identify the scope of the function being called. To identify the scope of the function being called, pass the object where the setInterval() method can execute (the object scope) as the first parameter and the method name you want to execute as the second parameter (as shown in the second signature). This ensures that the desired method is executed from the scope of the object reference passed in. When the method is executed in this manner, it can reference member variables on the object using the this keyword.

Identify the scope where the interval identifier was set. To identify the scope where the interval identifier ( intervalId ) was set, you can assign it to a member variable on the object scope that you pass to setInterval() . In this way, the function being called can locate the interval identifier at this.intervalId .

Clear previously set intervals. To clear previously set intervals before starting new ones, you should usually call clearInterval() before calling setInterval() . This ensures that you do not overwrite or otherwise destroy your intervalId variable, which is the only reference to the currently running interval. To call clearInterval()prior to calling setInterval() , both the initiating script and the script being executed must have access to the intervalId , as shown in the Examples.

Note: Always be sure to call clearInterval() when you want the script to stop looping.

Parameter

functionReference : Function — A reference to the function to be called.
interval : Number — The time in milliseconds between calls to the functionReference or methodName function passed in.If interval is less than the SWF file’s frame rate (for example, 10 frames per second [fps] is equal to 100 millisecond intervals), the interval function is called as close in time to the value of interval as possible. Executing long, memory-intensive scripts during an interval causes delays. If the function being called initiates a change to visual elements, you should use the updateAfterEvent() function to make sure that the screen refreshes often enough. If interval is greater than the SWF file’s frame rate, the interval function is called only after interval has expired and the playhead has entered the next frame; this minimizes the impact each time the screen is refreshed.
param : Object [optional] — Parameters passed to the function that was sent to functionReference or methodName . Multiple parameters should be separated by commas: param1 , param2 , ..., paramN
objectReference : Object — An object that contains the method specified by methodName .
methodName : String — A method that exists in the scope of the object specified by objectReference .

Pengembalian
Number — An integer that identifies the interval (the interval ID), which you can pass to clearInterval() to cancel the interval.

Contoh
Example 1: The following example traces a message at an interval of 20 milliseconds, up to 10 times, and then clears the interval. The object scope, this , is passed in as the first parameter, and the method name, executeCallback , as the second. This ensures that executeCallback() is executed from the same scope as the calling script.

var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 10;
var duration:Number = 20;

function executeCallback():Void {
    trace("executeCallback intervalId: " + intervalId + " count: " + count);
    if(count >= maxCount) {
        clearInterval(intervalId);
     } 
     hitung + +;
 }

intervalId = setInterval(this, "executeCallback", duration);

Example 2: The following example is similar to the first, except that it calls clearInterval() before setInterval() . This can help prevent unwanted loops and is especially important in event-based systems where the initiating script can be executed multiple times before any particular interval has been cleared.

var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 10;
var duration:Number = 20;

function executeCallback():Void {
    trace("executeCallback intervalId: " + intervalId + " count: " + count);
    if(count >= maxCount) {
        clearInterval(intervalId);
     }
     hitung + +;
 }

function beginInterval():Void {
    if(intervalId != null) {
        trace("clearInterval");
        clearInterval(intervalId);
     }
    intervalId = setInterval(this, "executeCallback", duration);
 }

beginInterval();
beginInterval();
beginInterval();

Example 3: The following example shows how to pass a custom argument to the function that is being called.

var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 10;
var duration:Number = 20;
var colors:Array = new Array("red", 
            "blue", 
            "yellow", 
            "purple", 
            "green", 
            "orange", 
            "salmon", 
            "pink", 
            "lilac", 
            "powder blue", 
            "mint");

function executeCallback(param:String) {
    trace("executeCallback intervalId: " + intervalId + " count: " + count + " param: " + param);
    clearInterval(intervalId);
    if(count < maxCount) {
         hitung + +;
        intervalId = setInterval(this, "executeCallback", duration, colors[count]);
     }
 }

if(intervalId != null) {
    clearInterval(intervalId);
 }

intervalId = setInterval(this, "executeCallback", duration, colors[count]);

Example 4: The following example shows how to use setInterval() correctly from an ActionScript 2.0 custom class. Note that similar to previous examples, this is passed to the setInterval() function to ensure that the called method is executed within the correct scope.

class CustomClass {
    private var intervalId:Number;
    private var count:Number = 0;
    private var maxCount:Number = 10;
    private var duration:Number = 20;

    public function CustomClass():Void {
        beginInterval();
     }

    private function beginInterval():Void {
        if(intervalId != null) {
            trace("clearInterval");
            clearInterval(intervalId);
         }
        intervalId = setInterval(this, "executeCallback", duration);
     }

    public function executeCallback():Void {
        trace("executeCallback intervalId: " + intervalId + " count: " + count);
        if(count >= maxCount) {
            clearInterval(intervalId);
         }
         hitung + +;
     }
 }

In a new document, instantiate a new instance of the new class:

var custom:CustomClass = new CustomClass();

Lihat juga
clearInterval() , updateAfterEvent() , class


setProperty Function

setProperty(target: Object , property: Object , expression: Object ) : Void
Player version: Flash Player 4

Changes a property value of a movie clip as the movie clip plays.

Parameter

target : Object — The path to the instance name of the movie clip whose property is to be set.
property : Object — The property to be set.
expression : Object — Either the new literal value of the property, or an equation that evaluates to the new value of the property.

Contoh
The following ActionScript creates a new movie clip and loads an image into it. The _x and _y coordinates are set for the clip using setProperty() . When you click the button called right_btn , the _x coordinate of a movie clip named params_mc is incremented by 20 pixels.

this.createEmptyMovieClip("params_mc", 999);
params_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");
setProperty(this.params_mc, _y, 20);
setProperty(this.params_mc, _x, 20);
this.right_btn.onRelease = function() {
    setProperty(params_mc, _x, getProperty(params_mc, _x)+20);
 };

Lihat juga
getProperty()


setTimeout Function

setTimeout() : Number
Player version: Flash Player 8

Runs a specified function after a specified delay (in milliseconds). The setTimeout() function is similar to the setInterval() function, except that setTimeout() calls the function once and then is automatically deleted.

To preserve the ability to use the clearTimeout() method to prevent setTimeout() from calling the function, be sure to assign the return value of the setTimeout() call to a variable.

Parameter

functionReference : Object — The name of the function to execute. Do not include quotation marks or parentheses, and do not specify parameters of the function to call. For example, use functionName , not functionName() or functionName(param) .
delay : Number — The delay, in milliseconds, until the function is executed.
args : Object — Zero or more arguments, separated by commas, to be passed to the function.

Pengembalian
Number — Unique numeric identifier for the timed process.

Contoh
The following example uses setTimeout() to call a function named my_delayedFunction after a two(2) second delay, and uses the return value to call clearTimeout() if the user presses the Escape key. The example will output the string “two second delay” after two seconds has elapsed, unless the user presses the Escape key beforemy_delayedFunction is called.

var my_timedProcess:Number = setTimeout(my_delayedFunction, 2000, "two second delay");

function my_delayedFunction (arg1) {
    trace(arg1);
 }

var escListener:Object = new Object();
escListener.onKeyDown = function() {
    if (Key.isDown(Key.ESCAPE)) {
        clearTimeout(my_timedProcess);
     }
 };
Key.addListener(escListener);

When you use this example, be sure to select Control > Disable Keyboard Shortcuts in the test environment.

Lihat juga
clearTimeout() , setInterval()


showRedrawRegions Function

showRedrawRegions(enable: Boolean , [color: Number ]) : Void
Player version: Flash Player 8

Provides the ability for the debugger player to outline the regions of the screen that are being redrawn (that is, dirty regions that are being updated). The outlines can also be turned on with the Show Redraw Regions menu option.

Parameter

enable : Boolean — Specifies whether to enable ( true ) or disable ( false ) redraw regions. When set to true , the redraw rectangles are shown. When set to false, the redraw rectangles are cleared.
color : Number [optional] — The color to draw with. The default is red: 0xFF0000.

Contoh
The following example demonstrates the showRedrawRegions function.

var w:Number = 100;
var h:Number = 100;

var shape1:MovieClip = createShape("shape1");
shape1.onEnterFrame = function():Void {
    this._x += 5;
    this._y += 5;
 }

var shape2:MovieClip = createShape("shape2");
shape2.onEnterFrame = function():Void {
    this._y += 5;
 }

_global.showRedrawRegions(true);

function createShape(name:String):MovieClip {
    var mc:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
    mc.beginFill(0xFFCC00);
    mc.moveTo(200, 200);
    mc.curveTo(300, 200, 300, 100);
    mc.curveTo(300, 0, 200, 0);
    mc.curveTo(100, 0, 100, 100);
    mc.curveTo(100, 200, 200, 200);
    mc.endFill();
    return mc;
 }

startDrag Function

startDrag(target: Object , [lock: Boolean , left: Number , top: Number , right: Number , bottom: Number ]) : Void
Player version: Flash Player 4

Makes the target movie clip draggable while the movie plays. Only one movie clip can be dragged at a time. After a startDrag() operation is executed, the movie clip remains draggable until it is explicitly stopped by stopDrag() or until a startDrag() action for another movie clip is called.

Parameter

target : Object — The target path of the movie clip to drag.
lock : Boolean [optional] — A Boolean value specifying whether the draggable movie clip is locked to the center of the mouse position ( true ) or locked to the point where the user first clicked the movie clip ( false ).
left,top,right,bottom : Number [optional] — Values relative to the coordinates of the movie clip’s parent that specify a constraint rectangle for the movie clip.

Contoh
The following example creates a movie clip, pic_mc , at runtime that users can drag to any location by attaching the startDrag() and stopDrag() actions to the movie clip. An image is loaded into pic_mc using the MovieClipLoader class.

var pic_mcl:MovieClipLoader = new MovieClipLoader();
pic_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg",
    this.createEmptyMovieClip("pic_mc", this.getNextHighestDepth()));
var listenerObject:Object = new Object();
listenerObject.onLoadInit = function(target_mc) {
    target_mc.onPress = function() {
        startDrag(this);
     };
    target_mc.onRelease = function() {
         stopDrag ();
     };
 };
pic_mcl.addListener(listenerObject);

Lihat juga
stopDrag() , MovieClip._droptarget , MovieClip.startDrag()


stop Function

stop() : Void
Player version: Flash Player 2

Stops the SWF file that is currently playing. The most common use of this action is to control movie clips with buttons.

Lihat juga
gotoAndStop() , MovieClip.gotoAndStop()


stopAllSounds Function

stopAllSounds() : Void
Player version: Flash Player 3

Stops all sounds currently playing in a SWF file without stopping the playhead. Sounds set to stream will resume playing as the playhead moves over the frames in which they are located.

Contoh
The following code creates a text field, in which the song’s ID3 information appears. A new Sound object instance is created, and your MP3 is loaded into the SWF file. ID3 information is extracted from the sound file. When the user clicks stop_mc, the sound is paused. When the user clicks play_mc, the song resumes from its paused position.

this.createTextField("songinfo_txt", this.getNextHighestDepth, 0, 0, Stage.width, 22);
var bg_sound:Sound = new Sound();
bg_sound.loadSound("yourSong.mp3", true);
bg_sound.onID3 = function() {
    songinfo_txt.text = "(" + this.id3.artist + ") " + this.id3.album + " - " + this.id3.track + " - " 
        + this.id3.songname;
    for (prop in this.id3) {
        trace(prop+" = "+this.id3[prop]);
     }
    trace("ID3 loaded.");
 };
this.play_mc.onRelease = function() {
    /* get the current offset. if you stop all sounds and click the play button, the MP3 continues from 
       where it was stopped, instead of restarting from the beginning.  * /
    var numSecondsOffset:Number = (bg_sound.position/1000);
    bg_sound.start(numSecondsOffset);
 };
this.stop_mc.onRelease = function() {
    stopAllSounds();
 };

Lihat juga
Sound class


stopDrag Function

stopDrag() : Void
Player version: Flash Player 4

Stops the current drag operation.

Contoh
The following code, placed in the main Timeline, stops the drag action on the movie clip instance my_mc when the user releases the mouse button:

my_mc.onPress = function () {
    startDrag(this);
 }

my_mc.onRelease = function() {
     stopDrag ();
 }

Lihat juga
startDrag() , MovieClip._droptarget , MovieClip.startDrag() , MovieClip.stopDrag()


String Function

String(expression: Object ) : String
Player version: Flash Player 4 — Behavior changed in Flash Player 7.

Returns a string representation of the specified parameter, as described in the following list:

  • If expression is a number, the return string is a text representation of the number.
  • If expression is a string, the return string is expression .
  • If expression is an object, the return value is a string representation of the object generated by calling the string property for the object, or by callingObject.toString() if no such property exists.
  • If expression is a Boolean value, the return string is "true" or "false" .
  • If expression is a movie clip, the return value is the target path of the movie clip in slash (/) notation.

If expression is undefined , the return values are as follows:

  • In files published for Flash Player 6 and earlier, the result is an empty string (“”).
  • In files published for Flash Player 7 and later, the result is undefined .

If expression is undefined , the return value is undefined .

Note: Slash notation is not supported by ActionScript 2.0.

Parameter

expression : Object — An expression to convert to a string.

Pengembalian
String — A string.

Contoh
In the following example, you use ActionScript to convert specified expressions to a string:

var string1:String = String("3");
var string2:String = String("9");
trace(string1+string2); // output: 39

Because both parameters are strings, the values are concatenated rather than added.

Lihat juga
Number.toString() , Object.toString() , String Class , ” ” (string delimiter)


substring Function

substring(string: String , index: Number , count: Number ) : String

Deprecated as of Flash Player 5 — This function was deprecated in favor of String.substr() .

Player version: Flash Player 4

Extracts part of a string. This function is one-based, whereas the String object methods are zero-based.

Parameter

string : String — The string from which to extract the new string.
index : Number — The number of the first character to extract.
count : Number — The number of characters to include in the extracted string, not including the index character.

Pengembalian
String — The extracted substring.

Lihat juga
String.substr()


targetPath Function

targetPath(targetObject: Object ) : String
Player version: Flash Player 5 — Support for Button, TextField, and Video objects added in Flash Player 6.

Returns a string containing the target path of a MovieClip, Button, TextField, or Video object. The target path is returned in dot (.) notation. To retrieve the target path in slash (/) notation, use the _target property.

Parameter

targetObject : Object — Reference (for example, _root or _parent ) to the object for which the target path is being retrieved. This can be a MovieClip, Button, or TextField object.

Pengembalian
String — A string containing the target path of the specified object.

Contoh
The following example traces the target path of a movie clip as soon as it loads:

this.createEmptyMovieClip("myClip_mc", this.getNextHighestDepth());
trace(targetPath(myClip_mc)); // _level0.myClip_mc

Lihat juga
eval()


tellTarget Function

 tellTarget(target: String ) { 
    statement(s); 
 }

Deprecated as of Flash Player 5 — Macromedia recommends that you use dot (.) notation and the with statement.

Player version: Flash Player 3

Applies the instructions specified in the statements parameter to the Timeline specified in the target parameter. The tellTarget action is useful for navigation controls. Assign tellTarget to buttons that stop or start movie clips elsewhere on the Stage. You can also make movie clips go to a particular frame in that clip. For example, you might assign tellTarget to buttons that stop or start movie clips on the Stage or prompt movie clips to jump to a particular frame.

In Flash 5 or later, you can use dot (.) notation instead of the tellTarget action. You can use the with action to issue multiple actions to the same Timeline. You can use the with action to target any object, whereas the tellTarget action can target only movie clips.

Parameter

target : String — A string that specifies the target path of the Timeline to be controlled.
statement(s) — The instructions to execute if the condition is true .

Contoh
This tellTarget statement controls the movie clip instance ball on the main Timeline. Frame 1 of the ball instance is blank and has a stop() action so it isn’t visible on the Stage. When you click the button with the following action, tellTarget tells the playhead in ball to go to Frame 2, where the animation starts:

     on (release) {
        tellTarget("_parent.ball") {
             gotoAndPlay (2);
         }
     }

The following example uses dot (.) notation to achieve the same results:

     on (release) {
        _parent.ball.gotoAndPlay(2);
     }

If you need to issue multiple commands to the ball instance, you can use the with action, as shown in the following statement:

     on (release) {
        with(_parent.ball) {
             gotoAndPlay (2);
            _alpha = 15;
            _xscale = 50;
            _yscale = 50;
         }
     }

Lihat juga
dengan


toggleHighQuality Function

toggleHighQuality()

Deprecated as of Flash Player 5 — This function was deprecated in favor of _quality .

Player version: Flash Player 2

Turns anti-aliasing on and off in Flash Player. Anti-aliasing smooths the edges of objects and slows down SWF playback. This action affects all SWF files in Flash Player.

Contoh
The following code could be applied to a button that, when clicked, would toggle anti-aliasing on and off:

     on (release) {
        toggleHighQuality();
     }

Lihat juga
_highquality , _quality


trace Function

trace(expression: Object )
Player version: Flash Player 4

You can use Flash Debug Player to capture output from the trace() function and display the result.

Use this statement to record programming notes or to display messages in the Output panel while testing a SWF file. Use the expression parameter to check whether a condition exists, or to display values in the Output panel. The trace() statement is similar to the alert function in JavaScript.

Use this statement to record programming notes or to write messages in the log file. Use the expression parameter to check whether a condition exists, or to write values to the log file.

You can use the Omit Trace Actions command in the Publish Settings dialog box to remove trace() actions from the exported SWF file.

Parameter

expression : Object — An expression to evaluate. When a SWF file is opened in the Flash authoring tool (using the Test Movie command), the value of the expressionparameter is displayed in the Output panel.

Contoh
The following example uses a trace() statement to display in the Output panel the methods and properties of the dynamically created text field called error_txt :

this.createTextField("error_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
for (var i in error_txt) {
trace("error_txt."+i+" = "+error_txt[i]);
 }
/* output:
error_txt.styleSheet = undefined
error_txt.mouseWheelEnabled = true
error_txt.condenseWhite = false
 ...
error_txt.maxscroll = 1
error_txt.scroll = 1
 * /

unescape Function

unescape(string: String ) : String
Player version: Flash Player 5

Evaluates the parameter x as a string, decodes the string from URL-encoded format (converting all hexadecimal sequences to ASCII characters), and returns the string.

Parameter

string : String — A string with hexadecimal sequences to escape.

Pengembalian
String — A string decoded from a URL-encoded parameter.

Contoh
The following example shows the escape-to-unescape conversion process:

var email:String = "user@somedomain.com";
trace(email);
var escapedEmail:String = escape(email);
trace(escapedEmail);
var unescapedEmail:String = unescape(escapedEmail);
trace(unescapedEmail);

The following result is displayed in the Output panel.

user@somedomain.com
user%40somedomain%2Ecom
user@somedomain.com

unloadMovie Function

 unloadMovie(target: MovieClip ) : Void
unloadMovie(target: String ) : Void
Player version: Flash Player 3

Removes a movie clip that was loaded by means of loadMovie() from Flash Player. To unload a movie clip that was loaded by means of loadMovieNum() , useunloadMovieNum() instead of unloadMovie() .

Parameter

target : Object — The target path of a movie clip. This parameter can be either a String (eg “my_mc”) or a direct reference to the movie clip instance (eg my_mc). Parameters that can accept more than one data type are listed as type Object .

Contoh
The following example creates a new movie clip called pic_mc and loads an image into that clip. It is loaded using the MovieClipLoader class. When you click the image, the movie clip unloads from the SWF file:

var pic_mcl:MovieClipLoader = new MovieClipLoader();
pic_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg",
    this.createEmptyMovieClip("pic_mc", this.getNextHighestDepth()));
var listenerObject:Object = new Object();
listenerObject.onLoadInit = function(target_mc) {
    target_mc.onRelease = function() {
        unloadMovie(pic_mc);
        /* or you could use the following, which refers to the movie clip referenced by 'target_mc'.  * /
        //unloadMovie(this);
     };
 };
pic_mcl.addListener(listenerObject);

Lihat juga
MovieClip.loadMovie() , MovieClipLoader.unloadClip()


unloadMovieNum Function

unloadMovieNum(level: Number ) : Void
Player version: Flash Player 3

Removes a SWF or image that was loaded by means of loadMovieNum() from Flash Player. To unload a SWF or image that was loaded with MovieClip.loadMovie() , useunloadMovie() instead of unloadMovieNum() .

Parameter

level : Number — The level ( _level N ) of a loaded movie.

Contoh
The following example loads an image into a SWF file. When you click unload_btn , the loaded content is removed.

loadMovieNum("yourimage.jpg", 1);
unload_btn.onRelease = function() {
    unloadMovieNum(1);
 }

Lihat juga
loadMovieNum() , unloadMovie() , MovieClip.loadMovie()


updateAfterEvent Function

updateAfterEvent() : Void
Player version: Flash Player 5

Updates the display (independent of the frames per second set for the movie) when you call it within an onClipEvent() handler or as part of a function or method that you pass to setInterval() . Flash ignores calls to updateAfterEvent that are not within an onClipEvent() handler or part of a function or method passed to setInterval() . This function works only with certain Mouse and MovieClip handlers: the mouseDown, mouseUp, mouseMove, keyDown and keyUp handlers for the Mouse class; the onMouseMove, onMouseDown, onMouseUp, onKeyDown, and onKeyUp handlers for the MovieClip class. It does not work with the Key class.

Contoh
The following example show how to create a custom cursor called cursor_mc . ActionScript is used to replace the mouse cursor with cursor_mc . ThenupdateAfterEvent() is used to continually refresh the Stage to make the cursor’s movement appear smooth.

 Mouse.hide ();
cursor_mc.onMouseMove = function() {
    this._x = this._parent._xmouse;
    this._y = this._parent._ymouse;
    updateAfterEvent();
 };

Lihat juga
onClipEvent() , setInterval()

6 comments on “Macromedia Flash ( Fungsi Global )

  1. Wow Lengkap Banget.

  2. OK. Dah Scriptnya, tar di coba di rumah deh.
    Thank nih ane comot langsung. hehhe :)

  3. Lengkap sih mas, tapi masih bingung –a
    kalo bikin action buat balik ke halaman sebelumnya gimana ya ?

  4. kalau error karena global gimana ya ?
    harusnya kan kebaca file dalam bentuk angka … persisnya seperti ini

    if(_global.i==29)_global.i=1;
    if(_global.i==0)_global.i=28;
    loadMovie(“file/”+_global.i+”.png”,tampil_start);
    stop();

    pas compile error tidak ada namun ketika mau dibuka muncul output :
    Error opening URL ‘file:///C|/Users/Khairil/Documents/E%2DCommerce%20FLASH%5FSLIDE/file/undefined.png’

    harusnya ../file/1.png kok malah muncul undefined.png

  5. whoah this weblog is wonderful i really like studying your posts. Keep up the great paintings! You already know, lots of individuals are searching around for this information, you can help them greatly. aggebddkdagd

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logout / Ubah )

Twitter picture

You are commenting using your Twitter account. Logout / Ubah )

Facebook photo

You are commenting using your Facebook account. Logout / Ubah )

Google+ photo

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Ikuti

Get every new post delivered to your Inbox.

Bergabunglah dengan 894 pengikut lainnya.

%d bloggers like this: