apache-flex 如何判断设计文档中的文本框内容是通过java脚本还是action脚本进行了更改?

pgccezyw  于 2022-11-01  发布在  Apache
关注(0)|答案(1)|浏览(123)

我得到了一个要求,以找出是否在文本框的内容得到了改变或没有通过行动脚本。到目前为止,我比较我的服务器端数据,以检查内容从indesign文档的文本框,但现在我想检查是否有任何默认标志,以避免服务器端调用。

kr98yfug

kr98yfug1#

跟踪变化看起来确实可行。另一种选择可能是使用空闲事件来监控故事的变化。基本上就是Josh刚才建议的。


# targetengine "storiesChanges"

main();
function main()
{
	var db = {};

	var myIdleTask = app.idleTasks.item("checkStories");
	if ( !myIdleTask.isValid ) {
		myIdleTask = app.idleTasks.add({name:"checkStories", sleep:100});
		myIdleTask.addEventListener(IdleEvent.ON_IDLE,onIdleEventHandler, false);
	}

	function onIdleEventHandler(myIdleEvent)
	{
		var doc = app.properties.activeDocument;
		if ( !doc ) {
			db = {}
			return;
		}

		var sts = doc.stories, st, id;
		var n = sts.length;

		while ( n-- ) {
			st = sts[n];
			id = st.id;

			if ( !db[id] ) {
				$.writeln ("Storing "+id );
				db[id] = st.contents;
			}
			else if ( db[id]!=st.contents ) {
				$.writeln ( "Some changes were made on story "+id+" at "+(new Date()) );
				db[id] = st.contents;
			}
			else {
				$.writeln ( "No changes were made for story "+id );
			}
		}
	}
}

相关问题