Canvas - control the object with the keypress js function

Hello

I'm trying to help CC Flash and HTML5 Canvas control a ball (instance name ball_mc) on stage with the arrows using JS. Tried some variations, but not luck. Any suggestions?

Ty

this.addEventListener ("keypress", keyDownHandler.bind (this), true);

function keyDownHandler (event) {}

Get that touches the user presses

key var = event.which;

switch (key) {}

case 37: / / key left

move the 1 ball left by subtracting ballX 1

This.ball_mc.x-= 1;

break;

Case 39: / / right button

move the ball 1 just by adding 1 to ballX

This.ball_mc.x += 1;

break;

}

Hello

You can try the following code. This will help you get the desired on the key downwards movement.

document. OnKeyDown = keyHandler.bind (this);

function keyHandler (event) {}

var e = event | Window.Event;

switch (e.keyCode) {}

37-case:-this.ball_mc.x = 1;

break;

Case 39: this.ball_mc.x += 1;

break;

}

}

Thank you

Sangeeta

Tags: Adobe Animate

Similar Questions

  • How can I control the Visual effect with the Camera class?


    I checked the document:

    http://help.Adobe.com/en_US/AS3LCR/Flash_10.0/Flash/Media/camera.html

    But still can't find any information on how to control the Visual effect (like brightness, saturation and so on) my pc camera.

    This kind of work is possible with actionscript?

    You can't unless the manufacturer of the device has an API available for him.
    There is no possibility to control the native camera functions by default.

  • Toolbox for CreateJS: how to control the main timeline from outside the canvas.

    Hey everybody,

    I'm currently doing something simple, but my animation film breaks whenever I try to change my code. I created a basic animation in Flash where an object moves from the left side of the canvas, to the right and then loops of the last frame of the first image. Nothing else. The animation is simply placed on the main timeline. I exported the animation with the Toolbox for CreateJS through the extension of the Flash and animation series as it should. I'm trying to start and stop (reboot of the first image) the animation with the mouse on and off mouse events. I want that the events to fire when wriggling over/stop a div outside the animation canvas tag. Is this possible with CreateJS? I'm trying to find a way to control the main timeline without being inside the canvas tag.

    HTML example:

    http://www.thephotoncore.com/testing/example_test.html

    Example Code:

    < id article 'container' = >

    < canvas id = "canvas" width = "550" height = "400" style = "background-color: #cccccc" > < / canvas >

    < section id = "animation_control" >

    < p > hover over to start and stop animation. < /p >

    < / section >

    < / section >

    Thanks again for the help!

    -DJ

    Hi DjPhantasy5,

    All the clips on the scene are children of the scene,

    So now the "mouseover" all clips on the stage could be stopped with stop and on the "mouseout/mouseouthandler()" all the children could be restarted with gotoAndPlay like this:

    function Stop()

    {

    If (stage & stage.children)

    {

    var t = stage.children.length;

    for (i = 0; i< l;="">

    {

    child var = stage.children [i];

    If ('stop' in child)

    Child.Stop ();

    }

    }

    }

    function Restart()

    {

    If (stage & stage.children)

    {

    var t = stage.children.length;

    for (i = 0; i< l;="">

    {

    child var = stage.children [i];

    If ("gotoAndPlay" children)

    child.gotoAndPlay (0);

    }

    }

    }

    See http://www.liauw.nl/forums/adobe/djfantasy5/index.html

    But it is also possible to expose "ball1", for example, by adding it to the document.

    This can be done by adding the code for "ball1" as follows:

    / * js

    document.ball1 = this;

    */

    Then stop the animation would look like:

    function Stop()

    {

    If ('ball1' in the document)

    document.ball1.stop ();

    }

    etc.

    Have fun!

    Ronald

  • Control the transparency of null objects

    Is it possible to control the transparency with a null object. I know that you can scale, rotate etc but I have no luck with transparency. Is there a work around?

    You can whisk the attribute of the opacity of the layer you want to order to the opacity of the null value attr.

    (1) select the layer draw and the layer that you want to control and press T to expose the attributes of opacity.

    (2) alt + click on the stopwatch for the opacity of the layer you want to be a slave (the opacity value should turn red & the expression will prove controls)

    (3) click on + drag the spiral to the attribute of opacity of the null value.  (in the layers slave expression field you should see something like "thisComp.layer("Null_1").transform.opacity")

    4) click on the layer to exit the field of expression.

    (5) If you want to disconnect alt click on the stopwatch for opacity of layers slave again.

  • Why is it not possible to use SIRI on my apple TV remote to control the HomeKit products? I should be able to control all the devices with my Apple TV remote and SIRI HomeKit!

    Why is it not possible to use SIRI on my apple TV remote to control the HomeKit products? I should be able to control all the devices of HomeKit with my SIRI voice remote control and using Apple TV!

    If the new apple TV can act as a concentrator HomeKit and I use SIRI on my iPhone to control my locks, thermostat, lights, etc. Why am I not able to do the same thing with SIRI via voice commands on my Apple TV remote? When is this going to work?

    Also, when Apple will come out with a response to the echo of Amazon? I've tired to wait... do it already! If you build it, they will come...

    Thank you!

    This is a community to a user, and Apple will not see your rant. If you have suggestions about Apple TV, Siri and HomeKit the best thing to do is to submit your comments here. http://www.Apple.com/feedback/AppleTV.html

  • Do not display the SVG objects with the effect of filter &lt; feSpecularLighting &gt;

    When I open a file Scalable Vector Graphics (.svg) in Firefox, all objects with filters that contain the < feSpecularLighting > filter primitive, are not displayed at all, and in rare cases, even cause Firefox crashes.

    For example:

    It must be rendered like this:

    In order to get the SVG file to render as PNG, you must edit kernelUnitLength of 0.01 to about 1.0 (or delete). Don't know if something might have changed in the way Firefox handles this attribute to cause such a radical difference.

    I should test in a clean profile to see if I get the same result...

    Edit: Same result in a clean profile, i.e. without extensions or changes to the default factory settings.

  • I connect my macbook pro to monitor via HDMI, but there is no sound control can do with the macbook, can you help me

    I connect my macbook pro to monitor via HDMI, but there is no sound control can do with the macbook, can anyone help?

    You must use the volume control on the monitor. That's how Apple means yo do and does not provide any method using Mac

  • Satellite M100 with Debian - how to control the power and the cooling fan on

    Hey,.

    I M100 and I installed debian, works very well, but there is a problem.
    Cooling fan turns on the top speed of all time. I m not shy on unix.
    How can I control cooling fan?
    How to control the power to the laptop?

    Hi mate,

    have you ever heard of the toshutils? I highly recommend trying these tools. Just google for toshutils and you'll find a few nice applications. Should usually be included in the distribution you have, also, I would check with 'apt - get search toshutils.

    See you soon

  • Volume adjusts at random. Cannot control the volume with other software, ie iTunes.

    I have a HP Pavilion dv7-7000 Quad. The music playback volume goes up and down. Also, I can't control the volume in itunes or winamp. If I turn the volume in itunes there for a while, but back down. When I turn the volume to 1% in itunes, it says there for a few seconds and it slowly rises to the top.

    I tried a lot of things trying to get this problem resolved and spent over 2 hours with HP tech rep:

    1 uninstall the audio driver, restart, install the driver.

    2 bios flash

    3 reinstall the sound driver using HP Recovery Manager

    4 Windows repair.

    5 Chkdsk

    The only thing that worked was

    Uninstalled the audio driver in Device Manager and is looking for new devices and installed windows automaticlly refreshment and it fixed the issue... * beep *? I had my helmet in the decision-making when the driver installed.

    I'm afraid to turn my computer off now.

  • Control the Structure of the event with text file

    I'm new relativaly in LabVIEW (experience only about 2 weeks). I am currently control a stepper motor using a structure of the event. Similar to the sample code given by LIFA, I entered my settings how the engine not move away, then press a button on the windows before, and it works this way. I also have other equipment that works as well in LabVIEW, as a transnational step; all components operate individually.

    Now, I'm trying to make the more automated system and to ensure that all the different equipment work in the same code. So, I tried to implement a structure of the event using a text as an input file to try to control events. The text file has a table 1 d of numbers going down vertically (only the line numbers change). So, I used a table of index function to take the numbers one by one, use a loop (while loop in this example) to go to the bottom of the column of numbers. However, the event not register the change, even if the indicator shows the value is changing.

    Attached, it's my test code and the text file that I use to try to control the structure of the event. Please let me know what I am doing wrong. Thank you.

    Oh, now I understand what you tried to say. I'm using a loop and a case structure to activate different events with the entries in the table. I thought case structures and event were the same, but you taught me the event structures are used just for the façade stuff. Thank you all!

  • Get the hDC for a Canvas control

    Hello

    I have a DLL that takes a hDC parameter, which is then 'draw' something using Windows API. An example of this can be the function WinSDK TextOut (HDC hdc int nXStart int nYStart LPCTSTR lpString int cbString).

    How could I get the hDC to a Canvas control or another control (not the Panel) in order to use these functions?

    Also, are there caveats to be aware of?

    Kind regards

    Jason.

    As far as I know, CVI controls are not windowed controls, so they do not have their own window handles and you cannot get a handle to the device context for them. It goes same for children signs CVI. You will only be able to get a handle to the device context for the main table covering.

  • How can I control the speed of the piezo BPC203 with Nanomax-TS 311D/M

    I use the BPC203 to control the movement of the nanomax 311D/M. Stadium I was able to change the position of the scene depending on the size of level by writing code in labview using the ActiveX control. I need the code to control the speed of the movement of the scene, for example, if the size of my step is 1 micron, I want to point to less possible speed Steplessly no (say 10 seconds to move this step size). I realized that the scanning speed could control the entrance to Piezo voltage it by speed and called "setslewrate" method to call node of the piezo and adjust the speed of scanning of loop closed as 0.75 (I assumed here units are: V/s not volt/milliseconds) and waited for the loop to go slowly with my scanning speed that I have not connected the hardware to the labview but the loop runs with processor speed not with the scanning speed. does it in fact possible to simulate the scan rates in Labview without hardware integration? Is there an another mentod for controlling the speed of Piezo? The answers are very welcomed. Please find a block diagram image FYI rasthaus...

    Hi Sara,.

    I have a few suggestions. The first is that you have a parallel loop that does the same thing as your initial loop, but change the channel so that it works with the direction of Z.

    Alternatively, you could create a new VI dealing with your direction of Z. Then, you can create void VI on your 2 vi. Then call your sub VI a VI main run one after the other. Here is a labview help link that shows you how to create sub screw: http://zone.ni.com/reference/en-XX/help/371361J-01/lvconcepts/creating_subvis/

  • How to control a VI (with a while loop and a structure of the event) from an another VI

    Hello

    I have the main VI which I want to be driven from an another VI. But I can't do that and I don't know what is happening.

    For example: VI main, I have a while loop with a structure of the event, there is a Boolean controller controlling a Boolean LED, which is inside the structure of the event. And the other VI, there is just a Boolean controller and functions of applications to open the main VI.

    How can I control the Boolean LED in VI main, changing the State of the Boolean controller in an another VI?

    Thank you.

    There are different options, but depending on what you want to do. For this example I can't give you a specific solution.

    I do not understand why you do what you do. Why do you call your 'principle VI' dynamically? What is the advantage to do? There are also other ways to call a VI dynamically, based on real cases (for example the method "call and forget", etc...).

    In you principle VI, control you Boolean ("THATCHER") is not the case of corresponding event. This is not usually a good practice, keep it inside.

    Also, why you try to communicate with the caller and callee VI through such a way to twist? There are better ways to do it.

    In one of my projects, I use the user event to launch orders in case of case of appellant VI.

    some Associates more readings for you:

    http://www.notatamelion.com/2015/03/23/how-to-make-dynamic-subvis/

    http://forums.NI.com/T5/LabVIEW/Dr-Damien-s-development-event-structures-III-communicating-with/m-p/...

  • [Bug of LabVIEW report] 'Create all the constants' does not create a constant for the controls when mixed with flags

    The shortcut of the comics 'Create all the constants' cannot create a constant to a control when it is mixed with flags:

    Colors of the palette is a table control, the other two are indicators.

    results in:

    With the help of the 'constant to create' (which is something else altogether) works very well with the table control (of course, the constant is not connected to the Terminal in this case).

    Tested in LV 2016 64 bit on Windows 7

    You can change the functionality of the right click plugin by opening the Terminals_core.vi all the wires in the .llb following and by removing the structure of matter on the image below (keep remove it just method the structure around him). He did what you wanted in the original post, but is not very useful when you start to use it on items with multiple terminals (especially multiple output terminals). The code makes it seem quite expected, he travels all terminals it concludes and checks whether it is an input or output terminal. If it's an entry, it creates a constant, if it is an output, it does nothing. The change that I did just creates a constant whether it is an input or output.

    time Board \resource\plugins\PopupMenus\edit and diagram\Wire all Terminals.llb Unwired

  • Just upgraded to Vista Home Premium to XP. Got a Packard Bell with RF for the Media Center remote control, worked fine with XP, but is no longer compatible with Vista.

    after update to XP media center units Vista remote control

    Just upgraded to Vista Home Premium to XP.  Got a Packard Bell with RF for the Media Center remote control, worked fine with XP, but is no longer compatible with Vista.  I checked the usb driver for the usb XF-10 rf remote receiver and it is fine, uninstalled and reinstalled it.  Handset was working fine a few days ago.  I also went in 'Administrator', 'services' and then active HID, but it still does not work.  Media works well, but it would be nice to have the operation of the remote control!  Not particularly computer, simply suggestions please!  Thank you, Nick.

    Hi Nicolas,

    I suggest you to check the battery. Additionally, make sure that you have installed the right drivers for you Consumer IR Port.

    For more information, you can check the link below,

    http://www.PackardBell.com/index.html

Maybe you are looking for

  • Why I have to sign in to IgHome every time I open my browser?

    I have two computers, one with xp and one with win 7. On xp, I open my browser and am ready to go. I click on gmail and my mail is opened. ON win 7 I have to connect to customize igHome and then signed to gmail to get the job. As the case with everyo

  • Toshiba stor.e 1 TB HARD drive no longer works

    Hi all I have a new Toshiba stor.e 1 TB HARD drive and was transfer photos and music to it and all was fine, I ejected it but when I plugged it back I get the message: F: is not accessibleData error (cyclic recovery control) A quick search and it say

  • XY graph tracing

    Hi all I had a program where I read ascii file delimited by tabs, two-colum.  The first column contains X values.  The second column contains values Y. I would like to build a program that traces on the XY trace and returns the last value.  Everythin

  • How to insert an image in Wordpad?

    Anyone have any suggestions on how to insert an image in Wordpad? Thanks in advance for your suggestions

  • Z10 BlackBerry App world

    World of app in my z10 stopped to open, what can I after restarting does not help?