|
-
Find certain letters at beginning of textbox?
I wanted to make an application in flash that switches the first letters of two words. (I know it's a stupid idea, just wanted to show my dad I could...) Okay. I have two text boxes, and when I hit the "swap" button, I want it to switch the first two letters of the two words and put it in a third text box. If it is a consonant pair like sh, ch, st, cr... I want it to move both of the letters. I have a lot of experience in Actionscript 2.0 but none in 3.0. Any help?
Edit: I am sorry if this has been posted before. If it has please direct me to the topic and you can delete this topic.
Last edited by Akskater1000; 11-20-2008 at 06:51 PM.
-
I dont understand the part about putting the word in a third text box, but this should get you started:
PHP Code:
swapbtn.addEventListener(MouseEvent.CLICK, swap);
function swap(e:MouseEvent):void { var input1:String = ti1.text; var input2:String = ti2.text; var subbed1 = input1.substring(0,2); var subbed2 = input2.substring(0,2); trace("first two letters of text box 1: " + subbed1); trace("first two letters of text box 2: " + subbed2); }
make two text inputs. One called 'ti1' the other 'ti2' and then a button called swapbtn and you can see what I did work.
-
First thing I have to say is "WOW" Actionscript 3.0 is sooo much different...
NOT COOL!!! NO MORE _ROOT!!!
Back to the topic. I think you didn't understand what I was trying to say, actually I know, and it's my fault. I should have been more clear. What i'm trying to do is make an application that swaps the first letter (if it's a pair of letters i.e. ch, sh, sm, st...) and puts the finished, and swapped word into the third text box. Ill give an example. I put "Smelly" into the first text box and "Cheese" into the second. I click swap and the third text box reads "Chelly Smeese" Do you get it now?
Last edited by Akskater1000; 11-20-2008 at 09:28 PM.
-
oh ok well do what i said before, make your third text input, name it ti3 and do this:
PHP Code:
swapbtn.addEventListener(MouseEvent.CLICK, swap);
function swap(e:MouseEvent):void { var input1:String = ti1.text; var input2:String = ti2.text; var subbed1 = input1.substring(0,2); var subbed2 = input2.substring(0,2); var newString1 = input1.substring(2); var newString2 = input2.substring(2); ti3.text = subbed2 + newString1 + " " + subbed1 + newString2; }
AS3 isnt too much different. Their still is root, its just not called _root. It is now just root. Same with all the other properties. _x isnt _x, its just x..etc
Plus with my example, their would be no reason to use root in the first place.
-
Yes, I know it doesn't use root. I was trying before on something else. And I get an error. I tried messing around with it, but can't fix it.
I get error 1023: Disable overdrive.
1021: Duplicate function definition.
-
Duplicate function just means you have a function with the same name more than once. That code worked for me
-
Yea, that's what I thought. But it didn't work for me...
-
its easy..copy what I posted..make three text boxes nammed ti1, ti2 and ti3 and a button called swapbtn and it will work. I guarantee it.
-
Yup, I just made a new .fla document. It works now. I'm too lazy to make it detect if there are 1, 2, or 3 consonant groups, I just made 6 boxes. Type "Smelly" and "Cheese" into the middle row. http://skaterms.webs.com/Word%20Swapper.swf
Sorry about the link there are no more .swf hosters anymore T.T
Now do you see about the consonant groups? wanna help with that?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|