2016-11-12 47 views
1

我有一個具有不同位置的「虛擬地圖」的SWF文件。當每個位置被點擊時,用戶被重定向到一個超鏈接。如何根據點擊目標使用navigateToURL將用戶發送到其他網址?

我將如何使每個位置重定向到不同的超鏈接?

您可以從here或查看下載的SWF它在線:http://www.fastswf.com/NInMHKU

這裏是ActionScript代碼,它可以讓用戶在點擊某個位置時被重定向:

package 
{ 
    import flash.net.URLRequest; 
    import flash.net.navigateToURL; 
    import flash.events.MouseEvent; 

    public class Map 
    { 
     public function Map() 
     { 
     } 

     public function gotoLocation(param1:int) : void 
     { 
      if(param1 != 999) 
      { 
       navigateToURL(new URLRequest("http://www.baidu.com"),"_blank"); 
      } 
     } 

     private function closeMap(param1:MouseEvent = null) : void 
     { 

     } 
    } 
} 

一個叫JPEXS免費Flash反編譯程序反編譯的SWF文件後,我發現有兩個不同的,因爲地圖上的每個位置上的文件。舉個例子,下面是噴泉的文件。來源

:中Flumsfountain_499.as

package SkylandersSuperchargersMap_26_10_15_fla 
{ 
    import flash.display.MovieClip; 

    public dynamic class Flumsfountain_499 extends MovieClip 
    { 


     public function Flumsfountain_499() 
     { 
     super(); 
     addFrameScript(0,this.frame1,1,this.frame2); 
     } 

     function frame1() : * 
     { 
     stop(); 
     } 

     function frame2() : * 
     { 
     stop(); 
     } 
    } 
} 

來源:flumsfountainlPU_520.as

package SkylandersSuperchargersMap_26_10_15_fla 
{ 
    import flash.display.MovieClip; 

    public dynamic class flumsfountainlPU_520 extends MovieClip 
    { 


     public function flumsfountainlPU_520() 
     { 
     super(); 
     addFrameScript(18,this.frame19); 
     } 

     function frame19() : * 
     { 
     stop(); 
     } 
    } 
} 


以前我試過...

我能夠使用RABCDAsm反編譯的SWF到許多不同的文件,這裏是代碼(源文件:Map.class.asasm),這是由AS3項目,在這個問題上產生:

trait method QName(PackageNamespace(""), "gotoLocation") 
    method 
    name "gotoLocation" 
    refid "TestGotoLocationFunction/instance/gotoLocation" 
    param QName(PackageNamespace(""), "int") 
    returns QName(PackageNamespace(""), "void") 
    flag HAS_PARAM_NAMES 
    paramname "param1" 
    body 
    maxstack 4 
    localcount 2 
    initscopedepth 0 
    maxscopedepth 1 
    code 
     getlocal0 
     pushscope 

     getlocal1 
     pushshort   999 
     ifeq    L13 

     getlex    QName(PackageNamespace("flash.net"), "navigateToURL") 
     getglobalscope 
     findpropstrict  QName(PackageNamespace("flash.net"), "URLRequest") 
     pushstring   "http://www.baidu.com" 
     constructprop  QName(PackageNamespace("flash.net"), "URLRequest"), 1 
     pushstring   "_blank" 
     call    2 
     pop 
L13: 
     returnvoid 
    end ; code 
    end ; body 
    end ; method 
    end ; trait 
+0

_Note_:**(1)**請確保您測試,它可能重新編譯** **工作新的SWF從JPEXS反編譯的代碼。 **(2)**另外,FastSWF.com鏈接提供了一個「修改」的SWF(如base64或類似的),因此當它從站點保存後,無法在反編譯器中作爲有效的SWF打開(字節數甚至從預期的「CWS」或「FWS」字節值開始)。我已將FastSWF鏈接替換爲以前問題中的可測鏈接。最後確認您可以成功重新編譯新的SWF。然後我們會知道你在哪裏需要答案,否則編輯'.ASasm'代碼是你最好的選擇。 –

