可以在ActionScript告诉当SWF发布? [英] Can ActionScript tell when a SWF was published?

查看:175
本文介绍了可以在ActionScript告诉当SWF发布?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个小类,增加了日/月盒显示的SWF从Flash中发布的日期。

I'd like to write a little class that adds a Day/Month box showing the date a SWF was published from Flash.

我定期工作的公司产生许多,许多主权财富基金和各的许多版本,遍历个月的过程。我们一直在使用与客户进行沟通的一个版本跟踪系统是日/月日期框,给人的SWF的发布日期。到现在为止,我们已经填补用手发布日期。如果有什么办法可以做到这一点编程使用ActionScript那简直太棒了。

The company I work for regularly produces many, many SWFs and many versions of each, iterating over the course of months. A version-tracking system we've been using to communicate with our clients is a Day/Month date-box that gives the date the SWF was published. Up until now, we've been filling in the publish date by hand. If there's any way I can do this programatically with ActionScript that'd be fantastic.

任何见解?基本上,我需要的是电话,让我的出版日期,甚至..关于下一个SWF发表,我可以用它来擀成某种形式的..自动版本识别,独此SWF的情况下,任何东西。

Any insight? Basically, all I need is the call that gives me the publish date, or even.. anything about the circumstances under which a SWF was published that I could use to roll into some form of.. automated version identification, unique to this SWF.

那么,能不能动作告诉当SWF发布?

So, can ActionScript tell when a SWF was published?

推荐答案

乔治是正确的。的Adobe偷偷包含编译日期为每个编译的SWF无证ProductInfo标签。该DisplayObject.loaderInfo.bytes包含加载的显示对象的完整uncom pressed的swf。

George is correct. Adobe sneaks an undocumented ProductInfo tag that contains the compilation date in to every compiled swf. The DisplayObject.loaderInfo.bytes contains the the complete uncompressed swf that loaded the Display Object.

<一个href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#loaderInfo">http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#loaderInfo

所以,最快捷的方式来获取SWF的编译日期无需外部库(从显示对象):

So the quickest way to get the swf's compilation date without external libraries (from a Display Object):

import flash.utils.Endian;
import flash.display.LoaderInfo;
import flash.utils.ByteArray;
...

private function getCompilationDate():Date{
  if(!stage) throw new Error("No stage");

  var swf:ByteArray = stage.loaderInfo.bytes;
  swf.endian = Endian.LITTLE_ENDIAN;
  // Signature + Version + FileLength + FrameSize + FrameRate + FrameCount
  swf.position = 3 + 1 + 4 + (Math.ceil(((swf[8] >> 3) * 4 - 3) / 8) + 1) + 2 + 2;
  while(swf.position != swf.length){
    var tagHeader:uint = swf.readUnsignedShort();
    if(tagHeader >> 6 == 41){
      // ProductID + Edition + MajorVersion + MinorVersion + BuildLow + BuildHigh
      swf.position += 4 + 4 + 1 + 1 + 4 + 4;
      var milli:Number = swf.readUnsignedInt();
      var date:Date = new Date();
      date.setTime(milli + swf.readUnsignedInt() * 4294967296);
      return date; // Sun Oct 31 02:56:28 GMT+0100 2010
    }else
      swf.position += (tagHeader & 63) != 63 ? (tagHeader & 63) : swf.readUnsignedInt() + 4;
  }
  throw new Error("No ProductInfo tag exists");
}

该SWF规格:<一href="http://www.adobe.com/content/dam/Adobe/en/devnet/swf/pdf/swf_file_format_spec_v10.pdf">http://www.adobe.com/content/dam/Adobe/en/devnet/swf/pdf/swf_file_format_spec_v10.pdf

这篇关于可以在ActionScript告诉当SWF发布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