String Replace Help
Hello guys
I am trying to set text that it loaded into flash to disply x amount of characters like: blah blah blah blah = blah blah...
I can do this with php
PHP Code:
$topic = substr($user['topic'], 0, 25)."...";
How would i do it with flash??
I had a look i the AS dictionary and found this: code: myString.substr(start, [length]) but i am still a little bit lost.
Cheers Paul
FlashKit > Flash Help > Flash ActionScript
Posted on: 09-23-2003, 06:30 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Replace String
how can i replace all occurrences of the search string in dynamic text field with the replacement string??
like "str_replace" in PHP..
String Replace
Hello all
Is there an actionscript command which will replace part of a string, similar to the str_replace command in php?
thanks for any help
String.replace()
theres a replace method in the string class, but its not documented in the actionscript 2.0 reference on devnet. The syntax is pretty self explanatory looking at the method in the class in the first run folder:
Code:
function replace( re:String, repl:String ):String; // Central API
It doesnt seem to work
Code:
var test:String = "testerosa";
trace(test.replace("test", "tits"));
outputs undefined in flash 8 using player 8 (the method is in the flash player 7 string class as well)
How To Replace String?
How do i replace string with string?(i forgot how to do the split and join)
How do i replace string with image?
String Replace
Hello, I've been just starting on actionscript 2.0 for some things I want to get done. Currently, the data that I receieve is sent such as
str = "/'Hello/"";
What I want to do is to make a string replace that would allow me to change the backslashes, basicly like phps' stripslash. As well as probably if I figure that out, I can change " to ".
Could anyone guide me to a correct location on how to do this? I've tried a couple examples with no luck for stripping backslashes, any help, guides, etc would be great.
Thanks!
String.replace()
Hi guys,
Ok I have an input text field with htmlText set to false.
Now, I want to grab data from the text field but I want to convert line breaks to "<br />". I used this code...
Code:
textDescription.text.replace("
", "<br />");
Which works fine for the first line break but any breaks after that aren't replaced. Any ideas?
String Replace
Hi!
I want to replace "bad characters" in a text string received from an XML document but the replaced text seems to be undefined inside the for loop.
ActionScript Code:
for ( var i:Number = 0; i < l; i++ )
{
String.prototype.replace = function(s, z) { return unescape(escape(this).split(s).join(z)); };
cl.txt_text.html = true;
cl.txt_text.htmlText = text.replace("å", "ĺ");
}
String.replace(); Help
I have a string: "this is some test®"
And I need to to replace ® with the actual symbol. I have tried everything to get str.replace to replace this, but I can't seem to get it to work. Can anyone help me out?
String.replace
Who's got the bomb digity string utilities class....... yea?
I could sure use a string.replace().
Thanks for your MIND!
How Do I Replace Text In A String?
I'm importing a block of text from a ColdFusion page into a Flash movie. All the double quotes (") in the text are currently set as the HTML character:
Code:
"
.
Basically, I want Flash to replace all instances of
Code:
"
. with an actual ("). How can you do this in Flash?
Thanks!
[Edited by tenetarns on 08-17-2002 at 11:25 AM]
Replace Parts Of A String
I´ve got a string like "A little bird" but I need a string without " " (e.g. "A_little_bird").
Anybody an idea?
Replace Part Of A String
I have a sting which holds HTML formatted data passed into a variable and I need to replace an HTML tag in that string <STRONG> with a flash recognisable <B>. Is there a way I can check the string and swap them over?
.....thanks for any help.
String Search And Replace
Example:
astr = "Hello everyone"
(search string for all occurences of "everyone" and replace with "fred")
output:
astr = "Hello Fred"
How can I do this?
String Replace In Flash
How to replace loaded var. value like this one
"test1" into "test2" ?
Let me explain this a little bit, when I load variable I get this value
"test1"
I need something that`ll replace it to this variable value
"test2"
Replace Text In String
Hi, may I know any code that can be used to replace a character in a string of text? I can use 'indexof' to find the correct character index, but I need to replace it with a new charcater.. can anyone give me some guide??
Thanks..
String Replace Regexp ?
Hi !
I would like to replace in a htmlText all the <IMG SRC="...."> tags with <A HREF="..."><IMG SRC="...."></A>
is there an easy way of doing this ?
Thanks
Rodrigo
How Do I Replace String During Input?
How do i replace selected text during input?
I have a multiline input box, now assume while typing in it, the user selects some text and then clicks on a button nearby, on click, i want to replace the selected text, with the tagged version of the text(wrap it in tags)! How can i do this?
String.replace Using RegEx Help
Let's say that I have a block of text like the following. "The blah system is the perfect system to use".
I am using string.replace searching for "blah system" because that needs to be capitalized correctly to where all instances of it should be "BLAH SYSTEM". Here is the code I am using.
ActionScript Code:
tempStr.replace(/blah system/gi,"BLAH SYSTEM");
However, using the example above I end up with "The BLAH SYSTEM is the perfect SYSTEM to use". So it's capitalizing the word system even when it's not preceeded by blah. I don't know much about using RegEx but is there a way to make it only replace those words as a combined string?
Replace String With MovieClip
Now this seems farely simple. But, I'm struggling to find resources on this topic.
It will need to work similar to a chat application. Finding and replacing ": )" with .
Obviously you cant place a MovieClip inside a Dynamic TextField, but will need to atleast line up and add space needed to adjust the right side of the string.
Now, to be able to work out the space and width requirements. Would I need to be using TextLineMetrics (AS3)?
If anyone can point me in the right direction... or even better show me something that works? I'd be very grateful.
Kieran
Search And Replace In A String
Hi Reader,
I have a text field and I want to replace some of the words in it with others. For example I could have.
The red fox jumped over the brown fence, red again.
And I want to replace all the "red" with purple. Is there a simple flash function for this? If so I have been unable to find it.
Any help will be great.
Thanks
Leah
Replace Part Of A String?
I need to replace part of a string and I'm not sure of the best method... For example, I want to replace the "and" in this string:
"Run and Jump"
with and ampersand (&), so the string is now:
"Run & Jump"
I was told to use split and join, but that returns errors because it's not an array?
Please help!
Thanks,
Eddie
String Replace Functions
Per another user's request...(this was previously posted in the Flash 8 area)...
And I have [updated], tested and confirmed that replaceMultiple will work correctly. ( i discovered a misspelling in the previous version).
i have also included method speed information, for those nuts (like myself) that are concerned about processing speed.
replace is recursive, so it is considered Order 1 (uber fast)
replaceMutiple is a single loop, considered Order n (a little slower--but if you're working with a fixed set of data, you're good to go!)
Code:
/**
* I took out the original version of this function i posted because I realized the snippets sticky had a better way to do this. (plus, this is easier to read)
* this version, however, assumes you want the actual String prototype to modify its contents -- use as needed
* @param String search
* @param String replace
* @return String
*/
String.prototype.replace = function(search:String, replace:String):String {
this = this.split(search).join(replace);
return this;
}
/**
* Replaces characters within a string
* replace(Array, string|char)
* Method Speed: n
* @param Array instances
* @param String|char replacement
* @return string
*/
String.prototype.replaceMultiple = function(instances, replacement) {
for(i=0;i<instances.length;i++)
this = this.replace(instances[i],replacement);
return this;
}
don't forget these depend on some code found in the Kirupa tutorial 'bestof_search' which scans XML files
Code:
/*
* contains()
* @param String
* @return int
*/
String.prototype.contains = function(searchString){
return (this.indexOf(searchString) != -1);
}
/**
* contains()
* @param String searchvalue
* @return bool
*/
Array.prototype.contains = function(searchValue){
var i = this.length;
while(i--) if (this[i] == searchValue) return true;
return false;
}
with the aforementioned code and the code below, you can build a tiny xml search engine...which i am currently developing for an application
Code:
/**
* GetKeyWords()
* Method Speed: Order n
* Method Type: loop
* @param String query
* @return String[]
*/
GetKeyWords = function(query) {
var keys= [];
// the next two lines could be combined, but it's just too hard to read; so they're split up like good like codelings
query = query.replaceMultiple(punctuation,' '); // spaces are our delimiter, (this could be customized in the method signature, but I don't think it would be any easier to use
var captured = query.toLowerCase().split(' '); // and as such, we will use them to break up our query into keywords
for(i=0;i<captured.length;i++)
if(!isIgnoredWord(captured[i], ignoredWords)) keys.push(captured[i]);
return keys;
}
/**
* isIgnoredWord(str, array)
* Method Speed: Order 1
* @param String str
* @param Array wordList
* @return bool
*/
isIgnoredWord = function(str, wordList) {
if(str.length<3) return true;
return wordList.contains(str.toLowerCase());
}
AS3 RegExp And String.replace
This is an AS3 question (I forgot to put it in the title).
When using the replace method with a regex pattern, is there anyway to have the replace method start back at the beginning of the string after it has found a match.
For example:
ActionScript Code:
var r:RegExp = /1a1/g;var s:String = "1a1a1";trace(s.replace(r, "1")); //1a1
The replace method returns 1a1, which also matches the regex pattern but doesn't get replaced with 1. What I assume happens is that the replace method starts searching the string again after the index of the last replaced match. So, in this case, it will only see a1 after the first replace which doesn't match the pattern.
I was thinking that I might have to just call the replace method recursively until there are no more matches left, but I was hoping that there would be a better way.
Thanks for any help
[AS3] Replace Items In A String
I have been working on this all day and cannot seem to find a solution. I am trying to build a function where I can pass in a string and as many parameters as I want. The parameters that I am passing in will replace the #1 and #2 in the url string. This needs to be dynamic so that if I am passing in #1 - #20, I just need to add in the parameters to my ... rest array and it will automatically replace and return the correct url to me.
So far I have a reg exp that finds the patterns that I am looking for and I can replace the first parameter. But I need a way to loop through all the params and change them all. That is where I am stuck on because in string.replace( pattern, .... ) I cannot add in rest[i] as my repl:Object. I tried putting it into a loop but that just ends up replacing #1 and #2 with the first item in my rest array.
I don't have to use reg exp but it just seems like the best way, feel free to suggest other methods.
ActionScript Code:
var myURL:String = "http://www.foo.com.aspx?SessionID=#1&lpn=#2";
replaceItems( myURL, "FormPage", "ListPage" );
function replaceItems( string:String, ... rest ):String
{
var pattern:RegExp = /[#][0-9]/g;
// I can't seem to find a way to make it rest[i] so that it will replace #1 and #2 with rest[0] and rest[1].
return( string.replace( pattern, rest[0] );
}
Search And Replace String Help
ok, here's my problem. I have html being sent back to my flash file from a database. I wisht to display the data rendered as HTML, but there is a slight snag!
The data I am getting has NO "" quote marks in the font tags, and flash will not render it. Flash understands <font color="#ffffff"> but NOT <font color=#ffffff> it will not render.
I have a nifty script I found that will replace things but the problem is that is will only replace the same exact item.
Heres what I mean:
Code:
notes = "<font color=#ffcc00>hello</font><font color=#ff0000>hello</font>"
//
function searchAndReplace(holder, searchfor, replacement) {
temparray = holder.split(searchfor);
holder = temparray.join(replacement);
return (holder);
}
//
notes = searchAndReplace(notes, "color=#"+notes.substr(notes.indexOf("color=#")+7, 6), "color="#"+notes.substr(notes.indexOf("color=#")+7, 6)+""");
//
trace(notes);
output: <font color="#ffcc00">hello</font><font color=#ff0000>hello</font>
Notice in the output the first set of font tags is fine, it put in the quote marks where they were supposed to be, but the 2nd set of font tags is not exctly like the first set, so it is not replaced. I need a way to find the "color=" string, skip ahead 7 spaces and attach a quote mark " to the end making it color="#??????" but I'm not sure how to do this.
Please some one help me.
Thanks in advance.
Ragscoon
String Replace Function In Flash 5...
Hi,
Has anyone written a string replace function in Flash 5? If so any chance of posting the actionscript for it? Have had an absolute ball-ache trying to get the one I'm doing to work!
Cheers,
Ears
Find And Replace Characters In String...
(F5)
What's the best way to find and replace a certain character from within a string, that I got from user input ?
say i want to replace all "ä" with ae and vice versa.
thanks
Replace Multiple Character In A String?
The following script is finding all instances of "&" in the var url1_hold and then writing the var url1 and replacing "&" for "...and..." in that string.
//THIS WORKS------------------
for (i = 1; i <= _root.url1_hold.length; i++) {
if (substring (_root.url1_hold, i, 1) != "&") {
_root.url1 += substring (_root.url1_hold, i, 1)
} else {
_root.url1 += "...and...";
}
}
//---------------------------
I also need to be able to do the reverse. But the following script does not work:
//THIS DOESN'T WORK----------
for (i = 1; i <= _root.url1.length; i++) {
if (substring (_root.url1, i, 1) != "...and...") {
_root.url1_hold += substring (_root.url1, i, 1)
} else {
_root.url1_hold += "&";
}
}
//---------------------------
I am guessing that the script that I am using is only able to look for one character in a string and that is why I am having issues.
Anyone know of a work around?
Thank you kindly...
Replace A Character In A Text String
Hi,
I have a text string and i want to replace a char in it. I find the char but i don`t know how to change it.
For example the text string is "Axristos" and i want to change the letter "A" with the letter "B". Is there any way to do that?
I just want the script of changing, not the function to find the letter.
I can create a new text string with the old one and changing just that letter but i want something easier and less complex(if there is something)
String Parse/search & Replace Help...
Im looking for a better way to do the following:
take a string (variable), and search it for key 'words' (elements) and replace them with another...
doing it 1 word at a time seems simple enough:
PHP Code:
function emailParse(targetString, searchFor, replaceWith) { trace("BEFORE: " + targetString); tempArray = targetString.split(searchFor); targetString = tempArray.join(replaceWith); trace("AFTER: " + targetString);}var myString:String = "The quick sliver fox jumped over the lazy brown dog";emailParse(myString, "brown", "orange");
however, if I wanted to, say, parse out several 'tags/elements', and grab the sub string/characters between these elements.. I guess Im at a loss for an efficient way of doing so:
PHP Code:
function emailParse(targetString, searchFor, replaceWith) { trace("BEFORE: " + targetString); tempArray = targetString.split(searchFor); targetString = tempArray.join(replaceWith); trace("AFTER: " + targetString);}var myString:String = "hey my email address is: [ email ]myemail@domain.com[ /email ], dont forget it.";emailParse(myString, "[ email ]", "<a href ='myemail@domain.com'>");
Id like to not only replace the [ email ] & [ /email ] tags but also grab the characters in between them and use it in the [ email ] tag replacement..
make sense?
any ideas or suggestions on logic or approach are appreciated.
Thanks
update:
this sorta works:
PHP Code:
function emailParse(targetString, searchFor, replaceWith) { trace("BEFORE: " + targetString); //find string between tags var openEmailPos:Number = targetString.indexOf("[email]"); var closeEmailPos:Number = targetString.indexOf("[/email]"); var tempEmail:String = targetString.substring(openEmailPos+7, closeEmailPos); tempArray = targetString.split(searchFor); targetString = tempArray.join(replaceWith+tempEmail+"'>"); trace("AFTER: " + targetString);}var myString:String = "hey my email address is: [email]myemail@domain.com[/email], dont forget it.";emailParse(myString, "[email]", "<a href='");
but I guess Id like something more efficient? something that can do both tags? in the same function perhaps.. (guess I'll go back and fiddle with it)
this seems to work as well handling both tags and the characters in between:
PHP Code:
function emailParse(targetString, searchOpen, replaceOpen, searchClose, replaceClose) { //find string between tags var openEmailPos:Number = targetString.indexOf("[email]"); var closeEmailPos:Number = targetString.indexOf("[/email]"); var tempEmail:String = targetString.substring(openEmailPos+7, closeEmailPos); tempArray = targetString.split(searchOpen); targetString = tempArray.join(replaceOpen+tempEmail+"'>"); tempArray = targetString.split(searchClose); targetString = tempArray.join(replaceClose); trace("AFTER: " + targetString);}var myString:String = "hey my email address is: [email]myemail@domain.com[/email], dont forget my old email address as well: [email]myemail2@domain.com[/email].";emailParse(myString, "[email]", "<a href='", "[/email]", "</a>");
still open to suggestions if there is a better, more efficient way of course.
thanks
String.replace() Not Working Properly...
I'm using this to remove punctuation:
ActionScript Code:
var bareString1:String = new String(_textsArray[i].toLowerCase());
var bareString2:String = bareString1.replace("-", " ");
var bareString3:String = bareString2.replace(".", "");
var bareString4:String = bareString3.replace(",", "");
trace(bareString1);
trace(bareString2);
trace(bareString3);
trace(bareString4);
...but it doesn't work completely:
and if you have low self-esteem, hang up, all our operators are too busy to talk to you.
and if you have low self esteem, hang up, all our operators are too busy to talk to you.
and if you have low self esteem, hang up, all our operators are too busy to talk to you
and if you have low self esteem hang up, all our operators are too busy to talk to you
Why? What's going on?
I've tried it as a RegExp but I still get the same.
Help With RegEx On String.replace() Not Working.
I have a regular expression that finds all of the XML tags in a string. So everything between "<>". I used Rubular.com to validate that it works as expected.
The goal is to change the case of the XML from UPPERCASE to lowercase tags in a string before creating a new XML object with it.
So I used the RegExp with String.Replace(regex,function), i also added the /ig switch, but it's not working. the string remains the same.
Code:
private function clickHandler(e:Event):void
{
var str:String = "<RECORDS TRANSACTION_ID="1000149"><RECORD><ID>251801</ID><PLS>1</PLS><WHO>MIKE</WHO><TITLE>TEST FOR</TITLE></RECORD><RECORD><ID>187001</ID><PLS>1</PLS><WHO>MIKE</WHO><TITLE>WAHT</TITLE></RECORD><RECORD><ID>188001</ID><PLS>1</PLS><WHO>MIKE</WHO><TITLE>NEWRECORD FOR DEMONSTRATION</TITLE></RECORD><RECORD><ID>199801</ID><PLS>1</PLS><WHO>MIKE</WHO><TITLE>NEW FOR DEMO 2</TITLE></RECORD><RECORD><ID>255801</ID><PLS>1</PLS><WHO>MIKE</WHO><TITLE>TEST 123</TITLE></RECORD></RECORDS>"
str.replace("(<.[^(><.)]+>/ig)",toLowerCase);
}
private function toLowerCase(match:String, match1:String, index:int, input:String):String
{
return match.toLowerCase();
}
Any help is appreciated.
Find And Replace Characters In String?
Hello.
Checked google, but only found some outdated,homemade functions.
Is there no other way to Find char in a string and replace it?
the shortest function i found was about 30 Lines long.
String, Character Replace Function, Comments Please
Ok, long story short, i need a way to replace characters throughout a whole string. What i am doing, is loading a big article that is inside an xml attribute (the blah="" tag thing). I am doing various things with the article, such as splitting it up to be in pages, ect.
My problem lies in the fact that xml hates html tags format.. as they seem to be the same thing basically, so what i am wanting is a way to replace a few key characters that html goes by.
In otherwords, i need to write stuff like <a href="asfunction:blah,blah">Link</a>, ect in an xml file. But since i dont see a way to do that, i am going to write it with different characters; Something XML is happy with. For example
Code:
(,)a href=(')asfunction:blah,blah(')(.)Link(,)/a(.)
Now i know that looks insanely weird, and i'll prob use dif characters, but what i am doing is replacing anything XML might not like (i cant remember if it doesent like " or not) with my own custom character.
Now to get to what this post is about, what do you think would be the best way to replace the characters? I may be missing some simple way around this, so please correct me if i am.
But what i plan on doing, is building a custom replace function with some String features. Say you want to replace all instances of (,) with < after loading the XML Node Attribute into a String. What i am going to do is make my function hold a Variable for completed string, temp string, and old string.
Apon the function being called, it takes a parameter of a string, searches via String.indexOf, for the first instance of (,). Once it finds an instance you log what number it starts at, lets say it starts at 51 characters in. It then takes characters 0-50, puts them in the finalized string, adds the replace character <, takes out the (,) from the front of the temp string, which leaves characters 54 and on. so then it does the same thing, searches via indexOf, for (,) and if it finds anything, it does it all over again.
Mostly i am wondering is this the best way to do this in flash? It will get the job done, but seeing as i am be searching big big strings, full blown articles, i want to make sure i wont bog it down completely. Or who knows, i dont know flash that well so there may be something built in to do this, i just didnt see it in "String".
Thanks to any comments, and hopefully you understand what i am trying to say lol.
[MX04] String Search & Replace With TextFormat?
Good morning all,
I am attempting to simplify things further to speed development, so here goes.
Below is a script I picked up sometime back, and it has served me well. However, I would now like to extend it by having the new text, in this case 'Betty Rubble.....' assigned the color 'blue' without having to manually identfy it's location in the string (7, 35, blue) as I am no doing by using the tip I picked up yesterday--it is the last line of the script below.
Any ideas or assistance would be greatly appreciated.
Code:
String.prototype.searchReplace = function(find, replace) {
return this.split(find).join(replace);
};
blue = new TextFormat();
blue.color = 0x0000FF;
var myString = "This is Fred Flinstone at the Bedrock Inn.";
base.text = myString;
trace(myString);
btn.onRelease = function() {
var newString = myString.searchReplace("Fred Flinstone", "Betty Rubble, Barney's wife,");
trace(newString);
base.text = newString;
trace(newString);
base.setTextFormat(7, 35, blue);
};
Replace Curly Quotes In String With Straight Ones
Hi folks,
I've been searching for some code to find all the curly quote marks in a string, and convert them to their straight equivalents - the pixel font I'm using doesn't have the curly ones!
“ -> "
” -> "
‘ -> '
’ -> '
Can anyone advise on this?
Thanks for your time
3stripe
Search And Replace A String Value In External File?
So I've searched around and found a couple of threads that gave me some pointers on how to replace certain values within a variable, but I can't find any help on how to replace a string from an external file.
The reason I'm asking is so I can load external text files created from a blogging platform and if someone should happen to type in a "&" in their entry it won't screw up the entire post.
So I'm wondering if there is a way to do a search and replace for "&" symbols and replace them with the correct "%26" value so they can be used within the text file.
Any ideas?
Find And Replace Text In A String Variable
I want to be able to find and replace text within a flash variable
example:
Code:
text = "the |bold|cat|/bold| sat on the mat";
change to:
Code:
text = "the <b>cat</b> sat on the mat";
is this possible?
if so do you know of any documentation?
String Replace Via Actionscript, Doesn't Work...
Since there is no built-in string replace function for flash and actionscript, so I did the user defined function to take care of that. The user defined function is what I found from the the google search.
Code:
function strReplace(thisStr,what,byWhat) {
while (thisStr.indexOf(what)>-1) {
var tmp = thisStr.split(what);
thisStr = tmp.join(byWhat);
}
return (thisStr);
}
It was working great until it goes into an infinite loop when the parameters was used in strReplace() function like this...
Code:
test = strReplace(strData,"McDonald","<a href='blah blah'>McDonald</a>");
Then I found that in the function code above which showed that the loop that never reached the end of the string as it would start a new loop again once it is finished. So, I did a different function instead..
Code:
function strReplace(thisStr,what,byWhat){
var counter=0;
while (counter<thisStr.length) {
var startPos = thisStr.indexOf(what, counter);
if (startPos == -1) {
break;
} else {
var before=thisStr.substr(0,startPos)
var after=thisStr.substr(startPos+what.length,thisStr.length)
thisStr=before+byWhat+after
var counter=before.length+replace.length
}
}
return thisStr;
}
So, I tried it again and it still go into an infiinite loop. So, what did I do wrong? Need someone with a fresh eyes to see the codes...
Thanks,
FletchSOD
Error 2101: The String Passed To UrlVariables.decode() Must Be Url-encoded Query String
I am trying to make a flash contact form which will submit the firstname, lastname, email and comments to an asp.net page.
I am have having the following error:
Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs
I am using the following action script code as pasted below. This action script is communicating with an asp.net file to send the email out. In the end it responds back with response=passed or failed.
I have already spent around 3 hours figuring it out.. and looking through the internet for resolution but no luck. Any help will be appreciated.
stop();
submit_btn.addEventListener(MouseEvent.CLICK, submit);
function submit(e:MouseEvent):void
{
var variables:URLVariables = new URLVariables();
variables.firstname = firstname_txt.text;
variables.lastname = lastname_txt.text;
variables.email = email_txt.text;
variables.comments2 = comments_txt.text;
var req:URLRequest = new URLRequest(”emailacount.aspx”);
req.method = URLRequestMethod.POST;
req.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, sent);
loader.addEventListener(IOErrorEvent.IO_ERROR, error);
loader.load(req);
status_txt.text = “Sending…”;
}
function sent(e:Event):void
{
status_txt.text = “Your email has been sent.”;
firstname_txt.text = “”;
lastname_txt.text = “”;
email_txt.text = “”;
comments_txt.text = “”;
}
function error(e:IOErrorEvent):void
{
status_txt.text = “There was an error. Please try again later.”;
}
and the following asp.net code:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Net.Mail" %>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Try
Dim fromEmailAddress = "paul@lancierinc.com"
Dim toEmailAddress = "rizwandar@gmail.com"
Dim firstName = Request.QueryString("firstname_txt")
Dim lastName = Request.QueryString("lastname_txt")
Dim comments = Request.QueryString("comments_txt")
Dim userEmail = Request.QueryString("email_txt")
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress(fromEmailAddress)
mail.To.Add(toEmailAddress)
'set the content
mail.Subject = "Email from" & firstName & " " & lastName
mail.IsBodyHtml = True
Dim strBody As String = "<b>Email from</b>" & " " & firstName & " " & lastName & "<br><b>Email Address:</b> " & userEmail & "<br><b>Comments:</b> " & comments
mail.Body = strBody
'send the message
Dim smtp As New SmtpClient("mail.lancierinc.com")
smtp.Send(mail)
Dim urltoencodestring2 = "response=passed&err=0"
'Response.Write(urltoencodestring2)
Catch smtpEx As SmtpException
'A problem occurred when sending the email message
'ClientScript.RegisterStartupScript(Me.GetType(), "OhCrap", String.Format("alert('There was a problem in sending the email: {0}');", smtpEx.Message.Replace("'", "'")), True)
Response.Write(smtpEx.Message)
Dim urltoencodestring = "response=failed&err=1"
'Response.Write(urltoencodestring)
Catch generalEx As Exception
'Some other problem occurred
'ClientScript.RegisterStartupScript(Me.GetType(), "OhCrap", String.Format("alert('There was a general problem: {0}');", generalEx.Message.Replace("'", "'")), True)
Dim urltoencodestring3 = "response=failed&err=1"
'Response.Write(urltoencodestring3)
End Try
End Sub
</script>
String Passed To URLVariables.decode() Must Be A URL-encoded Query String...
I really don't understand why this won't work? I've made a test which sends some POST data to a script on my page which works fine. But why does not this work?
Code:
var mapsize = _cmap.fieldx.toString(16) + _cmap.fieldy.toString(16);
var names = "Zomis_AI6";
var description = "descr";
var result = "gameresult";
var upldata: String = "mapsize="+mapsize+"&names="+names+"&description="+description+"&result="+result;
trace(upldata);
var variables:URLVariables = new URLVariables(upldata);
var request2:URLRequest = new URLRequest();
request2.url = "http://www.zomis.net/record.php";
request2.method = URLRequestMethod.POST;
request2.data = variables;
var loader2:URLLoader = new URLLoader();
loader2.dataFormat = URLLoaderDataFormat.VARIABLES;
loader2.addEventListener(Event.COMPLETE, uploadcomplete);
try {
loader2.load(request2);
trace("Loaded");
}
catch (error:Error) {
trace("Unable to load URL");
}
Tracing gets:
Code:
mapsize=1010&names=Zomis_AI6&description=descr&result=gameresult
Loaded
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables$iinit()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()
Randomize String And Create Textfields With String Txts
Hi,
is there some easy method to randomize elements of an array (to randomize index numbers) and create textfields with name of these elements ?
I had no problem making a photo gallery with strings but now I have to do a menu , with spacing (there should be same space between all the words of an array generated textfields)...How can this be accomplished ?Thanx in advance, Meerah
Convert Multiline String To A One Line String With RegExp
better get my own thread for that
How can I convert a multiline String to a one line String?
EX:
PHP Code:
Testing is always full of man made bugs.
<a href="http://www.betterthannothing.com" title="betterthannothing" target="_blank">
<font color="#22229C">Believe</font>
</a>
me when times comes that you have to
<a href="http://www.vreate.com" target="_blank">create</a>
useless stuff to test some other useless stuff to have
<a href="http://www.vreate.com">some</a>
real results.. its a pain.
<img src="http://www.markval.com/deerPack.jpg" height="484" width="352"/>
<em>Got to try that stuff to eventually love it one day.</em>
and should result in
Code:
Testing is always full of man made bugs.<a href="http://www.betterthannothing.com" title="betterthannothing" target="_blank"> <font color="#22229C">Believe</font></a>me when times comes that you have to<a href="http://www.vreate.com" target="_blank">create</a>useless stuff to test some other useless stuff to have<a href="http://www.vreate.com">some</a>real results.. its a pain.<img src="http://www.markval.com/deerPack.jpg" height="484" width="352"/><em>Got to try that stuff to eventually love it one day.</em>
I think it have to play with the ^ (caret) and m (multiline) ... just need to put the puzzle together.
String.as (Fishing Line Or Kite String)
Hello everyone. After reading the article on Glen Rhodes (Proud Canadian) I was wondering exactly how to insert the string.as file. I have been having huuuuuuge speed issues with my code. My file sizes are quite small (40 - 60 k)but they are very sluggish.
Thank you......
Please help
http://www.moodvibe.com
Trouble With String.indexOf And String.lastIndexOf
Hi,
I have an input text field used for time. I'm trying to set it up so the user has to enter a valid time into the box.
I set the box to be only 5 characters in length and to only use numbers and the ":" character.
I thought this code would insure there wouldn't be two ":" characters and the ":" would be at lease one character from the begining and at least two from the end.
But the if you enter 2:321 it comes back as a valid time.
Thanks in advance,
thurston
Code:
if(string.indexOf(":", 1) == string.lastIndexOf(":", string.length-3) ){
trace("Valid Time");
}else{
trace("Invalid Time!!!");
}
|