# Referencing Text Field within Custom Class

**URL:** https://forum.kirupa.com/t/referencing-text-field-within-custom-class/266766
**Category:** flash
**Created:** [July 24, 2008, 4:54am UTC](https://forum.kirupa.com/t/referencing-text-field-within-custom-class/266766 "2008-07-24T04:54:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Blazey](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@Blazey](https://forum.kirupa.com/u/Blazey)
#### Post date: [July 24, 2008, 4:54am UTC](https://forum.kirupa.com/t/referencing-text-field-within-custom-class/266766/1 "2008-07-24T04:54:15Z")

</div>

I have set up two classes, one is the DocumentClass and it imports a custom class i have made called XMLLoader. The problem is I want to change the value of a dynamic text field on the stage with the instance name xml\_txt from within the XMLLoader class…

```auto

package classes
{
    import flash.display.MovieClip;
    import classes.XMLLoader;
    
    public class DocumentClass extends MovieClip
    {
        public function DocumentClass():void
        {
             var xml:XMLLoader = new XMLLoader();
        }
    }
}

```

```auto

package classes
{
    import flash.events.*;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    
    public class XMLLoader
    {
        var req:URLRequest = new URLRequest("myXML.xml");
        var loader:URLLoader = new URLLoader();
        
        public function XMLLoader():void
        {
            loader.addEventListener(ProgressEvent.PROGRESS, loadProgress);
            loader.addEventListener(Event.COMPLETE, loadComplete);
            loader.load(req);
        }
        
        private function loadProgress(event:ProgressEvent):void
        {
           var percent:Number = ( 100 / event.bytesTotal ) * event.bytesLoaded;
           trace(Math.round(percent));
        }

        private function loadComplete(event:Event):void
        {
            var newLoader:URLLoader = URLLoader(event.target);
            trace(newLoader.data);
        }
    }
}

```
