# Problem accessing main timeline textfield from class

**URL:** <https://forum.kirupa.com/t/problem-accessing-main-timeline-textfield-from-class/258533>\
**Category:** flash\
**Created:** [April 24, 2008, 6:56pm UTC](https://forum.kirupa.com/t/problem-accessing-main-timeline-textfield-from-class/258533 "2008-04-24T18:56:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![x0b](https://avatars.discourse-cdn.com/v4/letter/x/e495f1/32.png) [@x0b](https://forum.kirupa.com/u/x0b)\
**Post date:** [April 24, 2008, 6:56pm UTC](https://forum.kirupa.com/t/problem-accessing-main-timeline-textfield-from-class/258533/1 "2008-04-24T18:56:48Z")

</div>

Hello,

I’m having a real hard time trying to work this one out. I’m pretty new to AS3 and OOP in general, but I’m slowly progressing.

I have an uploading class that I have made that uploads mp3s to a server, that works fine, the problem I’m having is inputting information about the file into a textfield that is located on the main stage. I can’t work out how to refer to it properly, as the old AS2 method of dot syntax doesn’t work.

I had the uploader working fine when it was is in it’s own fla and not utilising external classes, and the textfield displayed exactly as I wanted. I just want to get my head round using classes and thus having cleaner, modular code.

I’ve searched all day and found some stuff that I think might help, such as displayobject and defining root and stage, but I can’t really get my head round how to do it.

Here are some code snippets that hopefully you’ll be able to make sense of…

The main fla code:

```auto

mUpload.bPlay.addEventListener(MouseEvent.CLICK, uploadFile);

function uploadFile(evt:MouseEvent):void {
    var tester:Uploader = new Uploader();
    }

```

and the Uploader.as file code:

```auto
package {

    import flash.net.*;
    import flash.events.*;
    import flash.display.Sprite;
    import flash.text.TextField;
    
    public class Uploader extends Sprite{

        private var fileTypes:FileFilter = new FileFilter("mp3 (*.mp3)", "*.mp3");
        private var allTypes:Array = new Array(fileTypes);
        private var fileRef:FileReference = new FileReference();
        public var tStatus:TextField;
        
        public function Uploader():void {
            fileRef.addEventListener(Event.SELECT, selectHandler);
            fileRef.addEventListener(Event.COMPLETE, completeHandler);
            try {
                var success:Boolean = fileRef.browse(allTypes);
                trace("Uploading...");
                    } catch (error:Error) {
                trace("Unable to browse for files.");
            }
        }
        private function selectHandler(event:Event):void {
            var fileTypes:FileFilter = new FileFilter("mp3 (*.mp3)", "*.mp3");
            var allTypes:Array = new Array(fileTypes);
            var request:URLRequest = new URLRequest("http://www.blahblah.com/alive/uploads/uploader.php");
            try {
                fileRef.upload(request);
            } catch (error:Error) {
                trace("Unable to upload file.");

            }
        }
        private function completeHandler(event:Event):void {
tStatus.text = "Successfully Uploaded - " + event.target.name + " - " + event.target.size;
        }
    }
}

```

I have a textfield that i have created on the stage called tStatus within which I want to display some information once I have uploaded the file.

Any help would be greatly appreciated, for my sanity’s sake :stare:
