flash data integration:
Is it possible in your app to restrict the input in the textfields? myField_text.restrict = "A-Z 0-9 a-z";
Well, I need these tags in the field to make it work HTML wise on the output end, I just need to identify them so that when I send them via the XML Connector, I won't have any problems. Here is the final code someone helped me come up with. function convertForXMLTransfer(txt:String):String { //Declarations var fromTo:Array = [["&", "&"], ["<", "<"], [">", ">"], ["\"", """], ["'", "'"]]; var sp:String = txt; var num:Number = 0; var tmp:Array = new Array(); // for (i=0; i<fromTo.length; ++i) { for (j=0; j<sp.length; ++j) { if (sp.charAt(j) == fromTo[i][0]) { ++num; if (j == 0) { tmp[0] = sp.slice(1, sp.length); sp = fromTo[i][1].concat(tmp[0]); } else if (j == (sp.length-1)) { tmp[0] = sp.slice(0, sp.length-1); sp = tmp[0].concat(fromTo[i][1]); } else { tmp[0] = sp.slice(0, j); tmp[1] = sp.slice(j+1, sp.length); sp = tmp[0].concat(fromTo[i][1], tmp[1]); } } } } return sp; }
Since this is a two part question, I'll leave a post here and in the actionscript section. I am using an XML Connector and I am sending strings back and forth to the mySQL DB (using php) though my question doesn't concern this much. When I send that string, it may and most likely will have invalid characters in the string for that transfer (>, <, ", ' and &) so I am trying to write a function that will swap these characters after the user submits the form. The code I'm using looks like so: function convertForXMLTransfer(txt:String):String { //Declarations var fromTo:Array = [["&", "&"], [">", ">"], ["<", "<"], ["\"", "'"], ["'", "'"]]; var sp:String = ""; var tmp:Array = new Array(); //loop to search for characters for(i=0; i<fromTo.length; ++i) { for(j=0; j<txt.length; ++j) { if(txt.charAt(j) == fromTo[0]) { tmp[0] = txt.slice(0, j); tmp[1] = txt.slice(j+1, txt.length); sp = tmp[0].concat(fromTo[1], tmp[1]); } } } return sp; } The problem is that my code seems to be pretty inconsistent because is not seeing every character. It may not have time to run through every character thoroughly before the execution time is up or for some other reason. Does my code have a problem and does anybody know of a better way to do this? Thanks for your help! function convertForXMLTransfer(txt:String):String { //Declarations var fromTo:Array = [["&", "&"], [">", ">"], ["<", "<"], ["\"", """], ["'", "'"]]; var sp:String = ""; var tmp:Array = new Array(); // for(i=0; i<fromTo.length; ++i) { for(j=0; j<txt.length; ++j) { if(txt.charAt(j) == fromTo[i][0]) { tmp[0] = txt.slice(0, j); tmp[1] = txt.slice(j+1, txt.length); sp = tmp[0].concat(fromTo[i][1], tmp[1]); //trace(txt.charAt(j)+"\n"); //sp = txt.split(from[i]).join(to[i]); } } } return sp; }
Don't see what you're looking for? Try a search.
|