Javascript and flash mx

i am trying to get values from an html page by using a javascript function!
i have made a butoon with the code :
on (release) {
getURL(“javascript:changeText()”);
myTxt.text=gUserID;
}

and in the html page i made a java script function :

<SCRIPT LANGUAGE=“JavaScript”>
function changeText() {
window.document.js.SetVariable(“gUserID”, “111”);

}

but what happens is that i get the value “111” only after i press the button twice!!! and not once!
why is that?
what can i do to make it work?
Thanks in advace
Peleg