# Getting the result of a Javascript function into Flash?

**URL:** <https://forum.kirupa.com/t/getting-the-result-of-a-javascript-function-into-flash/215735>\
**Category:** flash\
**Created:** [February 9, 2007, 9:46pm UTC](https://forum.kirupa.com/t/getting-the-result-of-a-javascript-function-into-flash/215735 "2007-02-09T21:46:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pseudodigm](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@pseudodigm](https://forum.kirupa.com/u/pseudodigm)\
**Post date:** [February 9, 2007, 9:46pm UTC](https://forum.kirupa.com/t/getting-the-result-of-a-javascript-function-into-flash/215735/1 "2007-02-09T21:46:25Z")

</div>

This is driving me nuts.

So, I have a site that has a button on it and someone did a little javascript so that each time you click the button you go to a randomly selected URL from an array of links.

Now, I was told to give my flash button the same functionality. I’m not really a coder, so instead of re-inventing the wheel, I’m trying to get the result of the javascript into my action script. So far, I’m completely unlucky.

Here’s the javascript:

```auto

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
                    var uc = 4;    
                    var u = new Array(uc);    
                    u[0] = "http://blahblahblah.html";
                    u[1] = "http://blahblahblah.html";
                    u[2] = "http://blahblahblah.html";
                    u[3] = "http://blahblahblah.html";
                    function pickRandom(range) {
                        if (Math.random)
                            return Math.round(Math.random() * (range-1));
                        else {
                            var now = new Date();
                            return (now.getTime() / 1000) % range;
                        }
                    }
                    function pickRandomURL() {
                        var choice = pickRandom(uc);
                        return u[choice];
                    }
                </SCRIPT>    

```

And here’s the link that calls it:

```auto

onClick="this.href=pickRandomURL()"

```

I’ve tried the basic GetURL(“javascript:pickRandomURL();”), but I guess the javascript isn’t reaching the flash. I tried a loadVar, but I’m probably not doing it right…Ditto for PassFlash().

Can anyone help me with this please?

Thanks,

Rick
