Reading keyboard in oop AS2

Just getting to use AS2 OOP and while I understand nearly all
the game should be in classes rather than the fla timeline, all the
game code I've seen, even those games that define the game objects
in classes, still put the keyboard reading commands in the fla. Is
this good practice?
I've tried putting the key commands in classes and can't get
them to work. Can someone post a short example of reading a keyDown
in a class. Thanks

>> Is this good practice?
Well, technically speaking in true OOP, probably not.
>> Can someone post a short example of reading a
keyDown in a class.
See attached. The class moves a mc (in the fla there should
be a mc with a linkage name 'Ball') untill you hit the spacebar.

Similar Messages

  • Reading Keyboard

    As I am new to this, can you please help with reading keyboard input and storing it in a variable.
    thanx

    Try this. THe "essential part" is creating new objects(i think) The rest is self explanitory Hope it helps
    //Paul Rodger ***MARKS*** 14/1/02
    //A program which takes numbers from a file and enters them into an array.
    //The stream of numbers is terminated when the number -1 is discovered
    ///////////////////////////////ESSENTIAL/////////////////////////////////////
    import java.io.*;
    class number
         static BufferedReader keyboard = new
                   BufferedReader(new InputStreamReader(System.in));
         static PrintWriter screen = new PrintWriter(System.out, true);
         static public void main(String[] args) throws IOException{
    //local Data
         double number;
         //asks for number, its entered then displayed
         screen.println("please enter a number");
    number= Double.parseDouble(keyboard.readLine().trim());
    screen.println("the number is" +number);
              }

  • Read keyboard input as binary

    how can i read keyboard input as binary

    7biscuits wrote:
    I want to be able to get keyboard input as binary as the key is being pressed, without having to press enter,That requirement should have been posted in your original question!
    7biscuits wrote:
    This is required to enable my program respond to (ctrl , alt , shift , F1 , F2 etc) key's.
    Does anyone know how to do it?Reading keyboard input without pressing return on the standard shell (command prompt), this is not possible with Java.

  • Write/read file in OOP

    Hello,
    I have to make class that reads/creates tdms file
    I know OOP concepts from C++ and I ve seen write and safe class to file example  in labview but I have no idea haw to make it and what are benefits of using OOP in this case..
    I thought about creating privete methods to write and read data from obiect  and then creating public methods to set path filename etc.
    but I don't know haw to write obiect to tdms file
    Any help appreciated

    Dr. Damien has been working to naswer your question and his series on LVOOP file I/O are indexed starting in post # 26 here.
    It is a multi-part series.
    In volume 8 he posted this Domaion model.
    Have at it.
    Post up Q's in those threads. WE really need a OOPer to review and comment.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Why Firefox doesn't read keyboard input properly on Windows when chained deadkeys are involved?

    I'm trying to customize my keyboard layout on Windows. I have finally installed my new layout. However some of key combinations doesn't work on some applications. One of them is Firefox. It seems it doesn't handle chained deadkeys. And for some reason RightAlt + Q which sould produce "\" produces some wierd combination – this parcitual wierd issue is specific to Firefox. I can send an installer of the keyboard.
    Thank you for help

    Hello,
    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information. <br>
    '''Note''': ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!
    Thank you.

  • Creating a RSS (feed) reader in Flash with AS2

    Hi everybody and thank you for reading. I´m working in a rss reader for my website, that has already a rss channel created. I created this in a file that is called news.rss. So I made the interface of the reader in Flash, and then continue inserting a code. But when I try the swf, it just shows the title of my channel, but any of my news. What is the problem? Here is my code: 
    var rssurl:String = "http://amorenaccion.netau.net/news.rss";
    //var rssurl:String = "unijimpe.xml";
    var rssxml:XML = new XML();
    rssxml.ignoreWhite = true;
    rssxml.load(rssurl);
    rssxml.onLoad = function() {
        var nodo:XMLNode = rssxml.firstChild.firstChild;
        var vtit:String = "";
        var vurl:String = "";
        var vdes:String = "";
        var vcon:String = "";
        for (i=0; i<nodo.childNodes.length; i++) {
            var snodo:XMLNode = nodo.childNodes[i];
            switch (snodo.nodeName) {
                case "title":
                    vtit = snodo.firstChild.nodeValue;
                break;
                case "link":
                    vurl = snodo.firstChild.nodeValue;
                break;
                case "description":
                    vdes = snodo.firstChild.nodeValue;
                break;
        txttitle.htmlText = "<a href=\"" + vurl + "\">" + vtit + "</a>";
        txtdescription.text = vdes;
        txtcontent.htmlText = vcon;
    function getContent(vxml) {
        var stit:String = "";
        var surl:String = "";
        var sdes:String = "";
        for (j=0; j<vxml.childNodes.length; j++) {
            var sxml:XMLNode = vxml.childNodes[j];
            switch (sxml.nodeName) {
                case "title":
                    vtit = sxml.firstChild.nodeValue;
                break;
                case "link":
                    vurl = sxml.firstChild.nodeValue;
                break;
                case "description":
                    vdes = sxml.firstChild.nodeValue;
                break;
        return "<a href=\""+vurl+"\"><b><font color=\"#990000\">"+vtit+"</font></b></a><br>"+vdes+"<br><br>";

    You should use the trace() function to see what values your code is processing for the loaded data.  Looking at the rss file itself it does not appear to be consistent with its structure, so you might need to check that out as well.

  • HttpServer error in reading buffer size via keyboard input - HELP

    I've written a simple HttpServer program that reads keyboard input to construct a buffer to copy the requested file into the socket's output stream. I've done the string-to-integer conversion using BufferedReader and parse.Int. However, when I go to use the int later in the program, I keep getting the message "variable b may not have been initialized." Can anyone tell me what's missing from the code below? Thanks.
    private static void sendBytes(FileInputStream fis, OutputStream os)throws Exception
         //Construct a buffer via console input
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String str;
         int b;
              System.out.println("Enter desired buffer size or CTRL-C to break.");
         //Convert entry to an integer
         do
              str = br.readLine();
                 try
                   b = Integer.parseInt(str);
              catch(NumberFormatException e)
                   System.out.println("Invalid entry.");
         while((str=br.readLine())!=null);
         //Construct a buffer
         byte[] buffer = new byte;
         int bytes = 0;
         //Begin timing HTML page delivery
         long start, end;
              System.out.println("Timing for Web page delivery");
         start = System.currentTimeMillis();
         //Copy requested file into the socket's output stream
              while((bytes = fis.read(buffer)) != -1)
              os.write(buffer, 0, bytes);

    As the message suggests, what is missing is code to initialize the variable b. The first mention ("int b;") does not initialize it. The second mention ("b = Integer.parseInt(str);") only initializes it if no exception is thrown. So it's possible for b to be uninitialized when you actually try to use it.
    What do you need to change? First you need to decide what's to be done if the keyboard input isn't a valid integer. Do you have a default value in mind? If so, put that where you declare the variable ("int b = 42;"). If not, just initialize the variable to zero ("int b = 0;").

  • Reading mouse and keyboard outside program

    Hi!
    Is it possible to do what title says? I would like to make program that record everything that user do with mouse and keyboard and then "play" same actions again.
    Playing is easy using Robot class. Also reading (polling) mouse location on screen is possible with PointerInfo class.
    But is it really so that I can't read mouse clicks or keypresses any way when mouse or keyboard focus is outside the Java program frame? At least I didn't find any kind of class that I could use for this.
    Thanks!

    No spyware, I was thinking more like cheating in one game ;-)
    But well, that's a bit odd. There is already PointerInfo telling mouse coordinates, why not somekind of ButtonInfo telling state of mouse buttons...
    I have additional question, related to this same thing:
    If I want to make Java program that run on background (i.e. no frame or window visible) and I want to have it so that when you press for example ctrl+shift+L, that Java program gui appears to screen.
    But if it's not possible to read keyboard events outside program frame, this isn't possible either? Or is there some workaround to this?
    There seems to be possibility of using SystemTray coming in Java version 6, that nice! But still, I would like to know is there any way to "wake up" Java program that doesn't currently have any kind of gui visible on screen.
    Thanks again!

  • How to add actions to keyboard?

    Hello I´ve been looking around the net, and found a lot
    of confusing information.
    I would like to know how to add simple actions like
    gotoAndPlay("next"); to a key.
    e.g. the right arrow.
    How could I do this? any simple way?
    thanks in advance, marcelo.

    In AS3 you can just use:
    if(event.keyCode == Keyboard.A)
    help doc:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/ui/Keyboard.html
    In AS2 you can use:
    if(String.fromCharCode(Key.getCode()) == "a")
    help doc:
    http://help.adobe.com/en_US/AS2LCR/Flash_10.0/00001143.html#300959
    That way you don't have to look up the key codes.

  • Get Blackberry to unleash the full power of the Q10 Keyboard.

    About me:
    * A  am a heavy Blackberry user and developer since the 7200.
    * I Love BB Keyboard because it's a workhorse, it just gets thinks done faster.
    My Feedback:
    * Q10 is still missing lots of the keyboard Magic of the 9900 
    How Can this be done....
    #1 Home Screen Shortcuts
    Long Press for phone speed dial, one key press for app shortcuts
    Details
    1. Just like we always had long press any key for speed dial
    2. Give us the option to have the home screen function like a live search (as it works now)
    or we can assign each key to a program of our choice (and use the "s" to launch the live search), like it was on the 9900, but make it better where we can choose what program gets launched using what key (before it was hardcoded and was not changeable by the user)
    The current option in the search  is nice (like "bbm mark") but does not replace the direct key to program shortcut.  (it's not a conflict you can have both)
    #2 Email Advanced/Saved Search
    Message Advanced Search, with its Saved Search option linked to a hot key.
    Details
    on the 9900 if I wanted to search all my unread email from client "X"
    1. Press M from the home screen (to open my email box)
    2. Press Alt+O (or any saved key) from the message list (to bring up a saved search..)
    that took me less than 2 seconds,
    Now try doing that on the Q10 and let me know how many keys you have to press, and more 
    important how long it will take you!! Actually you can't even do it since you can only search for 1 item at a time, I can't search for all emails where the "from address" is [email protected] and the subject contains "call me" etc.
    How it should work..
    1. Just Bring back what we had in os7
    #3 Forward conditions
    Forward conditions for mail box (what should be sent to device)
    on the 9900 I was able to chose to forwarded or not to forward email based on a condition or to have it come in as a level1 email,  Bring back what we had in os7
    #4 Email Body view
    Html email view.
    give me an option to show email in fit with mode, now it does not always fit and may be to wide.
    #5 Black Background.
    Black Background in calendar (and other) app.. its impossible to see my calendar outside in the sun
    I understand you made it black to save battery life.. give me the choice to make it white and have a less battery life.
    #6 Bedside mode
    Bedside mode has no option to automatically go into airplane mode automatically (like we had in os7)
    #7 Auto on/off
    Auto on/off based on day or weekend..
    Bring back what we had in os7
    #8 Note List Search
    Note list  (now "reminder") missing search option
    #9 Camera App keyboard shortcuts
    Camera app has no keyboard shortcut to change flash options, change from video to picture, swap to front camera  
    #10 Contact List Category
    Contact list is missing filter by category  
    Bring back what we had in os7
    #11 "Mark Prior Read" Keyboard Shortcut.
    "Mark prior read" needs keyboard shortcut and is not working properly
    #12 Power standby mode
    now you only have an option to fully turn off your phone, i want close my phone at night but not close all my apps... like we had in os7
    This can all be done without effecting the z10 or any other phone.
    Summary
    A Q10 Should not be a Z10 with a keyboard Glued on to it.
    I know Blackberry put in lots of keyboard shortcuts, but they're not done yet.
    I don't speak for myself, being the blackberry guy in my company
    everyone comes to complain to me with all their issues..
    Now please don't say.. well you can do that by pressing here and swiping there and tapping there.. let's make the Q10 keyboard work for us...
    it's about getting the job done faster.. and more efficatintly
    Something to think about on the next phone design,
    the back key is sorely missed, it's a lot faster and more accurate then trying to get the swipe just right..
    what would be a good idea for the next phone is to make a side button that can be programmed to do whatever you like, like we had till now but also can be programmed as a back button.. think about that  no loss of screen size.. and I still have my back button, you can still keep the swipe but give us the choice..)

    Other people have been having similar problems with songs over a number of days, I assume that there has been a problem with Apple's servers.
    Depending upon what country that you are in (music can't be re-downloaded in all countries) then try deleting the incomplete tracks from your iTunes library and redownload them via the Purchased link under Quick Links on the right-hand side of the iTunes store home page on your computer's iTunes : re-downloading.
    If you aren't in a country where you can re-download music or if they re-downloas in the same state then try the 'report a problem' link from your purchase history : log into your account on your computer's iTunes via Store > View My Account and you should then see a Purchase History section with a 'see all' link to the right of it ; click on that and you should see a list of your purchases ; find those songs and use the 'Report a Problem' link.

  • Question about reading a string or integer at the command line.

    Now I know java doesn't have something like scanf/readln buillt into it, but I was wondering what's the easiest, and what's the most robust way to add this functionality? (This may require two separate answers, sorry).
    The reason I ask is because I've been learning java via self study for the SCJA, and last night was the first time I ever attempted to do this and it was just hellish. I was trying to make a simple guessing game at the command line, I didn't realize there wasn't a command read keyboard input.
    After fighting with the code for an hour trying to figure it out, I finally got it to read the line via a buffered reader and InputStreamReader(System.in), and ran a try block that threw an exception. Then I just used parseInt to get the integer value for the guess.
    Another question: To take command line input, do you have to throw an exception? And is there an easier way to make this work? It seems awfully complicated to take user input without a jframe and calling swing.
    Edited by: JGannon on Nov 1, 2007 2:09 PM

    1. Does scanner still work in JDK1.6?Try it and see. (Hint: the 1.6 documentation for the class says "Since: 1.5")
    If you get behaviour that doesn't fit with what you expect it to do, post your code and a description of our expectations.
    2. Are scanner and console essentially the same thing?No.
    Scanner is a class that provides methods to break up its input into pieces and return them as strings and primitive values. The input can be a variety of things: File InputStream, String etc (see the Scanner constructor documentation). The emphasis is on the scanning methods, not the input source.
    Console, on the other hand, is for working with ... the console. What the "console" is (and whether it is anything) depends on the JVM. It doesn't provide a lot of functionality (although the "masked" password input can't be obtained easily any other way). In terms of your task it will provide a reader associated with the console from which you can create a BufferedReader and proceed as you are at the moment. The emphasis with this class is the particular input source (and output destination), not the scanning.
    http://java.sun.com/javase/6/docs/api/java/util/Scanner.html
    http://java.sun.com/javase/6/docs/api/java/io/Console.html

  • Problem in reading integers data

    hi all,
    i'm reading integers from console and storing them in a file and then reading back, but my data is inconsistent.can anybody tell me the reason for this.
    heres my code snippet...
    DataInputStream in = new DataInputStream(System.in);
              DataOutputStream out = new DataOutputStream(new FileOutputStream("intdata.txt"));
              try{
                   int a = in.readInt();
                   out.writeInt(a);
                   out.close();
                   in.close();
              }catch(EOFException eofe){
                   throw new RuntimeException(eofe);
              DataInputStream in2 = new DataInputStream(new FileInputStream("intdata.txt"));
              System.out.println(in2.readInt());
              in2.close();

    The whole problem here is in that last phrase "a readInt() function which should function exactly as i'm expecting." What it actually does do in the posted code is sit there doing nothing, or rather it waits for more input. It's doing exactly what its API documentation says it will do.
    But you say it "should function exactly as i'm expecting." Now unless you pay Sun a very, very big sum of money DataInputStreams are going to go on behaving as documented in the API. That isn't going to change. You had better change what you are expecting.
    If you throw a String like "58" at a DataInputStream readInt() will not produce 58. (And nowhere in the documentation of the class does it suggest it will.) What it will do - and I've tried this - is sit there and do nothing. This was sort of what Ceci was getting at by "Broken As Designed". It's not that DIS is broken, after in2 (see below) works fine. But using it to read keyboard input is a Bad Thing.
    Having changed what we expect, we need to rethink that "apart from parseInt" bit. We need a plan B, and here it is. We are reading a string (a bunch of characters such as people produce when they hammer a keyboard) - so we'll use a Reader. We want an entire line, so we'll make it a BufferedReader and use its readline() method. And we want to obtain an int from that string, which pretty much suggests ... parseInt().
    At any rate, that's my suggestion! Something along the lines of:import java.io.BufferedReader;
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import java.io.EOFException;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStreamReader;
    public class Test {
        public static void main(String[] args) throws Exception {
            //DataInputStream in = new DataInputStream(System.in);
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            DataOutputStream out = new DataOutputStream(new FileOutputStream("intdata.txt"));
            try{
                //int a = in.readInt();
                int a = Integer.parseInt(in.readLine());
                     * Add this line to see what int the DataInputStream
                     * is creating based on your "85"
                System.out.println("The number I typed in was " + a);
                out.writeInt(a);
                out.close();
                 //in.close();
            } catch(EOFException eofe) {
                throw new RuntimeException(eofe);
            DataInputStream in2 = new DataInputStream(new FileInputStream("intdata.txt"));
            System.out.println(in2.readInt());
            in2.close();
    }Which results in58
    The number I typed in was 58
    58

  • Keyboard layouts, linux and Swing

    Hi,
    I have some applications written with Swing. They run fine on Windows but on my linux box I can't type national (non-us) characters in it. I also did run JEdit which also behaves wrong - it can display non-us characters when I load file from disk but regardless of what keyboard layout I choose in KDE it can't recognize it correctly. Linux programs works fine.
    I did some investigations and found, that KeyListener always returns 0x00 for those keystrokes which should produce national characters.
    I need to be able to switch keyboard layouts at runtime without changing OS locale - this is multilangual application.
    So, my question is: what do I have to do with my linux box setup to have correctly working keyboard layouts with swing applications? Mabe someone can explain me how java reads keyboard in X-es?
    regards,
    Tomasz Sztejka

    Ok, I have found that when I set system locale to pl_PL (by export LC_ALL="pl_PL" from shell) then Polish keyboard works.
    The problem is, I can't do that - the system locale must be left unspecified (POSIX or C) and Java application must be able to accept input from many languages all around the world.
    For example, if I switch keyboard to bulgarian, swing sees some japanese (or similar) characters. On the other hand, when I will set locale to ru_RU then russian layout works correctly, while polish does produce garbage.
    Please, help!

  • Oops programming

    hi,friends
    does anybody working on ABAP OBJECTS?
    so what r the diffrent programs ur writing using oops approach in ABAP? i mean reports......like that....
    plz explain something ur working on ABAP OBJECTS..in real time....

    Hi Prashanth
    You use OOPS for the following advantages.
    Complex software systems become easier to understand, since object-oriented structuring provides a closer representation of reality than other programming techniques.
    In a well-designed object-oriented system, it should be possible to implement changes at class level, without having to make alterations at other points in the system. This reduces the overall amount of maintenance required.
    Through polymorphism and inheritance, object-oriented programming allows you to reuse individual components.
    In an object-oriented system, the amount of work involved in revising and maintaining the system is reduced, since many problems can be detected and corrected in the design phase.
    You will releaze OOPS advantage only if you involve in complex projects.
    For reading in ABAP OOPS concepts, refer the below links.
    BC404 is SAPs reference material on OO programming in ABAP.
    Object Service
    http://help.sap.com/saphelp_nw04s/helpdata/en/ab/9d0a3ad259cd58e10000000a11402f/frameset.htm
    ABAP - Shared Objects
    http://help.sap.com/saphelp_nw04s/helpdata/en/14/dafc3e9d3b6927e10000000a114084/frameset.htm
    OO interfaces
    http://help.sap.com/saphelp_nw04s/helpdata/en/c3/225b5354f411d194a60000e8353423/frameset.htm
    ABAP Objects
    http://help.sap.com/saphelp_nw04s/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    ABAP OO Books
    ABAP Objects
    by Horst Keller, Sascha Kruger
    ABAP Objects - Reference book
    by Horst Keller, Joachim Jacobitz
    Dont forget to reward, if it helps ;>)
    Regards,
    Rakesh.

  • Does anyone know where I can get a replacement keyboard for my imac G5 power PC purchased in December 2005

    Does anyone know where in the UK or Ireland I can get a replacement keyboard for my imac G5 power PC purchased in December 2005. Running Mac OSX 10.4.1.1?

    Not sure where in Ireland to look, but be aware that SOME Apple Aluminum boards will work with 10.4.11. The first Al boards and those through the first few months of 2011 were compatible with any Mac running OS 10.4.11 and having USB ports. Then they changed them to require 10.6.8 for full function.
    The ones compatible with 10.4.11 (MB110LL/A) have the icon for Dashboard on the F4 key; the later ones (MB110LL/B) have an icon consisting of six tiny rectangles grouped to form a larger rectangle. The keyboard boxes are nearly identical except for:
    the system requirements printed on the front panel
    the back panel on the first model reads "Keyboard" where the newer model reads "Keyboard with Numeric Keypad."
    When looking for older parts, always consider a Mac User Group:
    http://appleusergroupresources.com/?page_id=394

Maybe you are looking for