A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [MX] Input color code ex.#00DDBB

  1. #1
    Member
    Join Date
    Dec 2004
    Posts
    33

    [MX] Input color code ex.#00DDBB

    Is it possible to have an input variable on screen that you can input stuff like

    #00DDBB
    #1BA0DA

    etc..
    and on a certain frame, your MovieClip is that color you typed???
    would that be hard to do?

    I tried this.. my noob attempt
    Code:
    _root.MCColor = new Color("MC");
    _root.MCColor.setRGB(0x(color_code));
    and
    Code:
    _root.MCColor = new Color("MC");
    _root.MCColor.setRGB((color_code));
    Lindsay

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Yes.
    Here's an example. All it takes is this piece of code:
    code:

    my_txt.onChanged = function()
    {
    if (this.text.length == 6) {
    d = '0x' + this.text;
    d = parseInt(d, 16);
    var c = new Color(my_mc);
    c.setRGB(d);
    }
    };


    , a movie clip called my_mc and an input text field my_txt.

    It doesn't take the # into account, you should write 00DDBB instead of #00DDBB, but if you want to use it, it's very simple to change.

  3. #3
    Member
    Join Date
    Dec 2004
    Posts
    33
    Hey I tried that, nothing happens when I run it..
    so I altered it and tried this...
    Code:
    if (_root.my_txt.length == 6) {
    	d = '0x'+_root.my_txt;
    	d = parseInt(d, 16);
    	var c = new Color(_root.my_mc);
    	c.setRGB(d);
    }
    all that did was turn the mc black every time.


    Anyways this is exactly what I did...
    Put your (unaltered)code in frame 2.
    Frame one I put stop();
    On frame one and two there is a
    MC instance name: my_mc
    and an
    input text, instance name: my_txt
    I run the program, type in 00DDBB, right click and play.... nothing happens.
    Lindsay

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    ... my post was supposed to have a .fla attached.


    here it is
    Attached Files Attached Files

  5. #5
    Member
    Join Date
    Dec 2004
    Posts
    33
    I know I'm triple posting, sorry, but I still haven't figured this out, I need, probably that same code nunomira gave me, but converted for Flash MX.
    Plz nunomira could you convert that fla. to Flash MX, actionscript 2.0
    Or somebody else help? plz?
    Lindsay

  6. #6
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    I saw you were using MX (thanks for the info) so I took that into account and saved the file in MX 2004 as MX... or so I thought...

    I'm really sorry. First, I didn't upload the file, than it was in the wrong version.

    Here it is again, saved for MX (I triple-checked!).

    Let me know if it's finally ok.
    Attached Files Attached Files

  7. #7
    Member
    Join Date
    Dec 2004
    Posts
    33
    thanks nunomira, the fla. works now and i can open it..

    but.....
    I think the scripting might be wrong??? maybe??? everytime I type in something, like.. this..

    5EB79F
    or this
    8A98BF
    or this
    CF5EEC

    It just turns the box black. Is there a way around this? Is it because its MX? or...?? something else maybe?

    btw, if you want, ill show you what im working on, after it all works..
    Lindsay

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center