# AS3 + Javascript Communication

**URL:** <https://forum.kirupa.com/t/as3-javascript-communication/281075>\
**Category:** flash\
**Created:** [February 4, 2009, 5:27pm UTC](https://forum.kirupa.com/t/as3-javascript-communication/281075 "2009-02-04T17:27:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shinkdog](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@shinkdog](https://forum.kirupa.com/u/shinkdog)\
**Post date:** [February 4, 2009, 5:27pm UTC](https://forum.kirupa.com/t/as3-javascript-communication/281075/1 "2009-02-04T17:27:52Z")

</div>

Hello,

So basically, I have a javascript array and a function on my html page, and I need actionscript to be able to pick the right one from the array and run the function based on what button I pushed.

My javascript is:

```auto
<script>
        navArray = new Array();

        navArray["home"] = "../index.aspx";
        navArray["about"] = "../about.aspx";
        navArray["contact"] = "../contact.aspx";
        navArray["services"] = "../services.aspx";
        navArray["mediainterface"] = "../mediainterface/";
        navArray["photogallery"] = "../photogallery/";

        function navigate(which) {

            if (window.opener) {

                if (which == "contact" || which == "services")
                {
	                window.open (navArray[which], 'newWin')
                }
                else if (which == "photogallery" || which == "mediainterface")
                {
	                window.location = (navArray[which]);
                }
                else 
                {
	                window.opener.location = navArray[which];
	                opener.window.focus();
                }
        	
            }
            else 
            {
                window.location = (navArray[which]);
            }	

        }
</script>

```

I’m a little lost on the AS part of it, what would be the best way to have the each different button run it’s respective part in the JS array/function?

Thanks
