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); } 

  1. if using addchild() method must inherits features of displayobjectcontainer. , if using inventory class document class, must extends sprite or movieclip.

  2. document class must defined public access specifier.

  3. 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);         }    } } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -