A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] splice array

  1. #1
    Senior Member
    Join Date
    Jan 2003
    Location
    Middel east
    Posts
    239

    [F8] splice array

    hi all hope every is in good health

    my problem is I have 3 MC in an array which i want visible= false for 2 of them so i tried to splice one out of the array but could not this is the code
    Code:
    on (release) {
    	sums_array = new Array("0", "1", "2");
    	index = Math.round(Math.random()*sums_array.length);
    	sums_array.splice(index, 1);
    	trace(index);
    	//trace(sums_array);
    	for (i=0; i<sums_array.length; i++) {
    		_root["ball"+i]._visible = false;
    	}
    }
    hope i made myself clear
    by the way i am not too good with array
    thankssssssssssss for any help

  2. #2
    Island Boy
    Join Date
    Apr 2006
    Posts
    655
    why not just use an if statement in your for loop to exclude the MC you want to be visible.

    Code:
    for (i=0; i<sums_array.length; i++) {
                  if (i!=clipPointer){
                          	_root["ball"+i]._visible = false;
                  }
    }

  3. #3
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try -
    Code:
    on (release) {
    arr = [0, 1, 2];
    arr.sort(function(){return Math.floor(Math.random()*3)-1});
    arr.pop();
    trace(arr);
    for (var i=0; i<arr.length; i++) _root["ball"+arr[i]]._visible = false;
    }

  4. #4
    Senior Member
    Join Date
    Jan 2003
    Location
    Middel east
    Posts
    239

    thank you very much

    dear a_modified_dog thank you very much you have save the day
    thanks you are a hero

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