向安宇知识库 向安宇知识库
  • 读书向
  • 学习向
    • AI工具
    • AI研究
    • 笔记
    • AIP:克丽丝AI日志
  • 创作向
    • 写作
      • 非虚构
      • 剧本
      • 小说
      • 文言
      • 随笔
      • 日记
    • 视听
      • 纪录片
      • 设计
      • 视频
      • 摄影
    • 课程
  • 影视向
    • 创意策划
    • 前期拍摄
    • 后期制作
    • 影像实验
    • 影像设备
    • 大师镜头
    • 电影赏析
    • 视频论文
    • 项目复盘
  • 折腾向
    • 穿越机
    • 户外
    • 代码
    • 手工
    • 书法
    • 篆刻
    • 绘画
首页 › 创作向 › 课程 › AE表达式|32、如何将表达式链接到外部文件或JSON文件?
  • 0
  • 0

AE表达式|32、如何将表达式链接到外部文件或JSON文件?

向安宇
2018-10-22 13:46:28

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:

  • Select File > Import.

  • To import, select a .JSON file and click Open.

  • The file is added to your project window. Create a composition with the footage.

  • Add a solid to the composition. To add a solid, select Layer > Solid.

  • In the Timeline panel, twirl open the properties of the solid layer and Alt+Click the Opacity parameter.

  • Change the data in the expression to modify your animation. You can control the JSON data and the data is referenced from the data file where all the information is stored.

  • You can also replace the JSON file with another JSON file to change the data being referenced. To replace, select Replace Footage > File, and open the new file from your computer.

To use the data, you can apply an expression on the property you wish the data to drive, then:

  • Use the sourceData attribute to read the data in a .JSON file. For example:

    1
    var sampleData = footage("sample.json").sourceData;
  • To return its value, reference the specific property inside the JSON data. For example,

    1
    myData.engineData.RPM or myData.latitude.value.

例如有这样一个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中会同时更改。

< 返回目录

AE表达式
0
AE表达式|31、如何创建一个虚线圆圈?
上一篇
AE表达式|33、如何调用系统时间?
下一篇

评论 (0)

登录后可发布~
立即登录
暂无评论

向安宇

痴迷文字,醉心影像
447
文章
5
评论
325
喜欢

近期评论

不同意知识过时这么快,数学公式几百年都没变啊
—— Baron von Laughsalot 10 月前 1.我将深入研究如何提升学习力,以及如何用AI提升学习效率
这学习方法太适合我这种记性差的了,必须追更!
—— 狂血战士 11 月前 AIP克丽丝的构想
数字人做语言教学太香了,求Anni快出实操指南!
—— 贪吃小熊 11 月前 Anni搞钱系列:普通人用AI,到底能做起来什么副业?
想问作者会开线下课吗?想带孩子去听听
—— 秋分桂落 11 月前 1.我将深入研究如何提升学习力,以及如何用AI提升学习效率
想问下这个AI工具对服务器配置要求高吗?
—— 狂喜的烟花 11 月前 wordpress也要拥抱AI

猜你喜欢

AE表达式|02、怎样规范地书写表达式?

AE表达式|02、怎样规范地书写表达式?

2018-07-02 22:49:55
2,880 1 8
人像精修的思路——高低频和观察图层

人像精修的思路——高低频和观察图层

2019-06-28 21:14:30
3,764 0 4
一分半钟学会无人机720全景拍摄

一分半钟学会无人机720全景拍摄

2018-03-12 14:20:05
1,300 0 0
AE表达式|15、如何用音频驱动动画?@ linear

AE表达式|15、如何用音频驱动动画?@ linear

2018-08-27 17:14:45
2,140 0 3

关于我:

想要读万卷书,行万里路,看万部电影。

推荐栏目:

视频论文 课程 后期制作 非虚构 照片 视频

特色专题:

专题汇总 宜看一侃 帧影帧画 重读文学史 青玉记
Copyright © 2016-2026 向安宇知识库. Designed by nicetheme. 鄂ICP备16005400号-1 鄂公网安备42050602000017号
  • 读书向
  • 学习向
    • AI工具
    • AI研究
    • 笔记
    • AIP:克丽丝AI日志
  • 创作向
    • 写作
    • 视听
    • 课程
  • 影视向
    • 创意策划
    • 前期拍摄
    • 后期制作
    • 影像实验
    • 影像设备
    • 大师镜头
    • 电影赏析
    • 视频论文
    • 项目复盘
  • 折腾向
    • 穿越机
    • 户外
    • 代码
    • 手工
    • 书法
    • 篆刻
    • 绘画
  • 剪辑
  • 转场
  • 纪录片

向安宇

痴迷文字,醉心影像
447
文章
5
评论
325
喜欢