A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: I spent three hours on this code bit.. and no luck .HELP!!

  1. #1
    Senior Member
    Join Date
    Mar 2001
    Posts
    283

    Unhappy

    ... to give you some info, the MC "person" is on the main timeline and "this" is inside a MC called "powerup".. now I want "this" to move to where " person" is all the time.


    --------------------------------
    onClipEvent (keyDown) {
    with (_root) {
    posx = getProperty (_root.person, _x );
    posy = getProperty (_root.person, _y );
    setProperty (this, _x, posx);
    setProperty (this, _y, posy);
    }
    }
    ---------------------------------

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Posts
    190

    Erm...

    Put this in the "this" actions:
    Flash 5:
    onClipEvent (keyDown) {
    _x = _root.person._x;
    _y = _root.person._x;
    }

  3. #3
    Senior Member
    Join Date
    Mar 2001
    Posts
    283
    I will try to tell the problem instead of just throwing around code..

    im stuck on how to get a MC thats inside another MC to read the x,y cords of a MC on the timeline and update its own cords on a per frame rate.

  4. #4
    Member
    Join Date
    Jun 2001
    Posts
    52
    Hey why cant u just make the 2 MC a movie and make them play when u want them to by using the AS

  5. #5
    Senior Member
    Join Date
    Mar 2001
    Posts
    283
    because the MC inside the MC is the enemy.. the thing its headed twards is the hero.. the MC that holds the enemy allows it to move and scroll with the hero ala zelda/final fantasy..i.e. background moves..

    if I can place all the enemys on there own MC that moves relative to the hero inside there MC and also allows them to detect objects in there paths.. then im all set.

    right now I can only do two monsters

    let me give you an example.. in final fantasy.. the hero stays in the same place, the back ground moves... however also in zelda.. the enemys not only have to move to get the hero, they also have to collide with background objects as well as moving relative to the background as the hero is walking...

    therefore, I would LIKE to know if there is a way to feed data of the hero who is on the maintime line.. to the MC that would hold the monsters..however I am having problems getting the heros data to be read by the enemys inside a MC... that is my main issue..

    how do you get a MC inside another MC to read the x,y cords of a MC on the timeline? ...

    you dont have to understand any of this really.. just understand that im having PROBLEMS getting MC's inside another MC to read the cords of a MC on the main timeline..



  6. #6
    Senior Member
    Join Date
    Feb 2001
    Posts
    314
    Tartersause--Try this:

    this._x = _root.person._x - _parent._x
    this._y = _root.person._y - _parent._y

    The problem you're having is caused because this._x and this._y are relative to the coordinates of its parent movie clip. Therefore, when you change this._x and this._y, you need to adjust by the coordinates of _parent, which is what the subtraction in the above script does.

    That should work, but let me know.



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