A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: variable looking for array content, array looking for another array...

Threaded View

  1. #1
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601

    variable looking for array content, array looking for another array...

    it's been a while since i posted something here... but i'm having a little trouble with that, can someone put me in the correct way? thanks ^^

    here we go, how can i tell a variable to "record" the content of an array? the array must be safe of course. here's what i have:

    Code:
    array_n = ["a", "b", "c", "d", "e"];
    check1 = array_n[0]+array_n[1]+array_n[2];
    trace(check1);
    ^ this works fine! the trace action give me abc. BUT:

    Code:
    for (i=0; i<=2; i++) {
    	check1 = array_n[ i ];
    }
    trace(check1);
    ^ here, the trace action give me only c. it's normal, ok. but how can i keep the for loop and having again abc as a result?



    another problem/question
    here, the idea is quite the same, but it doesn't work as i want either
    Code:
    combo_array = new Array();
    combo_array[0] = ["down", "forward", "forward"];
    combo_array[1] = ["down", "down", "forward", "forward"];
    combo_array[2] = ["down", "backward"];
    combo_array[3] = ["down", "down"];
    //
    combo_actual = ["down", "forward", "forward"];
    > now i'm writing a for loop; i just want to check if one of the combo_array is similar to the combo_actual one:

    Code:
    trace(combo_actual);
    for (i=1; i<=combo_array.length; i++) {
    	trace(combo_array[i-1]);
    	if (combo_array[i-1] == combo_actual) {
    		trace("working!");
    	}
    }
    here are the results with the trace actions:
    trace(combo_actual)
    > down,forward,forward

    trace(combo_array[i-1])
    > down,forward,forward
    > down,down,forward,forward
    > down,backward
    > down,down

    as you can see, there is a similarity (down,forward,forward), but the "working!" never appears. am i missing something?

    thanks for your help ^^
    Last edited by marmotte; 06-15-2003 at 11:44 AM.

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