Copy link to clipboard
Copied
I have an template Slot game an want to start the Spin when the "a" is pressed. The AS code is externaly i stopped devolping Flash with AS2. No i couldn´t get the simple code to work. Here the Code from the Slot Games:
package net.nosov{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import net.nosov.utils.Utils;
/**
* ...
* @author Nosov Vitaliy
*/
public class Main extends MovieClip {
public var engine : Engine
public var bet : Bet
private var help : Help
public var balance_credit : IncreaseAnimation
public var balance_won : IncreaseAnimation
public var balance_bet : IncreaseAnimation
// Define here how many images will be duplicated in slot
// For example, if you have 5 images, they will duplicated to
// have good smooth animation. Ussualy you don't need to change it
public const images_total_spin = 20
// Spin time of slot, define in seconds
public const spin_animation_time = 2
// How many coins will take from CREDITS if user don't have
// won combination. Also you need to remember about bet value
// Final result will be spinCOST x User Bet
public const spinCOST = 8
public function Main() {
Utils.root = MovieClip(this)
engine = new Engine()
bet = new Bet()
help = new Help()
btn_spin.buttonMode = true
btn_spin.addEventListener(MouseEvent.CLICK, spind_do)
// Credit text field
balance_credit = new IncreaseAnimation(999, txt1, 7)
// Won text field
balance_won = new IncreaseAnimation(0, txt2, 5)
// Bet text field
balance_bet = new IncreaseAnimation(1, txt3, 2)
}
private function spind_do(e:MouseEvent):void {
btn_spin.mouseEnabled = false
btn_spin.mouseChildren = false
engine.spin()
}
}
}
Now i thought i have simply change the funkction btn_spin. But i couldn`t get it to work. Can someone assist me !
Copy link to clipboard
Copied
call engine.spin();
Copy link to clipboard
Copied
This is AS2 ? Right ? I need an AS3 procedure like this:
function reportKeyDown(event:KeyboardEvent):void
{
trace("Key Pressed: " + String.fromCharCode(event.charCode) + " (character code: " + event.charCode + ")");
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);
please tell me what i have to change. thanks
Copy link to clipboard
Copied
it is as3.
function reportKeyDown(event:KeyboardEvent):void
{
engine.spin();
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);