# Printing the array to the screen problem,

**URL:** <https://forum.kirupa.com/t/printing-the-array-to-the-screen-problem/328019>\
**Category:** Uncategorized\
**Created:** [April 13, 2012, 8:58am UTC](https://forum.kirupa.com/t/printing-the-array-to-the-screen-problem/328019 "2012-04-13T08:58:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcfg](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jcfg](https://forum.kirupa.com/u/jcfg)\
**Post date:** [April 13, 2012, 8:58am UTC](https://forum.kirupa.com/t/printing-the-array-to-the-screen-problem/328019/1 "2012-04-13T08:58:09Z")

</div>

Hello there here is the code , which pulls the array from the web service and prints out to the screen if you mind have a look at my code , the code simply cant print the text by SetText:void method .

Thanks for your help attention, being open minded to help developers

function loadArray(evt:ResultEvent):void {

```
   var groupList:ArrayCollection = evt.result as ArrayCollection;       

```

var j:int = 0;

```
for ( j=0;j&lt;40;j++) { 
var tmpText:String = groupList[j].CatName.toString();
	catName_XML.push(tmpText.substr(0,1).toLocaleUpperCase()+tmpText.substr(1,20).toLocaleLowerCase());
 }
 trace(catName_XML.length);
 trace(catName_XML.toString());

 myGreeter.myArray=catName_XML;
 

  LoadedXML();
  	 
 
} 

//private function filterAnswersByAgeGroup(from:int, to:int):Array {

```

function LoadedXML( ):void{

```
loading.alpha = 0;

trace(myGreeter.myArray);

catName_XML=myGreeter.myArray;
trace("en son array uznluk" + "

```

" + catName\_XML.length);  
drawNames();

}

function drawNames()  
{  
//if (i \< catName\_XML.length)  
// {  
catName\_XML=myGreeter.myArray;  
setTEXT();  
trace("draw names function, names could not be loaded here ");  
//i++;  
//drawNames();  
//}  
//else  
// {  
// trace(“ekrana yazdırıldı.”);  
// trace(“her yazdırma da bu mu var”) ;  
// } // xml olarak basarken drawNames() func  
}

//////////////////////////////////////////////////////////////////////////////////////////  
//GUI TEXT IMPLEMENTATION

/////////////////////////////////////////////////////////////////////////////////////////  
var LastWidth:Number = 0;  
var LastWcount:Number = 0;  
var raw:int = 0;  
var LastHeight:Number = 0;  
//function setText  
function setTEXT()  
{  
var textStyle:TextFormat = new TextFormat();  
var newFont:Font=new font1();  
textStyle.font = newFont.fontName;  
[//textStyle.font](https://textStyle.font) = “HelveticaRounded Bold”;  
textStyle.color = 0x313131;  
textStyle.size = 18;  
textStyle.bold = false;  
textStyle.kerning = true;  
textStyle.italic = false;

```
if (selectedFlag == true || searchFlag == true)
{////////////////////////////////////////////////////////////////////selected dizilim
	if (i &lt; 12)
	{
		var theName2 = new TextField();
		var theRatio = new TextField();
		theName2.autoSize = TextFieldAutoSize.LEFT;
		theRatio.autoSize = TextFieldAutoSize.RIGHT;
		theName2.background = true;
		theRatio.background = true;
		theName2.backgroundColor = 0xFFFFFF;
		theRatio.backgroundColor = 0xFFFFFF;
		theRatio.width = 50;
		theName2.multiline = false;
		theRatio.multiline = false;
		theName2.wordWrap = false;
		theRatio.wordWrap = false;
		theName2.selectable = false;
		theRatio.selectable = false;

		theName2.text = catName_XML*;
		theRatio.text = Number(Number(popular_XML*) + 1) + "%";

		theRatio.setTextFormat(textStyle);
		theName2.setTextFormat(textStyle);

		var MCs2:Sprite = new Sprite();
		var MCs22:Sprite = new Sprite();
		MCs2.addChild(theName2);
		if (searchFlag)
		{
			MCs22.addChild(theRatio);
		}
		theName2.y = - theName2.height;
		theRatio.y = - theName2.height;
		theRatio.x = 150 - theRatio.width;

		MCs2.name = "kitty" + i;
		MCs2.mouseChildren = false;
		ALLnames.addChild(MCs2);
		SLTnames.addChild(MCs22);
		theName2.embedFonts = true;
		theRatio.embedFonts = true;

		MCs2.y = Math.floor(i / 2) * 45;
		MCs2.y += 45;
		MCs22.y = MCs2.y;
		var kln:Number = i % 2;
		if (kln == 0)
		{
			MCs2.x = 10;
			MCs22.x = MCs2.x;
		}
		else
		{
			MCs2.x = 300;
			MCs22.x = MCs2.x;
		}
		/*if (ALLnames.numChildren!=1) {
		//MCs2.x = 15+ALLnames.getChildAt(ALLnames.numChildren-2).x+ALLnames.getChildAt(ALLnames.numChildren-2).width;
		for (var z:Number=0; z&lt;=kln; z++) {
		ALLnames.getChildAt(ALLnames.numChildren-z-1).x -= MCs2.width/2;
		//trace(ALLnames.getChildAt(ALLnames.numChildren-z-1).name)
		}
		} else {
		MCs2.x -=MCs2.width/2;
		MCs22.x = MCs2.x
		}
		if (i==catName_XML.length-1&&(i+1)%2==1) {
		ALLnames.getChildAt(ALLnames.numChildren-1).x += MCs2.width/2;
		}*/
		//if (i&gt;16) {
		//ALLnames.removeChild(MCs);
		//}
	}
}
else
{/ ////////////////////////////////////////////////////////////////////////normal dizlim
	var theName:TextField;
	theName = new TextField();
	theName.autoSize = TextFieldAutoSize.LEFT;
	//
	theName.background = false;
	theName.backgroundColor = 0xFFFFFF;
	theName.multiline = false;
	theName.wordWrap = false;
	theName.selectable = false;
	theName.antiAliasType = AntiAliasType.ADVANCED;
	theName.text = catName_XML*;

	var MCs:Sprite = new Sprite();
	MCs.addChild(theName);
	theName.y -= theName.height;
	MCs.name = "kitty" + i;
	MCs.mouseChildren = false;
	ALLnames.addChild(MCs);
	theName.setTextFormat(textStyle);
	theName.embedFonts = true;

	//MCs.scaleX = MCs.scaleY = (Number(popular_XML*)*1.5/67)+.7;
	MCs.scaleX = MCs.scaleY = (Number(popular_XML*)*1.5/67)+.8;
	if (ALLnames.numChildren == 1)
	{
		MCs.y = -5;
	}
	else
	{
		MCs.y = ALLnames.getChildAt(ALLnames.numChildren - 2).y;
	}
	//trace(MCs.name);

	LastWidth += MCs.width + 20;
	//trace(LastWidth);
	if (LastWidth &lt; 470 && ALLnames.numChildren != 1)
	{
		LastWcount;
		MCs.x = 20 + ALLnames.getChildAt(ALLnames.numChildren - 2).x + ALLnames.getChildAt(ALLnames.numChildren - 2).width;
	}
	else
	{
		raw++;
		MCs.x = 0;
		MCs.y += 47;
		LastWidth = MCs.width;
	}
	//trace(raw);
	if (raw &gt; 6)
	{
		ALLnames.removeChild(MCs);
	}
}
ALLnames.buttonMode = true;
//MCs.y = Math.floor(i/7)*50;

//for (var z:Number=0; z&lt;=kln; z++) {
//
//ALLnames.getChildAt(ALLnames.numChildren-z-1).x -= MCs.width/2;
////trace(ALLnames.getChildAt(ALLnames.numChildren-z-1).name)
//}

/*
var kln:Number = i%7;
if (kln == 0) {
MCs.x = 0;
} else {
if (ALLnames.numChildren!=1) {
MCs.x = 15+ALLnames.getChildAt(ALLnames.numChildren-2).x+ALLnames.getChildAt(ALLnames.numChildren-2).width;
//for (var z:Number=1; z&lt;=kln; z++) {
//ALLnames.getChildAt(ALLnames.numChildren-z-1).x -= MCs.width/2;
//trace(ALLnames.getChildAt(ALLnames.numChildren-z-1).name)
//}
} else {
MCs.x = 350-MCs.width+10;
}
}
if (ALLnames.numChildren!=1) {
//MCs.x = 15+ALLnames.getChildAt(ALLnames.numChildren-2).x+ALLnames.getChildAt(ALLnames.numChildren-2).width;
for (var z:Number=0; z&lt;=kln; z++) {
ALLnames.getChildAt(ALLnames.numChildren-z-1).x -= MCs.width/2;
//trace(ALLnames.getChildAt(ALLnames.numChildren-z-1).name)
}
}*/

```

}
