Copy link to clipboard
Copied
The adding bit works fine:
// get this pconn count
var this_p_conn:Number = Object(this).parent.p_conn;
// get current pconn total
var c_this_p_conn:Number = Object(root).part_count.p_conn_count.text
// add this pconn count to total pconn
var v_this_p_conn:Number = Number(this_p_conn+c_this_p_conn);
// Update total pconn with new value
Object(root).part_count.p_conn_count.text = String(v_this_p_conn)
Removing a value from the total is another story, this looks like it should work but it does not:
// get this pconn count
var count_p_conn:Number = Object(this).parent.p_conn;
// get current pconn total
var total_p_conn:Number = Object(root).part_count.p_conn_count.text;
// subtract this pconn count from total pconn
var new_p_conn:Number = Number(total_p_conn-count_p_conn);
// Update total pconn with new value
Object(root).part_count.p_conn_count.text = String(new_p_conn);
Any ideas or suggestions? My eyes are a bit blurry from looking at code, maybe I missed something obvious. Thanks in advance!
Copy link to clipboard
Copied
Never mind, I got it worked out now.
I had the subtraction code firing AFTER my remove self code, so the player never got to fire the subtract code:
var b:MovieClip = Object(this).parent;
Object(this).parent.parent.removeChild(b);
I placed the subtract code before the above code and now it works fine... I think I need powernap...
The lesson here is that apparently code fires from the top to the bottom, mind the order of how your code is stacked.
Sorry for the fuss! Carry on.