Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flash.events.MouseEvent;
- var a:Number;
- var b:Number;
- var hasilop:Number;
- var Tambah:Boolean = false;
- var Kurang:Boolean = false;
- var Bagi:Boolean = false;
- var Kali:Boolean = false;
- samadengan.addEventListener(MouseEvent.CLICK, Hasil);
- function Hasil(event:MouseEvent)
- {
- if(Tambah)
- {
- a = Number(A.text);
- b = Number(B.text);
- hasilop = a+b;
- hasil.text = hasilop.toString();
- } else if(Kurang)
- {
- a = Number(A.text);
- b = Number(B.text);
- hasilop = a-b;
- hasil.text = hasilop.toString();
- } else if(Kali)
- {
- a = Number(A.text);
- b = Number(B.text);
- hasilop = a*b;
- hasil.text = hasilop.toString();
- } else if(Bagi)
- {
- a = Number(A.text);
- b = Number(B.text);
- hasilop = a/b;
- hasil.text = hasilop.toString();
- }
- }
- tambah.addEventListener(MouseEvent.CLICK, tambahClick);
- function tambahClick(event:MouseEvent)
- {
- Tambah = true;
- Kurang = false;
- Kali = false;
- Bagi = false;
- operasi.text = "+";
- }
- kurang.addEventListener(MouseEvent.CLICK, kurangClick);
- function kurangClick(event:MouseEvent)
- {
- Kurang = true;
- Tambah = false;
- Kali = false;
- Bagi = false;
- operasi.text = "-";
- }
- kali.addEventListener(MouseEvent.CLICK, kaliClick);
- function kaliClick(event:MouseEvent)
- {
- Kali = true;
- Tambah = false;
- Kurang = false;
- Bagi = false;
- operasi.text = "*";
- }
- bagi.addEventListener(MouseEvent.CLICK, bagiClick);
- function bagiClick(event:MouseEvent)
- {
- Bagi = true;
- Tambah = false;
- Kurang = false;
- Kali = false;
- operasi.text = "/";
- }
- reset.addEventListener(MouseEvent.CLICK, resetAll);
- function resetAll(event:MouseEvent)
- {
- A.text = "";
- B.text = "";
- hasil.text = "";
- operasi.text = "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement