Help with converting to an external as file

Hello I am currently trying to convert a script I have to an external .as file.
My problem is not that it won’t work out of the box. I think it may need to be completely rewritten.
Can someone please let me know what I would need to do to make this script work externally.

        _loader = new URLLoader();
        _request = new URLRequest(url + "?id=" + (this.parent as MovieClip).userInfo.id);
        _request.method = URLRequestMethod.GET;
        _loader.addEventListener(Event.COMPLETE, onLoadData);
        _loader.load(_request);

    function onLoadData(e:Event):void {
        var str:String =  e.target.data;
        
        var array:Array =str.split("-");
        for(var i:int;i < array.length; i++)
           output(i+1,array[i]);
    }
    
    function output(field:Number,i:int):void 
    {
        
        
        if (field == 5)
        {
        stmBar = new resourceBar(0, 0, i, "Stamina", 0x990000);
        addChild(stmBar);
        stmBar.x = -200;
        stmBar.y = 50;
        }
        else if    (field == 6)
        {
        tenBar = new resourceBar(0, 0, i, "Tenacity", 0xFF9900);
        addChild(tenBar);
        tenBar.x = 200;
        tenBar.y = 50;
        }
        else if    (field == 7)
        {
        potBar = new resourceBar(0, 0, i, "Potency", 0xCC3399);
        addChild(potBar);
        potBar.x = -200;
        potBar.y = 100;
        }
        else if    (field == 8)
        {
        spdBar = new resourceBar(0, 0, i, "Speed", 0x00CC00);
        addChild(spdBar);
        spdBar.x = 200;
        spdBar.y = 100;
        }
        else if    (field == 9)
        {
        crtBar = new resourceBar(0, 0, i, "Crit", 0x009999);
        addChild(crtBar);
        crtBar.x = -200;
        crtBar.y = 150;
        }
        else if    (field == 10)
        {
        awrBar = new resourceBar(0, 0, i, "Awareness", 0x3399CC);
        addChild(awrBar);
        awrBar.x = 200;
        awrBar.y = 150;
        }
        else if    (field == 11)
        {
        resBar = new resourceBar(0, 0, i, "Resistance", 0x999999);
        addChild(resBar);
        resBar.x = -200;
        resBar.y = 200;
    
        addEventListener(Event.ENTER_FRAME, onLoop);
        }
    function onLoop(e:Event):void
    {        
        stmBar.change(1);
        tenBar.change(1);
        potBar.change(1);
        spdBar.change(1);
        crtBar.change(1);
        awrBar.change(1);
        resBar.change(1);
    }
}

as of right now when its in the timeline it works perfect. the external resourceBar class works aswell. I just want to make this external aswell.

I mostly get errors with the _loader and _request not being defined.
Hope I can get this resolved.Thanx again