Move Multiple direction in Soccer Game...?!

Hello,
I have create simple keyboard event to move the ball/player to right, left, top & bottom. lets say the user click up arrow to move up after that he press the right arrow while still pressed the up arrow to move to top right and if he release the top arrow while still pressed right arrow he will move to the right only. How can i do that ?!
function SoccerMove(e:KeyboardEvent):void {
    if(e.keyCode == 37) {
            SoccerBall_mc.x -= 5;
    }else if(e.keyCode == 38) {
            SoccerBall_mc.y -= 5;
    }else if(e.keyCode == 39) {
            SoccerBall_mc.x += 5;
    }else if(e.keyCode == 40) {
            SoccerBall_mc.y += 5;
stage.addEventListener(KeyboardEvent.KEY_DOWN, SoccerMove);
Regards,

thanks kglad,
I do it using hitTestObject. Can i make better code then what i have now as you can see it's large for just move and a lot of conditions
import flash.events.KeyboardEvent;
import flash.events.Event;
var TopArrow:Boolean;
var BottomArrow:Boolean;
var RightArrow:Boolean;
var LeftArrow:Boolean;
var PlayerSpeed:int = 3;
//-------------------- Move The Player --------------------
function SoccerTrue(e:KeyboardEvent):void {
          if(e.keyCode == Keyboard.LEFT) {
                    LeftArrow = true;
          }else if(e.keyCode == Keyboard.UP) {
                    TopArrow = true;
          }else if(e.keyCode == Keyboard.RIGHT) {
                    RightArrow = true;
          }else if(e.keyCode == Keyboard.DOWN) {
                    BottomArrow = true;
stage.addEventListener(KeyboardEvent.KEY_DOWN, SoccerTrue);
function SoccerFalse(e:KeyboardEvent):void {
          if(e.keyCode == Keyboard.LEFT) {
                    LeftArrow = false;
          }else if(e.keyCode == Keyboard.UP) {
                    TopArrow = false;
          }else if(e.keyCode == Keyboard.RIGHT) {
                    RightArrow = false;
          }else if(e.keyCode == Keyboard.DOWN) {
                    BottomArrow = false;
stage.addEventListener(KeyboardEvent.KEY_UP, SoccerFalse);
function SoccerMove(e:Event):void {
          if(LeftArrow && !SoccerBall_mc.hitTestObject(LeftLine)) {
                    SoccerBall_mc.x -= PlayerSpeed;
          if(TopArrow && !SoccerBall_mc.hitTestObject(TopLine)) {
                    SoccerBall_mc.y -= PlayerSpeed;
          if(RightArrow && !SoccerBall_mc.hitTestObject(RightLine)) {
                    SoccerBall_mc.x += PlayerSpeed;
          if(BottomArrow && !SoccerBall_mc.hitTestObject(BottomLine)) {
                    SoccerBall_mc.y += PlayerSpeed;
this.addEventListener(Event.ENTER_FRAME, SoccerMove);

Similar Messages

  • How do I move multiple Divs at a time?

    Hi,
    I can't seem to figure out how I move multiple Divs at a time. I have resized certain Div in the middle and now I have to move all the Divs that are below it up to align it with that certain div again. How do I select and move all the Divs in once? I know you can move them one at a time by changing the position in the properties or just drag them in the design view, but I have a fairly large amount of Divs.
    Thanks in advance,
    EC

    but is there any other way? Like changing something in the properties that will make the Divs bump up to the Div aoove that when you remove one out of there
    I'm afraid not.
    I  imported the whole site as divs by splitting the images in photoshop and saving it for web and devices.
    This is approach is OK for quick comps to show a client but definitely NOT suitable for a production site.  As soon as you attempt to edit your layout, the page will explode and fall apart.  This is caused by the rigid/fragile code that graphics apps attempt to generate based on the images sizes.
    Start over.  Use graphics apps to slice and optimize images only.
    Use DW to build your HTML and CSS code.
    Creating  your first web site in DW CS5 -
    http://www.adobe.com/devnet/dreamweaver/articles/first_website_pt1.html
    Adobe Developer's Center - Getting Started tutorials
    http://www.adobe.com/devnet/dreamweaver/?view=gettingstarted
    Using  DW Page Properties to create a basic CSS style sheet
    http://kb2.adobe.com/community/publishing/505/cpsid_50576.html
    APDivs as a primary layout method seldom works well. Here is why:
    http://apptools.com/examples/pagelayout101.php
      Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • How do I import or move multiple selected photos to an existing album in iPhoto 9.6? In previous versions I could select and drag multiple photos into an album. Now I can only move one photo at a time. Help!

    How do I import or move multiple selected photos to an existing album in iPhoto 9.6? In previous versions I could select and drag multiple photos into an album. Now I can only move one photo at a time. Help!

    Try this general troubleshooting procedure:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home/Library/ Preferences folder.
    2 - delete the contents the following folder: User/Library/Containers/com.apple.iPhoto
    3 - reboot, launch iPhoto and try again.
    NOTE: For Mavericks and Yosemite,  go to your Home folder and use the View ➙ Show View Options menu to bring the this window:
    where you can check the Show Library Folder checkbox.

  • Linking multiple devices and different game accounts on one gamecentre

    Hi I have multiple accounts on multiple devices on one Game Centre account but I want to link a specific one to my new iPad ? Just wondering if this is possible as I have bought my partner an iPad but it will only link my clash of clans progress to the iPad from my phone but I want it to link her progress ?? Any help would be appreciated
    Thanks!

    1. Give her a separate user account on your computer. If you have a backup copy of the library, you can restore it.
    2. If you encounter a 90-day waiting period, click here and ask the iTunes Store staff if they'll remove it.
    (125941)

  • Is there a way to move photos directly from one iPhoto library to another iPhoto library?

    Is there a way to move photos directly from one iPhoto library to another iPhoto library?

    Not using iPhoto - Aperture can or iPhoto Library Manager can
    LN

  • From my music how do i move multiple songs at once to a playlist

    From( My Music) how do I move multiple songs at once to a playlist.
                                        Thanks

    Your issue has nothing to do with Apple networking. You may get better results in getting a solution if your post your issue to the iTunes area of the Apple Support Communities.

  • Move multiple clips at once

    I often have to move multiple layers of clips or still images and keep their position relative to each other. In AE and in PS I can select multiple layers and drag their position around freely, but in Premiere Pro, I can only drag one layer at a time.  Bouncing to AE is not a solution for me because everything I work with needs to be timed with multiple layers of audio at all times.  Nesting is not a solution for me because I need to be able to adjust each layer independently as well.  This is a feature I would use (and did use in FCP) dozens of times every day!  I really need this.  Any chance it's coming in a future update? 

    Hi Chris,
    Hi Kevin, I resurrected this old thread today so I'm not sure if the original poster is still around but thanks for the replies.
    Sure, no problem.
    The After Effects work around is quite long winded for what seems like a very simple task, but I do appreciate your point about how FCP was designed differently from the beginning.
    Indeed, it really seems that way from the outset, but AE launches really fast these days. You can set up these kinds of comps very quickly and be back in Premiere Pro in no time. Remember how Motion and FCP used to work together? I think of it in the same way.
    Sure it would be better if Premiere Pro had all the goodies FCP had (like this feature), but it's a totally different application and so you may have to adjust your expectations.
    I'm sure it's not the case of just changing a couple of lines of code in Premiere, unfortunately! Hopefully the "multiple clip parameter editing" and "horizontal/vertical lock" features can be implemented in the future.
    That's often the case, but the question is then "when would we have the time to write and test that code when there are 800 priorities ahead of it?" The key is feature requests. The more we get for any one feature, the faster it rises to the top of the list of priorities.
    If anyone else would like these please submit feature requests! http://www.adobe.com/go/wish
    You have the right idea. Thanks!
    Kevin

  • How do you move multiple tabs?

    Is it possible to move multiple tabs?
    I have about half a dozen tabs in a table that all need to move right by about 15mm or so. Tried shift clicking to select multiple tabs but that doesn’t seem to work.
    Really hope I don’t have to select each individual tab to move them.
    Sorry if this has been asked before but I can’t find an answer.
    Thanks in advance.

    OK, let me try to understand.
    You have some tab-delimited information. Is the whole frame just the text like this:
    If so, just move the frame over +15mm
    Or, if it has other text before or after the tabbed-delimited text like this:
    The above text is a table. But it looks like the other text.
    You can select all the text and make it a table, then just merge the cells for the paragraphs.
    You can then delete the indents for the table as well as the borders.
    But I agree that just a half dozen tab stops are easy to move.

  • How do I move multiple folders to  a new location

    I'm tring to reorganize after a computer crash. How do I move multiple folders to  a new location?

    In the Organizer you can switch to Folder Location View by clicking the Display button (near top right)
    You can then expand he folder tree in the left hand pane and drag and drop.

  • Is there a way to move multiple Calendar items from one date to another?

    Hello. I have far too many Calendar items every day in my iCal. Until I finally pare them down to a reasonable level, I need to "reschedule" all of my unfinished ToDo items and reminders, to another day, later in the week.
    There doesn't seem to be any "Select All" feature available.
    Is there a way to move multiple Calendar items from one date to another?
    Thanks in advance!

    Still no ideas? Apple, please come up with a fix. Thanks.

  • Is there a way to move multiple calendar events at once (as there always has been)?

    In all iterations of iCal then Calendar you could move multiple events at once in a number of different ways...
    Has anybody found a way to do this in the latest version of Calendar 8.0?

    Thanks for that, the hand tool and selector tool were not displayed on the toolbar, but once I had added them via the options then the problem was resolved.

  • How to move multiple images in applet

    Hi,how to move multiple images in applet or random images in applet .
    Means moving images.gif around the applet with different starting point ,help me to create that move method ..

    why don't you check the tumbling duke applet as provided free in this site? :-)

  • To Move Multiple Files from one directory to another.

    Hi,
    I need to move multiple files from one directory in UNIX (application server ) to another. I need something like an FM 'STRALAN_COPY_FILES' which is also valid in ECC 6.0.
    Thanks in advance.

    Hello Sachin
    Below you see a copy of how to use EPS_FTP_PUT using transaction SE37.
    Import parameters               Value             
    RFC_DESTINATION =                 NONE              
    LOCAL_FILE             =         filename          
    LOCAL_DIRECTORY   =              /dir1/dir2        
    REMOTE_FILE             =        filename          
    REMOTE_DIRECTORY   =             /dir1             
    OVERWRITE_MODE        =          F        " force -> overwrite existing file                 
    TEXT_MODE                    =   B               " binary
    TRANSMISSION_MONITOR            X       " display transmission monitor            
    *RECORDS_PER_TRANSFER            10                
    *REQUESTED_FILE_SIZE             0                 
    *MONITOR_TITLE                                     
    *MONITOR_TEXT1                                     
    *MONITOR_TEXT2                                     
    *PROGRESS_TEXT                                     
    *OBJECT_NAME  
    Regards,
      Uwe

  • Is there an easy way to move multiple icons from one screen to another?

    I have multiple screens on my iphone 5c display.  I want to move multiple icons at the same time from one screen to another.  Is there a way to do this?

    You could put them all in a single folder and move the folder to another screen.

  • How do I move cards in a solitaire game on the ipad

    How do I move cards in a solitaire game on the ipad?

    lawrencefromcheshire wrote:
    How do I move cards in a solitaire game on the ipad?
    Touch card, drag/move to desired position.
    Stedman

Maybe you are looking for

  • Opinions on implementing a JAAS login module to achieve SSO

    We are looking at implementing SSO from a sharepoint website to the portal.  The users who are accessing the Sharepoint site are using their own computers and are not members of the AD Domain, so they could theoretically be using any computer in the

  • How can i switch my iTunes account to a different users account on my i mac

    how do i reset my parental control pass word i forgot it and cant get in too my  iTunes

  • In Options, I cannot access the 'Privacy' area to change any options

    I am trying to change the Privacy options, when click on the Privacy icon, no options appear. Using Windows Vista Home with all the updates up to date, and Firefox ver. 7.0.1

  • HELP - Trouble inserting

    Why does dreamweaver close when trying to insert items such as images, swf etc. When i try to insert things such as images or swf files in dreamweaver cs6, the program just closes. I go insert > image (click on it) and it just closes. No crash inform

  • Aperture with NAS

    Hi, New to a Mac, and had been trying to use iPhoto. My issue is that I have a NAS with all photos on, I've bought a MacBook Air with 128gb SSD so don't really want to be storing a lot locally. iPhoto didn't seem to meet my requirements, as it was al