actionscript 3 - AS3 doesn't recognize a variable I just declared -
i'm trying load background image, i'm getting error saying "error: access of undefined property assetloader." what's going on here?
import flash.display.loader; import flash.net.urlrequest; class inventory { private var assetloader:loader = new loader(); assetloader.load(new urlrequest("image.png")); //error on line addchild(assetloader); }
if using
addchild()
method must inherits features ofdisplayobjectcontainer
. , if usinginventory
classdocument
class, must extendssprite
ormovieclip
.document class must defined public access specifier.
only globally(class property definitions) declared variables allowed use
private
,public
. not allowed use locally(within functions). , timeline not allow use access specifiers.package { import flash.display.loader; import flash.net.urlrequest; import flash.display.movieclip; public class inventory extends movieclip { private var assetloader:loader; public function inventory() { // constructor code assetloader= new loader(); assetloader.load(new urlrequest("image.png")); //error on line addchild(assetloader); } } }