Newbie question about CLASS
I am trying to start my first flash website by using actionscript
and I have a problem with loading image with outside actionsctipt file.
here is the code:
package {
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
public class Index_page extends MovieClip {
private var req:URLRequest=new URLRequest("picture/index_page/image_logo.png");
private var logoLoader:Loader = new Loader();
logoLoader.load(req);
addChild(logoLoader);
}
}
when I publish the swf file, it comes out the error message saying,
access to undefined property logoLoader as well as req and logoLoader.
and the method addChild also became undefined.
How could that be since I`ve already declared those variables at the beginning?
But, if I put them in a function like this, it works.
public function Index_page() {
logoLoader.load(req);
addChild(logoLoader);
}
my point is,
Does it neccessary to make so many lines for only loading an image?
or there is a better way to do this. I am not really famiier with package
and class things...thanks for any help!