[FMX] text -> movieclip

Hi, I’d be grateful if someone help me.

There’s a textfield(Var: inputText), a button and MovieClips(ASCII values 32 to 126).
When you input some letters to the textfield and push the button, I wanna show you the MovieClips of letters which you just input. (you input “flash” -> push the button -> the MovieClips “f” “l” “a” “s” “h” appear.)

I wrote some scripts to the frame1 (_root.movieclips._visible = false; …) and the button(see following).

on (release) {
s = new String(_root.inputText);
if ( s.slice( 0, 1 ) == “A”) {
_root.A._visible = true;
} else if ( s.slice( 0, 1 ) == “B”) {
_root.B._visible = true;
// continue and continue and continue…
}
if ( s.slice( 1, 2 ) == “A”) {
_root.A2._visible = true;
// continue…
}
}

*the instance names of the movieclips are A, B, C, …

I know this scripts are lengthy and not great. But I couldn’t think any more. Should I use the “attachMovie” or something else? If so, how can I write the scripts briefly?
I’m a really really beginner so there must be strange points in my explanation… sorry.

Are you trying to do something like this…

http://www.kirupa.com/developer/actionscript/ascript_text_animation.asp

???

Thank you for replying me lostinbeta, but no, sorry, I couldn’t explain correctly.
I wanna show you the movieclips of alphabets.
I wanna use the strange font to show you some characters but I don’t think
all of you have the same font as mine. so…
Do you understand the meaning from my explanation?

I think so, not sure I have the skill to do it, but I will give it a try.

If I am reading your original method correctly you would have about 6 million lines of code for a word…lol.

I am sure there is an easier way… I just have to figure it out :slight_smile:

Alright well I have this SO FAR…

Create 3 movie clips. In the library right click on them and go to the linkage properties. Click on the “Export for Actionscript” checkbox.

While in the linkage properties, give one the name “a”, another the name “b”, and a third the name “c”.

Then put this code in a Frame.

myString = "abc";
end = myString.length;
for (i=0; i<end; i++) {
	_root.attachMovie(String(myString.charAt(i)), String(myString.charAt(i))+i, i);
	letter = _root[String(myString.charAt(i))+i];
	letter._x = 27*i;
}

Ok, I finished a version on my end. I can’t believe I pulled this off myself!!!

I am so proud of myself…lol.

Check the attachment .fla.

You will need to go to Control/Test Movie to see it work. Of course it is generic and I just used basic letters no animations, but I was trying to whip it up real quick.

easier way :slight_smile:

yes you should use attachMovieclip, no you should not do it that way. :wink:

first off, instead of having THAT many movieclips, just make one movieclip with frames for each letter. If you already made and named the movieclips, Im sorry. Having them in one movieclip means you dont need instance names (or to set linker IDs for attaching) for EVERY letter. All you need is that one clip and then just use a gotoAndStop to go to the letter you need it to.

Then, all you need to do is, probably on textField.onChanged is attach that clip with all the letters and add it to what letters are already there (providing the proper offset) and then tell it to goto and stop at the frame of that letter, which you could actually have in there placed based on their ASCII value, or do something like the ASCII-31 or whatever.

The only problem will be that the changing of the textfield isnt always linear, meaning someone could go back and change the first word in which case you would have to re-attach everything - so you might just want to attach everything on every onChanged.

[edit] started this before lost posted his example so I dont know if this is ‘easier’ than that or not ;)[/edit]

Hey Sen… Good method. As I said before… I am just glad I was able to pump something out that actually worked…lol.

Hey lostinbeta! You’re genius!!
Thank you very much for your work, I really appreciate it.

And senocular, thank you for your idea.
I guess your method is great, but as I wrote before,
I’m a really beginner and I’m not sure whether I can do it
according to your method… but I’ll try at least.

Anyway thank you very much!
I think I’m happier than you lostinbeta! lol.

Hey no problem Roko. I am glad I could save you having to write 6 billion lines of code.

And I am not a genius :blush:

I learned the String(expression) method from Sen here… he taught me a ton.

*Originally posted by lostinbeta *
**
And I am not a genius :blush:

I learned the String(expression) method from Sen here… he taught me a ton. **

hense you know a ton, hense you are a genius :slight_smile:

LOL… no, I didn’t mean it like that!

I meant that you taught me a lot of things recently that I didn’t know before… which wasn’t hard… because I didn’t know that much :beam: :wink:

OK, you guys are both genius.

lostinbeta, you’ve got a great teacher and you’re a great teacher
for me as well!

It was my pleasure :slight_smile:

I taught myself something just now too :beam: