我需要一些Flash横幅的帮助。我需要在横幅中做一个隐藏div的按钮,我已经找到了在AS2中执行此操作的方法,但我需要使用AS3,我根本不了解ActionScript,所以我需要你的帮助。 / p>
我发现此代码,不幸的是它在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>
我的按钮实例名称为&#34; closeBt&#34;我想隐藏div&#34; #flashcontainer&#34;
请帮帮我。
更新
我的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 :(得分: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。
答案 1 :(得分:1)
private function init():void
{
closeBtn.addEventListener(MouseEvent.CLICK,onClick);
}
private function onClick(e:MouseEvent):void
{
if(ExternalInterface.available)
ExternalInterface.call("hideDiv","operator");
}
答案 2 :(得分:0)
试试这段AS3代码:
import flash.external.ExternalInterface;
closeBt.addEventListener(MouseEvent.CLICK, clickHandlerButton);
private function clickHandlerButton(e:MouseEvent):void{
if(ExternalInterface.available) ExternalInterface.call("hideDiv","flashcontainer");
}