You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Justin Mclean <ju...@classsoftware.com> on 2013/10/20 00:39:39 UTC
Odd SDK code in Spark button
HI,
Looking to see if join("") was used anywhere else found this:
if (!styleName || styleName is String)
{
if (_emphasized)
super.styleName = style + " emphasized";
else
super.styleName = style.split(" emphasized").join("");
}
Would not be a performance bottle neck but why not just use replace?
Justin
RE: Odd SDK code in Spark button
Posted by Maurice Amsellem <ma...@systar.com>.
To replace everywhere, use replace() with a RegExp and "g" option
style.replace ( / emphasized/g, "") will replace all occurrences.
(not absolutely sure about the RegExp exact syntax).
Cf. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/String.html#replace()
Maurice
-----Message d'origine-----
De : Tianzhen Lin [mailto:tangent@usa.net]
Envoyé : dimanche 20 octobre 2013 01:00
À : dev@flex.apache.org
Objet : RE: Odd SDK code in Spark button
Apparently "replace" only replaces the first occurrence of the string, so split/join is a more reliable route.
http://stackoverflow.com/questions/3214886/javascript-replace-only-replaces-
first-match
Tangent
p.s. JavaScript is drunk.
-----Original Message-----
From: Justin Mclean [mailto:justin@classsoftware.com]
Sent: Saturday, October 19, 2013 6:40 PM
To: dev@flex.apache.org
Subject: Odd SDK code in Spark button
HI,
Looking to see if join("") was used anywhere else found this:
if (!styleName || styleName is String)
{
if (_emphasized)
super.styleName = style + " emphasized";
else
super.styleName = style.split(" emphasized").join("");
}
Would not be a performance bottle neck but why not just use replace?
Justin
RE: Odd SDK code in Spark button
Posted by Tianzhen Lin <ta...@usa.net>.
Apparently "replace" only replaces the first occurrence of the string, so
split/join is a more reliable route.
http://stackoverflow.com/questions/3214886/javascript-replace-only-replaces-
first-match
Tangent
p.s. JavaScript is drunk.
-----Original Message-----
From: Justin Mclean [mailto:justin@classsoftware.com]
Sent: Saturday, October 19, 2013 6:40 PM
To: dev@flex.apache.org
Subject: Odd SDK code in Spark button
HI,
Looking to see if join("") was used anywhere else found this:
if (!styleName || styleName is String)
{
if (_emphasized)
super.styleName = style + " emphasized";
else
super.styleName = style.split(" emphasized").join("");
}
Would not be a performance bottle neck but why not just use replace?
Justin