A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: OnPress & duplicateMovieClip

  1. #1
    Registered User
    Join Date
    Feb 2006
    Location
    Canada
    Posts
    28

    OnPress & duplicateMovieClip

    On "layer 1" I have a button with the following code.


    button1.onPress = function() {
    duplicateMovieClip(_root.Circle_mov,"test1",2);
    setProperty ("test1", _x, random(275));
    setProperty ("test1", _y, random(275));

    trace ("here I am");
    };

    In my libary I have a movieclip called "circle_mov"
    I am expecting that when I click on the button an instance of "circle_mov" is created on layer 1. This does not happen.

    Any clue as to why this does not work.

    thanks in advance.
    Last edited by star1210; 02-13-2006 at 03:28 PM. Reason: did not complete

  2. #2
    Junior Member
    Join Date
    Feb 2006
    Posts
    29
    To put something in the your flash document from the library don't you use attachMovieClip()? What you're doing is trying to duplicating circle_mov but to duplicate it you need it somewhere on your Flash document, because it's where the duplicateMovieClip code looks at.

  3. #3
    Registered User
    Join Date
    Feb 2006
    Location
    Canada
    Posts
    28
    You are right, when I created an instance of circle_mov on my layer 1 , duplicateMovieClip worked. However, in my application I want to copy from the Libary.

    I tried the following as suggested but it did not work, can someplease help.

    button1.onPress = function() {
    attachMovie("Circle_mov", "test1", 6);
    test1._x = 50;
    test1._y = 150;

    trace ("here I am");
    }

  4. #4
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    Do you have the correct linkage ID for the clip set in the library?

    K.

  5. #5
    Registered User
    Join Date
    Feb 2006
    Location
    Canada
    Posts
    28
    K

    I am new to this. How would I check ?

  6. #6
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    Right click the clip in the library and choose Properties or Linkage.

    You need to give it a linkage ID that is the same as the first parameter in the attachMovie call...

    K.

  7. #7
    Registered User
    Join Date
    Feb 2006
    Location
    Canada
    Posts
    28
    K
    Thanks for throwing me the lifeline

    that worked.

    Mal

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