A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: controling individual mc after we duplicate

  1. #1
    Junior Member
    Join Date
    Apr 2004
    Posts
    10

    controling individual mc after we duplicate

    Hi all! I have a question...let's say we duplicate dynamicaly an MC four times, and place the duplicants on stage dymamicaly like this:

    ball0._visible = 0;
    for (i=1; i<=4; i++) {
    duplicateMovieClip(ball0, "ball"+i, i+20);
    _root["ball"+i]._x = 125;
    _root["ball"+i]._y = 360;
    _root["ball"+i]._xscale = 80;
    _root["ball"+i]._yscale = 80;

    }

    Then how do we control individual MC's x and y position after a drag and drop?
    thanks....

  2. #2
    2HT
    Join Date
    Jul 2000
    Posts
    96

    How to control after duplicating mc's

    Hello, well I hopefully will answer your question in the best possible manner. After you duplicate an item you must understand that you have to literally direct all actionscript dynamically on a frame instead of actually selecting on the MC or Button via the timeline.

    For that reason we would go about the actionscript like this:

    _root.ball1.onPress = function () {
    this.startDrag();
    //whatever other statements
    }

    _root.ball1.onRelease = function () {
    this.stopDrag();
    //whatever other statements
    }

    You can then place these actionscripts everywhere that would reference whatever paths help you.

  3. #3
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    One of the advantages of duplicate movie is that is passes the code of the master clip to the duplicated ones. So, you can set your startDrag and stopDrag on the master clip in an onEnterFrame and each clip will be draggable. Also, in the onClipEvent , you can assign a variable so that each duplicated MC will keep track of it's own x or y position. Something like.....
    myX = this._x;
    myY = this._y;

    Then to access the _x or _y position of any clip on the stage, just check the myX, myY variables.
    trace(_root.ball1.myY)

    HTH
    NTD

  4. #4
    Junior Member
    Join Date
    Apr 2004
    Posts
    10
    Thank you so much for your reply. I have tried it though and kind of had some diffirculties but now it is working. The variable solution is a very clever concept!
    thank you :-)

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