Move the object for a certain interval of time

Hello, I am working on a tile set based, and currently I'm trying to fix the movement. I want to make is that my character moves easily for a fixed amount of time. I could not be explaining my self very clearly, but I want to do something like this:

function keyPress(event:KeyboardEvent)

{

If (event.keyCode is Keyboard.RIGHT)

{

Moves 25 characters pixels to the right smoothly.

}

}

Hope I did understand, any help is much appreciated

Here's a way to move a key maintained, but it will not help if someone starts to sting the key since you have a timed speed movement.  To overcome that you'd have to have a listener for the interpolation, which contains a similar restriction / control...

var rightDown:Boolean = false;

stage.addEventListener (KeyboardEvent.KEY_DOWN, keyPress);
stage.addEventListener (KeyboardEvent.KEY_UP, keyRelease);

function keyPress(event:KeyboardEvent)
{
If (event.keyCode is Keyboard.RIGHT)
{
if(!rightDown) {/ / only allow the interpolation occurs when the key is pressed first}
rightDown = true;
Tween here

}
}
}

function keyRelease(event:KeyboardEvent)
{

reset the command when the key is released
If (event.keyCode is Keyboard.RIGHT)
{
rightDown = false;
}
}

Tags: Adobe Animate

Similar Questions

  • How to rotate objects for a certain period of time

    h

    Animation of basic skills. You must rotate in the timeline panel, click the stopwatch to activate animations for this transformation. Create a startup key image if it is not already done. Move head to play the ending time, rotate your object and the keyframe of the judgment must be created.

    Much easier to do than to read or post.

  • Maintain a solenoid open for a certain period of time

    Hello

    I have a NI 9472 with a solenoid attached. I developed a simple vi to operate the solenoid valve (normally closed) when a preset pressure (i.e. pressure) is reached, that is, the valve opens when the pressure exceeds the set value and closes when it falls below the set value.  However, what I really want the vi to do is open the tap for a certain period of time (say 1 dry), so that the built-up pressure may be entirely liberated before the tap is closed, so pressure is composed from zero again and the cycle repeats. I have read some threads already, but I haveen can't has found an answer that works for my application. Please check and looking forward for your help!

    Try this... Make sure you put a wait function in your loop, otherwise you use 100% of your CPU

  • Cannot move the object

    Hello

    I scanned a drawing that I place on it's own layer from the office, he was directly drawn, expanded and consolidated.

    When I select to move it, either using the arrow keys or the transformation/move command, I get a message that I've ever seen before "cannot move the objects. "The requested transformation would make some objects fall completely the drawing area.

    Could someone explain what it means?

    Thanks for any advice.

    Occurs usually when you have a wandering point or a selected guide. Zoom out all the way. You have something that is going to the grey area (outside the mount table) completely.

  • We have installed Office 2010 on a system that died & want to move the software for my new system. How to reactivate my product key Code

    We have installed Office 2010 on a system that died & want to move the software for my new system.  How to reactivate my product key Code

    Assuming that you had bought a copy of the sale at retail of Office 2010 (i.e., it not was not preinstalled by the manufacturer of the computer or downloaded and installed using a "product key card"), just install it on the new system and turn on normally.  In some cases, you may use telephone activation and explain the circumstances (i.e., the old computer is dead).

    Microsoft Office is not a step "off authorizes" as some other apps (Adobe comes to mind).

  • Where can I get a list of the updates released for Windows 7 for a certain period of time?

    Where can I get a list of the updates released for Windows 7 for a certain period of time, without resorting to the use of windows update program, and having in mind that the list updates installed locally, no full

    Oh, this https://technet.microsoft.com/en-us/windowsserver/bb332157.aspx?f=255&MSPPError=-2147217396 is exactly what I need, thank you very much!

  • I opened a high-density .tiff file in photoshop, but I can't move the object

    I opened a high-density .tiff file in photoshop, but I can't move the object

    Chances are that the image is the same size as the document. You can either add Web Image > canvas... size , use the crop tool and do drag outwards to create more space, or reduce the size of the image ctrl-t or command-t then scale the image inward.

  • I'm on a Mac and run creative cloud in my office and at home. When I'm at home whenever I run a creative program of clouds, such as InDesign or PhotoShop, he asks if I want to start a free free use for a certain period of time. Why is he asking me t

    I'm on a Mac and run creative cloud in my office and at home. When I'm at home whenever I run a creative program of clouds, such as InDesign or PhotoShop, he asks if I want to start a free free use for a certain period of time. Why he asked me this when I'm already a user, pay a subscription and said can I use my account on 2 machines?

    Hi Dwayne,

    Please see Troubleshooting FAQ: what should I do if I have a subscription, but my application acts as if I had a trial?

    License FAQ: Can I install Creative Cloud on several computers?

    It could be useful!

    Rayyan

  • Definition of the object for movies Styles

    Hello!

    In the ExtendScript API, movie, I can see a property called appliedObjectStyle (which is similar to that for images). But when I try to apply an object style to video, InDesign does not. The object Style Panel is disabled and there is no way to select an object style. Because this type of property has been listed in the API, I suppose it's possible to do. Could someone help me with affixing of an object style to the movies?

    Thank you.

    See this thread:

    Re: Place multiple images in a container (rectangle, oval, polygon)

  • Move the object centerpoint

    I would like to create a series of numbers in a radial chart for an indicator of speedometer. It should be fairly easy to create a number, move the center point to the middle of the dial and then run a certain number of degrees. But it is desperately difficult. I was also told to use Parent and create a small object in the Center and use layers for numbers of parents. I do not see how things to a parent or who carry out.

    Anyone have any suggestions?

    Thank you!

    Andacar

    Do you want the numbers to stay oriented vertically or follow the Ark? After the arc is not a problem, maintain the vertical alignment is more delicate.

    For the text rotated:

    1. First point position in place text object (12:00 position works well).
    2. Object text selected, choose "rotation tool" and Option + click on in the center of the dial
    3. Degree of rotation of type and click 'Copy' (to calculate the type of rotation 360 / [dial positions number] and press "Tab".) I will return extra degree).
    4. Press 'Cmd + D' to duplicate the last action until all text objects are in place
    5. Updated text of characters of your choice

    For the text without rotation:

    1. Create the first text object
    2. Convert to symbol
    3. Follow steps 2-4 from above
    4. Select all occurrences of symbols
    5. Click 'Reset' (this is to realign all vertical)
    6. With all instances of the symbol selected, click on "break the link.
    7. Updated text of characters of your choice
  • arrows move the object in opposite directions - default type in vertical orientation

    Hi Illustrator community.

    Two questions were really annoys me and so far I've been unable to find a solution:

    On my Macbook Pro 13, 2012 ", in this version of Illustrator CC (not a problem for other products CC), the arrows are somehow put out: using the left/right arrows moves objects vertically, and using up/down arrow keys moves objects to the left and right." Even if I tried to get used to it, it's really slow me down I checked the preferences and keyboard shortcuts, and unless I'm missing something, there seems to be a setting for this?

    Also when using the standard tool (not the vertical type tool), initially type is placed rotate 90 degrees counterclockwise, and after that I flip back to a horizontal position, I can move and edit fine. Any suggestions?

    Thanks in advance,

    Mark

    Mark,

    Edit > preferences > General > constrain Angle should be 0 degrees.

    If this is the case, Illy may think, it is not, and then she made a mess of things (and perhaps other things, too). In this case, it may be time for the list below.

    Unless you subscribe to the vertical version.

    The list:

    Sometimes, (some) things may fail or stop working for no apparent reason. When (other) possible reasons/remedies do not work, it is perhaps a kind corruption (temporary or permanent), or even preference settings which disturbs, which can be cured with something on the following list put in place in order to provide a catch-all solution for otherwise intractable cases. It starts with a few easy suggestions and safe) 1 and 2) for cases less serious and goes two ways 3) and 4) to reset the default preferences (easily but irreversibly and more laboriously but more completely and also reversible), then follows a list 5) various other possibilities, and it ends with a complete reinstallation 6). If no other suggestion doesn't work, or if no other suggestion appears, you can start on the list and decide how to go or who can apply.

    The following is a general list of things, try when

    (A) the question is not in a specific file,

    (B) you have a printer installed, connected and turned on if it's a physical printer (you can use Adobe PDF/Acrobat Distiller as a printer by default without the need to have a printer on, of course you will need to specify when you really need print on paper), and

    (C) It is not caused by problems with opening a file from external media (see below).

    You tried/made some of them already; 1 and 2) are easier for temporary strangenesses and 3) and 4) specifically may be corrupted/inconvenient preferences); ((5) is a list in itself and 6) is the last resort.

    If possible / there is, you must record a current work first, of course.

    (1) close Illy and open again.

    (2) restart the computer (you can make up at least 5 times);

    (3) close Illy and press Ctrl + Alt + Shift / Cmd + Option + shift during startup (easy, but irreversible);

    4) move the folder (follow the link with this name) with closed Illy (more tedious but also more thorough and reversible), for CS3 - CC you can find the file here:

    https://helpx.Adobe.com/Illustrator/KB/preference-file-location-Illustrator.html

    5 look through and try the relevant among the other options (click on the link with that name, item 7) is a list of the usual suspects among other applications which can disturb and confuse Illy, point 15) applies to the maybe CS5, CS6 and CC);

    Even worse, you can:

    6 (A) uninstall (check the box to delete the preferences, if any), B) run the cleanup tool (if you have CS3/CS4/CS5/CS6/CC) and C) reinstall. It is important to use this step three way: otherwise, things may persist.

    http://www.Adobe.com/support/contact/cscleanertool.html

  • move the object or shift page

    Hello!

    I have a lot of files with x A4 pages.

    At the top right of the pages, there is a box with name and address.

    I can move the box?... I need to translate the box down to a few millimeters...

    Alternatively, move all the contents of the page down (not only the box...)... what I can do in javascript?

    Thank you

    Andrea

    You cannot move content selectively in a PDF using JavaScript. The only way to move programmatically, an object or a group of objects is via a plug-in of Acrobat (written in C or C++). However, you can move all the contents of the page using JavaScript by changing the harvest of your pages and media boxes. Take a look at this script, it shows how this is done. The script moves all content by an inch (72pt). If you need a different distance, you must convert the distance you want to move your content in mm at points. A point is 1/72nd of an inch and one inch is 25.4 mm.

    // move content down by a certain amount
    (function() {
        var a = this.getPageBox("Media");
        a[1] += 72;     // 72pt is 1"
        a[3] += 72;
        this.setPageBoxes({cBox: "Media", rBox: a});
        a = this.getPageBox("Crop");
        a[1] += 72;     // 72pt is 1"
        a[3] += 72;
        this.setPageBoxes({cBox: "Crop", rBox: a});
    })();
    
  • move the object left and right

    Hi, how are you all? I hope you all well...

    Now IAM trying to do more spells for the hero and this spell is the fireball

    I want to spend the time the hero is on the right also leave when the hero on the left

    I tried with this code when you press w it should move 10 or 20 px then it must stop

    but the fact of idont this step "then it must stop" because of this error as the fireball, call

    like I want to

    TypeError: Error #1010: a term is undefined and has no properties.

    Hero / onEnterFrame)

    Here is the code

    HERO class

    package {}


    import flash.display.MovieClip;

    import flash.events.KeyboardEvent;

    import flash.ui.Keyboard;

    import flash.events.Event;

    import flash.sensors.Accelerometer;
    import flash.media.Sound;
    import flash.media.SoundChannel;


    SerializableAttribute public class extends MovieClip {HERO
    var NIGHTJUNGLE:nightjungle = new nightjungle
    var ELECTRICALSHIELD:electricalshield = new electricalshield;

    var speed: int = 3;
    var fireballindex:Array = new Array
    var dir:int;
    var ELECTRICITY: electricity = new electricity;
    var SOUNDCHANNEL:SoundChannel = new SoundChannel
    var firespeed:int = 50
    var i: int
    public void HERO() {}

    addEventListener (Event.ADDED_TO_STAGE, onAddedToStage);

    }

    public void onAddedToStage(event:Event):void {}

    addEventListener (Event.ENTER_FRAME, onEnterFrame);

    stage.addEventListener (KeyboardEvent.KEY_DOWN, onKeyDown);

    stage.addEventListener (KeyboardEvent.KEY_UP, onKeyUp);


    SOUNDCHANNEL = NIGHTJUNGLE.play (1,1000)
    gotoAndStop (4);

    }

    public void onEnterFrame(event:Event):void {}

    x += dir * speed;
    {if (fireballindex [i] .stage)}
    .x += fireballindex [i] 1
    }

    }

    public void onKeyDown(event:KeyboardEvent):void {}

    If {(event.keyCode is Keyboard.RIGHT)

    gotoAndStop (2);

    dir = 1;
    Speed = 10
    If (ELECTRICALSHIELD.stage)
    addChild (ELECTRICALSHIELD)

    }


    If {(event.keyCode is Keyboard.LEFT)

    gotoAndStop (1);


    dir = - 1;
    Speed = 10
    If (ELECTRICALSHIELD.stage)
    addChild (ELECTRICALSHIELD)

    }

    If {(event.keyCode is Keyboard.UP)

    gotoAndStop (1);

    y = 10;

    }

    If {(event.keyCode is Keyboard.Q)

    Speed = 30;

    addChild (ELECTRICALSHIELD);
    SOUNDCHANNEL = ELECTRICITY.play)

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


    fireballindex.push (new fireball())

    addChild (fireballindex [i])
    fireballindex [i] .width = 50
    fireballindex [i] .x += firespeed * dir

    i ++
    trace (i)
    }
    If (event.keyCode == Keyboard.E) {}
    MovieClip (parent).aa.x = x + 100
    }
    }

    public void onKeyUp(event:KeyboardEvent):void {}

    If {(event.keyCode is Keyboard.Q)

    If {(ELECTRICALSHIELD.stage)

    removeChild (ELECTRICALSHIELD);
    If (SOUNDCHANNEL! = null)
    Speed = 0;
    SOUNDCHANNEL = ELECTRICITY.play (1,1)

    }

    }
    If {(event.keyCode is Keyboard.W)


    }

    If {(event.keyCode is Keyboard.LEFT)
    Speed = 0
    gotoAndStop (3);
    If (ELECTRICALSHIELD.stage)
    addChild (ELECTRICALSHIELD)

    } Else if (event.keyCode == Keyboard.RIGHT) {}
    Speed = 0
    gotoAndStop (4);
    If (ELECTRICALSHIELD.stage)
    addChild (ELECTRICALSHIELD)
    }

    }

    }

    }

    Thank you

    I would not use 'i' to target the object of the fireball.  In the case of the fireballs to withdraw at any time, that the value of i will be false.  The fireball that you add may not of fireballindex [i].

    If all the code that goes in the same neighborhood, then I declare the instance var name and use the name...

    var fBall:fireball = new fireball();

    fBall.name = "fb" + String (i)";

    fBall.width = 50;
    fBall.x += firespeed * dir;

    fireballindex.push (fBall);

    addChild (fBall);

    i ++ ;

    Later if you need to target this fireball, you can use the table or you can use its name.

    If you still want to use the non-var approach (I see no reason to) then instead of target

    fireballindex [i]

    I would target the last element added to the matrix who is definitiely going to be

    fireballindex [fireballindex. Length-1])

  • Move the object object vs. copy

    OK, the assistants of the Illustrator, I have another puzzle - it is more often the case (more often) that when I call the command move what I really want to do is to copy the intended purpose x or y inches. The command move has a button for copying, but the default action is to move. Is it possible to change the default action to copy? or y at - it another command I should use? I would like a simple method to make the x - up for printing layouts.

    Thank you!!!

    -g-

    You could grab the object, press the alt key and move it. You can enter a new x-y-value or in the transform Panel, and then press alt + enter.

  • Move the object of class position

    Hello

    I'm looking for how to move an object from its current position to a coordinate _x designated.  I want a current position to a variable which followed where he is currently and travel automatically without having to say move from 24.7 to 35.8, for example. I am usuing tweener mx base classes and would like to keep it this way.  Basically, I create a nav where a point flies in the selection of nav. So the end result is I want the code that says travel to this coordinate _x wherever you are currently.

    Thank you!

    1. it is not the tweener class.  It's the tween class.

    2. you can put all of these on a single line if statements and use an interpolation function:

    navHome.onRelease = function() {     if (navBullet._y == -360 || navBullet._y==-319||navBullet._y==-279||navBullet._y==-237||navBullet._y==-196) {          bulletTween = new Tween(navBullet, _y, Back.easeOut, navBullet._y, -402, 1.5, true);     }};
    
    
    

Maybe you are looking for