免费教程_免费网赚教程_破解版软件-寂涯网络学习基地

当前位置: 主页 > 网站相关 > 网站编程 > 通过Flash+JavaScript+API来解析fla文件(2)

通过Flash+JavaScript+API来解析fla文件(2)

时间:2012-05-24 12:59来源:未知 整理:寂涯网络 点击:


和下一步自动批阅功能.最终解析结果在TreeView控件中以
树状结构显示。该应J}j完整地呈现了如何读取fla文件中的主
要对象属性值的过程和方法。
6.2外部应用程序代码
uses
ShellAPI;//引用函数ShellExecute所需单元
procedure TForml ButconlClick(Sender:TObject);#Buttonl
Il点击事件
Var
fList:TStringList;
b:beolean;
procedure split(var tarlist:TStringlist;s:string;c:widechar);
,,i亥子过程根据特殊字符分割字符串(在本应用中,以”.”字符分
,膈字符串)
var
i:integer;tempstr:string;se:widestring;
begin
tempstr:=”:
tarlist Clear;
if s<>“then
begin
se:=widestring(s);
for i:=1 to length(sel do
begin
if se[i]=c then
begin
tarlist.Add(tempstr);
tempstr:=“:
end
else
tempstr:=tempstr+seli];
end;
tarlist Add(tempstr);
end;
end;//split子过程结束
begin//ButtonlClick主程序.解析伯文件井以树形结构显示
||舟析结果
b:=true;
fList:=TStnngList.Create;
DeleteFile(’c:\fTree txt’):
DeleteFile(’c:\fltest txt 7):
ShellExecute(Handle."open’,’flash exe’."c:\fltest jsfl’,州,
SW_SHOW):
while b do //等待flash exe执行js制完毕并释放txt控制
,Arv
fList.LoadFromFile(’c坩Iteat.txtl; ,,导人结果文件(txt)
b:=false;
exceDt
continue;

end;
split(fList.Utf8ToAnsi(fList.Strings[0]),’,,)://以“,”为分隔符分
蒯字符串。形成一棵树 fList.SaveToFile(’c:\fTree.txt,).
TreeViewl.LoadFromFile(’c:\fTree.txt,).
fList.Free;
end;
6.3 jsfl文件中的Flash JavaScript代码
该代码显示了对fla文档中各个主要对象(如场景、图层、
关键帧、实例、元件等)及其属性的读取方法。为了更好地观
察代码。简化了对fla文档中对象属性的读取,即减少了同一
个对象的属性读取代码行,一般读取2个属性。更多的属性可
以参看Flash中的帮助文件。源代码如下:
var Level=0;//{模拟栈指针
var strlis=new Array();//定义(字符串)数组
Mar str=new String();
f1.openDocument(。file:///C:/check.fla。):
getTabStr(i)胳到前缀符Tab串,用来构建树的
//层次
{
var S=‘。:
while(i>0)
{s+=‘ 。:/tab键
i--:}
return S:
l
function strlisPush(i,S)//替换字符串中的某些特殊符号并
∥追加到strlis数组中
{
str=String(s);
str=str.replace(Ar/g.”):str=str.replace(An/g,");
str=str.replace(/./g.”)://去掉“,”
str=str.replace(//9,“}://去掉Tab符
str=str.reptace(/('、s’)I舾’$)/g,“)∥去掉首尾空格
strlis.push(getTabStr(i)+str);
l
var doc=f1.getDocumentDOM0;//文档对象模型
tl=new 朋寸间轴对象数组
var lib=doc.1ibrary; //flash元件库对象
var itemArray=new Array(); //元件对象数组
var layerGroup=new Array(); //图层对象数组
var frameGroup=new Array(); //帧对象数组
var elementGroup-new Array();//元素数组
var fillitem=new Array(); ,/填充对象数组
var strokeltem=new Array(); II笔触对象数组
var filterGroup=new Array(); //滤镜对象数组
var timeLines=new Array(); ,/H寸间轴对象数组
itemArray=lib.items;
timeLines=doc.timelines;
i=O:j-0:t=0:
strlisPush(LeveI,"doc。):
Level++;
str|isPush(LeveI,"height’):
st r|isPush(LeveI+1,doc.height);
str|isPush(LeveI,"width。):
strlisPush(LeveI+1,doc.width);
st rIisPush(LeveI,。backgroundCoIor。):
st—isPush(LeveI+1,doc.backgroundCoIor);
st rIisPush(Level,"frameRate。):
strlisPush(LeveI+1。doc.frameRate);
st r|isPush(LeveI,"sceneCount。):
st r|isPush(Level+1.timeLines.1ength);
function getArray(xarray)

var s=“;var k=0:
for《k=O;k<xarray.1ength;k++)
{s=s+xarray【k】+‘:。}

本页地址 http://www.jybase.net/wangzhanbiancheng/20120524933.html

百度搜索更多

谷歌搜索更多

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------

评价:
昵称: 验证码:点击我更换图片
推荐内容
赞助商
赞助商


关于本站免责声明视频更新google百度地图视频地图RRS订阅

如有什么问题请在本站留言,或发邮件到 hxt167#foxmail.com