Moving a Movieclip towards its rotation?

Hello!
Basically, what I'm trying to accomplish is moving a movieclip towards the direction it's facing.
I've been scoping around the net for different ideas on how to do it, but I've only found AS2 tuts.
What I've done already is making the movieclip rotate around it's own center when the user presses either the left or the right arrow-key.
What I'm now trying to accomplish is to make the movieclip move forward to the direction it is currently facing when the user presses up and vice versa for pressing down.
Any ideas on how to do this?

Yes this I did understand.
But, the thing is, when I set these values, the player automatically spawns in the top left corner?
The thing is.
I still want the player to spawn in the middle of the screen, whilst allowing the player to rotate and move towards the rotation.
How would I solve this with a Keyboard Eventlistener?..
I'm already using a switch(e.keyCode) with the appropriate keyCodes.
Like so:
public function keyDownHandler(e:KeyboardEvent):void
switch(e.keyCode)
case Keyboard.LEFT: player.rotation -= 5; break;
case Keyboard.RIGHT: player.rotation += 5; break;
case Keyboard.UP: player;
The "update" function is exactly like yours, but the thing it is doing now, is setting the players X value in the top left corner..

Similar Messages

  • I moved my iphoto folder to a new location by mistake. I've moved it back to its original location, but iphoto no longer sees the photos. What step(s) am I missing to return to the setup I had.

    i moved the folder containing all of my photos to a new location on my hard drive by mistake. I've moved it back to its original location, but iphoto no longer sees the photos. What step(s) am I missing to allow iphoto to see the photos as it did before. Also,
    I am trying to back up all of my photos to a thumb drive. Is there a way to do this thru iphoto?

    Witholut knowing what you did, it's hard to know what you missed doing, no?
    Try Hold down the option (or alt) key key and launch iPhoto. From the resulting menu select 'Choose Library'
    Backing up just the Photos? File ->Export
    Backing up the Library? 
    Most Simple Back Up
    Drag the iPhoto Library from your Pictures Folder to another Disk. This will make a copy on that disk.
    Slightly more complex:
    Use an app that will do incremental back ups. This is a very good way to work. The first time you run the back up the app will make a complete copy of the Library. Thereafter it will update the back up with the changes you have made. That makes subsequent back ups much faster. Many of these apps also have scheduling capabilities: So set it up and it will do the back up automatically. Examples of such apps: Chronosync or DejaVu . But are many others. Search on MacUpdate

  • How do I prevent itunes from moving my music from its original place ie folders in an external drive when I play music from itunes. I have all my music in artist folders and separated by MPG3/MPG4 and FLAC folder within the artist folder.

    How do I prevent itunes from moving my music from its original place ie folders in an external drive when I play music from itunes. I have all my music in artist folders and separated by MPG3/MPG4 and FLAC folders within the artist folder and itunes moves the track/s whenever i try and load selected music to my ipod/iphone. I've tried to find some sort of preference to prevent this, but no joy? What am I missing?

    Try opening iTunes preferences. Then click on advanced tab. Then uncheck "Copy files to iTunes media folder when adding to library." By default, iTunes copies music to its own media folder when you use iTunes to play the music.

  • Moving tabs from one window to another makes the new window vanish. I have hot corners enabled so when I move up to the right corner of my display I can see all my open windows but when I click on the tab that I moved to make it its own window it vanishes

    Moving tabs from one window to another makes the new window vanish. I have hot corners enabled so when I move up to the right corner of my display I can see all my open windows but when I click on the tab that I moved to make it its own window it vanishes

    I came up with an alternative solution.
    Instead of actually trying to move the JInternalFrame from one JDesktopPane to another, I added a single, maximized JInternalFrame to the left side. When one of the right side frames is to be docked, I merely copy its ContentPane to the single JInternalFrame on the left, set the original to be non-visible, and adjust the properties of the JSplitPane to make the "docked" frame appear.
    When the "close" button on the docked frame is pressed, I simply undo this procedure to "undock" the frame and redisplay it on the right-hand side (with its content intact from the docked frame, but in its original position).

  • Moving a movieclip in a certain direction

    Hi!
    So, i got this movie clip (say a military tank), and i have attached to it a missile by script. When the tank moves, the missile moves with it, and when the tank rotates, the missile rotates with it. Now what i want it, when i hit the space button, to shoot the missile in the direction it is pointed to. How can i do this, please? Kindly advice how to do it please.
    Here's a video clip of my tank and missle: http://youtu.be/ksA8BM-z4kU
    Thanks for any response.
    KasunL

    if you chose your transform points wisely, you can use the tanks rotation property to direct your missile.  but don't attach to the missile to the tank.  that will be problematic for more than 1 reason.
    so you would usually look something like the following in a loop (eg, enterframe) and you may need to adjust the tanks rotation if its default rotation of 0 fails to point towards the position x axis.:
    missile.x+=speed*Math.cos(Math.PI*tank.rotation/180);
    missile.y+=speed*Math.sin(Math.PI*tank.rotation/180);
    eg,
    var m:Missile;
    var speed:int=whaTEVER;
    var tankW:Number = tank.width;
    function bF(e:KeyboarEvent):void{
    m=new Missile();
    this.addChild(m);
    m.rotation=tank.rotation;
    m.x = tank.x+tankW/2*Math.cos(tank.rotation*Math.PI/180);
    m.y = tank.y+tankW/2*Math.sin(tank.rotation*Math.PI/180);
    m.addEventListener(Event.ENTER_FRAME,enterframeF);
    function enterframeF(e:Event):void{
    e.currentTarget.x+=speed*Math.cos(Math.PI*e.currentTarget.rotation/180);
    e.currentTarget.y+=speed*Math.sin(Math.PI*e.currentTarget.rotation/180);
    if(e.currentTarget.x>stage.stageWidth||e.currentTarget.y>stage.stageHeight||e.currentTarge t.x<0||e.currentTarget.y<0){
    this.removeChild(MovieClip(e.currentTarget));
    e.currentTarget.removeEventListener(Event.ENTER_FRAME,enterframeF);

  • Moving a movieclip's location

    let's say i have _level0.box1.ball
    I want to move ball into _level0.box2 so it will become
    _level0.box2.ball
    How do I do this and have ball keep all it's original
    properties?

    I did think about it.
    Part of the way object oriented languages work is that you
    can move objects to different parents when needed. However, the
    movieclip object can't be moved at run time because of it's run
    time usage.
    For example, if you have a deck of cards, you would put 52
    card objects inside of a deck object. Then you can pass the card
    objects to the player objects and to the 'table' object. But if the
    card is always visible on the stage, it's harder to do this because
    you can't change a movieclips location. Sure you can use wannabe
    pointers, but then you get screwed on movie depths because of
    parent movie clips.
    All in all, it's a huge mess and it should be easier, hence
    why I tried to use the forums.

  • Is it possible to batch duplicate a movieclip including its actionscript contents...?

    ... and change a small part of the action script in each one, for example have it change '1.jpg' into '2.jpg' and so on?
    Any help would be enormously appreciated!
    Oli.

    if you have a movieclip that has the following code on its timeline and that has linkage id = mcID:
    this.createEmptyMovieClip("targetMC",1);
    targetMC.loadMovie(imageURL);
    you could use:
    for(var i=1;i<33;i++){
    var mc:MovieClip = this.attachMovie("mcID","mc",this.getNextHighestDepth());
    mc.imageURL = i+".jpg";

  • Is anyone experiencing screen flicker when entering a search or moving mouse pointer towards results on google search page?

    I have a new medion laptop and have version 4 of firefox installed
    and am noticing that when conducting a search from tool bar (google) my screen flickers after pressing the enter key or when I move my mouse pointer towards the google results.
    I do not get the same problem when using either internet explorer or google chrome, suggesting that either firefox or one of its plug ins is to blame!
    I carried out the same search for the word Apple all using the google search engine preference.
    Interested to know if anyone can help

    Excellent suggestion to disable Add-ons. The problem on my system was the "Optimize Google" add-on. I went to the add-on's home page and it's defunct, so we can't expect updates that will fix the problem. So I deleted it from my system and everything is rosy.

  • Weblogic nohup problem when its rotated

    Hi All!
    Hi All
    I hope anyone can help me, i have an j2ee app under weblogic 8.1 server, i redirect the log to an external file (nohup.out), this file grows fast and i use a cron calling a script to rotate it everyday at 00:05 hrs. and the server stills running, everything is ok, but when the rotate file is calling uses the next command 'cat /dev/null > nohup.out' to resize the nohup file to 0 kbs, then when someting is write on the nohup the file grows as its first size, writting binaries to replace the info erased before, how can i rotate my nohup without that problem ocurs and without shutting down my server everyday!! Thanks!!!
    Oscar Badillo

    This is nohup.out
    8196
    starting
    Jumpy is = ::::::::::::::
    /dmm
    12121212
    8264
    starting
    Jumpy is = ::::::::::::::
    /dmm
    12121212
    8264
    starting
    Jumpy is = ::::::::::::::
    /dmm
    12121212
    8264
    starting
    Jumpy is = ::::::::::::::
    /dmm
    12121212
    8264
    starting
    Jumpy is = ::::::::::::::
    /dmm
    12121212
    8264

  • Moving many movieclips

    I'm new. I'd like to create a file that has 3 groups of
    movieclips. Group 1 never moves in the users viewport. Whenever
    group 2 moves, group 3 moves as well, but group 3 can also move
    independently. I expect to draw all of the mc's by hand instead of
    with AS, otherwise I would create them all as children of one mc
    and move that. Do I just make 3 groups and move them? Is there a
    way to add movieclips to one big clip after they are already drawn?
    Just looking for advice on the best terms to google to figure out
    how to proceed. Thanks in advance.

    Or should I build three different files and import the output
    swfs into one and set the rules there?

  • Mutliple framed MovieClip and its Class

    I have a 4 framed MovieClip in my library named 'MC Swatch
    Set' with a
    defining class named SwatchSet. Each of the frames contains 2
    - 4
    MovieClips with instance names
    swatch1
    swatch2
    swatch3
    swatch4
    For this post, please refer to
    http://www.seanberry.com/swatches.png
    On frame 1, swatch 1 and 3 are present.
    On frame 2, swatch 1, 2 and 3.
    On frame 3, swatch 1, 3 and 4.
    and on 4, swatch 1, 2, 3 and 4.
    In my class I have an _init() function that takes two args.
    The first is
    the label of the frame to jump to out of the 4. The second
    argument is an
    object that is used to specify the colors to use with setRGB
    on the various
    swatches. So, if the _init() function was called and the
    first argument was
    'P1S2' the MovieClip would go to frame 3 ( P1S2 == '1 Primary
    color, and 2
    secondary colors')
    Since there will only ever be one of these "MC Swatch Set"
    MovieClips, I
    only instantiate it once when I place it on the stage with an
    attachMovie().
    So here is the problem. When I call the _init() the first
    time, it works
    like a charm. It goes to the correct frame, and changes the
    colors of the
    swatches. But, when I call _init() again, with new
    parameters, I encounter
    a problem.
    The problem is best illustrated in the image referenced
    above. Basically,
    even though I know the MovieClip instance is changing frames
    (I know this
    because I put a trace on each frame which works and because
    the outlines of
    the swatches on the MovieClip are correct) the instance of
    the movieclip I
    have already used is visible.
    Is it because I can only use an instance name once? Since I
    have, for
    example, a movieclip with instance name swatch2 on frames 2
    and 4, is it
    whichever one gets used first?
    Thanks.

    "abeall" <[email protected]> wrote in
    message
    news:ecd12k$840$[email protected]..
    >I don't exactly know, other than Flash thinks the same
    instance is on frame
    >1
    > and frame 2 if they have the same name, and that can
    easily confuse Flash
    > if in
    > actuality they are different.
    >
    > Try this. Create a MovieClip in the IDE called
    "myMovie_mc". Make the
    > document
    > 20 frames. On frame 10, put:
    > myMovie_mc.swapDepths(1);
    > myMovie_mc._x += 150;
    > myMovie_mc._y += 150;
    > myMovie_mc._alpha = 50;
    >
    > No stop() commands. Now play the movie. Congradulations,
    you have
    > successfully
    > confused the Flash Player! :-) Similar type of thing, I
    think.
    >
    Yep, that demonstrates a similar problem. What I don't
    understand though,
    is why there is a copy of myMovie_mc in the new position,
    with the new alpha
    when the player loops back to frame 1. Just counter-intuitive
    it seems.
    Thanks again for the help. The empty keyframe in between
    frames containing
    like instance names did the trick and was a simple solution
    to implement.
    I had found other ways around this problem, like individual,
    unique instance
    names for each MovieClip but like your solution much better.

  • Moving a movieclip

    I would like to achieve the following:
    I have an oversized moveclip which i will place on the stage.
    When flash swf  is running, I would like to move the movieclip left, right, up or down when i mousedown. Just like the "MOVE" tool in photoshop.
    Is there a sample.fla on this?

    you can use startDrag(), stopDrag() for this.

  • 2008 Macbook Pro gets sections of vertical lines along the right facing side of the screen... the sections vary in colour when moving the display on its hinges, and is relieved slightly when applying upwards pressure to the bottom of the display.. cheers!

    There are two different sections of the screen that get this effect... first off the closest to the right will distort about an inch in... then after some time another inch willl follow. the best way i can describe is a band of moving horizontal lines spreading virtically down the screen about an inch in width, changing in colour.
    any help i much appreciated! obiously the mac is out of warranty... is there a 'do it yourself' approach i can take? replacing the lvds cable? just thought id ask first before i start taking things apart!
    cheers guys!

    Whoa, I think I just figured out what the problem is, but it's really wierd.
    So, I didn't do anything about it, since it was a little expensive, and just used the laptop with an external screen (which works fine).
    For some reason, I tried to use it as a laptop today, and it worked perfectly. I took it downstairs, and after a while it stopped working again, and the screen started doing all those wierd things it did as described in the original post. It was working fine for hours, upstairs.
    Then somehow it hit me! The laptop had been upstairs in my computer/storage room (which happens to be freezingly cold atm, since I don't heat that room, let's say it's like max 8°C in here) for a long time, which means the laptop was also pretty cold.
    Downstairs, in the living room, it's a lot hotter, about 20°C.
    So, it seems to be temperature-related. Now, as crazy as this sounds, I tested it for 10 hours in a row.
    I took it upstairs and downstairs at least 5 times. tried plugging in devices, using it with and without power supply, but whatever I did the result was the same:
    -Use it upstairs (cold room): It works, I can do whatever I want to it, open and close the laptop as much as I desire, it keeps working as it should.
    -Use it downstairs (hot room): It works for a while, even pretty long (as long as you don't close it and open it again). Once you open it downstairs after it has been there for a while, all issues pop up again.
    Can someone please explain how this is possible ?

  • Is it possible to lock a PDF so the view cannot be changed? (its rotation clockwise, or counter-clockwise)

    Hey Guys, I'm in a little bit of pickle, just wanted to make sure i wasn't doing anything wrong for the boss man. Can the view for a document be locked?

    No. The view can always be changed by the user (but not the document itself
    if you apply a security policy that forbids that).

  • Unable to connect to WIFI- I have been using touch in India and it was working fine. Now I moved to USA and its not able to connect

    I have done RESET network setting, reset the IPOD with no data lost and all- still not able to connect
    All other devices at my room are connecting and everything is fine.
    can you please help me out in resolving the issue?
    Ashwin.

    If this did not help:
    - iOS: Troubleshooting Wi-Fi networks and connections
    - iOS: Recommended settings for Wi-Fi routers and access points
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Last, restore the iPod, first from backup and if problem persists, restore to factory settings/new iPod

Maybe you are looking for