Posted By

adrianparr on 07/13/10


Tagged

menu time date publish metadata as3 modify contextMenu modification right-click swfreader senocular modifydate ContextMenuItem


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

StrawMan
shalomfriss
tspitzr


AS3 Show SWF Publish Date and Time in Right-Click Menu


 / Published in: ActionScript 3
 

URL: http://www.senocular.com/flash/actionscript/?file=ActionScript_3.0/com/senocular/utils/SWFReader.as

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.

  1. import flash.ui.ContextMenu;
  2. import flash.ui.ContextMenuItem;
  3. import flash.events.ContextMenuEvent;
  4. import com.senocular.utils.SWFReader;
  5.  
  6. var swfReader:SWFReader = new SWFReader(root.loaderInfo.bytes);
  7. var menuItemLabel:String = "SWF Publish date: "+ getSwfModificationDate(swfReader);
  8. var cm:ContextMenu = new ContextMenu();
  9. cm.hideBuiltInItems();
  10. var cmi:ContextMenuItem = new ContextMenuItem(menuItemLabel);
  11. cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onCmi_MENU_ITEM_SELECT);
  12. cm.customItems.push(cmi);
  13. this.contextMenu = cm;
  14.  
  15. function getSwfModificationDate($swfReader:SWFReader):String {
  16. var metadata:String = $swfReader.metadata;
  17. var swfMetadataArray:Array = metadata.split("xmp:ModifyDate>");
  18. var modDate:String = swfMetadataArray[1].substr(0, 19);
  19. var date:String = modDate.substr(0, 10);
  20. var time:String = modDate.substr(11, 8);
  21. return date + " " + time;
  22. }
  23.  
  24. function onCmi_MENU_ITEM_SELECT(event:ContextMenuEvent):void
  25. {
  26. System.setClipboard(event.target.caption);
  27. }

Report this snippet  

You need to login to post a comment.