AS3: need help to solve a problam function

Hey, I need your help once again.

I have a wheelchair clip that I want to just move left and right in a loop, I have this code:

var wheelChairRightTimer:Timer = new Timer (120,24);
var wheelChairLeftTimer:Timer = new Timer (120,24);

wheelChairRightTimer.addEventListener (TimerEvent.TIMER, moveRight);
wheelChairRightTimer.addEventListener (TimerEvent.TIMER_COMPLETE, startMoveLeft);
wheelChairLeftTimer.addEventListener (TimerEvent.TIMER, moveLeft);
wheelChairLeftTimer.addEventListener (TimerEvent.TIMER_COMPLETE, startMoveRight);

wheelChairRightTimer.start ();

function moveRight(event:TimerEvent):void {}
wheelChair.x = wheelChair.x + 20;
}

function moveLeft(event:TimerEvent):void {}
wheelChair.x = wheelChair.x - 20;
}

function startMoveLeft(event:TimerEvent):void {}
wheelChairLeftTimer.start ();
}

function startMoveRight(event:TimerEvent):void {}
wheelChairRightTimer.start ();
}

The problam is with the last function "startMoveRight". Without this feature the wheelchair goes right and left as he should and everything stops. I added the last function loop the movment, but after the first round of movment left and right (which works well), it seems that all 4 functions are called together so the wheelchair is battery mobile 20 px right and left 20 px.

I know this probably isn't the best way, in other ways, or just a way to fix this will help a lot!

This should do it:

// speed
var vx:Number = 20;

var chairTimer:Timer = new Timer(120);
chairTimer.addEventListener(TimerEvent.TIMER, moveChair);
chairTimer.start();

function moveChair(e:TimerEvent):void {
     wheelChair.x += vx;
     if (chairTimer.currentCount % 24 == 0) {
          // change direction
          vx *= -1;
     }
     e.updateAfterEvent();
}

Post edited by: Andrei1

Tags: Adobe Animate

