Bah, like I said early, it's one line of code:

fontColor.selectedColor = parseInt(textbox.text.replace("#",""),16);

It's not something you'd want to do very often, and we already have
parseInt, which is strangely enough, for the parsing of ints.

-Josh

On Wed, Aug 13, 2008 at 5:50 AM, Gordon Smith <[EMAIL PROTECTED]> wrote:

>  Although in MXML and CSS source code you can specify a color in the
> format #D3D3D3, at runtime Flex components dealing with colors generally
> represent them as RGB unsigned integers like 0xD3D3D3, not as strings like
> "#D3D3D3". We probably should have provided better conversion routines
> between the two representations, but I don't think we expected developers to
> need to do this. We assumed that user interfaces would present a
> ColorPicker, not a TextInput for typing in a string like "#D3D3D3", and that
> databases would store a uint, not a String, because this is more efficient.
> Please file an ECR and get people to vote for it if you feel that this is a
> significant deficiency in Flex.
>
>
>
> Gordon Smith
>
> Adobe Flex SDK Team
>
>
>  ------------------------------
>
> *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Dale Cook
> *Sent:* Monday, August 11, 2008 6:09 PM
> *To:* flexcoders@yahoogroups.com
> *Subject:* [flexcoders] Re: Is It Just Me?
>
>
>
> Right, it does have a text box, with the color in Hex notation, so
>
> you'd assume that there'd be a real easy way, in ActionScript, to pass
> a hex value to it, but there isn't.
> I find this perplexing.
>
> --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, "Josh
> McDonald" <[EMAIL PROTECTED]> wrote:
> >
> > Well the first case wouldn't help mapping from a text-field, and the
> post
> > was more about "I can't figure our how to parse a number" than "how
> should I
> > work with colours?"
> >
> > StyleManager.getColorName is an awful, *awful* name for that API if it
> > converts from hex colours to uints :)
> >
> > But I'd still just use parseInt.
> >
> > Wait, doesn't the colour picker *have* a textbox you can copy/paste
> a hex
> > code to and from?
> >
> > -Josh
> >
> > On Tue, Aug 12, 2008 at 10:33 AM, Maciek Sakrejda <[EMAIL PROTECTED]>wrote:
> >
> > > Well, in this particular case, you could do
> > >
> > > // just use uint directly
> > > fontColor.selectedColor = 0xd3d3d3;
> > >
> > > // or use StyleManager
> > > fontColor.selectedColor = StyleManager.getColorName("#D3D3D3");
> > >
> > > Admittedly, getColorName() is rather poorly named, and StyleManager is
> > > not the most obvious place to look (and the
> > > looks-like-it-should-be-the-right-thing ColorUtil class is not very
> > > helpful).
> > >
> > > Every framework has some unfortunate design decisions; Flex is really
> > > quite good once you get the hang of it.
> > >
> > > --
> > > Maciek Sakrejda
> > > Truviso, Inc.
> > > http://www.truviso.com
> > >
> > > -----Original Message-----
> > > From: Dale Cook <[EMAIL PROTECTED]>
> > > Reply-To: flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>
> > > To: flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>
> > > Subject: [flexcoders] Is It Just Me?
> > > Date: Mon, 11 Aug 2008 23:59:55 -0000
> > >
> > > OK, so I'm new to Flex but I have a lot of experience with other
> > > development platforms and languages(.NET, RoR, Javascript, etc.).
> > >
> > > I've read a few books and I've just been doing some fairly simple
> > > stuff to get my feet wet but already I'm starting to get a little
> > > fustrated with things that should be really easy. Perhaps I'm just
> > > missing something.
> > >
> > > For example, I have a colorpicker object and I want to set the
> > > selected color programmatically depending on which textinput field a
> > > user is in. So I suspected that I could do something like
> > >
> > > //the name of the color picker is fontColor
> > > fontColor.selectedColor = "#D3D3D3"
> > >
> > > and everything would be good - but that doesn't appear to be the case.
> > > It looks like I have to convert the hex into a uint. OK, that seems
> > > like a lot more work than it should be but OK, I'll just use the
> > > DecimalToHex function of the int class... oh, wait there isn't one.
> > > There isn't a conversion anywhere that I can find to do this without
> > > writting even more code.
> > >
> > > Is it just be or does this seem like a lot of work to do something
> > > that most other modern languages handle without any additional coding,
> > > or an I completely missing something?
> > >
> > > Dale
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > --
> > > Flexcoders Mailing List
> > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > Search Archives:
> > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> > > Links
> > >
> > >
> > >
> > >
> >
> >
> > --
> > "Therefore, send not to know For whom the bell tolls. It tolls for
> thee."
> >
> > :: Josh 'G-Funk' McDonald
> > :: 0437 221 380 :: [EMAIL PROTECTED]
> >
>
> 
>



-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]

Reply via email to