+0

@ VC.One嗨,爲什麼有鏈接到修改後的SWF的原因是,當您點擊某個位置時,您編輯到帖子中的正確鏈接不會重定向到相同的URL。你能推薦我一個網站,我可以上傳修改後的SWF文件,其中一個可以在反編譯器中作爲有效的SWF文件打開?我將研究SWF是否可以重新編譯。 –

+0

我的意思是網站本身正在做一些與上傳瑞士法郎的防拷貝的東西(嘗試保存瑞士法郎爲測試目的只提供一個加密文件)。如果僅在線查看,則不是問題,但回答者需要通過反編譯原始swf來重新創建問題。 –

回答

2

編輯文件com.binweevils.externalUIs.map.Map。爲

public function gotoLocation(param1:int) : void 
    { 
    if(param1 == 190) 
    { 
     navigateToURL(new URLRequest("http://www.different.com"),"_blank"); 
    } 
    else if(param1 == 113) 
    { 
     navigateToURL(new URLRequest("http://www.something.com"),"_blank"); 
    } 
    else 
    { 
     navigateToURL(new URLRequest("http://www.baidu.com"),"_blank"); 
    } 
    } 

你可以找到從參數1的值:

 this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.halloween_btn,818)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.sinksSub_btn,116)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.tinksTree_btn,191)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.doshPalace_btn,102)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.gongsPipenest_btn,103)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.shoppingMall_btn,104)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.castleGam_btn,113)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.flem_manor_btn,125)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.partyBox_btn,10013)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.rumsCove_btn,129)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.flumsFountain_btn,190)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.riggsPalladium_btn,111)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.post_btn,120)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.figgsCafe_btn,156)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.grottoClub_btn,109)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.labsLab_btn,172)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.nestStreet_btn,115)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.nest_btn,5)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.binPetsParadiseRight_btn,100)); 
    this.mapLocs.push(new com.binweevils.externalUIs.map.MapLocation(this,this.binPetsParadiseLeft_btn,101)); 

每一行:

this.mapLocs.push(new com.binweevils.externalUIs.map. MapLocation(this,this.flumsFountain_btn,190));

提供了進一步可以作爲參數1對的buttonMCroomIDgotoLocation()有條件地瀏覽瀏覽器。

您可以從下載的SWF https://drive.google.com/open?id=0B_AKfmXEaZvQUldqNkU3ZW9ZMTg

NOTE: You shouldn't decompile and use others property without permission unless it is for educational purpose.

+0

感謝您的回答,我即將試用。請問你從哪裏得到param1的值列表? –

+0

他們被發現在相同的Map.as文件中 –

0

如果城堡或任何其他元素可以被賦予的屬性具有獨特的字符串值,你可以嘗試像

private function mClick(me:MouseEvent):void{ 
    goToURL(me.target.url_String); 
} 

private function goToURL(urlString:String):void{ 
    navigateToURL(new URLRequest(url_String)); 
} 

你只需要有一個屬性在類中調用該url_String該城堡是一個實例(顯然它需要成爲一個自定義類),並且當你實例化該類時,它會用你希望城堡去的url來定義它的屬性。像:

var castle:Location = new Location("http://www.baidu.com"); 

顯然Location將是你的自定義類,可能是這個樣子:

public class Location extends Sprite { 
    public var url_String:String; 
    private function Location(s:String):void{ 
     url_String = s; 
    } 
} 
+0

嗨尼爾,謝謝你的迴應!我對AS非常陌生,但是這非常令人興奮。在我用RABCDAsm解碼文件後,我在「SkylandersSuperchargersMap_26_10_15_fla'目錄中找到了城堡的兩個文件,名爲** gamscastle_293.script.asasm **和** gamscastle_293.class.asasm **。我會修改哪一個元素來爲元素提供像您提到的唯一字符串的屬性? –

+0

哦,可能是一級 –

+0

謝謝,我會試試看。你知道我原來的帖子中的代碼,我應該刪除它嗎? –

相關問題