java - Flex/Flash 4 ExternalInterface.call - trying to get a string from HTML to Actionscript -


I have to get a string from HTML and put it in an action script.

actionscript:

  import flash.external.ExternalInterface; Secure function getUserName (): zero {var is available: boolean = external interface available; Var findUserName: string = "findUserName"; If (available) {var foundUserName: string = ExternalInterface.call (findUserName) .toString (); Alert.show (foundUserName);}}  

javascript:

  function findUserName () {var label = document.getElementById ("user name-label" ); If (label.value! = "") {Warning ("The name in the box is:" + label.value); Return label.value;} Then "nothing in the text box";}}  

JSP:

  & lt;% iUser session user session = Session manager .getSession ();% & gt; & Lt; Logic: notEmpty name = "user session" & gt; & Lt; Logic: not real value = "anonymous" name = "user session" property = "user login" & gt; & Lt; Td align = "right" width = "10%" & gt; & Lt; Input id = "user name-label" type = "text" value = "& lt; bean: write name =" user session "property =" user login ID "/> / & Gt; & Lt; / TD & gt; & Lt; / Logic: notEqual & gt; & Lt; / Logic: notEmpty & gt;  

HTML provided:

  & lt; Td align = "right" width = "10%" & gt; & Lt; Input id = "username-label" type = "text" value = "a valid-username" /> & Lt; / TD & gt;  

When javascript execution hits

  var label = document.getElementById ("username-label");  

An empty returned and crash occurs, no warnings show that no error message is shown. I can successfully search a Firefox DOM Inspector by "username-label" (document.getElementById ())

The only alert box that has popped up is that action script warning box and the content is empty .

FirFox 3.5 windows, Container is Tomcat.

Please consult in advance and thank you.

  import flash.external.ExternalInterface; Public function getUserName (): zero {var is available: boolean = external interface available; // var findUserName: string = "findUserName"; If (available) {ExternalInterface.call ("findUserName"); }}  

Now create a button and call this function getUserName and now try entering a warning message in javascript and see if this is a call.

Make the method public and let us know if you can call the name of the JavaScript method.

Note: : Protected and private will also work, it's just for testing.

More Updates:

  function findUserName () {// We are initially checking ourselves Return (! Document.getElementById); Var label = document.getElementById (user name-label); warning label); If (label.value! = "") {Warning ("The name in the box is:" + label.value); Return label.value;} then "nothing in the text box";}}  

Describe your JavaScript function above and let me know.

Thank you.


Comments