# Event.COMPLETE inside a function?

**URL:** <https://forum.kirupa.com/t/event-complete-inside-a-function/326904>\
**Category:** flash\
**Created:** [January 20, 2012, 1:43pm UTC](https://forum.kirupa.com/t/event-complete-inside-a-function/326904 "2012-01-20T13:43:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tompa](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Tompa](https://forum.kirupa.com/u/Tompa)\
**Post date:** [January 20, 2012, 1:43pm UTC](https://forum.kirupa.com/t/event-complete-inside-a-function/326904/1 "2012-01-20T13:43:59Z")

</div>

Hello!  
I have created a class named XMLclass and inside that class there is a function named returnFillColor.  
The function looks like this:

```auto
public function returnFillColor(XMLchild:uint):String{
    var xmlLoader:URLLoader = new URLLoader();
    var xmlData:XML = new XML();
    xmlLoader.load(new URLRequest(xmlURL));
    xmlData = new XML(xmlLoader.data);
    XML.ignoreWhitespace = true
            
    return xmlData.Thing[XMLchild].color;
}

```

When i call this function from my main class, it returns nothing because the XML wasn’t done loading. I’ve double-checked this by adding addEventListener(Event.COMPLETE) outside the function.

So my question is!  
Is there any way to return data from the xml-file with just one function?  
(like adding event.Complete to the returnFillColor-function)

_Really grateful for answer!  
~Tompa_
