Groups | Blog | Home
all groups > flash actionscript > october 2006 >

flash actionscript : inex/indexOf


indigomontoya
10/3/2006 7:16:51 PM
so im trying to use ined of and substr to take a certain part of an xml file
and show it in a textbox, but for some reason it shows the whole file. the box
is only big enough to show whats below, but it can be scrolled to show the rest
of the file.

Team Snipers: Team Snipers on
Relic</title><link>http://www.bungie.net/stats/gamestats.aspx?gameid=578548391&a
mp;player=Inden 1</link><pubDate>Tue, 03 Oct 2006 04:31:17


im trying to get it to stop after Relic
its doing other things too, determining which color won the game and thats
working fine, but the index part that im trying to display isnt working


// Create a new XML object.
var file:XML = new XML();
var fileIndex:String = new String();
var gameIndex:Number = new Number();
var gameIndexx:Number = new Number();
var indexLength:Number = new Number();
var gamePlayed:String = new String();
// Set the ignoreWhite property to true (default value is false).
file.ignoreWhite = true;

// After loading is complete, trace the XML object.
file.onLoad = function(success) {
trace(file);
holder_txt.text = file;
fileIndex = holder_txt.text;
gameIndex = fileIndex.indexOf("Team")
gameIndexx = fileIndex.indexOf(":"[gameIndex])
indexLength = gameIndex - gameIndexx;
gamePlayed_txt.text = fileIndex.substr(gameIndex, indexLength)





trace(fileIndex.indexOf("(Red)"));
trace(fileIndex.indexOf("(Blue)"));
if(fileIndex.indexOf("(Blue)") > fileIndex.indexOf("(Red)")){
winner_txt.text = "Blue";}
else{
winner_txt.text ="Red";}
};

// Load the XML into the file object.
file.load("http://www.bungie.net/stats/halo2rss.ashx?g=Inden 1");
indigomontoya
10/4/2006 5:49:06 PM
Anton Tupikov
10/4/2006 7:03:03 PM
Hello, indigomontoya!

According your variant, you should convert the XML document to String at line
14 in your example, before applying methods of String class:

fileIndex = file.toString();

But!!! Better try to parse and analyse your data as XML the document...



AddThis Social Bookmark Button