我正在尝试编写一个函数,将 TextFormats 应用于它们所属的 TextFields。问题是,我无法将其放入正确的“表格”(如果甚至有正确的表格)。
我的功能目前看起来像这样
function applyFormat(TextFild:String,Format:String,EmbFont:String,NameInJson:String){
//
//example:applyFormat("myTextField","myTextFormat","myFont","TextStuff")
//
//myData=json object
//all textfields etc. already exist. Just anyone wants to ask if they've been already generated.
//at first i thought it could be as easy as this
this[Format].font=myData.NameInJson.Font //doesn't work obviously
//then I tried this method
this[Format].font=myData.this[NameInJson].Font //doesn't work either
//couldn't find a real solution for this on the internet...
//how it should turn out in the end: myTextFormat.font=myData.TextStuff.Font
}
myData 的相关部分如下所示:
"TextStuff":
{
"Font":"Arial",
"Size" : "16",
"Bold" : "true",
"Color" : "0xFFFFFF"
}
我是否需要更改我的 Json 文件才能做到这一点?我是否忽略了一种处理此类变量/值的方法?