讲故事的手艺人 讲故事的手艺人
  • 创作向
    • 写作
      • 非虚构
      • 剧本
      • 小说
      • 文言
      • 读书
      • 随笔
    • 拍摄
      • 纪录片
      • 设计
      • 视频
      • 摄影
  • 策划向
    • 策划资料
    • 创意之道
    • 短视频研究
  • 技术向
    • AI
    • 前期拍摄
    • 后期制作
    • 原创教程
    • 影像实验
    • 影像设备
    • 穿越机
  • 艺术向
    • 研究学习
    • 大师镜头
    • 电影赏析
    • 视频论文
    • 经验总结
  • 注册
  • 登录
首页 › 技术向 › 原创教程 › AE表达式|32、如何将表达式链接到外部文件或JSON文件?

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

向安宇
2018-10-22 13:46:28原创教程阅读 2,755

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) 收藏(0)
AE表达式|31、如何创建一个虚线圆圈?
上一篇
AE表达式|33、如何调用系统时间?
下一篇

请登录以参与评论

现在登录
暂无评论
标签
720全景 ACES AE AE案例 AE表达式 Anyu翻译 CSC电影学院 fusion Hackintosh MG动画 ps教程 vlog wordpress 创意方法 剪辑 字幕 帧影帧画 抖音 摄影 文案 混剪 混音 灯光 看电影 磨皮 穿越机 纪录片 编剧 美术 美食 論語 调度 调色 达芬奇 重讀文學史 青玉记
室内360全景图的简单修图
2020-10-13 21:51:45
2,691 0 0
达芬奇:高频锐化
2020-03-21 22:41:26
3,878 0 3
3、ISO
2019-11-06 21:54:32
1,754 0 0
2、光圈和景深
2019-11-03 17:10:31
1,756 0 2
  • 0
  • 0
关于我:

想要读万卷书,行万里路,看万部电影。当过人民教师,做过策划师,入行影视做剪辑、导演。艺术是目的,技术是支撑,不断钻研,积聚梦想,同时分享干货。

推荐栏目:
视频论文 原创教程 后期制作 非虚构 照片 视频
特色专题:
专题汇总 宜看一侃 帧影帧画 美食摄影 重读文学史 青玉记
Copyright © 2016-2025 讲故事的手艺人. 鄂ICP备16005400号-1 鄂公网安备42050602000017号
  • 创作向
    • 写作
    • 拍摄
  • 策划向
    • 策划资料
    • 创意之道
    • 短视频研究
  • 技术向
    • AI
    • 前期拍摄
    • 后期制作
    • 原创教程
    • 影像实验
    • 影像设备
    • 穿越机
  • 艺术向
    • 研究学习
    • 大师镜头
    • 电影赏析
    • 视频论文
    • 经验总结
# 剪辑 # # 转场 # # 纪录片 #
向安宇
痴迷文字,醉心影像
420
文章
5
评论
325
喜欢