# Load file and onEnterFrame question

**URL:** <https://forum.kirupa.com/t/load-file-and-onenterframe-question/253094>\
**Category:** flash\
**Created:** [February 27, 2008, 3:22am UTC](https://forum.kirupa.com/t/load-file-and-onenterframe-question/253094 "2008-02-27T03:22:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorilla1](https://avatars.discourse-cdn.com/v4/letter/g/278dde/32.png) [@gorilla1](https://forum.kirupa.com/u/gorilla1)\
**Post date:** [February 27, 2008, 3:22am UTC](https://forum.kirupa.com/t/load-file-and-onenterframe-question/253094/1 "2008-02-27T03:22:03Z")

</div>

The code below reads from an xml file, builds an array and then fades the text from the array elements in and out. However, the onenterframe function begins to play before the array has finished loading, so the first message or two does not appear. How does one code this so that the function that displays the messages does not run until the file load is done? - G

var interval:Number = new Number (55);

// counter for transitions  
var i:Number = new Number (0);

// current object in array  
var j:Number = new Number (0);

// in or out  
var inOutNothing:String = new String(‘in’);  
this.createTextField(‘textFaderText’, this.getNextHighestDepth(), 0,0,300, 30);  
this.createEmptyMovieClip(‘textFader’, this.getNextHighestDepth());  
textFader.beginFill(0xFFFFFF);  
textFader.moveTo(0, 0);  
textFader.lineTo(300, 0);  
textFader.lineTo(300, 30);  
textFader.lineTo(0, 30);  
textFader.lineTo(0, 0);  
textFader.endFill();

myxml = new XML();  
myxml.ignoreWhite = true;  
myxml.onLoad = loadxml;  
myxml.load(“msg.xml”);  
function loadxml(loaded) {  
if (loaded) {  
myxml = this.firstChild;  
images = [];  
textArray = [];  
total = myxml.childNodes.length;  
for (i=0; i\<total; i++) {  
textArray\* = myxml.childNodes\*.attributes.imgtitle;  
trace(textArray\*);  
}

} else {  
image\_dis = “Xml not loaded”;  
}  
}

this.onEnterFrame = function ():Void {  
// if fading in   
if (inOutNothing == ‘in’) {

```
	// if it the first time on this item
	if (i &lt;= 1) { 

```

formatA.color = 0xFF0000; // red  
formatA.italic = true;  
formatA.font = “Arial”;  
formatA.size = 12;

```
		textFaderText.text = textArray[j];
		//textFaderText.setTextFormat (formatA);

			textFaderText.setTextFormat(new TextFormat("Arial", 12));
		//var scottfieldTextFormat = textFaderText.getTextFormat();

```

//trace(scottfieldTextFormat.font);

```
	} 
	
	textFader._alpha = 100 - (100/interval) * i;
	
	if (i == interval) { 
		i=0; 
		inOutNothing = 'nothing'; 
	}
	
} else if (inOutNothing == 'out') {
	textFader._alpha = (100/interval) * i;
	if (i == interval) { 
		
		//if (j == (textArray.length-1)) { delete this.onEnterFrame; }
			if (j == (textArray.length-1)) { j=-1; }

		i=0; 
		inOutNothing = 'in'; 
		j++; 

	}
	
} else {
	
	if (i == interval) { i=0; inOutNothing = 'out'; }
	
}
i++;

```

}
