1

I'm trying to have my HTML page call my functions in my AS3 but my JavaScript keeps saying not a function. My SWF is on the same domain.

AS3:

public function Client() {
        ExternalInterface.call('flashReady');
        if (ExternalInterface.available) {
            //ExternalInterface.addCallback("sendToActionScript", receivedFromJavaScript);
            ExternalInterface.addCallback("jsPlayStream", onPlayStreamHandler); //FLV.play()
            ExternalInterface.addCallback("jsStopStream", onStopStreamHandler); //FLV.stop()
            ExternalInterface.addCallback("jsSoundStream", onSoundHandler); ////FLV.volume(0 - 1)
        }
}

private function onPlayStreamHandler(value:String):void {
    flvPlayer.play();
}

private function onStopStreamHandler(value:String):void {
    flvPlayer.stop();
}

private function onSoundHandler(value:Boolean):void {
    if (value == true) {
        flvPlayer.volume = 1;
    } else {
        flvPlayer.volume = 0;
    }
}

JS Code:

$("#vidPlay").click(function () {
    if (bFlashReady == true) {
        thisMovie("Client").jsPlayStream("play");
     }
});

$("#vidPause").click(function () {
    if (bFlashReady == true) {
        thisMovie("Client").jsStopStream("stop");
    }
});

$("#vidSoundOn").click(function () {
    if (bFlashReady == true) {
        thisMovie("Client").jsSoundStream(true);
    }
});

$("#vidSoundOff").click(function () {
    if (bFlashReady == true) {
        thisMovie("Client").jsSoundStream(false);
    }
});

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }
}

HTML:

           <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="222" height="174" id="Client" align="middle">
                <param name="movie" value="Client.swf?v=1.1" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#2B2B2B" />
                <param name="play" value="true" />
                <param name="loop" value="true" />
                <param name="wmode" value="window" />
                <param name="scale" value="showall" />
                <param name="menu" value="true" />
                <param name="devicefont" value="false" />
                <param name="salign" value="" />
                <param name="allowScriptAccess" value="always" />
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="Client.swf" width="222" height="174">
                    <param name="movie" value="Client.swf?v=1.1" />
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="#2B2B2B" />
                    <param name="play" value="true" />
                    <param name="loop" value="true" />
                    <param name="wmode" value="window" />
                    <param name="scale" value="showall" />
                    <param name="menu" value="true" />
                    <param name="devicefont" value="false" />
                    <param name="salign" value="" />
                    <param name="allowScriptAccess" value="always" />
                <!--<![endif]-->
                    <a href="http://www.adobe.com/go/getflash">
                        <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                    </a>
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object>
7
  • 1
    You should use document.getElementById() to locate your Flash objects. That will work on all browsers. Commented Jan 26, 2012 at 14:57
  • Where is your "flashReady" function declared in your javascript? Commented Jan 26, 2012 at 14:58
  • @ToddBFisher My bad I forgot to enter that in the snippet :) Commented Jan 26, 2012 at 15:09
  • @Pointy if you want to put that has an answer I will check it. Thanks! Commented Jan 26, 2012 at 15:10
  • @zLan done :-) Hope it helps! Commented Jan 26, 2012 at 15:12

1 Answer 1

2

I think that your code that finds your Flash objects could be simplified (and, probably, fixed) by making it use document.getElementById().

function thisMovie( movieName ) {
    return document.getElementById( movieName );
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.