Hi
I have a text chat program which let users input text message.
I want them able to input text by pressing 'Enter' key on keyboard.
It has compiled error on AS3. How should I fix it?Code:if(Key.isDown(Key.ENTER)){
addTextMessage();
}
Printable View
Hi
I have a text chat program which let users input text message.
I want them able to input text by pressing 'Enter' key on keyboard.
It has compiled error on AS3. How should I fix it?Code:if(Key.isDown(Key.ENTER)){
addTextMessage();
}
http://code.google.com/p/bigroom/wiki/KeyPoll
http://bigroom.googlecode.com/files/KeyPoll.zip
put the KeyPoll.as file in the folder with your main swf.
From your document class, the main one, do
to call it from your otherclasses/functions you use.Code:import flash.ui.keyboard;
...
public static var Key:KeyPoll= new KeyPoll(stage);
Alternatively, you can make your own Keys.as class that simply has the key codes for the key code you need like this:Code:if("Document class name".Key.isDown(Keyboard.ENTER)){
call function
}
Use another public static variable for Keys like the KeyPoll.Code:package
{
public class Keys
{
public function Keys()
{
}
public var Left:int = 37;
public var Up:int = 38;
public var Right:int = 39;
public var Down:int = 40;
}
}
EDIT: I forgot you need to put stage in the KeyPoll parameters
When I write
import flash.ui.keyboard;
var Key:KeyPoll= new KeyPoll(stage);
if(Key.isDown(Keyboard.ENTER)){
doConnectKey();
}
It has compile error to say no such class.
If I write
import uk.co.bigroom.input.KeyPoll;
It has no compile error. But there is no response when I press enter.
You need to put the KeyPoll.as file i linked in the same folder with your main swf, or the path of the class that uses it.
If you did do that, please post the compile error.
Finally, I got it run
Here are the steps:
1. put the as file in the directory \uk\co\bigroom\input\KeyPoll.as with your fla file because it is in a package uk.co.bigroom.input
2.
Thanks for helpCode:import flash.display.Sprite;
import flash.events.Event;
import flash.ui.Keyboard;
import uk.co.bigroom.input.KeyPoll;
var key:KeyPoll;
key = new KeyPoll(this.stage);
stage.addEventListener(Event.ENTER_FRAME, enterFrame);
function enterFrame(ev:Event):void {
if(key.isDown(Keyboard.ENTER)) //For Enter key
{
callFunction();
}
}
I have set of 16 functions in AS2.0
I need them to execute in a sequence so that when function-1 overs then it calls function-2 when function-2 overs then it calls function-3 and so on. SUch that it behave like movie.
There is no fixed interval of time for execution of function.
Each has its own time.
Each function has some set of work that it perform on reading from XML file.
any thoughts,
thanking you
Can you do that like:
function1()
{
execute job 1;
function2();
}
function2()
{
execute job 2;
function3();
}
function3()
{
execute job 3;
stop();
}
I have tried to do it...but it do in a while ....
All function get executed at a time.
Before completion one other starts.
Any other way to do it.
Thanks.
Firstly, I think you can add some trace point to do debug
e.g. function1()
{
trace("function1 starts");
execute code;
......
trace("function1 end");
function2();
}
another way is put those functions in different frames. after excute all functions in one frame and gotoAndStop(2);
Or could you post your code here if problem has not solved.
No problem,
But you didn't need to make the the directories uk.co.bigroom.input.KeyPoll;
Just edit the KeyPoll.as so that it's package matches your root document or wherever you put it
for example
c:/flash/Game.fla
c:/flash/Game.as
c:/flash/util/KeyPoll.as
Code:***KeyPoll.as***
package util
{
...
public class KeyPoll
{
Code:***Game.as****
package
{
import util.*;
...
public class Game extends Sprite{
...