Similar Questions

  • Warning for Vista: Diagnosis, event id #407 and Vista error: Diagnostics, event #402, need help to solve

    I need help to solve the following issues:

    Warning in the event log: Source diagnosis, event id #407, error #407, 402 # and #408.

    Thank you!

    Julie

    Hello

    1 have had any changes made on the computer before the show?

    2. what exactly is the problem that you are facing on the computer?

    3. What is the full and exact error message?

    4. do you have problems of performance on the computer?

    Method 1:

    Check the link and see if it helps:

    "Error, warning, or critical" events are recorded in the computer a Windows Vista-based Diagnostic Performance/Operational event log

    http://support.Microsoft.com/kb/942910

    See also:

    http://TechNet.Microsoft.com/en-us/library/cc733455 (WS.10) .aspx

    Method 2:

    Check out the links and check if that helps:

    Ways to improve your computer's performance

    http://Windows.Microsoft.com/en-us/Windows-Vista/ways-to-improve-your-computers-performance

    Optimize Windows Vista for better performance

    http://Windows.Microsoft.com/en-us/Windows-Vista/optimize-Windows-Vista-for-better-performance

  • Need help to solve the problem with the margin at the bottom of the converted pdf file.

    Need help to solve the problem with the margin of the converted CEO down. What caused the change in format?

    Hi jerrio1949,

    There is no way to change the margin, you settle back into your original file & then convert to PDF format.

    Kind regards
    Nicos

  • Need help to write a Boolean function

    Hello

    I would appreciate you help for writing a Boolean function!


    Below are the possible expressions:

    ${brand.name}

    ${model.name}

    ${franchise.name}

    ${supercategory.name}

    ${category.name}


    VALIDATE any combination of the expressions above (upper and lower case) in a string.


    For example:

    «It's the best brand of ${brand.name} template category, ${model.name} franchise ${franchise.name} supercategory $ {supercategory.name} and ${category.name} category.»


    If one of the above expressions is incorrect in the string, the function returns error.

    I'd appreciate your kind help!


    Thanks in advance!

    Mustak

    Maybe (watching scary)

    with

    data in the form of

    (select txt "this is the best brand of ${brand.name} of model category ${model.name} franchise ${franchise.name} supercategory $ {supercategory.name} and ${category.name} category".)

    of the double

    Union of all the

    Select txt ' is the best brand of ${Brand.name} of model category ${Modl.name} franchise ${Franchise.name} supercategory $ {Supercategoory.name} and ${Category.name} category.

    of the double

    )

    Select sys_connect_by_path (case when instr (lower (txt),' ${' | level case when 1 then 'brand'}))

    When 2 then 'model '.

    When 3 then 'franchise '.

    When 4 then 'supercategory.

    else 'category.

    end: '. (name}') > 0

    then '1'

    else ' 0'

    end,' ') boolean,.

    txt

    from the data

    where connect_by_isleaf = 1

    connect by level<=>

    and prior txt = txt

    and prior sys_guid() is not null

    BOOLEAN TXT
    1 0 1 0 1 It's the best brand of ${Brand.name} template category, ${Modl.name} franchise ${Franchise.name} supercategory $ {Supercategoory.name} and ${Category.name} category.
    1 1 1 1 1 It's the best brand of ${brand.name} template category, ${model.name} franchise ${franchise.name} supercategory $ {supercategory.name} and ${category.name} category.

    Concerning

    Etbin

  • Need help to solve the problem in valueset...

    Hi all

    I need help in the creation of the set value.
    My requirement:
    I need 2 1. date settings 2. how far
    When I chose the first parameter (to date) ex: 01-01-2010.
    If I chose the 2nd parameter in this one, I need to display equal or superior to that date (i.e., based on the first parameter). that is, grater than or equal 1 January 2010 "this date. Not displaying does not forward then this date.
    With the help of $flex$, we can do this am getting the error.
    You can help me pls to it.

    Thanks in advance.


    Kind regards
    Leelakrishna.G

    Hello

    If you use the value defined in the program settings simultaneously, the only thing to do is go to the simultaneous program settings screen, go to the parameter "Date from" and mark the field Range as low. Then go to the parameter "To Date" and mark the highest field. In this way, the system will not allow the user to enter a "Date to the ' who is older than the 'Date '. It will be useful.

    Kind regards.

  • To AS2 AS3, need help.

    I learned Flash using AS2 and I try now migrate to AS3, but some of the simplest things have changed.  I know I can't put script directly on movieclips now, but I do not know how to use if the conditions to check for movieclips hit some frames, etc.

    Can someone direct me to the tutorials on the displacement of AS2 AS3 and some of the fundamental behaviors of AS3.

    For example:

    If I had a movieclip I used as a button and I tried jumping a specific image when another movieclip on the stage struck a framework?  With AS2, I could simply put a script on the movieclip itself that says something like:

    onClipEvent (EnterFrame)

    {

    If (this ._currentframe is 10)

    {

    _parent.sampleClip.gotoAndStop (2);

    }

    }

    I don't know how to do simple same navigation like this in AS3 code.

    Thanks for the help.

    There are a lot of tutorials and a few great books too. For tutorials that you probably want just a search on any specific problems that you find. Regarding the example you gave, it is a little different in 3 and also better:

    someMovieClip.addEventListener (Event.ENTER_FRAME, checkFrame);
    function checkFrame(e:Event) {}
    if(someMovieClip.currentFrame == 10) {}
    sampleClip.gotoAndStop (2);
    }
    }

    I say better because you don't need to worry about scope as you did in 2 - checkFrame is not executed in the context of the someMovieClip - sampleClip is available directly, you don't need to 'parent' to access.

  • Need help to solve problems on iPad Air2 after updating iOS 10

    Hey guys this is my second post in the forums of the iPad on the same issues - have not been able to sort them yet Dazs.

    (1) my iPad can't Touch ID even after the restoration of the aircraft there was "failure to put in place Touch ID error" and whenever I turn on the Tablet I get a notification that says: «cannot activate Touch ID on iPad»

    When I go to settings to set a new mark I simply get an NDR regardless of switching Touch ID access power (iTunes/App store + phone unlock) as support interviews suggest.

    2) there is a general delay in the camera, the on/standby button does not respond as it used to, and especially when I turn on the iPad must be 2min30secs to get switched on - I timed it actually! Before the update simply took 15 seconds, my old laptop powers on more quickly than my iPad now!

    I restored my iPad, and while all the other functions work with delay however, but these two big things are bugs me a lot. They are not resolved after the restore the device.

    How to solve these problems please help!

    Here is the error I get when I try to configure the contact ID.

    This is the error that I get whenever I turn on the unit.

    And iPad takes so long in power! Record the time more myself!

  • Need help to solve the problem with worm:win:32 / cridex.e

    Please help me to solve this problem worm:win:32 / cridex.e

    Hello

    Scan of Malware in Safe Mode with network.

    http://www.bleepingcomputer.com/tutorials/how-to-start-Windows-in-safe-mode/#Vista

    Windows Vista

    Using the F8 method:

    1. Restart your computer.
    2. When the computer starts, you will see your computer hardware are listed. When you see this information begins to tap the F8 key repeatedly until you are presented with the Boot Options Advanced Windows Vista.
    3. Select the Safe Mode with networking with the arrow keys.
    4. Then press enter on your keyboard to start mode without failure of Vista.
    5. To start Windows, you'll be a typical logon screen. Connect to your computer and Vista goes into safe mode.
    6. Do whatever tasks you need and when you are done, reboot to return to normal mode.

    Once in Safe Mode with network, download and run RKill.

    RKill does NOT remove the malware; It stops the Malware process that gives you a chance to remove it with your security programs.

    http://www.bleepingcomputer.com/download/rkill/

    Then, download, install, update and scan your system with the free version of Malwarebytes AntiMalware in Mode safe mode with networking:

    http://www.Malwarebytes.org/products/malwarebytes_free

    See you soon.

  • Dead sounds - need help to solve the problem

    Its just died suddenly.  Troubleshooters tell me disabled audio - can't find that

    Audio device manager - disabled and does not by default - which is not found

    Need services of generator of the window and the window Audio end - totally lost

    I did not hit anything either or to change anything whatsoever.  All tests show its OK and speakers OK - sound is not muted

    I think that everything the only thing that could be linked has been tested.  I think that MS convenience store gave me the advice above.  However, when I look for those

    elements, quite simply, I do not see them, and I don't know where else to go to get them.

    Can someone help me, please?

    Convenience store must give you the option to fix, have you taken steps to solve the problem in the troubleshooter?

    That you have installed new software before the problem happens?

    Try to run a full system scan with:

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

  • New to AS3 needing help with the key

    OK Im a newb full when it comes to AS3.  Here's what I'm trying to accomplish, I try to make my link button to another page of mine and it loads into the central computer of the original source page.  I found some code to bind the button to a Web site or else my page, but it just opened another window and as previously indicated, I want it to load into the central computer, the button is in the left frame.  Any help would be great, here is the code I use to bind.

    aboutbtn.addEventListener (MouseEvent.MOUSE_DOWN, mouseDownHandler);
    function mouseDownHandler(event:MouseEvent):void {}
    navigateToURL (new URLRequest (". (("/ aboutus.htm '));
    }

    Thanks in advance for the help

    You beat me to it: Yes, it was the parenthesis.

  • Need help to solve the problem on my Satellite U500 PSU9ME

    Dear Toshiba

    I've always used laptops for years working time or personal laptops; I decided to change Toshiba because I hear a lot how they are and high quality!

    Since I bought my laptop and I'm having all sorts of problems with it!

    1. 1st day I bought the laptop, the screen started black out on me and come back several times, I went to the dealer who has replaced for me right now, but the replacement does the same thing for a while even with the bios and drivers updated and then after a few days it worked fine.

    2. I've updated of bios easily to v1.6 and now 1.7 released and I tried hard updated but the update won t work at all, it keeps stuck to the CMD screen.

    3 today, I had a massage from warning saying that the problem with the cooling system has been detected and I need to return it to the service!

    I'll take it tomorrow at the service, but the laptop was purchased on March 24, 2010 only! And it has been registered online on March 26, 2010;

    The service will open and check it out or fix it but it is neither normal nor acceptable when a laptop cost me almost 1200USD and worked less than 2 months and the experience of this.

    I have didn't even use it again as heavy I used to other brands which has never had a single issue!

    This does not mean your laptops are bad, but IE please help and provide solutions or maybe this model needs an urgent review!

    Thank you!

    Model: SATELLITE U500

    > 1. 1st day, I bought the laptop, the screen started black out on me and come back several times, I went to the dealer who has replaced for me right now, but the replacement does the same thing for a while even with the bios and drivers updated and then after a few days it worked fine.

    Seems, that it was a software issue since I noticed a similar problem after receiving some updates from Microsoft is the updated graphics driver

    > 2. I have updated to bios easily to v1.6 and now 1.7 released and I tried hard updated but the update won t work at all, it keeps stuck to the CMD screen.

    Wonder why you n t read the FAQ/HowTo section in this forum.
    Here you can find the BIOS update HowTo!
    http://forums.computers.Toshiba-Europe.com/forums/Ann.jspa?annID=60

    > 3. Today, I got a massage from warning saying that the problem with the cooling system has been detected and I need to return it to the service!

    Seems the cooling starts module malfunction the ASP technician should help you

    > The service will open and check it out or fix it but it is neither normal nor acceptable when a laptop cost me almost 1200USD and worked less than 2 months and the experience of it all.

    You're right, this is not normal cell behavior but it must be said that it s a machine and the machine could begin to malfunction it s nothing unusual and in your case, it was simply bad luck that happened after a short time of use

    I had a Toshiba laptop for 6 years and guest what? It s work great since the day of purchase trees

    Good day...

  • I NEED HELP TO SOLVE MY PROBLEM OF SANDY BRIDGE CHIPSET!

    Hello

    I need someone to receive the update for my Pavilion Dv7 help 4290us part!.

    It is one of the machines involved in the problem of Sandy Bridge, I checked several times...

    I'm already registered the laptop

    Thanks in advance

    Manuel Ramirez

    The number of product of your laptop is XZ037UA #ABA (here ABA means this model has been sold in the United States only). Where was this laptop bought exactly and where are you located now?

    HP offers a comprehensive guarantee and ideally, this should be covered free of charge. You can find more info on link below

    http://support.HP.com/us-en/document/bpr01266

  • I need help to solve a problem I'm having with an installatiion of set-up/repair Windows XP Home Edition service pack 3

    I have 2 computers running Windows Xp Home Edition Version 2002 Service Pack 3.  I tried to run a set-up/repair on one of them.  He loaded the files and went back to the stage of the installation.  He said at this point, it takes the file 'ASMS' of the S3CD.
    I copied the ASMS from the other computer files on my USB but the computer being the establishment does not recognize them.  The program disks that I bought with the computers at the same time say XP Home Editiion 2002 version, but nothing about service pack 3.

    What I need to know is if sp3 is the same for the home edition as it is for regular XP and is different ASMS files in the installation of the sp3 that they are in the House editiion.  If I buy the sp3 disc or download these files I will be able to complete the installation of the set-up/repair on my computer or is there perhaps something wrong with the device causing it to do what he did.

    I am also curios - running installation of set-up/repair on this subject, I lost all my files or will they preserved when I've completed the process?  If I lost my files I before moving on to Windows 7 or any other OS that supports available further in the future?

    Any help/information will be greatly appreciated.  Thank you.

    Hi RandyMeier,
     
    Service Pack 3 files will be different than the normal installation files.
     
    It would be useful to an original CD of Service Pack 3 for installation.
     
    There is an article that you can follow before that and check if it helps.
     
     
    If you are using a clean installation process all files may be lost.
     
    In this scenario, you should consider the upgrade of the operating system Windows 7.
     

    Kind regards

    Divya R - Microsoft technical support.

  • When I have my window starup (error loading dll) I need help to solve this problem

    HPDV6871US LAPTOP

    I uninstall a program from the control panel but some how when the starup high tower it allway come with dll (error loading)

    Help, please

    Uninstall the Kodak software system and if you need then this step to install it again.

  • Plan a game in AS3, need help

    Hi so I'll make quite a big game/app in AS3 and I need someone to point me in the right direction, I know as3 and have programmed many games.

    This game will include multiplayer and we're going to do this, use smartFox.

    Now the area I need some information on are servers to hold the details of the player. (Level etc., species)

    First of all:

    How to set up a server? Use MySQL? Is a Web page that I can connect to my game?

    How would I connect to it via AS3? I have to use SELECT MySQL and MySQL files to find the player and then send back it details?

    Basically, I need to know how the games as configuration servers FarmVile to contain details of the player because I have to do the same thing for this game.

    It's really how to get data to the game to you. When you use classes like URLLoader you can send variables (via GET or POST) on the server to authenticate and process your application. At that time then your PHP script is responsible to read the request and to answer with the information however you like it.

    For your first game, that I would recommend you stick with very structures known as XML or JSON for responses from your PHP scripts.

    For example, if you use JSON, first configure you your application in AS3, to say things that you receive text gross (binary or varying URL) return code. Your PHP script receives the request, performs the necessary operations (on the basis of data, etc.) to get the information you need. He is then responsible for structuring this back to what awaits Flash (JSON) and as you probably know PHP has built-in JSON (http://php.net/JSON) encoding. After your response of crafts and print, AS3 that will consider a response. Can you decode side AS3 as JSON and use the information according to your needs.

    Finally in the future when your game balance grows, you can start making web services which manage more efficient binary formats such as the authority of the financial markets. Then you can do it with the standard messages is not even worth performance wise. Also, you will go from HTTP requests to direct applications of socket. If your game is standard you can even use web based RESTful services so look at those if you're not familiar.

    Yes, you will need a host, but I can't recommend one because I have no idea what you're building. If you plan to build an MMO so no web host will really make you account inexpensive cluster hosted for this scale of a game. If it's just tracking the leader boards and user accounts then I often use hosts that adapts to of lowercase/cheap dedicated using my own equipment, like site5.com.

Maybe you are looking for

  • How can selectively sync you podcasts on your iPod or iPhone?

    I have the iPhone and the iPod connected to the same laptop using the same iTunes account. I don't want all the podcasts of course I synchronize with the iPod syncing the iPhone. I don't see in iTunes how to be selective podcast between two devices.

  • Photos crash when creating project

    All the Ive recently updated to El Capitan, nit course if that is the problem or not but Im going to ask the question. IM aware there are some threads about photos crashing, but none seems to be similar to mine Ive just returned from a trip and try t

  • How can I connect my updated printer driver Lexmark 4300 for hardware

    Help to install the updated driver on my printer which is a Lexmark 4300 series, please?

  • Nslookup DNS timedout

    Using the command PrompI get the following response: DNS request timed out.wait time was 2 secondsDNS request timed out.wait time was 2 secondsAsk mit.edu expired I am in nslookup and as an administrator. I'm taking a class in networking and assignme

  • Windows 7 Media Player - Server execution failed

    My PC woes began - a few weeks ago I had problems with RAM that I solved since. However, in the course of trying to diagnose the problem of memory, I installed and uninstalled a myriad of programs. And now my Windows Media Player won't play, while Me