The movie the script is in gets loaded into another movie. I can trace out _root.cat_color[0] etc... with no problems, even doing so in the for loop outputs proper values for _root.cat_colors[i]. If i trace out tempColor.length after the split, it always comes back undefined, thus the loop after that never happens.

trace("String: "+_root.cat_colors[0]);
// traces out bob,jim,john

var tempColor:Array = _root.cat_colors[0].split(",");

trace("Total: "+tempColor.length);
// traces out undefined when it should be 3




Adrian Lynch wrote:

Just took your code and plonked it in a new .fla and it works for me. Is
anything else happening in the movie or any included movies?

See it here: http://www.adrianlynch.co.uk/temp/colours.fla

Ade

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Mike
Boutin
Sent: 20 December 2005 23:41
To: Flashcoders mailing list
Subject: [Flashcoders] Wierd split


Im having a wierd problem with using .split on an array.  I create an
array 3 frames before in the same timeline like so:

_root.cat_colors = new Array();
_root.cat_colors[0] = "bob,john,betty";


Then 2 frames down the timeline I run a loop like so:

for (i=0; i<_root.cat_colors.length; i++) {

   trace("String: "+_root.cat_colors[i]);
  // The string traces properly here ex. bob,jim,john etc...

   var tempColor:Array = _root.cat_colors[i].split(",");
   trace("Total: "+tempColor[i]);
   // traces out undefined for the next loop never happens

   for (j=0; j<tempColor.length; j++) {
      trace("Color: "+tempColor[j]);
   }

}


Anyone know why this doesnt work? is there another way to achieve this?
If i create the array on the same frame as the loop, everything works
like it should.


Thanks!

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to