Results 1 to 7 of 7
Thread: ExternalInterface/Javascript
-
June 2nd, 2009, 02:05 PM #1114Registered User
postsExternalInterface/Javascript
I have a little problem that I've spent hours trying to figure out. I am trying to return an array from javascript. The problem (I assume) is that is has some php in the javascript function
Here is the code I am trying that doesnt work:
JavaScript:
<script type="text/javascript">
function JavaFunc(){
<?php
$company_name[0] = "Kirupa";
echo 'var company_name = new Array();';
echo 'company_name[0] = '.$company_name[0].';';
echo 'return company_name;';
?>
}
</script>
AS3
var theArray = ExternalInterface.call("JavaFunc");
theTextField.text = theArray[0]
if I change the javascript code to....
<script type="text/javascript">
function JavaFunc(){
<?php
echo 'var company_name = new Array();';
echo 'company_name[0] = "Kirupa";';
echo 'return company_name;';
?>
}
</script>
The textfield text is the first element of the array as it should. There must be something wrong with the way I'm echoing out the java from php. If anyone can help me understand what I'm doing wrong I would greatly appreciate it.
-
June 2nd, 2009, 02:29 PM #2
your echo is returning the String 'return company_name;'
it should be returing 'return'.$company_name;
because you want the value of $company_name; not a string that says $company_name,
ya dig?
-
June 2nd, 2009, 11:10 PM #3114Registered User
postsWhat's up GrndMasterFlash. It's been a while since I've had the honor. Thanks for your reply and sorry for the delay. OK so I tried your suggestion however it's not working for me. The problem is when I echo the php variable (echo 'return' .$company_name
, $company_name comes through as string "Array". The only was that I know how to communicate between php and javascript is to echo my javascript as string in the correct syntax.
-
June 2nd, 2009, 11:27 PM #420Registered User
postsI think that your php code an javascript code is correct.
Could you try following code in flash and see that work well or not.
ExternalInterface.call("alert","A try!");
-
June 2nd, 2009, 11:58 PM #5114Registered User
posts
-
June 3rd, 2009, 12:04 AM #620Registered User
postsI am sorry, I did not see clearly...
echo 'company_name[0] = '.$company_name[0].';';
echo 'company_name[0] = "'.$company_name[0].'";';
Do you understand what I mean?
-
June 3rd, 2009, 12:20 AM #7114Registered User
posts

Reply With Quote


Bookmarks