1、怎样链接到问层?
eval() 函数计算 JavaScript 字符串,并把它作为脚本代码来执行。
如果参数是一个表达式,eval() 函数将执行表达式。如果参数是Javascript语句,eval()将执行 Javascript 语句。
eval(拾取器拾取文本图层到SourceText.value)
例如:
eval(thisComp.layer("myText").text.sourceText.value)
2、怎样引用外部txt文件?
新建txt文件,保存。
myPath = “txt文件位置”; //引用文件位置 val = $.evalFile(myPath); //引用外部文件中的js [val,val] // 将结果放入数组中
3、怎样链接JSON文件?
JSON(JavaScript Object Notation, JS 对象简谱) 是一种轻量级的数据交换格式。
To work with a standard JSON file, use the following steps:
例如有这样一个JSON文件Exanmle JSON File.json,其内容为:
{
"planet": {
"mercury": {
"name": "Mercury",
"radius": 2439.7,
"distance": {
"perihelion": 46001200,
"aphelion": 69816900
},
"gravity": 0.380
},
"venus": {
"name": "Venus",
"radius": 6051.8,
"distance": {
"perihelion": 107477000,
"aphelion": 108939000
},
"gravity": 0.904
},
"earth": {
"name": "Earth",
"radius": 6378.1,
"distance": {
"perihelion": 147095000,
"aphelion": 152100000
},
"gravity": 1.000
},
"mars": {
"name": "Mars",
"radius": 3389.5,
"distance": {
"perihelion": 206654500,
"aphelion": 249230000
},
"gravity": 0.376
},
"jupiter": {
"name": "Jupiter",
"radius": 69911.0,
"distance": {
"perihelion": 740520000,
"aphelion": 816620000
},
"gravity": 2.528
},
"saturn": {
"name": "Saturn",
"radius": 58232.0,
"distance": {
"perihelion": 1352550000,
"aphelion": 1514500000
},
"gravity": 1.065
},
"uranus": {
"name": "Uranus",
"radius": 25362.0,
"distance": {
"perihelion": 2742129000,
"aphelion": 3008413100
},
"gravity": 0.886
},
"neptune": {
"name": "Neptune",
"radius": 24622.0,
"distance": {
"perihelion": 4459512500,
"aphelion": 4537303400
},
"gravity": 1.14
}
},
"star": {
"sun": {
"name": "Sun",
"radius": 695700.0,
"gravity": 27.940
}
},
"dwarf": {
"pluto": {
"name": "Pluto",
"radius": 1188.3,
"distance": {
"perihelion": 4436800000,
"aphelion": 7375900000
},
"gravity": 0.620
}
}
}
想要访问文件中的earth的半径radius,其表达式写为:
myDate = footage("Exanmle JSON File.json").sourceDate;
myDate.planet.earth.radius
这是一个动态链接,修改json文件中的值,AE中会同时更改。
评论 (0)