2012-05-10 172 views
0

我需要一些关于Flash横幅的帮助。我需要做一个隐藏div的横幅按钮,我已经找到了一种在AS2中做的方法,但是我需要使用AS3,我根本不知道ActionScript,所以我需要你的帮助。Flash按钮隐藏DIV AS3

我发现这个代码,不幸的是它在AS2:

on (release) { 
import flash.external.ExternalInterface; 
ExternalInterface.call("hideDiv", "operator"); 
} 

<script type="text/javascript"> 
function hideDiv(id) 
{ 
    document.getElementById(id).style.display = 'none'; 
} 
</script> 

我的按钮实例名称为“closeBt”,我想隐藏格“#flashcontainer”

请帮助我。

UPDATE

我的AS3代码

import flash.external.ExternalInterface; 
import flash.events.MouseEvent; 


var myStage:Stage = this.stage; 
myStage.scaleMode = StageScaleMode.NO_SCALE; 
myStage.align = StageAlign.TOP_LEFT; 

function resizeDisplay(event:Event):void{ 

    var swfWidth:int = myStage.stageWidth; 
    var swfHeight:int = myStage.stageHeight; 

    var flagaYPos:Number = swfHeight - flaga.height; 
    var flagaXPos:Number = swfWidth - flaga.width; 

    flaga.y = 40.75; 
    flaga.x = -31.4; 

} 

myStage.addEventListener(Event.RESIZE, resizeDisplay); 

closeBt.addEventListener(MouseEvent.CLICK, clickHandler); 

trace("Button has been Clicked"); 

function clickHandler(e:MouseEvent):void { 
    if(ExternalInterface.available) 
    ExternalInterface.call("hideDiv", "operator"); 
} 

和我的HTML身体

<body style="margin:0; padding:0"> 
<script> 
function hideDiv("operator") 
{ 
    document.getElementById("operator").style.display = 'none'; 
} 
</script> 
<div id="operator"> 
<!--url's used in the movie--> 
<!--text used in the movie--> 
<!-- saved from url=(0013)about:internet --> 
<script language="JavaScript" type="text/javascript"> 
    AC_FL_RunContent(
     'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0', 
     'width', '100%', 
     'height', '100%', 
     'src', 'Kopia baner01', 
     'quality', 'high', 
     'pluginspage', 'http://www.adobe.com/go/getflashplayer', 
     'align', 'top', 
     'play', 'true', 
     'loop', 'true', 
     'scale', 'noscale', 
     'wmode', 'transparent', 
     'devicefont', 'false', 
     'id', 'Kopia baner01', 
     'bgcolor', '#ffffff', 
     'name', 'Kopia baner01', 
     'menu', 'true', 
     'allowFullScreen', 'false', 
     'allowScriptAccess','sameDomain', 
     'movie', 'Kopia baner01', 
     'salign', 't' 
     ); //end AC code 
</script> 
<noscript> 
     <object style="display: none" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="100%" height="100%" id="Kopia baner01" align="top"> 
     <param name="allowScriptAccess" value="sameDomain" /> 
     <param name="allowFullScreen" value="false" /> 
     <param name="movie" value="Kopia baner01.swf" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="salign" value="t" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /> <embed src="Kopia baner01.swf" quality="high" scale="noscale" salign="t" wmode="transparent" bgcolor="#ffffff" width="100%" height="100%" name="Kopia baner01" align="top" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /> 
     </object> 

</noscript> 
    </div> 
</body> 

AS是在时间轴上,我没有对AS,AS2或AS3任何技能,我会喜欢将横幅隐藏div如此接近btn会关闭横幅

+0

我发现了一个错误的功能hideDiv(操作员)无法正常工作hideDiv(“经营者”)我不知道我在想什么 – gidzior

回答

1

在AS3中,它看起来像这样:

import flash.external.ExternalInterface; 
import flash.events.MouseEvent; 

closeBt.addEventListener(MouseEvent.CLICK, clickHandler); 

function clickHandler(e:MouseEvent):void { 
    ExternalInterface.call("hideDiv", "operator"); 
} 

此代码假定您将脚本添加到时间线。如果您使用的是文档类,那么您可以在“功能”之前添加一个“私有”修饰符。你提到你在AS3方面不是很有经验,所以时间轴将是现在的路。但是,如果你认真对待AS3,请看看Classes。

+0

什么也没有发生: [我会编辑我的问题任何秒 – gidzior

+0

我,m试图设置退出按钮在Flash横幅 – gidzior

+0

尝试添加跟踪调用clickHandler,以确认该按钮被点击。另外,在进行ExternalInterface调用之前添加if(ExternalInterface.available),如@ Baris示例中所示。 – Corey

1
private function init():void 
{ 
    closeBtn.addEventListener(MouseEvent.CLICK,onClick); 
} 


private function onClick(e:MouseEvent):void 
{ 
    if(ExternalInterface.available) 
     ExternalInterface.call("hideDiv","operator"); 
} 
0

尝试这一块的AS3代码:

import flash.external.ExternalInterface; 
closeBt.addEventListener(MouseEvent.CLICK, clickHandlerButton); 
private function clickHandlerButton(e:MouseEvent):void{ 
    if(ExternalInterface.available) ExternalInterface.call("hideDiv","flashcontainer"); 
}