Moving Movie Clips dynamically

Here's the deal. I have a function that I call to move the
movie clips based on string that holds the movie clip instance
name. The function as I have it now can be seen below listed under
figure A. Figure B shows my call to that function. It takes in an
array of strings and passes the current index to the function.
Figure C shows my output panel text after I run the function.
For some reason, the function is only moving one of my
movieclips, and none of the others. I can tell this by tracing the
instance ._x value, as shown in figure D. So, I know that my calls
to the movieclip instances are correct, but why can I only move one
card?? I know the movie clips are instantiated, as can be seen in
Figure E, which show my objects list that I get from my debug menu.
Any ideas/suggestions?

My latest crack at it... I create multiple controllers for
each movie clip, and I test the calling of the method by inserting
a string literal as the call, still no luck. No matter how many
times I call move, it will only work on the last card that I call.
Framerate does not matter.

Similar Messages

  • Moving a Movie Clip dynamically

    Hi All,
    I want to move a movie clip dynamically on a predifined
    track. How could I do this? help me.
    Thanks in advance
    Ankur

    Ankur Arora wrote:
    > Hi All,
    > I want to move a movie clip dynamically on a predifined
    track. How could I do this? help me.
    what kind of "predefined track" is that ?
    Best Regards
    Urami
    !!!!!!! Merry Christmas !!!!!!!
    Happy New Year
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Center movie clips dynamically, as3.0

    Hi.  I have seen this discussed both on Adobe Forums and other sites but I can't seem to make sense of the code supplied by what I have seen thus far.
    I am trying to center display objects that are added to the stage at runtime dynamically through a basic drawing application.
    the code is something like this:
    1. add an event listener for the drawing event.
    2. add the path you want to draw to a container movie clip on the stage.
    3. add an enter-frame event listener to change the scale of the path randomly .... and this is the moment i want to change the default top,left registration point to the center,center of the path.  each path has its own registration point as i can tell thus far but at this point the scale is happening from the top,left of the container rather than about the path's own self.  and if it were to happen about the path i would have to get the bounds of the path and do some averaging to center the registration point.
    unfortunately i don't know what the code looks like to achieve what i'm trying to get.
    any help is appreciated.  thanks in advance.

    Well if using the graphics.lineTo method is Bitmap data then that is what I'm using.  But each call to the shape that I'm drawing is a new Shape(); .  The second paragraph you wrote seems a bit daunting when viewing it in the abstract sense.  Your first reply was a bit more concrete but I guess the first response didn't account for everything being in one container.  Should I create a container2 Movie Clip and create that as a new box on a per-shape basis so that I have multiple container2 mc's in the following path:
    container.container2[i].shape[i] where i would be an index (such that i++) though the code wouldn't be written exactly that way. ?
    (To store localX,Y positions in an array or vector shouldn't be too hard but I would need to try it several times before I get it right).

  • HitTesting edges / moving Movie Clips stage length

    This is sort of a multi-layered question- I have a movie clip that I sectioned off in quadrants:
    http://img401.imageshack.us/img401/2250/tempnw.jpg
    The red dot is the player, the stage is the size of one square. My goal is to, when the player moves to either of the 4 edges, the next section of the quadrant comes up (meaning if the player moves to the right edge, the section that borders the right edge will slide on screen, and the old section will slide off screen).
    I was wondering if there was a way to hitTest if an object is touching any part of the edges? Is the hitTestPoint method something I should look into? What I have so far is an object off screen (black rectangle), that when the player touches the quadrants slide like I want them to (at least I'm trying to make that work).
    Here is my code. I know some of it's wrong and/or I'm missing something. Any help would be appreciated.
    if(leftKeyIsDown && player_mc.x > -15)     //-15 is half the size of the temporary player_mc
              player_mc.x -= speed;
              if(player_mc.x < 0)     //take in account the size of the REAL player_mc
                   player_mc.gotoAndPlay(1);
                   stage.removeEventListener(KeyboardEvent.KEY_DOWN, pressKey);
                   stage.removeEventListener(KeyboardEvent.KEY_UP, releaseKey);
                   if(player_mc.hitTestObject(edge_mc))
                        map_mc.x = map_mc.x + stage.stageWidth;
              //map_mc.addEventListener(MotionEvent.MOTION_START, moveMap);
              //checkHitLocation(edge);
    /*function checkHitLocation():void
    /*function moveMap(event:MotionEvent):void
         var pointLeft:Point = new Point (0, 150.45);
         if(player_mc.hitTestPoint(pointLeft.x, pointLeft.y, true))
              map_mc.x -= stage.stageWidth;
    Also, I have it so all the quadrants together will be in a movie clip (map_mc), and nested in that movie clip will be the individual pieces, each quadrant with an individual instance name.

    I think my inability to understand array's and how to add/remove children from them is leading me to hit a wall. Would you mind helping explain it to me?
    package
         import flash.display.MovieClip;
         import flash.events.KeyboardEvent;
         import flash.events.Event;
         import flash.ui.Keyboard;
         public class Main extends MovieClip
              public var ground:MovieClip;
              public var nextGround:MovieClip;
              public var player:MovieClip;
              public var keyPressed:uint;
              public var rightKeyIsDown:Boolean;
              public var leftKeyIsDown:Boolean;
              public var speed:Number = 10;
              public var land:Array = new Array();
              public var landOrigin:Number = 650;
              public function Main()
                   ground = new beginGround_mc();
                   addChild(ground);
                   player = new player_mc();
                   addChild(player);
                   player.y = 200;
                   rightKeyIsDown = false;
                   leftKeyIsDown = false;
                   stage.addEventListener(KeyboardEvent.KEY_DOWN, pressKey);
                   stage.addEventListener(KeyboardEvent.KEY_UP, releaseKey);
                   stage.addEventListener(Event.ENTER_FRAME, hitting);
              public function hitting(event:Event):void
                   if(player.hitTestObject(ground.groundAdd1_mc))
                        trace("hit");
                        addNewGround();
                   for(var i:uint = 0; i < land.length; i++)                    //1
                        nextGround = land[i];
                        if(player.hitTestObject(nextGround.groundAdd2_mc))
                             trace("blue");
              public function addNewGround()                                       //2
                   nextGround = new ground_mc();
                   addChildAt(nextGround, 0);
                   nextGround.x += 700;
                   land.push(nextGround);
    As my code stands right now I got groundAdd2_mc to trace back the second statement. From here I need to keep adding instances of the nextGround movieclip right after one another every time the player hits groundAdd2_mc, and removing all the old ones the player can no longer see.
    I guess I really don't comprehend what //1 is doing, In my mind I put an instance of the nextGround_mc class in the land array and try and call it every time the player hits the appropriate hitTest, leading me to //2 addNewGround, where the new ground piece is added 'x' distance away; I'm not really comprehending how I can add only 1 instance 'x' distance away every time the player hits the hitTest.

  • Moving Movie Clips with Arrow keys

    How do i make it so when i click the left arrow key, it will
    change the movie clip to make it turn around?

    Yes, that's what the code I gave you is intended to do....
    you replace that code with whatever action you need to take to turn
    your movie around.
    I have no idea what your movieclip is doing, but I'm guessing
    by your response that if it was an arrow pointing left to right
    (just an example), you want it to be pointing right to left when
    the left arrow is pressed. If you want an immediate turn around,
    then the simplest way to do that is to have another frame
    containing the movieclip that it moves to where it faces the other
    direction--and to have it appear turned around, from the toolbar
    you select Modify -> Transform -> Flip Horizontal.
    So the movieclip would live inside another movieclip that has
    two frames with stop()'s for each frame. In the first frame you
    would have the subclip facing left to right, and in the second you
    would have it facing right to left. If we call that 2-framed
    movieclip "walker", the code I provided before would
    become...

  • How to resize movie clip dynamically

    how to resize movie clip sccording the stage size and width

    how to resize movie clip sccording the stage size and width

  • Moving movie clips with ActionScript

    I am trying to move four movie clips with actionscript in a
    circler motion with two buttons, one to rotate the mc’s to
    the left and one button to rotate the mc’s to the right. Here
    is a link to what I am trying to do;
    http://www.us.playstation.com/Lair/
    and it is undrer game features.

    Yes, that's what the code I gave you is intended to do....
    you replace that code with whatever action you need to take to turn
    your movie around.
    I have no idea what your movieclip is doing, but I'm guessing
    by your response that if it was an arrow pointing left to right
    (just an example), you want it to be pointing right to left when
    the left arrow is pressed. If you want an immediate turn around,
    then the simplest way to do that is to have another frame
    containing the movieclip that it moves to where it faces the other
    direction--and to have it appear turned around, from the toolbar
    you select Modify -> Transform -> Flip Horizontal.
    So the movieclip would live inside another movieclip that has
    two frames with stop()'s for each frame. In the first frame you
    would have the subclip facing left to right, and in the second you
    would have it facing right to left. If we call that 2-framed
    movieclip "walker", the code I provided before would
    become...

  • RePost: center movie clips dynamically, as3.0 ?

    I have a question that was somewhat answered but I now have some problems with, as far as implementing the solution is concerned.  I posted in August and I have revisited the file only now to see if I can create the changes necessary to center my mc's dynamically as they are drawn on the stage at runtime.  They need to center to themselves rather than having their registration points in the top left corner, per display object.
    Here is the thread:
    http://forums.adobe.com/message/5760947#5760947
    Thanks in advance for any responses.
    -markerline

    I attempted to reply yesterday but the forums became under maintenance (as we all re-logged in after).
    What I tried to post before the system went down was to give a single example as you had mentioned. To remove the complexity of the rest of the app so this can be understood alone and then implemented into your larger system.
    Centering via container in code is very simple as long as you can grab a hold of the shape in code as well.
    Here's a complete AS3 example of centering a single object inside a container. I just want you to paste this into a new AS3 doc so you can tell me you understand how it works. After that, the more complex multi-object container in a container approach comes in:
    e.g. 2 squares rotating:
    import flash.display.Shape;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.display.Sprite;
    // start rotation loop using a Timer to turn all objects
    var moveTimer:Timer = new Timer(10,0);
    // function to rotate objects
    moveTimer.addEventListener(TimerEvent.TIMER, handleTimer);
    // draw a rect shape
    var redrect:Shape = new Shape();
    redrect.graphics.lineStyle(3,0x0,1,true);
    redrect.graphics.beginFill(0xFF0000);
    redrect.graphics.drawRect(0,0,100,100);
    redrect.graphics.endFill();
    addChild(redrect);
    // position at x:100 / y:100 on stage
    redrect.x = 150;
    redrect.y = 200;
    // now draw a blue square but with a container while centering the shape
    // container
    var blueContainer:Sprite = new Sprite();
    addChild(blueContainer);
    // draw a rect shape
    var bluerect:Shape = new Shape();
    bluerect.graphics.lineStyle(3,0x0,1,true);
    bluerect.graphics.beginFill(0x0000FF);
    bluerect.graphics.drawRect(0,0,100,100);
    bluerect.graphics.endFill();
    blueContainer.addChild(bluerect);
    // position in center of container (subtract half width/height)
    //-------------centering code----------------
    bluerect.x -= bluerect.width / 2;
    bluerect.y -= bluerect.height / 2;
    // position container
    blueContainer.x = 400;
    blueContainer.y = 200;
    // start timer which invokes function below
    moveTimer.start();
    // rotate the red rect (upper left reg) and blue (objects centered);
    function handleTimer(e:TimerEvent):void
              // just rotate both to see the registration
              redrect.rotation += 2;
              blueContainer.rotation += 2;
    Now do understand I know I can draw my bluerect with negative coordinates to achieve the same thing inside the shape (e.g. -50,-50,100,100) but the point here is containing potentially a complex object into a single object so the entire outer contents can be measured and rotated from a single center point. That comes after this simple code is understood.

  • Can I change the registration point of a movie clip?

    I'm loading a movie clip dynamically and its registration
    point defaults to top-left corner. I need to change it to the
    center, is this possible? if so, how?
    Thank you

    Thank you. I tried that and it didn't work too. Please check
    this code:
    loader.loadClip(_global.image_url+this["image1"], image1);
    DynamicRegistration.initialize(image1);
    image1.setRegistration( 20, 20);
    What is wrong with it?

  • Random location for a random movie clip

    I have various movie clips which I need to appear in one of
    four locations randomly. I need the movie clip to also be random. I
    also need more than one movie clip on stage at the same time. I
    believe the following needs to be used:
    Math.random
    duplicateMovieClip
    I also believ that the method needs to be generic. Apart from
    that I am stuck.
    Any help/ideas are appreciated.
    Hope my question makes sense?

    good point. to be honest thinking about it I dont really know
    why
    I have four movie clips, which the user controls called
    user1
    user2
    user3
    user4.
    In addition I have 6 additional movie clips which I need to
    appear and move (randomly) in one of four locations (based on a
    standard stage size):
    locations 1 (start position)
    x co-ordiantes 138.3
    y co-ordiantes 62.8
    locations 2 (start position)
    x co-ordiantes 549.3
    y co-ordiantes 53.8
    locations 3 (start position)
    x co-ordiantes 137.3
    y co-ordiantes 156.8
    locations 4 (start position)
    x co-ordiantes 543.3
    y co-ordiantes 147.8
    locations 1 (finish position)
    x co-ordiantes 291.3
    y co-ordiantes 162.8
    locations 2 (finish position)
    x co-ordiantes 397.3
    y co-ordiantes 162.8
    locations 3 (finish position)
    x co-ordiantes 280.3
    y co-ordiantes 257.8
    locations 4 (finish position)
    x co-ordiantes 400.3
    y co-ordiantes 258.9
    The maximum number of movie clips moving between the two
    positions at once should be 6. Ideally more than one from one
    location
    I would also like the speed at which they move to be
    different.
    The idea is that if a colission occurs between any one of the
    moving movie clips and the avatar(user 1-4) then points are added.
    Hope this helps.
    Thanks
    ******************

  • Transform on movie clips

    I am loading a bunch of movie clips dynamically. Right now,
    the movie clips undergo a color transform for the onRelease()
    action. Now, I want to be able to transform a group of movie clips
    on the onRelease() action of a single movieclip.
    What would be the recommendation to accomplish this task? I'm
    sure there are many ways to do it, but I don't know where to start.
    I tried to put the movie clips into an array to then access the
    movie clips. I can get the properties of the movieclips that I want
    to transform, but I cannot transform them.

    This is the code that I use:
    for (var j:Number = 0; j<quad.length; j++) {
    var bu_mc:MovieClip = quad[j];
    bu_mc.select();
    trace("xPos: "+bu_mc._x+" building: "+bu_mc._name);
    The correct _x and _name are displayed, but nothing happens
    to the movieclip.
    select() is a function that I've defined. It works when
    called by the movieclip itself, but is not working when called by a
    different movieclip.

  • How to stop a movie clip moving

    I'm not newbie to flash but I am newbie to coding using
    actionscript!!!
    I am trying to create a button that moves a movie clip
    ("content1") diagonally across the screen but once the movie clip
    reaches a certain x co-ordinate I want it to stop and then when I
    click another button I would like it to return to it's starting
    position. At the moment the movie clip moves if I click one of the
    buttons but as soon as I click another one it stops which it
    shouldn't it should go back in the other direction. The other
    problem is that once I've clicked a button I cant seem to get it to
    stop moving once it reaches a certain _x position it just keeps on
    moving off the stage.
    Below is the script I have so far not including any
    conditions to check if "content1" has reached it _x position
    Could anyone help please!!!!
    //on Right movie clip containing the button
    onClipEvent (enterFrame) {
    _root.content1._x += speedX;
    _root.content1._y -= speedY;
    //on Right button inside movie clip
    on (press) {
    speedX = 5.5;
    speedY = 1.33;
    //on Left movie clip containing the button
    onClipEvent (enterFrame) {
    _root.content1._x += speedX;
    _root.content1._y -= speedY;
    //on Left button inside movie clip
    on (press) {
    speedX = 5.5;
    speedY = 1.33;

    Many thanks ClBeech!!!
    I've tried the code you suggested but it doesn't seem to work
    :0(
    I'm working on a Mac using Flash Pro 8 which only has the
    option to publish as 'actionscript 1.0 or 2.0' is the script you
    supplied an actionscript 3.0?
    Below is the script with the amendments, I've changed my
    button instance names to match the script you supplied (left_btn /
    right_btn)
    stop();
    import mx.transitions.Tween;
    import mx.transitions.easing.Strong;
    var rposX = 369;
    //the ending x of the right position
    var rposY = 84;
    //the ending y of the right position
    var lposX = 116;
    //the ending x of the left position
    var lposY = 154;
    //the ending y of the left position
    right_btn.onPress = function() {
    new Tween(content1, '_x', Strong.easeOut, content1._x,
    rposX, time, false);
    new Tween(content1, '_y', Strong.easeOut, content1._y,
    rposY, time, false);
    left_btn.onPress = function() {
    new Tween(content1, '_x', Strong.easeOut, content1._x,
    lposX, time, false);
    new Tween(content1, '_y', Strong.easeOut, content1._y,
    lposY, time, false);

  • Printing a movie clip with dynamic text boxes

    I've got a certificate inside a movie clip, and i want the
    dynamic text box to dispay the user name, but for some reason it is
    coming up undefined, even though i have the dynamic text box set to
    finalname = _root.inputname, but it comes up as undefined on the
    screen. :( Can anyone tell me where i am going wrong?
    Is there a way to print just a specific movie clip on the
    screen? I can only print all the frames in the movie and without
    the dynamic text box... any help would be greatly
    appreciated.

    assign the mouseChildren property of your movieclip to false.

  • Dynamic text in different movie clip

    Inside scene one i have a movie clip that contains a movie
    clip that contains a dynamic text field. Also inside Scene one I
    have a different movie clip that contains a movie clip that
    contains a movie clip that contains a input text field. And I need
    for the user to type in to the input text field and see what they
    are typing show up in the dynamic text field. What would that
    script look like and where would I put it? Can anyone help
    please?

    hi!
    Lets say you have your dynamic clip on the same level as the
    movieclip containing your input field.
    _root.dynamic_texfield_name.text =
    _root.name_of_movieclip.input_texfield_name.text;
    If you need the dynamic textfield to be updated as soon as
    the user types something in the input field you can use a onChange
    handler.
    _root.name_of_movieclip.input_texfield_name.onChange =
    function(){
    _root.dynamic_texfield_name.text =
    _root.name_of_movieclip.input_texfield_name.text;
    }

  • Dynamic text in looping movie clip

    Hi,
    I am looping a movie clip which has a dynamic text box. I
    need to call data from XML and place the same in the Dynamic text
    box as per the duplicated movie clip. how do i do that.
    Thanks,
    Ayush

    on (release) {
    _parent.frontFields.topTextArch.ph2TopTextBrush._visible =
    false;
    That is the script attached to my button. I can see the text
    flash for a second when I push the button but it does'nt go away
    because the looping movie clip just continually goes back to the
    first frame and makes the ph2TopTextBrush text field visible again.
    I think I know what your saying. Your saying to attach a
    script to the first frame of the looping movie clip that would
    check to see which of the 3 dynamic text fields are visible. That
    would be perfect but I'm not sure how to do it.
    What would the script that I place on my button look like?
    What would the script in the first frame of the looping movie clip
    look like?

Maybe you are looking for