# IMPORTANT - Help with my syntax, pls!

**URL:** <https://forum.kirupa.com/t/important-help-with-my-syntax-pls/254966>\
**Category:** flash\
**Created:** [March 17, 2008, 7:54pm UTC](https://forum.kirupa.com/t/important-help-with-my-syntax-pls/254966 "2008-03-17T19:54:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![schammy79](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@schammy79](https://forum.kirupa.com/u/schammy79)\
**Post date:** [March 17, 2008, 7:54pm UTC](https://forum.kirupa.com/t/important-help-with-my-syntax-pls/254966/1 "2008-03-17T19:54:10Z")

</div>

[SIZE=2]I’m having trouble with the way I write my code (= newbie) and I really do need some help to 1) come up with a bettered script and 2) understand what I do wrong.[/SIZE]  
[SIZE=2]I will try and explain what I’m trying to achieve with the code below…[/SIZE]

[SIZE=2]I want to load a bunch of html text files into an array. Each file is to be displayed in a dynamic text field (html\_txt) when a related button is clicked. It is not super complicated but I’m lacking some knowledge…[/SIZE]

```auto
 
var currentButton:String;
 
var extFiles:Array = ["TXT/text1.html", "TXT/text2.html", "TXT/text3.html", "TXT/text4.html"];
 
function clickHandler(event:MouseEvent) {
currentButton = event.target.name;
switch (currentButton) {
case "b6" :
loadText(extFiles[0]);
break;
case "b7" :
loadText(extFiles[1]);
break;
}
 
}
function loadText(myrequest:URLRequest):void {
var textLoader:URLLoader = new URLLoader();
textLoader.addEventListener(Event.COMPLETE, textReady);
textLoader.load(myrequest);
}
 
function textReady(event:Event) {
this.contentHold.content1.html_txt.htmlText = event.target.data;
}

```

[SIZE=2]Right now, if I preview my swf with this code, I get: “ **Error #1034: Type Coercion failed: cannot convert “TXT/text1.html” to flash.net.URLRequest.** ”[/SIZE]

[SIZE=2]I used to have this script with ‘loadText(new URLRequest(“TXT/text1.html”));’ after each case. So basically, it was ‘load on demand’ over and over. Since I plan to use this piece of code in a larger, more complex project, I want to pre-load all my files in an array beforehand. I think I understand my error comes from changing the script abruptly and not adapting it. So this is where I need your help![/SIZE]

[SIZE=2]I guess you know everything now…[/SIZE]  
[SIZE=2]**[SIZE=5][COLOR=royalblue]A BIG THANK YOU FOR YOUR TIPS!!![/COLOR][/SIZE]**  
[/SIZE]
