简体   繁体   中英

How to change the value of an object property in actionscript3?

I'll start by showing my code.

var modules:Object = new Object();
modules = DPServices.getModules.lastResult;
for each (var item:Object in modules){
    if(item.menu == 0){
        // Don't know what to do here!!
    }
}
modulesDG.dataProvider = modules;

By the way this is ActionScript 3.

What I am trying to do is change the value from a 0 to 'No' or a 1 to 'Yes'. I have tried modules.menu = 'no' , modules.item.menu = 'no' , and modules.@menu = 'no' . So how do I change this value?

Is modules an object of objects? If not, this should be fine:

item.menu = 'no';

You want to change menu to 1 if it's 0?

Isn't it enough to just do:

if(item.menu == 0){
    item.menu = 1;
}

Though I'm not exactly sure what you're asking for.

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