Note that there are some explanatory texts on larger screens.

plurals
  1. POOdd numbers of object extraction from an array
    primarykey
    data
    text
    <p>I'm trying to get 2 objects at a time form the array for now. but soon I will be using odd number of length and splicing items.</p> <p>This works out perfectly so far with Even numbers in the Array, but I am not sure how to make it work with odd numbers. The way I think it may work is ask it to check the objects coming up next and if it is less than 2 than change the counters to 1. but I am not even sure how to put that in code specifically. I posted my code so far be</p> <pre><code>import flash.events.MouseEvent; import flash.net.Socket; var socket_Array_current_position = 0; var socket_counter = 2; var socket_Array: Array = new Array (); socket_Array.push(socket_one, socket_two,socket_three, socket_four, socket_five, socket_six); go_next_left.addEventListener(MouseEvent.CLICK, go_left); go_next_right.addEventListener(MouseEvent.CLICK, go_right); function go_left(going_left:MouseEvent) { if (socket_Array_current_position &gt; 0) { socket_remove(); socket_Array_current_position -= socket_counter; socket_x_position = 125; socket_display(); } } function go_right(going_right:MouseEvent) { if (socket_Array_current_position &lt; socket_Array.length-socket_counter) { socket_remove(); socket_Array_current_position += socket_counter; socket_x_position = 125; socket_display(); } } socket_display(); function socket_display() { var s = 0; for (s; s &lt; socket_counter; s++) { addChild(socket_Array[socket_Array_current_position + s]); socket_Array[socket_Array_current_position + s].x = socket_x_position; socket_Array[socket_Array_current_position + s].y = socket_y_position; //socket_Array[s].addEventListener(MouseEvent.CLICK, picked); socket_x_position = socket_x_position + 275; } } function socket_remove() { var s = 0; for (s; s &lt; socket_counter; s++) { removeChild(socket_Array[socket_Array_current_position+s]); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload