0

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

我找到了这段代码,不幸的是它在 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”,我想隐藏 div“#flashcontainer”

请帮帮我。

更新

我的 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 会关闭横幅

4

3 回答 3

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 很认真,请务必查看课程。

于 2012-05-10T15:25:01.283 回答
1
private function init():void
{
   closeBtn.addEventListener(MouseEvent.CLICK,onClick);
}


private function onClick(e:MouseEvent):void
{
    if(ExternalInterface.available)
        ExternalInterface.call("hideDiv","operator");
}
于 2012-05-10T15:25:10.563 回答
0

试试这段 AS3 代码:

import flash.external.ExternalInterface;
closeBt.addEventListener(MouseEvent.CLICK, clickHandlerButton);
private function clickHandlerButton(e:MouseEvent):void{
    if(ExternalInterface.available) ExternalInterface.call("hideDiv","flashcontainer");
}
于 2012-05-10T15:25:44.717 回答