简体   繁体   中英

Exposing static properties in your Flex class

I have an actionscript class in my flex app that looks like this:

package Assets
{    
    public class AppIcons {

        public function AppIcons() {

        }

        [Bindable]
        [Embed(source="assets/ico_16.png")]
        public static var Icon_16:Class;

        [Bindable]
        [Embed(source="assets/ico_32.png")]
        public static var Icon_32:Class;    

    }

}

I want to know if I can extend this class and create another class that lets me access the properties as instances of that new class. Since these are static, I cannot access these as instances.

You don't need an instance to call static variables. You can access them through the class.

Pattern for static method/variable: ClassName.StaticVariableName

So just call:

var icon:Class = AppIcons.Icon_16

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM