A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Lots of things same command- how?

  1. #1
    Member
    Join Date
    Jan 2007
    Posts
    56

    Lots of things same command- how?

    I've got 10 boxes on the stage.

    I want to start and stop dragging them all when needed.

    Do I have to type in

    boxone.onPress=function(){
    startDrag(this);
    }

    etc

    for ALL of them individually or can I assign the same commands to all 10 boxes just the once - it would save a lot of typing!

    Huw

  2. #2
    Member
    Join Date
    Mar 2009
    Location
    Pune
    Posts
    62
    I think all 10 boxes must be instances of the same movieclip. Then write onPress function inside the movie clip.

  3. #3
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    add all of the instance names to an array
    cycle thro the array in a loop setting start/stopDrag
    PHP Code:
    arr = [boxonebox2circle];

    for(var 
    n=0;n!=arr.length;n++){
    arr[n].onPress = function(){
    startDrag(this);
    };

    arr[n].onRelease = function(){
    stopDrag();
    };

    // end for 

  4. #4
    Member
    Join Date
    Jan 2007
    Posts
    56

    Thanks both!

    Thanks both work and have, what I can see as, differing advantages.

    Cheers

    Huw

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