Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

toString then split() don't work!

Guest
Mar 19, 2008 Mar 19, 2008
Hi there!

I applied to an Array the toString method and the split method to the obtained result.
This doesn't work.
What is the best process to use?
I want to obtain the split result as html formatted strings which I can display in an html enabled Text Field.

I thank you in advance for any help!

Best regards,
Gerry
TOPICS
ActionScript
939
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Mar 19, 2008 Mar 19, 2008
And of course, this would be more efficient
Translate
LEGEND ,
Mar 19, 2008 Mar 19, 2008
Gerry,

> I applied to an Array the toString method and the split method
> to the obtained result.
> This doesn't work.

It might, actually. 😉 Depends on exactly what you're after. Can you
show the code you've used so far?

> I want to obtain the split result as html formatted strings which
> I can display in an html enabled Text Field.

Let's see your code so far, including a brief examle of your current
array contents, and also a brief example of the ultimate formatting in which
you'd like the text to appear.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
Hi David!

Here is the array (traced and copied from the output window):
comboSelectedLabels = Cinéma et musicalité* (v.3 n˚1),Dispositif(s) du cinéma (des premiers temps)* (v.14 n˚1),La théorie du cinéma... enfin en crise** (v.17 n˚2-3),Écrit / écran* (v.4 n˚1)

I want to get the following which will display in a selectable dymamic text field:
Cinéma et musicalité* (v.3 n˚1)
Dispositif(s) du cinéma (des premiers temps)* (v.14 n˚1)
La théorie du cinéma... enfin en crise** (v.17 n˚2-3)
Écrit / écran* (v.4 n˚1)

Seems simple, hey?

Best,
Gerry

PS: You can also watch "Data Grid in a List Component???"
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 19, 2008 Mar 19, 2008
It would be best if you showed us the code you are using. I'm trying to figure out what kind of stuff you have in your array. How you split it? What exactly isn't working? ....
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
Thanks Rothrock for responding!

I give you below the code I use.
I declared comboSelectedLabels as a new Array for the purpose of testing.
In real world, it is an existing and working Array.
The trace() statements return undefined...

Best,
Gerry



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
It certainly works here.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
Hi Raymond!

Thanks for your reply.

Yes it works.
But not for split()...
I still have the whole text without any break in place of commas after each title.

How can I achieve this?

Best,

Gerry


PS: In real world, I don't have any double quotes in my Array
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
Aha. Me thinks we're getting somewhere now. Something like this perhaps?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
And of course, this would be more efficient
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
quote:

Originally posted by: Raymond Basque
And of course, this would be more efficient


CONGRATULATIONS, Raymond, you got it.
myNewString displays perfectly in an html enabled text field: each title is on its own line!

You really are a guru... :-)
I thank you for this very efficient help.

Sorry, David, ones can't always win! Ah ah ah !!!
But I thank you too, of course. You point something so interesting as if I was watching a dog running after its tail... That's me!!!

Best,
Gerry

PS: With such a name, Raymond, are you French? I am.





Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 19, 2008 Mar 19, 2008
Gerry,

> "Raymond Basque" <webforumsuser@macromedia.com> wrote
> in message news:frre65$o1m$1@forums.macromedia.com...
> It certainly works here.

Agreed. In principle, you're taking an array, converting it to a
string, then converting that comma-delimited string back into an array.
It's an effort in tautology ... unless I misunderstand what you're after,
you're ending up with the same thing you started with.

In your sample code from an earlier post in this thread, you ended up
naming a variable "myNewString," but you set it to an array.

var comboSelectedLabels:Array = new Array("a", "b", "c");
var myString:String = comboSelectedLabels.toString();
trace(myString);
var myNewString:Array = myString.split(",");
trace(myNewString);

In this revision, I've tried to clarify that. The String.split() method
returns an array (see the String.split() entry in the AS2 Language
Reference), so you wouldn't easily be able to populate a text field with the
content of myNewString.

If you want to display your list in a text field, you can step through
the original array's elements and use a for() loop. I'm not sure if this is
what you're after, but for what it's worth ...

var comboSelectedLabels:Array = new Array("a", "b", "c");

for (var n:Number = 0; n < comboSelectedLabels.length; n++) {
myTextField.text += comboSelectedLabels + "\n";
}

Does that help?


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
LOL. You're welcome GerryIsHere.
I would hesitate to use that "guru" word. There are plenty of folks frequenting these forums who could have pointed you in the right direction - David Stiller among them.
I would recommend you take a little time to look at some of the core AS3 classes. A little understanding of the Array and String classes can save you a lot of wasted time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
You certainly are right.
Maybe "guru" is a little exagerated...

I don't have AS3. I stick to AS2 because the few things I saw about AS3 didn't please me.
I think it is as complicated as the is not NaN logic... ha ha ha.
:-)

Gerry
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 19, 2008 Mar 19, 2008
LATEST
lol. Sorry-- though I was in the AS3 forum. But the same applies to AS2 classes.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines