If (child on screen) AS3 {play child} (keyboard.event)

Maby someone can help me with this? :

I have this script:

var answerA:Array = [];

function answerF(answerS:String,x:int,y:int,space:int):void {}

stiff var: int = answerS.length;

Word of the var: int;

If ((answerS.length % 2) == 0) {}

Word = (((raides * 150) + ((raides-1) * space)) / 2-150);

} else {}

Word = (((raides-1) * 150) + ((raides-1) * space)) / 2) - 75;

}

var nextX:int = x - Word;

var C: Class;

var letter: MovieClip;

for (var i: int = 0; i < answerS.length; i ++) {}

C = Class (getDefinitionByName (answerS.charAt (i)));

Letter = new C();

addChild (letter);

answerA.push (letter);

letter.x = nextX;

letter.y = y;

nextX += letter.width + space;

}

}

On the library, I have objects whose names A, B, C, D, E, f... to Z

This script adds letters from the library. With this script all ok it works perfectly for me, but I want keyboard event for each letter to play but now I don't know how to do this.


I have a script:


stage.addEventListener (KeyboardEvent.KEY_DOWN, AKeyDown);

function AKeyDown(event:KeyboardEvent):void {}

If (event.keyCode == Keyboard.A) {}

A.Play ();

}

}

This script works then object instance name.

And I want to do:

stage.addEventListener (KeyboardEvent.KEY_DOWN, AKeyDown);

function AKeyDown(event:KeyboardEvent):void {}

If (event.keyCode == Keyboard.A) {}

If child with class name an exist on screen}

playing the object with the name of class A


} else {}

var erreur.r: Sound = new eror();

errorR.play (0, 1);

}

}

}

What you need to do, is to give each child a name as you load them.  Then, you can target with their name property.

var C: Class;

var letter: MovieClip;

for (var i: int = 0; i<>

C = Class (getDefinitionByName (answerS.charAt (i)));

Letter = new C();

letter. Name = answerS.charAt (i);

addChild (letter);

answerA.push (letter);

letter.x = nextX;

letter.y = y;

nextX += letter.width + space;

}

}

stage.addEventListener (KeyboardEvent.KEY_DOWN, AKeyDown);

function AKeyDown(event:KeyboardEvent):void {}

trace ("key pressed:" + string.fromCharCode(0)) (event.charCode));
var ltr:MovieClip = MovieClip (getChildByName (string.fromCharCode(0)) (event.charCode)));
LTR. Play();

}

You will probably need to convert the string.fromCharCode(0)) (event.charCode) uppercase if you are naming them with capital letters.

Tags: Adobe Animate

Similar Questions

  • Qosmio G20-139: use the laptop screen to play on the Xbox 360

    Hi I have a question about the monitor function with the G20-139,

    I have an xbox 360 and would like to know if there is a way to use laptops screen to play on the 360 in high definition or composite mode using the monitor function. With the laptop came a composite cable at one end and a sort of headphone 3.5 mm at the other.

    I read the manual about the case and it does not work.

    Any help would be appreciated thanks

    Hello

    The port monitor - where you can connect with the composite cable can be used to display video from your digital camcorder, video game or VCR on the internal LCD screen. It can be used as a line-in port to allow the connection of a stereo device for audio input.

    In my opinion, you also need this cable to connect the Xbox to the Qosmio with composite cable plug-in software component.
    http://www.madcatz.com/default.asp?page=257&CategoryImg=Xbox_360_Cables

    Then to commence the Qosmio with the Monitor-in button that starts the Qosmio player.

    Good bye

  • Can I connect my WiiU to my iMac and use the iMac is a screen to play games?

    Can I connect my WiiU to my iMac and use the iMac as a screen to play games WiiU on it?

    N °

  • screen change on the spot while playing games (not in a big screen while playing)

    I upgraded my vista HP windows 7 laptop

    front in vista I use to play games on my laptop is 17 "the game must be full screen, but after the upgrade to windows 7, I can't full screen while playing

    and over my laptop has ATI Radeon 3100 256 MB graphics card, I can't use the same catalyst controller installed

    so please give me your answer to slove this as soon as possible

    Hello
     
    Step 1: We recommend that you visit the system manufacturer's Web site and download the Windows 7 compatible video card driver and successful installation on the computer.
    Here is the link of support for HP: http://welcome.hp.com/country/us/en/support.html
     
    Step 2: Once the driver is installed, adjust the display settings for the best appearance.
    Visit this link for more information: http://windows.microsoft.com/en-US/windows7/Getting-the-best-display-on-your-monitor
     
    For more information on troubleshooting the display problems with games, visit this link: http://support.microsoft.com/kb/263039
     
    Step 3: If the problem persists, we recommend that you cross check whether the game is compatible with Windows 7 by visiting the following link: http://www.microsoft.com/windows/compatibility/windows-7/en-us/default.aspx
     
    I hope this helps.
     
    Kind regards
    Syed
    Answers from Microsoft supports the engineer.
  • When I take a screenshot by pressing the print SCREEN key on my keyboard, I can't get a screen shot in small size, in a Word document.

    Original title: screen printing.

    Hi supperman.

    I have a problem with the screen capture. When I take a screenshot by pressing the print SCREEN key on my keyboard, I can't get a screen shot in small size, in a Word document.

    someone knows the reason for this? How can I get a screenshot in a normal size. Thank you very much.

    Hi tony.wang,

    If you copy the screenshot in a Word file, it will be the default page of the word file size. It will be in a smaller size to fit into the Word file.

    However, if you want to open the full-size screen capture, you can use Microsoft Paint on Windows application.


    Reference:
    Overview of Microsoft Paint

    Hope the helps of information.
    Please post back and we do know.

  • PC/tablet-is there a laboratory touchscreen top that works on windows 7 / 8, where the screen can detach the keyboard to use in the form of tablets, or screen can be reached for keyboard vertically or horizontally?

    Labtop / Tablet question -I'm shopping for a new Labtop.    Is there a laboratory touchscreen top that works on windows 7 / 8, where the screen can detach the keyboard used in the form of tablets and then transformed (with long vertical side) and attached to the keyboard to type a length full page (8.5 x 11 page) and then returned (long horizontal side) one attached to the keyboard (to be used as a stand) for a movie with all the features of present characteristics of a top laboratory such as 4 to 8 GB memory and a 500 GB hard drive (perhaps as part of the screen or connected to / through the keyboard, if it is used as a docking station)?

    It seems with all the technology of the tablet on the market that Microsoft or somebody would do something like that now.  Can someone help me? Thank you

    -Scott M

    PS: My wife has an ASUS transformer where the screen detaches from the keyboard, so it can be used in the form of tablets.  When it is attached to the keyboard, the keyboard acts as a stand to sit on the counter for watching movies.  And then the keyboard and the screen can fold them together, so when it is closed there is a stand-alone case. This, however, runs the Android operating system.  Basically, I want this same design (for the potability in a Briefcase), but with it running Microsoft Windows so it can be used as any other labtop.  It the keyboard could have a number pad are associated with, that would be a bonus.

    Hi pr-e-s,.

    You can check with asus.

    http://us.Acer.com/AC/en/us/content/home

    http://us.Acer.com/AC/en/us/content/group/notebooks

    http://us.Acer.com/AC/en/us/content/group/notebooks

  • Is there anyway to customize the screen to "play" when you create the project responsive for Tablet and mobile?

    Hello

    I was wondering if there is an easy way to customize the screen button "play". Currently, when the project is considered on the mobile, it displays the button on the large central room with the gesture icon in the upper right. Essentially my client do not like this, and although they don't have a landing page before moving in the course, they would prefer the page to be better integrated in the style of running. Basically, I want to put this page in a title page that shows a picture of background rather than having a white background all.

    I had a glance through the preferences and settings and have failed to find anything, so I thought I'd come and ask here see if someone else has done something similar before you start messing around with the release of HTML5.

    Any ideas or solutions would be very welcome!

    Thank you

    K

    Publish fewer setting/start and end, if you deselect the AutoPlay option, you can navigate to a picture that you want to use.

  • How to reference clips video parent/child with event handlers?

    I wonder how to reference correctly clips video parent/child, creating event handlers?

    I have a button in a movie clip, which is located in a clip.

    That's what my manager looks like now:

    This. DropMenus.DMSeats.ButtonSeats.addEventListener ("click", SeatsOver);

    The button instance name is ButtonSeats

    It is, I get this:

    TypeError: Error #1009: cannot access a property or method of a null object reference.

    Any idea where I could go wrong?

    Also, if I were to move the listener to drain directly into the clip where the button, how could I make reference to the parent/parent timeline (the main timeline)? Am I right to understand that .This refers only to the current clip?

    Thank you!

    You can place your code in a function that is called when your objects exist.

  • With the help of a keyboard event to play a different scene

    I want the user of my game to be able to press the space bar and to be considered as a new scene. I know how to do this with a button, but I can't understand the code to use for a keyboard event.

    Can someone help me understand how pressing the SPACEBAR reading a new scene?

    If the intention is really to stop at these images, use gotoAndStop(), gotoAndPlay() instead.  If you say something to gotoAndPlay where it already, is any stop() command that you could have in this context is already sold out, to run.

  • Capturing keyboard events?

    How is it possible to listen to keyboard events, as the depressed return key?  I understand the class ReturnKeyType does not yet work for the QNX InputText component, but even when it's that I'm not sure it will include keyboard events or if it will just be a Visual change to the BACKSPACE on the keyboard.

    I intend using the class flash.text.TextField (for portability) instead of qnx.ui.text.InputText.  Currently, the keyboard will activate and disappear the flash.text.TextField receives or loses the focus.  However, these text fields are the fields of data entry, so I would listen to the back of the key on the keyboard so that I may as well save entered data and remove the keyboard of the screen - or perhaps more simply, just leave the text field to listen to when it loses focus to save the data and allow the keyboard to disappear.  But how do I activate either by pressing back on the keyboard?

    Hey David,

    You can achieve this by using a listener to listen to the keys on your input object as a textfield and response following which keys are pressed. in your case you would listen for the Enter key and perform your actions like taking the focus and the keyboard on the screen. You can use the program below as a reference as to how this can be done:

    package
    {
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import flash.events.KeyboardEvent;
        import flash.text.TextField;
        import flash.text.TextFieldAutoSize;
        import flash.text.TextFieldType;
        import flash.ui.Keyboard;
    
        [SWF(width="1024",height="600",backgroundColor="#CCCCCC",frameRate="30")]
        public class TextFieldTest extends Sprite
        {
    
            private var myInput:TextField;
    
            public function TextFieldTest()
            {
                super();
    
                // support autoOrients
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
    
                myInput = new TextField();
                myInput.width = 300;
                myInput.height = 50;
                myInput.type = TextFieldType.INPUT;
    
                /*
                 * listen for what keys are being pressed and react with
                 * onKeyDown function
                */
                myInput.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
    
                addChild(myInput);
    
            }
            private function onKeyDown(e:KeyboardEvent):void
            {
                /*
                 * You can listen for any key presses under the
                 * flash.ui.Keyboard class. it has all the constants
                 * such as .ENTER, .END, etc
                */
                if (e.keyCode == Keyboard.ENTER)
                {
                    trace("You just entered");
    
                    /*
                     * Steal focus away from the textfield object
                     * focus can be set to anywhere and the keyboard
                     * will disappear
                    */
    
                    stage.focus = null;
    
                    /*
                     * Perform other actions such as saving data
                    */
                }
            }
    
        }
    }
    

    hope that helps. Good luck!

  • Sniff for PrintScreen. In Windows 8 blocked keyboard events, monitor what task is to the point.

    In God we trust.

    Good day, everyone.

    My application designed to block the screen capture. It is based on the events of keyboard hook.

    In Windows 8 my callback function is not called, when the monitor of the task is in short.

    I save my callback function with:

    lowLevelKybdHook_ = SetWindowsHookEx ( WH_KEYBOARD_LL, (HOOKPROC): MyCallbackFunction, hInstance, 0);

    It works perfectly in Windows 7 for all cases.

    Windows 8:

    -He works when the monitor of the task is not open.

    -It works, when Task Monitor is opened, not to the point.

    -It does NOT works when the monitor task in short, i.e. my callback function is not called when the task to monitor is the currently selected window.

    -Continue to work (to be called), when the monitor of the task is not to the point.

    I tried to use RegisterHotKey instead SetWindowsHookEx, it has the same effect.

    Any idea?

    Thank you in advance,

    Israel

    PS: I see the same effect with Microsoft Spy ++.
    Keyboard events are blocked, when Microsoft Spy ++ open and in focus.

    Hello Israel,

    Welcome to the Microsoft community.

    Your question of Windows is more complex than what is generally answered in the Microsoft Answers forum. It is better you post the same query in the Microsoft Developer Community. You can get more effective suggestions and adapted by experts familiar with this topic.

    You can also consult the following link:

    https://social.msdn.Microsoft.com/forums/en-us/4cda8492-df2e-4D6F-8eee-4b85c491a493/packet-sniffing?Forum=netfxnetcom

    Hope the helps of information. Let us know if you need help with Windows related issues. We will be happy to help you.

    Thank you

  • Global keyboard event listener?

    Is it possible to create a global keyboard event listener that is unrelated to a window, button, or other user interface element?  The best I could get to add the event to the window listener.  This only works if the window is active.  If the user clicks outside the window and then the receiver for the keyboard does not work.  In addition, when the dialog box appears first of all, it won't work until after the user has made some type of interaction with the window.  I want is to have keyboard shortcuts for users that work regardless of the place where they clicked on the screen, even if the dialogue window is not 'active'.  Is this possible?

    Here is the code I use to the receiver of keyboard for the window.

    mywindow.addEventListener ("keydown", function (k) {keyListen(k)});
    function keyListen(k){if(k.keyName=="Z"){alert("Do stuff here");}}
    

    I don't think that you can create listeners of world events, as for the first appearance of the dialog box, I solved this problem in my script: scripts buliarca BCM_ExtendShortcuts UI by a button activates the event listener to this button. A problem with attach listeners to window, it's in CC2015 events can only be attached to controls and not windows. Setting for windows works in CS6...

  • sequence of images, add the keyboard event loop?

    Hi all

    I have a sequence of 3d images that I want to run with the mouse and drag.

    So far I succeeded with that.

    Also added keyboard event.

    stage.addEventListener (KeyboardEvent.KEY_DOWN, keyPressed);

    function keyPressed(event:KeyboardEvent):void
    {
    If (event.keyCode is 39)
    {
    images_mc.gotoAndStop (images_mc.currentFrame + 1);
    }
    Else if (event.keyCode == 37)
    {
    images_mc.gotoAndStop (images_mc.currentFrame - 1);
    }
    }

    I tried looping event, that is, playing continuously until the button is pressed.

    Help, please.

    Thanks in advance.

    function keyPressed(event:KeyboardEvent):void

    {

    If (event.keyCode is 39)

    {

    If (images_mc.currentFrame<>

    images_mc.gotoAndStop (images_mc.currentFrame + 1);

    }

    else {}

    images_mc.gotoAndStop (1);

    }

    Else if (event.keyCode == 37)

    {

    {if(images_mc.currentFrame>1)}

    images_mc.gotoAndStop (images_mc.currentFrame - 1);

    }

    else {}

    images_mc.gotoAndStop (images_mc.totalFrames);

    }

    }

    }

  • Help with keyboard events

    Hi, I'm a rhythm box design in flash pro Cs6 actionscript 3.0 and I am trying to add a keyboard event that will trigger a key event that I have created loan, I can create the event to play the sound, but is not what I want, can I call for the button click event moves on the key event triggering the sound Here is an example of one of my buttons... code btn, thanks if anyone can help.

    import flash.events.KeyboardEvent;

    /*

    playsound2.fla

    PlaySound with additional features:

    Added TextBox.

    Display the ID3 information

    */

    btn.addEventListener (MouseEvent.CLICK, playSomeSound);

    function playSomeSound(e:MouseEvent)

    {

    var req:URLRequest = new URLRequest ("Savage.mp3");

    var s:Sound = new Sound (req);

    s.addEventListener (Event.COMPLETE, onSoundLoaded);

    s.addEventListener (Event.ID3, onID3Info);

    }

    function onSoundLoaded(event:Event):void

    {

    var localSound:Sound = event.target as Sound;

    localSound.play ();

    }

    function onID3Info(e:Event):void

    {

    var id3Props:ID3Info = e.target.id3;

    var sOut:String = txt.text = "";

    for (var propName:String in id3Props)

    {

    sOut = propName "=" + id3Props [propName] + "\n";

    trace (sOut);

    txt.appendText (sOut);

    }

    txt. Text = id3Props.comment;

    }

    var ba: ByteArray = new ByteArray();

    var gr:Sprite = new Sprite();

    Gr.x = 5;

    Gr.y = 50;

    addChild (gr);

    var time: Timer = new Timer (50);

    time.addEventListener (TimerEvent.TIMER, timerHandler);

    Time.Start ();

    function timerHandler(event:TimerEvent):void

    {

    SoundMixer.computeSpectrum (ba, false);

    var i: int;

    Gr.Graphics.Clear ();

    gr.graphics.lineStyle (2, 0xFF0000);

    gr.graphics.beginFill (0x00ff00);

    gr.graphics.moveTo (10, 10);

    Draw a circle. ;

    var w: uint = 15;

    for (i = 0; I < 512; i += w)

    {

    var t:Number = ba.readFloat ();

    var n: Number = (t * 200);

    gr.graphics.drawCircle (i, 0, - n);

    }

    }

    You can use the following to trigger your button event:

    btn.dispatchEvent (new MouseEvent (MouseEvent.CLICK));

  • Strange problem with the keyboard event listener

    I have a full screen touch app. To close the application, I set an event listener on keyboard for the key "0". I don't want the press user due to some restrictions Alt + F4 key combination. Problems begin when the application loses focus. Here's the code;

    protected function onComplete(event:FlexEvent):void
    {

    this.setFocus ();
    this.addEventListener (KeyboardEvent.KEY_DOWN, trapKeys, true, 0, true);

    }

    private void trapKeys(e:KeyboardEvent):void {}

    If (e.keyCode == 96) {}
    This.Close ();
    }

    Else if (e.keyCode == 48) {}
    This.Close ();
    }

    }

    When the user change the screen to a different with Alt + TAB application, or any other combination of keys flex app loses focus and does not work when he turns back to my app "0". How can I solve this problem?

    Thanks in advance.

    Hi, Ahmed.

    I have absolutely no problem with the solution you are trying to set up - you use mode full-screen interactive mode of keyboard?

    Please consider:

    on full add keyboard listener

    protected function applicationCompleteHandler(event:FlexEvent):void

    {

    this.stage.addEventListener (KeyboardEvent.KEY_DOWN, trapKeys);

    };

    //

    protected function applicationActivateHandler(event:AIREvent):void

    {

    If (this.stage)

    {

    switch the State to display full-screen when activated

    If (this.stage.displayState! = StageDisplayState.FULL_SCREEN_INTERACTIVE)

    {

    this.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

    };

    };

    };

    //

    private var exitHandled:Boolean = false;

    on NUMBER_0 | NUMPAD_0 exit-close

    protected function trapKeys(event:KeyboardEvent):void

    {

    If ((event.keyCode is Keyboard.NUMBER_0

    || event.keyCode is Keyboard.NUMPAD_0)

    (& this.exitHandled == false)

    {

    exitHandled = true;

    this.stage.removeEventListener (KeyboardEvent.KEY_DOWN, trapKeys);

    This.Close ();

    };

    }

    (Note: applicaton of the events 'applicatonComplete' and "applicationActivate" are routed to over managers)

    Kind regards

    Peter

Maybe you are looking for

  • time of release

    my unit locked since February and have still not unlocked. is it possible that you can speed up the progress? Contact your service, just ask me to wait two and a half months already, ask me always wait.

  • In FF 6 what happened to the ability to save all the open compressed under a bookmark?

    FF6 running on my PC and FF5 on my netbook. Don't seem to have the ability to save all tabs open under a single bookmark. What happened to this option? It is very useful when planning travel, for example, when all the hosting options can be collected

  • data has been replaced before it can be read by the system

    Hello I use a flow sensor that creates a frequency output and which connected to my PCI-6035E. When I run it, it works for a few seconds and then gives an error. Error 200141 ' data has been replaced before it can be read by the system. " I also test

  • Downgrade/reinstallation of Windows 7 to Vista

    I have recently upgraded to Windows 7. I want to reinstall Vista, because I found that it is not possible to downgrade. How can I find my ID/product number, old files activation key?

  • Over the Air (OTA) authentication .htaccess .htpasswd 401 error

    Hello I have a signed application for Blackberry build against v4.7 OS and OS v4.2. I've successfully installed on a site to download OTA (file .jad + individual .cod files). User can download and install via the web link. The problem is I'm trying t