Question

I need some help with flash banner. I need to do a button in banner which hides div, I've found a way to do it in AS2, but I need to use AS3, I don't know ActionScript at all so I NEED your help.

I've found this code, unfortunately it's in 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>

My button instance name is "closeBt" and I would like to hide div "#flashcontainer"

Help me please.

UPDATE

my AS3 code

   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");
}

and my html body

<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 is on timeline, i do not have any skills on AS, AS2 or AS3, i would like to hide div with banner so close btn would close the banner

Was it helpful?

Solution

In AS3, it would look like this:

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

closeBt.addEventListener(MouseEvent.CLICK, clickHandler);

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

This code assumes that you're adding your script to the timeline. If you're using a Document Class, then you would add a "private" modifier before "function". You mentioned you're not very experienced in AS3, so timeline will be the way to go for now. But, do look into Classes if you're getting serious about AS3.

OTHER TIPS

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


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

Try this piece of AS3 code:

import flash.external.ExternalInterface;
closeBt.addEventListener(MouseEvent.CLICK, clickHandlerButton);
private function clickHandlerButton(e:MouseEvent):void{
    if(ExternalInterface.available) ExternalInterface.call("hideDiv","flashcontainer");
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top