0

Is it possible to use a URLLoader in a class?

I am trying to use it in a class. Code is taken from: http://www.republicofcode.com/tutorials/flash/as3externaltext/

And here is my class I am trying to use it in but I get this error: C:\Users\com\defaultVars.as, Line 36 1046: Type was not found or was not a compile-time constant: Event.**

package com {
import flash.display.Stage;
import flash.*;

    public class defaultVars
    {



        // loader
        public var myTextLoader:URLLoader = new URLLoader();

        public function defaultVars() 
        {


            myTextLoader.addEventListener(Event.COMPLETE, onLoaded);

                    myTextLoader.load(new URLRequest("myText.txt"));
        }

      public function sampleFunction()
      {
         // trace("not used");
      }




/// ERROR LINE right below. But even if I fix this I get more errors.
function onLoaded(e:Event):void {
trace(e.target.data);
}

////////////////////////

    }

}
Papa De Beau
  • 3,744
  • 18
  • 79
  • 137

1 Answers1

0

try adding this to the top of your file.

import flash.events.*
import flash.net.*;
Dan Walmsley
  • 2,765
  • 7
  • 26
  • 45