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.

Similar Messages

  • 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..

  • 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.

  • 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 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?

  • Passing a variable to set a movieclip location

    In frame 1 of the the movie I have defined the following:
    var cl_y=502.0;
    Elsewhere, I am running the following script:
    -- seaty is the original position of the movie clip as
    defined in frame 1
    var seaty = this+"_y";
    -- resets the position of the movie clip to the original
    position
    this._y = seaty;
    (note - I am just setting the _y position in this code in
    order to simplify the forum post)
    I expected that this._y = seaty; would reset the position of
    the movie clip to the original position as defined in frame 1.
    However, nothing happens.
    I have used a trace () to discover the value of seaty:
    Running trace(seaty) produces _level0.cl_y
    Please note that trace(seaty) does not equal the value of
    _level0.cl_y (which is what I am wanting to achieve)
    I then tried replacing:
    this._y = seaty;
    with the following:
    this._y = level0.cl_y;
    And this produces the desired result (moving the movieclip to
    the original position)
    Even though seaty = level0.cl_y
    why does this work:
    this._y = level0.cl_y;
    and yet this doesn't work:
    this._y = seaty;
    (I need it to work because I need to use the same function to
    reset the position of numerous movieclips, all with different
    original positions)
    Many thanks in expectation

    Pulcinella2uk, it tells me you have elected not to receive
    private messages.....so i'll put my reply here for now....
    what version of flash are you using? if you're using an old
    version, something like this might work:
    onClipEvent(load){
    var seatx = this._x
    var seaty = this._y
    onClipEvent(mouseUp){ //or whichever event you're using
    this._x = seatx
    this._y = seaty
    if you're using 7 or later though, then actionscript really
    ought to go on a frame instead of on a clip. so the above code
    would reside on frame 1 of your movie, and look like:
    var seatx = this._x
    var seaty = this._y
    onRelease = function(){ //or whichever event you're using
    this._x = seatx
    this._y = seaty
    all that aside, if i understand your last question correctly,
    you're looking to establish these variables on the _root timeline,
    and access them later. the second code snippet above will produce
    the same result, but if you ever do want to access a variable based
    on a movieclips name in this way, you could do it like this:
    on frame 1of _root timeline:
    var c1_x=15;
    var c1_y=502.0;
    on frame 1 of clip:
    this._x = _root[this._name+"_x"]
    this._y = _root[this._name+"_y"]
    i hope that all made sense. let me know, and if you need to,
    send me a copy of your file so that i have a btter idea of what
    you're trying to accomplish

  • Can't locate movieClip

    This will be hard for me to explain, but please bare with me.
    I have loaded an external .swf file on to the stage with
    multiple movieClips in it. From the main timline of which I load
    this external .swf file, I am moving the movieclip(s) around the
    stage (with the commands of the arrow key). On the main timeline I
    have this:
    function this_function() {
    trace(mc_holder.village._x);
    onEnterFrame = function() {
    trace(mc_holder.village._x); //just to view the position of
    the external .swf file x value
    IF(this occurs) {
    this_function();
    } ELSE {
    that_function();
    //rest of stuff below
    When I trace the village on the onEnterFrame function, I am
    successful in viewing the value/position of the village in the in
    the external .swf file. However, if 'this_occurs' and I tell it to
    use the function 'this_function', where I tell it to trace the
    village again, it doesn't recongize the movieClip, or village.
    Instead of giving me a value, it just gives me 'undefined'. So why
    is it that the 'this_function' can't locate the external .swf file
    village? Hopefully I explained it so you can understnad my problem.
    Thanks

    never mind, I found a solution

  • [Flash CS5.5] bug movieclips dont show/Really Slow on High Quality Textures

    I have been using flash cs5.5 for a while now , and I start this project 3-4 days ago. Ever since I started to add in high texture in it, The program Freezes alot.
    I export my project as a swf and theres no lag at all in it.(thanks to Render:Cache as Bitmap)
    A bug happen when ALL the MovieClips/images/bitmaps No longer can be seen but u can click on it.
    As u can see.
    The visible is check in too.
    All I was doing is moving the movieclips/images/bitmaps(high detail 2000x1000 big) around and this happen.
    Also the program gets crazy laggy when high details are added. Then again , I export my project as a swf and theres no lag on the swf, full fps.
    if this helps
    intel(R) Pentium(R) 4 CPU 3.20 GBHz
    3.19 GHz , 2.00 GB of RAM
    After Reloading the hole file, everything is back to normal , but it still does this bug and its really slow. I cant Continue my project because of this bug.
    Flash barely use my ram or cpu.
    Help?

    Not for nothing but P4 single core CPUs are outdated by about 6 years. From your graphic I can see you're not using a version of flash in your era.
    That doesn't excuse freezing but your CPU in this day and age is basically a solar powered calculator. Most people have an ancient dual core 2+GHz system with 2-8GB ram. You're excessively behind the CPU curve. With that CPU you're running DDR400 on top of it.
    We're at DDR3 now (PC12xxx depending on your wallet).
    Please don't take this wrong but "high res" and "Pentium 4" should not be in the same sentence. I'm fairly sure you cannot even play 720p HD video let alone 1080p HD video on that processor with windows (maybe linux). How do you expect flash to react being much more complex?
    Your best option is to lighten the load on that old rig. Disable any antivirus software or anything else running to give your updated flash the best possible chance to run well given your computers limitations. Efficiency being king, sometimes people thing 3ghz = 3ghz. It doesn't. A 3ghz modern CPU will blow away your old 3ghz computer. This is not apples to apples. 

  • I need to set an image - on mouse event it will be moved across a drawing

    like a stickers

    Place the image in a movieclip or sprite and assign it an instance name so that you can assign an MouseEvent listener to it.  Make the event handler function process moving the movieclip/sprite.

  • Gradual Movement on a mouse over

    I'm trying to move a movie clip which has my main content in
    by having it scroll when a button (the button is independent to the
    clip I'm moving) is moused over, so that if the "up" button is
    moused over it will slowly move the movieClip in that direction.
    At present I have code (attached) that responds to my mouse
    being over a button by moving my movieClip (contentArea) unless the
    movie clip's x value is already at 0, in which case it stops.
    However, it does this all in one go, so it instantly is
    setting x to 0.
    Does anyone know how I could make this gradual, so say for
    every second the mouse is over the scroll area the movie clip would
    move a set number of pixels that way? Or am I over complicating
    things and there is an easier way to do this? It has to be mouse
    over as opposed to clicking as I want it to be intuitive.
    I'd be really grateful if anyone could help,
    Thanks
    Peter

    This is good, but how do you find out the correlation between the mouse point and the text position. For example:
    If the TextArea displays:
    This is a test.
    You might get the following if you put your mouse over "test".
    Mouse x=261 y=0
    Text position = 14
    My question is how do I determine that x=261 and text position=14 is "test".
    Thanks,
    Ashish

  • [as2] counteract buffered keyrepeat

    I'm moving an movieclip using the cursor keys. The device it has to run on, is too slow to process the keys realtime, so the keys are placed in a some sort of buffer and the object keeps on moving for a while when the key is released.
    The device places 8 keys in the buffer per second, but flash can only process 5 per second, so holding the key for a second, will look like I've pressed it almost twice as long.
    Does anyone know of a way to counteract this?
    I've tried using Key.isDown, but that returns true, even though they key is released, until the buffer is emptied.
    I've tried using the onKeyDown event to start the movement and stop the movement using the onKeyUp event, but it seems like the onKeyUp event only occurs when the buffer becomes empty. Even when I remove the onKeyDown listener, it seems like the buffer only decreases 1 key per frame.
    It might have worked when there is no keyrepeat in the hardware, but that is not an option.
    It would be helpfull if there was a timestamp indicating when the key was pressed, or some way to clear the buffer, but I've not found one.

    I agree, it should work, and on a PC it does.
    I've created a test movie that does 10 seconds of heavy rendering (at 0.9 fps) and then 10 seconds of very little load (which can run at 32fps, but the movie is set to 25) I've added logging with a timestamp which shows when the onKeyDown and onKeyUp events are triggered.
    I can see the keys being entered with the flashing led on the device, this always happens at 4 keys per second (I thought it was 8, but the led flashes twice per key)
    I hold the key for 5 seconds, thus entering aproximately 20 'keys'
    FLASH_TRACE: [63076] Heavy load: true
    -- this is where I physically press the button --
    FLASH_TRACE: [65229] onKeyDown event triggered
    FLASH_TRACE: [66331] onKeyDown event triggered
    FLASH_TRACE: [66358] onKeyDown event triggered
    FLASH_TRACE: [67514] onKeyDown event triggered
    FLASH_TRACE: [68711] onKeyDown event triggered
    FLASH_TRACE: [69903] onKeyDown event triggered
    -- this is where I physically release the button --
    FLASH_TRACE: [71006] onKeyDown event triggered
    FLASH_TRACE: [72067] onKeyDown event triggered
    FLASH_TRACE: [73198] onKeyDown event triggered
    FLASH_TRACE: [73215] Heavy load: false
    FLASH_TRACE: [73261] onKeyDown event triggered
    FLASH_TRACE: [73303] onKeyDown event triggered
    FLASH_TRACE: [73354] onKeyDown event triggered
    FLASH_TRACE: [73398] onKeyDown event triggered
    FLASH_TRACE: [73439] onKeyDown event triggered
    FLASH_TRACE: [73478] onKeyDown event triggered
    FLASH_TRACE: [73517] onKeyDown event triggered
    FLASH_TRACE: [73558] onKeyDown event triggered
    FLASH_TRACE: [73617] onKeyDown event triggered
    FLASH_TRACE: [73659] onKeyDown event triggered
    FLASH_TRACE: [73699] onKeyDown event triggered
    FLASH_TRACE: [73735] onKeyDown event triggered
    FLASH_TRACE: [73773] onKeyDown event triggered
    FLASH_TRACE: [73815] onKeyUp event triggered
    I clearly see keys being added to the buffer at 4fps, but only removed from the buffer at the framerate the movie is rendering.
    Adding a fast (1ms) interval does increase the rate at which the buffer is emptied, but only when there is 'some time left'.
    When the rendering is done within the 1/25th of a second, the interval is triggered as fast as possible (every 6ms).
    But when the desired framerate can not be matched, the interval is only triggered once in between frames.
    -- this is where I physically press the button --
    FLASH_TRACE: [5069] onKeyDown event triggered
    FLASH_TRACE: [5075] Key.isDown==true
    FLASH_TRACE: [5132] Key.isDown==true
    FLASH_TRACE: [6319] onKeyDown event triggered
    FLASH_TRACE: [6426] Key.isDown==true
    FLASH_TRACE: [7581] onKeyDown event triggered
    FLASH_TRACE: [7601] Key.isDown==true
    FLASH_TRACE: [8726] onKeyDown event triggered
    FLASH_TRACE: [8733] Key.isDown==true
    -- this is where I physically release the button --
    FLASH_TRACE: [9892] onKeyDown event triggered
    FLASH_TRACE: [9900] Key.isDown==true
    FLASH_TRACE: [11038] onKeyDown event triggered
    FLASH_TRACE: [11045] Heavy load: false
    FLASH_TRACE: [11046] Key.isDown==true
    FLASH_TRACE: [11099] onKeyDown event triggered
    FLASH_TRACE: [11105] Key.isDown==true
    FLASH_TRACE: [11134] onKeyDown event triggered
    FLASH_TRACE: [11147] onKeyDown event triggered
    FLASH_TRACE: [11154] onKeyDown event triggered
    FLASH_TRACE: [11160] Key.isDown==true
    FLASH_TRACE: [11184] onKeyDown event triggered
    FLASH_TRACE: [11190] onKeyDown event triggered
    FLASH_TRACE: [11197] onKeyDown event triggered
    FLASH_TRACE: [11203] onKeyDown event triggered
    FLASH_TRACE: [11210] onKeyDown event triggered
    FLASH_TRACE: [11216] onKeyDown event triggered
    FLASH_TRACE: [11223] onKeyDown event triggered
    FLASH_TRACE: [11229] onKeyDown event triggered
    FLASH_TRACE: [11235] onKeyDown event triggered
    FLASH_TRACE: [11241] onKeyDown event triggered
    FLASH_TRACE: [11247] onKeyDown event triggered
    FLASH_TRACE: [11255] onKeyUp event triggered
    The wierdest thing is happening here:
    The interval appears to speed up the onKeyDown events, but not trigger the interval itself??
    (I've also tried setting 5 intervals, but that makes no difference: the 5 intervals are all triggered, but only 1 key is removed, not 5)
    Anyway, I could make a small delay before doing the heavy rendering to create some time to remove a few frames from the buffer. but at 6ms per key, that's pretty expensive. In the most optimistic case, that would mean an extra 25ms wait to handle the 4 frames per second.

  • Creating a simple android/iphone game in flash-- having trouble

    Hey,
    I am a bit rusty on my flash, but not on my C++ or PHP. I am trying to get my movieclip to move on the x axis when a button is clicked and when that movieclip is clicked it dissapears. Pretty simple program, so I don't know what I am doing wrong. I am rewriting a program from c++ into AS3. I do this
    var mymc:MovieClip = new MovieClip;
    mymc.addEventListener(MouseEvent.CLICK, afunction);
    function afunction(event:MouseEvent):void
    mymc.x = +2;
    mymc.visible = false;
    I am pretty sure my problem is that I need to put the mymc.x = +2; code within the movie clip, so it runs when the movieclip runs and when someone clicks on the movieclip it will run the function afunction to make it invisible. Am I correct in my assumption?

    in as3 we dont use +2 for moving a movieclip, it would be something like += 2 if you wanted to move it constantly by two, but it would have to be a enter frame handler, If you want to simply movie it to a destination:
    var mymc:MovieClip = new MovieClip;
    mymc.addEventListener(MouseEvent.CLICK, afunction);
    function afunction(event:MouseEvent):void
    mymc.x = 100;
    mymc.visible = false;
    if you want it to look good, i suggest looking into greenstock, the as3 tweening engine. Its really easy to use here's an example:
    TweenLite.to(mymc, 3, {x:100});
    you instance your movieclip you want to move "my mc", then state the duration of the tween "3" and then the x value you want to tween the object to "[x:100]"

  • Previous frame without resetting

    As2
    How do you go back to a previous labeled frame and have that fame the same as you left it without it resetting that frame.
    I really want the x y positions of a MovieClip to stay where I moved the MovieClip to previously so I can go back to it.
    These did not work because of resetting.
    _root.prevFrame();
    _root.gotoAndStop("here");
    _root.gotoAndPlay("here");
    I could only pick one place and not what I wanted.
    _root.mc._x=224.9;
    _root.mc._y=124.5;
    I been stuck on this for a long time and would really appreciate some help on this.

    What is in the frame that causes it to revert to some other condition?  If you need to have the position of the object retained, then you need to assign it when you enter that frame, otherwise it will return to whatever the timeline condtions defined for it.
    Normally to have something not change when you enter a frame you need to implement conditional logic that says if(something) { make it so }

  • Moving to a frame in Movieclip timeline from the main timeline

    I am in the learning process. Working with FlashCS5 and AS3.
    Please bear with me if the issue appears to be too simple for you. Placed a movieclip(mcassessJohn) on the main timeline and moved to the frame labelled "johnFeedback" in the movieclip timeline using the following actionscript code.
    mcassessJohn.addEventListener(MouseEvent.CLICK, onJohnClick);
    function onJohnClick(evt:MouseEvent):void {
       mcassessJohn.gotoAndPlay("johnFeedback");
    This works fine. However problem starts when I place a button "questionJohn" in the movieclip(mcassessJohn) time line at frame "johnFeedback" and try to move to another frame by clicking the button and using the following actionscript code;
    questionJohn.addEventListener(MouseEventClick,onClick);
    function onClick(evt:MouseEvent):void {
      gotoAnd Play("johnFeedback");
    Placed the above code in actions layer in the movieclip timeline at frame "johnFeedback". I had placed the button also in the movieclip timeline at Frame "johnFeedback in layer buttons. No compiler error.No runtime error. Just nothing happens when I click on the button "questionJohn".
    Would appreciate if you can let me know where I am going wrong.

    Thats because if u assign the listeners to a parent movieclip it will not pickup listener assigned to its child.
    A work around is put a invisible btn inside mcassessJohn movieclip on frame 1 and assign onJohnClick function to that.
    And one more thing, i think u r trying to perform same operation on both the btns
    http://www.darshanrane.com

  • How to smoothly scale movieclip while moving it towards viewer?

    Hi,
    I have a movieclip (mstone) depicting a signpost, which is within another movieclip (graphic1). I am trying to scale mstone to increase by about 44%, and it needs to move along the screen in such as manner that it is moving towards the user. Some how the scale and the x,y coordinates I am providing don't seem to reflect the same way as it normally would, when I see the website live.
    Is there a smooth way to move the clip, without specifying particular x,y co-ordinates?? I am using the _xscale, _yscale, _x and _y properties. Not producing the desired effect.
    Any suggestions on a better way to approach this???
    Thanks

    No, I am doing all the scaling and moving withing the onLoadProgress. Since I am using ActionScript 2, not using any classes...would get too complicated for me...
    Code is something like this:
    ldrlistener.onLoadProgress = function(_mc:MovieClip, loaded:Number, total:Number) {
    var prcnt:Number = Math.floor( ( loaded/total ) * 100 );
    _root.ldrgraphic.mstone._width = 507.5;
    _root.ldrgraphic.mstone._height = 228.1;
    _root.ldrgraphic.mstone._x = 0;
    _root.ldrgraphic.mstone._y = 0;
    if(prcnt==90) {          // for 10, 20, 30, 40 and so on
    trace("loading:90");
    _root.ldgraphic.mstone._xscale += 4.4;
    _root.ldgraphic.mstone._yscale += 4.4;
    _root.ldgraphic.mstone._x = -254;
    _root.ldgraphic.mstone._y = -56;
    _root.ldgraphic.mstone.pertext.text = "10 meters";

Maybe you are looking for

  • EXCEPTION_ACCESS_VIOLATION in GetNlsSectionName??

    On WIndows XP I sometimes (about 10% of the time) get: An unexpected exception has been detected in native code outside the VM. Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x7C8189BE Function=GetNlsSectionName+0xD5D Lib

  • Search Results Display Preference as "Advanced" not working in R12

    Hi Everyone, I'm unable to do an Advanced search in R12(12.1.3) whereas "Standard" search is working fine at 'Search Results Display Preference' in Oracle Applications Home Page. Advanced search throws 'http 404' error in all upgraded instances. Is t

  • Universe prompt using User:[0,-1] not parsing in XI 3.1 ?

    Hi all, We're using @PROMPTs setup in the universe as filters so as to allow prompts in reports. An example of what we have is (@Select(AllValues\Entity In List) IN @Prompt('Select Entity', 'a','AllValues\Entity In List',multi,Constrained,Not_Persist

  • Shutter release tools /volume shutter only work in the native camera?

    This is so depressing. I have two different shutter release tools, one wired and one wireless. I LOVE them, because I am simply too shaky-handed and it ensures a stable picture. Combine with a tripod, and life is good. Except... it appears from my li

  • Disk Space of a new 2004s installation

    Hello guys, i want to build up a test system on a linux vmware system (no development system - a test system for us)... So i need to know the disks space that a "empty" installation is using? How many disk space is used in case of a new 2004s install