Revision: 28702
Updated Code
at July 13, 2010 02:48 by adrianparr
Updated Code
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); }
Revision: 28701
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 13, 2010 01:38 by adrianparr
Initial Code
import flash.ui.ContextMenu; import flash.ui.ContextMenuItem; 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); 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; }
Initial URL
http://www.senocular.com/flash/actionscript/?file=ActionScript_3.0/com/senocular/utils/SWFReader.as
Initial Description
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.
Initial Title
AS3 Show SWF Publish Date and Time in Right-Click Menu
Initial Tags
date
Initial Language
ActionScript 3