如何根据点击的目标使用 navigateToURL 将用户发送到不同的 URL?
How can I send the user to a different URL using navigateToURL depending on clicked target?
我有一个 "virtual map" 的 SWF 文件,位置不同。单击每个位置时,用户将被重定向到一个超链接。
如何让每个位置重定向到不同的超链接?
- 如果点击喷泉,用户将被重定向到 http://different.com
- 如果点击城堡,用户将被重定向到 http://something.com
您可以从 here or view it online: http://www.fastswf.com/NInMHKU
下载 SWF
以下是 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 Free Flash Decompiler反编译SWF文件后,我发现地图上的每个位置都有两个不同的AS文件。例如,下面是喷泉的文件。
来源: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
如果可以为城堡或任何其他元素提供具有唯一字符串值的 属性,您可以尝试类似
private function mClick(me:MouseEvent):void{
goToURL(me.target.url_String);
}
private function goToURL(urlString:String):void{
navigateToURL(new URLRequest(url_String));
}
您只需要在 class 中有一个名为 url_String
的 属性,城堡是其中的一个实例(显然它需要是一个自定义的 class ) 并且当您实例化 class 时,将其 属性 定义为您希望城堡前往的 url。喜欢:
var castle:Location = new Location("http://www.baidu.com");
显然 Location
是您的自定义 class,可能看起来像这样:
public class Location extends Sprite {
public var url_String:String;
private function Location(s:String):void{
url_String = s;
}
}
编辑文件com.binweevils.externalUIs.map.Map.as:
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");
}
}
您可以从以下位置找到 param1 的值:
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));
提供 buttonMC
和 roomID
,它们可以进一步用作 gotoLocation()
的参数 1 以有条件地导航浏览器。
您可以从 https://drive.google.com/open?id=0B_AKfmXEaZvQUldqNkU3ZW9ZMTg
下载 swf
NOTE: You shouldn't decompile and use others property without
permission unless it is for educational purpose.
我有一个 "virtual map" 的 SWF 文件,位置不同。单击每个位置时,用户将被重定向到一个超链接。
如何让每个位置重定向到不同的超链接?
- 如果点击喷泉,用户将被重定向到 http://different.com
- 如果点击城堡,用户将被重定向到 http://something.com
您可以从 here or view it online: http://www.fastswf.com/NInMHKU
下载 SWF以下是 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 Free Flash Decompiler反编译SWF文件后,我发现地图上的每个位置都有两个不同的AS文件。例如,下面是喷泉的文件。
来源: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
如果可以为城堡或任何其他元素提供具有唯一字符串值的 属性,您可以尝试类似
private function mClick(me:MouseEvent):void{
goToURL(me.target.url_String);
}
private function goToURL(urlString:String):void{
navigateToURL(new URLRequest(url_String));
}
您只需要在 class 中有一个名为 url_String
的 属性,城堡是其中的一个实例(显然它需要是一个自定义的 class ) 并且当您实例化 class 时,将其 属性 定义为您希望城堡前往的 url。喜欢:
var castle:Location = new Location("http://www.baidu.com");
显然 Location
是您的自定义 class,可能看起来像这样:
public class Location extends Sprite {
public var url_String:String;
private function Location(s:String):void{
url_String = s;
}
}
编辑文件com.binweevils.externalUIs.map.Map.as:
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");
}
}
您可以从以下位置找到 param1 的值:
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));
提供 buttonMC
和 roomID
,它们可以进一步用作 gotoLocation()
的参数 1 以有条件地导航浏览器。
您可以从 https://drive.google.com/open?id=0B_AKfmXEaZvQUldqNkU3ZW9ZMTg
下载 swfNOTE: You shouldn't decompile and use others property without permission unless it is for educational purpose.