/ Published in: ActionScript 3
This code uses Senocular SWFReader class to get the modification (publish) date of the SWF, and then displays it as a right-click menu item. You need to make sure that your SWF includes the XMP metadata. In the Flash IDE you can turn this on by going to Publish Settings > Flash > Include XMP metadata.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import flash.ui.ContextMenu; import flash.ui.ContextMenuItem; import flash.events.ContextMenuEvent; import com.senocular.utils.SWFReader; var swfReader:SWFReader = new SWFReader(root.loaderInfo.bytes); var menuItemLabel:String = "SWF Publish date: "+ getSwfModificationDate(swfReader); var cm:ContextMenu = new ContextMenu(); cm.hideBuiltInItems(); var cmi:ContextMenuItem = new ContextMenuItem(menuItemLabel); cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onCmi_MENU_ITEM_SELECT); cm.customItems.push(cmi); this.contextMenu = cm; function getSwfModificationDate($swfReader:SWFReader):String { var metadata:String = $swfReader.metadata; var swfMetadataArray:Array = metadata.split("xmp:ModifyDate>"); var modDate:String = swfMetadataArray[1].substr(0, 19); var date:String = modDate.substr(0, 10); var time:String = modDate.substr(11, 8); return date + " " + time; } function onCmi_MENU_ITEM_SELECT(event:ContextMenuEvent):void { System.setClipboard(event.target.caption); }
URL: http://www.senocular.com/flash/actionscript/?file=ActionScript_3.0/com/senocular/utils/SWFReader.as