2011
Nov
02

網頁好讀版

flash 載入其它的 swf

Example
  1. //建立 蛓入器loader
  2.  
  3. var loader:Loader = new Loader();
  4. //建立事件
  5. loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
  6. //下載
  7. loader.load(new URLRequest("test.swf"));
  8.  
  9. //下載完成,貼到影格中
  10. function completeHandler(event:Event){
  11. var _content:DisplayObject = event.target.content;
  12. object.addChild(_content);
  13. _content.x=0;
  14. _content.y=0;
  15.  
  16. }

Flash & php 多檔案上傳

Example
  1. //使用 File List 物件
  2. var fileList:FileReferenceList=new FileReferenceList();
  3. //建立 File list 事件,選取多個檔案
  4. fileList.addEventListener(Event.SELECT, selectHandler);
  5.  
  6. //建立Request 連結
  7. var request2:URLRequest = new URLRequest();
  8. //操作所選檔案清單中的第 1 個 ,可以寫一個 for 迴圈處理所有的檔案
  9. var file:FileReference = FileReference(fileList[0]);
  10. //建立單一 File 事件
  11. file.addEventListener(ProgressEvent.PROGRESS,progressHandler);
  12. file.addEventListener(Event.COMPLETE, completeHandler)
  13. file.upload(request2);

Flash 之 MD5編碼

Example
  1. static function MD(instring, keystring):String {
  2. //instring = FixFormat.addZero(instring, 10);
  3. //if(instring.length)
  4. var t_String:String = escape(instring);
  5. var key_num:Number = 0;
  6. for (var i = 0; i<keystring.length; i++) {
  7. key_num = keystring.charCodeAt(i)%10+key_num;
  8. }
  9. key_num = key_num%5;
  10. if (key_num == 0) {
  11. key_num = 1;
  12. }
  13. var t_length:Number = t_String.length;
  14. var t_counts:Number = 0;
  15. var getEncode:String = "";
  16. for (var i = 0; i<t_length; i++) {
  17. var s_tmp:Number = t_String.charCodeAt(i)*key_num;
  18. var s_tmp2:Number = s_tmp%94;
  19. s_tmp = Math.floor(s_tmp/94);
  20. t_counts = t_counts+s_tmp2+s_tmp;
  21. getEncode = getEncode+String.fromCharCode(s_tmp+33)+String.fromCharCode(s_tmp2+33);
  22. }
  23. getEncode = getEncode+String.fromCharCode((t_counts%94)+33);
  24. return (getEncode);
  25. }

Flash as3 內建右鍵選單之內容新增

Example
  1. myContextMenu = new ContextMenu();
  2. myContextMenu.hideBuiltInItems();
  3.  
  4. item = new ContextMenuItem("menu title");
  5. myContextMenu.customItems.push(item);
  6. this.contextMenu = myContextMenu;
  7.  
  8. //新增點選後的事件
  9. item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelectHandler);

網頁好讀版