解决fl.findObjectInDocByType/fl.findObjectInDocByName的毛病

今天在做一个从Fla导出PNG的东东时,要用到fl.findObjectInDocByType函数,但是一运行自己写的JSFL时,居然说fl.findObjectInDocByType不是一个函数。凭直觉这应该是函数未定义好。果然,在找了半天之后,找到这个文章帮了大忙。大概就是说要手动添加运行代码,使定义fl.findObjectInDocByType的JSFL代码的运行。我是照着最后一个大哥说的做的,就是在自己的JSFL里添加了:

if( fl.findObjectInDocByType == null ){
fl.runScript( fl.configURI + “Javascript/ObjectFindAndSelect.jsfl” );
}

用这一招是最灵的了。

再看一看fl.findObjectInDocByName()函数。帮助文档上说得清清楚楚:

用法

fl.findObjectInDocByName(instanceName, document)

参数

instanceName 一个字符串,指定在指定文档中某项的所有或部分实例名称。

document 要在其中搜索指定项的 Document 对象。

虽然说instanceName 是可以指定在指定文档中某项的所有部分实例名称,但是经过实验,只能取得实例名称完全匹配的元件,打开

ObjectFindAndSelect.jsfl
文件查找到91行FlashUtils_findObjectInTimelineByName,将108行的if (items[l].name == objName)改为if (items[l].name.match(objName))就可以了。
具体原因当然都很简单了!



////////////////////////
上面说的那篇文章内容如下(怕以后删了找不着):
Bug in JSFL fl.findObjectInDocByType in Flash CS3
March 6th, 2008
Goto comments Leave a comment

New CS3 JSFL library’s are broken which would have been great to have. I tried to use the new finObjectInDocByType and I even used the example provided in the livedocs and it crashes. Maybe this was not implemented for AS3? I hope this gets fixed soon we could do some rad stuff! Adobe use the bug system that you have for Flex for Flash too!

******BUG******
Concise problem statement:
fl.finObjectInDocByType crashes in the example given in live docs.
Steps to reproduce bug:
Create a JSFL script and place it in your commands directory like other jsfl code.
Copy and past the first example from livedocs for finObjectInDocByType
Create a flash as3 fla file and place a text field on the stage.
command -> script name
you will get an error stating: At line 64 of file “ObjectFindAndSelect.jsfl”: TypeError: nextSymbolItemObj has no properties.

ShareThis

Flash Platform, jsfl
Comments (5) Trackbacks (0) Leave a comment Trackback

Vincy
July 18th, 2008 at 07:29 | #1
Reply | Quote

This error can be resolved by following these simple steps:

1) Go to the following location:
C:\Documents and Settings\ocal settings\application data\adobe\flash cs3\en\configuration\javascript (windows xp):

2) Open “ObjectFindAndSelect.jsfl” file.

3) Copy and paste the following code at line number 29:
if (objTimeline == undefined) {
return
}

4) Close flash CS3 and restart again, things should work fine.
Vincy
July 18th, 2008 at 07:41 | #2
Reply | Quote

Just a point I forgot to mention:

Copy the JSFL file which uses “fl.findObjectInDocByType” command to the /Commands directory and then try running the command from the Commands menu.
Rost
March 13th, 2009 at 09:39 | #3
Reply | Quote

Vincy, your tips are brilliant. Helped me to fix my “fr.Find in Flash” Search panel completely.

I’d add a bit to your second comment:

It seems the “ObjectFindAndSelect.jsfl” file is executed automatically each time you run your JSFL code from the Commands menu.

But, if you run, for example, a JSFL file from your Flash Panel, the “ObjectFindAndSelect.jsfl” is not run automatically, so its functions like fl.findObjectInDocByType won’t be visible from your code.

To workaround this, just run the needed file before running your code:

fl.runScript( fl.configURI + \”WindowSWF/fr.findTextFromPanel.jsfl\

And its functions will start working for your flashpanel.

Thanks,
Rost
David Goodman
August 19th, 2009 at 09:54 | #4
Reply | Quote

I was wondering Rost, could you give me an example of how to fix the ObjectFindAndSelect.jsfl problem from the WindowSWF I am stuck on this and I’m unable to work out what to do from your comment.

My AS3 class that is linked up to the WindowSWF calls on a button click

MMExecute(“fl.runScript(fl.configURI + ‘Javascript/ObjectFindAndSelect.jsfl’);”)
MMExecute(“fl.runScript(‘file:///C|/svn/Flash/jsfl/brandLanguageConfigTools.jsfl’, ‘skinFile’,\”" + strToPass + “\”,\”" + cbFLA.selectedItem.label + “\”);”);

The 2nd MME has the fl.findByName call which causes the error, I also put the fl.runScript(ObjectFindAndSelect.jsfl) call inside the functions of that JSFL hoping that would get it working but no cookie :( any help?

thanks
slopps
June 3rd, 2011 at 10:20 | #5
Reply | Quote

Also, simply adding this code before you call findObjectInDocByType will fix it:
if( fl.findObjectInDocByType == null ){
fl.runScript( fl.configURI + “Javascript/ObjectFindAndSelect.jsfl” );
}

I found that in a comment for the CS4 livedocs.




你可能感兴趣的:(object)