A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Change movieclip color & text through dynamic txt

  1. #1
    Member
    Join Date
    Oct 2000
    Posts
    79

    Change movieclip color & text through dynamic txt

    Ok, I am developing an interface for a client (to display in their office, not web based). I need to include a way to let the client (not Flash or programming savvy) to update part of the interface saying whether or not property has been available, pending or sold. This will change a circle's color and a word (for example, "Sold!" and the circle would now be red). I can make this work through a dynamic txt file, but I have to use 2 txt files (one for the color and one for the text). My questions are these: How can I make this as simple as possible for the client? I would like to change the txt file so they just input "red" rather than "0xCC0000", and not have two txt files. (when I try to integrate them, the circle turns black rather than the color I specify). Lastly, how would I integrate a database if necessary?

    My code on the frame:

    Code:
    // *************************** //
    // MovieClip.setRGB() method //
    MovieClip.prototype.setRGB = function(newColor) {
    	(new Color(this)).setRGB(newColor);
    };
    // end MovieClip.setRGB()
    // *************************** //
    var a = new LoadVars();
    a.load("properties.txt");
    a.onLoad = function(success) {
    if (success == true) {
    trace("Text file load successful");
    // variable representing hex number
    circle = new Color("lot1");
    nColor =_root.a.lot1;
    circle.setRGB(nColor);
    
    } else {
    trace("Error: text file did not load properly!");
    }
    } // end onLoad()
    loadVariablesNum("propertiestext.txt", 0);
    And my color txt file (properties.txt):

    &lot1=0xCC0000


    And the word txt file (propertiestext.txt):

    &lot1status=Sold!
    &textloaded=OK


    All help is appreciated! Thanks!!!

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

    This part is relly confusing:
    code:

    circle = new Color("lot1");
    nColor =_root.a.lot1;
    circle.setRGB(nColor);


    especially because you redefined setRGB()...
    Here's a working example.

    You're doing the right thing when using LoadVars(). Why would you want to use loadVariablesNum()?

    Using one text file only, this is what you should have:
    Code:
    &lot1=0xCC0000&
    &lot1status=Sold!&
    And this should be the code in flash:
    code:

    // *************************** //
    // MovieClip.setRGB() method //
    MovieClip.prototype.setRGB = function(newColor)
    {
    (new Color(this)).setRGB(newColor);
    };
    // end MovieClip.setRGB()
    // *************************** //
    var a = new LoadVars();
    a.onLoad = function(success)
    {
    if (success) {
    trace("Text file load successful");
    // I guess it's just this:
    circle.setRGB(this.lot1);
    // for the word:
    trace("lot1status = " + this.lot1status);
    } else {
    trace("Error: text file did not load properly!");
    }
    };
    a.load("properties.txt");



    You can have something like red instead of the hex color in the external file. All you have to do is convert it in flash.
    For example:
    code:

    if (this.lot1 == "red") {
    myColor = ; // hex value
    } else if (this.lot1 == "blue") {
    myColor = ; // hex value
    }
    // and so on



    You may not need a database, as this is very simple, but creating an interface in HTM for example, for your client where he would choose the color and the text, would be nice.
    Then you'd use a server side scripting language like PHP to create the text file. The script could take care of all the details and it would be user friendly for the client.

  3. #3
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    How about this variant?
    Attached Files Attached Files

  4. #4
    Member
    Join Date
    Oct 2000
    Posts
    79
    Thank you both so much! That helps a lot. I knew the code was a bit messy, I got it from someone else and it didn't look quite right. And thank you for uploading that, it does EXACTLY what I wanted it to, you rock!

    I had thought of making the txt file in PHP to make it easier for my client, but I haven't played too much with that yet and wanted to make sure I could do it with the txt file first. Could you point me in the right direction for a good tutorial to prepare a user-friendly php page for my client?

    Thanks again guys, I really appreciate the help!

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