Help with events and listeners

Hi, I’m a noob who was suddenly thrusted into programming in flash for a school project, and many of the answers that have gotten me thus far were found in kirupa one way or another, but I’ve run into a snag that I can’t seem to get around…

I’m trying to make a program that grabs info from a text file then uses the info in the file to assign where certain balls will rotate (eventually I’ll configure it to looking like dots rotating around an invisible sphere)

Now, I can do these two things separately, load info from a file and make blue balls rotate around given points… but I’ve been tripping up hard on making them work together, and I think my problem is in how I handle the events and events listeners.

to work with the code, you’ll need to start a new flash AS3 file
Then on the stage create a circle with the oval tool
convert the circle to a symbol named “BlueCircle”
and name the linkage class as “BlueCircle”

then paste this code…

var longLatLoader:URLLoader = new URLLoader();
longLatLoader.dataFormat=URLLoaderDataFormat.VARIABLES;

longLatLoader.addEventListener(Event.COMPLETE, onLoaded);

//longLatLoader.addEventListener(Event.COMPLETE, addCircles);

 var city:Array = new Array(); 
 var country:Array = new Array(); 
 var longDeg:Array = new Array(); 
 var longmin:Array = new Array(); 
 var longDir:Array = new Array(); 
 var latDeg:Array = new Array(); 
 var latMin:Array = new Array(); 
 var latDir:Array = new Array(); 

function onLoaded(e:Event):void {

//This bit traces the info from the file, verifying a good load.
trace(e.target.data.city);
trace("
");
trace(e.target.data.country);
trace("
");
trace(e.target.data.longDeg);
trace("
");
trace(e.target.data.longmin);
trace("
");
trace(e.target.data.longDir);
trace("
");
trace(e.target.data.latDeg);
trace("
");
trace(e.target.data.latMin);
trace("
");
trace(e.target.data.latDir);
trace("
");

for(var f=0;f<=118;f++)
{
    
    city.push(e.target.data.city[f]);//Right now this block of code is useless as I can't access either
    country.push(e.target.data.country[f]);// array outside of the onLoaded function
    longDeg.push(e.target.data.longDeg[f]);
    longmin.push(e.target.data.longmin[f]);
    longDir.push(e.target.data.longDir[f]);
    latDeg.push(e.target.data.latDeg[f]);
    latMin.push(e.target.data.latMin[f]);
    latDir.push(e.target.data.latDir[f]);
        addCircles();
    
longLatLoader.addEventListener(Event.COMPLETE, addCircles);    //Been trying to figure out how 
                                                                //to place this code
    function addCircles(evt:Event)
{

var cy = 360;  //center y
    function AddCircle(evt:Event):void {
if (e.target.data.longDir[f] == 'N')
    {
         cy = 560 + int(e.target.data.longDeg[f]);
        trace ("cy is ",cy,"
");
    }else if (e.target.data.longDir[f] == 'S')
    {
         cy = 560 - int(e.target.data.longDeg[f]);
        trace ("cy is ",cy,"
");
    }
}
    var cx = 500;  //center x
    var a = 400;   //radius x
    var b = 100;   //radius y
    var r;
    var t;  

// Adding a circle to the stage
var newCircle:BlueCircle = new BlueCircle();
addEventListener(Event.ENTER_FRAME, dotRotation);
function dotRotation(evt:Event):void
{
    t += .01;
    //r += .1; //just for funsies
    newCircle.x = cx + a*Math.cos(r)*Math.cos(t) - b*Math.sin(r)*Math.sin(t);
    newCircle.y = cy + a*Math.sin(r)*Math.cos(t) + b*Math.cos(r)*Math.sin(t);
}
addChild(newCircle);
newCircle.scaleX = 1;
newCircle.scaleY = 1;
newCircle.alpha = 1;
addChild(newCircle);

    }
}
}

longLatLoader.load(new URLRequest("LongLatf.txt"));

into the first frame.
You’ll also need a text file named “LongLatf.txt”
Here it is,

rapidshare.com/files/434145343/LongLatf.txt

in the same folder as the AS file

I really want to get this done, and I really want to learn how to do it right…

Thanks a bunch in advanced and for all the help I’ve already gotten through this site!