A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: - Controlling MC Positions -

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Posts
    115
    First of all, I'm actionscript retarded. I gonna get a book or something, but until then I gotta post on this board.
    So I'm trying to control my movie clips dynamically using actionscript - I got the tell target, gotoandPlay stuff down, but I want find out how to move an MC according to the position of my other MCs, and/or the mouse.
    Specifically, I want to control the y position of an MC according to the y position of another MC. Basically, i want the y position to be the same, so when one moves, so does the other. I've tried a few things, but they don't seem to work. Can anyone help me or direct me to a good tutorial?

    Thanks,
    Tim

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Posts
    148
    try something like this:

    On the mc you want to move put-

    onClipEvent(enterFrame){
    _y = _root.otherMC._y;
    }

    otherMC being the mc you want to follow

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Posts
    115
    thanks, but that only seems to set the position for one frame. I want the other clip to follow it while it is moving. What am I missing?

  4. #4
    Senior Member
    Join Date
    Jul 2001
    Posts
    115
    anyone?

  5. #5
    Senior Member
    Join Date
    Oct 2000
    Posts
    519
    Have you definitely put the code inside an enterFrame clip event handler?

    DaveT's code is correct. If it's only updating once then my suspicion is that it's not in a frame loop.

    You have to right click the clip you want to do the following and select "actions" and then paste exactly that code suggested in the window. Then, provided your other MC is actually called otherMC and is targeted correctly it will work.

  6. #6
    Senior Member
    Join Date
    Jul 2001
    Posts
    115
    Ohhh
    I think I changed enterFrame to load, i thought it was an instruction from dave instead of an actual modifier. Can anyone enlighten me on what enterFrame actually does/means?

    Thanks

    -Tim

  7. #7
    Senior Member
    Join Date
    Oct 2000
    Posts
    519
    It's an event handler. The enterFrame handler will be executed every time the MC to which it is attached enters a frame. This means that if you attach it to a single frame movie clip it will basically execute the code within the event handle over and over again. This is why it is useful in this context. Because it executes constantly the position of your MC will be updated constantly keeping it in the right place rather than just moving it there once and only once.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center