A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: duplicateMovieClip under onClipEvent

  1. #1
    rafucho
    Join Date
    Jan 2006
    Location
    Mérida, Venezuela
    Posts
    27

    duplicateMovieClip under onClipEvent

    Hi everybody!
    I need to have a clip duplicate itself under an onClipEvent(load) handler, like:
    onClipEvent(load) {
    //clips duplicate itself
    }
    I've tried all sort of ways, always get a message to abort the script.
    I would appreciate any help.

  2. #2
    rafucho
    Join Date
    Jan 2006
    Location
    Mérida, Venezuela
    Posts
    27
    I'm beginning to think this cannot be done.

  3. #3
    Senior Member
    Join Date
    Nov 2004
    Posts
    928
    i=0;
    _root.onEnterFrame = function() {
    i++
    mc.duplicateMovieClip("mc"+i,i)
    _root["mc"+i]._x+=50*i;
    trace(i)
    }
    this will duplicate a movieClip with an instance name mc

  4. #4
    rafucho
    Join Date
    Jan 2006
    Location
    Mérida, Venezuela
    Posts
    27
    Thanks, only I would like to know if it can be done as part of an <onClipEvent(load)> attached to the clip I want to duplicate. Get me?

  5. #5
    Senior Member
    Join Date
    May 2005
    Posts
    324
    how about


    onClipEvent (load) {
    duplicateMovieClip (this, 1)
    }

    or something like that.

    remember, the depth value is important, as only one item can appear on one depth (to my knowledge)
    "great scott!"

    "I know, this is heavy!"

  6. #6
    rafucho
    Join Date
    Jan 2006
    Location
    Mérida, Venezuela
    Posts
    27
    This is the only alternative I hadn't tried. But then, how should I address the new copy of <this>? In other words, what would be the instance name of the new copy?
    I think you are getting close. Please continue, and thanks!

  7. #7
    Senior Member
    Join Date
    May 2005
    Posts
    324
    uplod your FLA file, i dont really get what you mean
    "great scott!"

    "I know, this is heavy!"

  8. #8
    rafucho
    Join Date
    Jan 2006
    Location
    Mérida, Venezuela
    Posts
    27
    Nothing more than on kf1 of "myMC_mc":
    onClipEvent(load) {
    duplicateMovieClip( "myMC_mc","copy1",1);
    copy1._x = someValue;
    copy1._x = someValue;
    }
    I wished I could put it more clear.
    I appreciate your patience.

  9. #9
    Senior Member
    Join Date
    May 2005
    Posts
    324
    have you set up the linkage? (right cliuck in the library view) linkage will give it a name to be used in actionscript, much like a variable
    "great scott!"

    "I know, this is heavy!"

  10. #10
    rafucho
    Join Date
    Jan 2006
    Location
    Mérida, Venezuela
    Posts
    27
    clip is already on stage, instance name "myMC_mc".

  11. #11
    Senior Member
    Join Date
    May 2005
    Posts
    324
    is the clip on the same level as the script?
    "great scott!"

    "I know, this is heavy!"

  12. #12
    Senior Member
    Join Date
    Nov 2004
    Posts
    928
    sorry i misread your first post.unless you are using flash5 and older then there is no reason to use onClipEvent syntax. so ....

    _root.onLoad= function() {
    my_mc.duplicateMovieClip("copy",1);
    copy._x = someValue;
    }

  13. #13
    rafucho
    Join Date
    Jan 2006
    Location
    Mérida, Venezuela
    Posts
    27
    frustrated and on the point of giving up I decided to try with attachMovie, like:
    onClipEvent(load) {
    for(i = 0; i < n; i++) {
    _root.attachMovie("clip", "clip" + i, i) ;
    _root["clip" + i]._x = 50 + 50 * i;
    _root["clip" + i]._y = 50 + 40 * i;
    }
    And it works! The question remains, why it doesn't work with duplicateMovieClip.
    My sincere appreciation for your time and patience.

  14. #14
    rafucho
    Join Date
    Jan 2006
    Location
    Mérida, Venezuela
    Posts
    27
    i'm using Flash MX.

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