A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Clone Placing

  1. #1
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    474

    Clone Placing

    Hey, does anyone know how I could clone an element then place each clone in a specific place? Like make 15 clones put one at (15,60) and another at (20, 65). I don't work a lot with clones so I wasn't really sure if this is possible. Thanks.
    BC

  2. #2
    Senior Member
    Join Date
    May 2005
    Posts
    163
    A cloned element is just like any other element you create the only difference is that it is a copy or clone of a pre-defined element. So you can use ANY of the element properties and methods available,

    To place a cloned element just use the .x and .y properties.

    For ex.

    PHP Code:
    var clone = element("test").clone();
    clone.
    15;
    clone.
    60

  3. #3
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    474
    yeh I figured someone would say this, I was more going for a
    for (x=0,x<15,x++){
    clone=element.clone
    clone.x=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
    clone.y=50
    }

    or something. So that there would be 15 clones and the first one would be at 1 x, second at 2 x, etc. Is something similar to this possible? I wanted to do this so I could keep all the collsions simple along with not making a bunch of elements.
    BC

  4. #4
    Senior Member
    Join Date
    May 2005
    Posts
    163
    Do it more like this..

    PHP Code:
    for (x=0,x<15,x++){
    clone=
    element.clone
    clone.
    x=x+1
    clone.y=50

    or you could store your X coordinates in an array if there is no pattern to them...

    PHP Code:
    coordX = new Array(1,4,25,6,90,100,15,73,34);
    for(var 
    i=0;i<coordX.length;i++) {
    clone=
    element.clone
    clone.
    x=coordX[i]
    clone.
    y=50

    You could also do another array or loop for the Y coordinate if it isn't static.

  5. #5
    Game Master ConnELITE's Avatar
    Join Date
    Apr 2005
    Location
    United States, DC
    Posts
    474
    ofcourse, x+1, haha. Havent tried it yet but its so simple! Thankyou.
    BC

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