A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 25

Thread: [RESOLVED] marking some nodes as checked

  1. #1
    Member
    Join Date
    Aug 2009
    Posts
    44

    resolved [RESOLVED] marking some nodes as checked

    Hi everyone,

    I'm looking for help on this problem as my flash 8 / AS 2 knowledge is fairly limited and I have been googling for a solution for quite some time with no luck.

    I have struggled through making an application that displays sequentially, through the use of next and previous buttons, information derived from an XML file
    that is presented in four different text fields. I would like to be able to "select or mark" some of the nodes as having been examined through double-clicking
    or dragging and dropping them in a certain target area.

    When I double click on the name field, I am looking for two things to happen:
    1. The text color in all four displayed fields to change and keep the new color.
    2. Have the information displayed transferred to another XML and a text file to be used elsewhere.

    Would something like this be too complicated? Appreciate any input.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Please provide current FLA file
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Member
    Join Date
    Aug 2009
    Posts
    44
    The file exceed the 300k.I'll try to trim some of the elements and bring it down to size.

  4. #4
    Member
    Join Date
    Aug 2009
    Posts
    44
    Here is the fla. I hope it is useful. Would you need a sample XML ?

  5. #5
    Member
    Join Date
    Aug 2009
    Posts
    44
    the file didn't upload

  6. #6
    Member
    Join Date
    Aug 2009
    Posts
    44
    It uploaded this time. Please take a look at it and see if you can help.
    thanks
    Last edited by ram_son; 12-05-2011 at 03:06 AM.

  7. #7
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    yes, please send the XML file as well!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  8. #8
    Member
    Join Date
    Aug 2009
    Posts
    44
    I shortened the original xml file.
    Last edited by ram_son; 12-05-2011 at 03:06 AM.

  9. #9
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    1. The text color in all four displayed fields to change and keep the new color.
    Double clicking the text would be difficult in Flash, because only AS3 has a built-in function for that. You'll have to make your own function based on timing to make a double-click, or you can find an alternate method! Either way, to check if you're double-clicking ON a text field, would also be difficult, as they're not movieclips, and you can't use hitTest with just textfields. Changing the texts' color is fairly easy, but to keep it after double-clicking, will involve, either a lot of variables, or saving them locally with SharedObject!

    2. Have the information displayed transferred to another XML and a text file to be used elsewhere.
    This is not possible without the aid of PHP, which is a server side scripting language, and you'll have to have a server with it installed in order to achieve this!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  10. #10
    Member
    Join Date
    Aug 2009
    Posts
    44
    Thanks Nig 13 for the response. How about this:

    for item # 1: Using a button instead of double clicking the text which will insert an attribute like "checked = true" and the application will change the text color based on whether the attribute is there or not.

    for item # 2: Could I use an empty XML file and a text file and then insert or append the data to them?

    Are these workable solutions? Please keep in mind that the fla files is using AS 2.

    Thanks for your assistance.

  11. #11
    Member
    Join Date
    Aug 2009
    Posts
    44
    After reading your post, I did quite a bit of reading on the subject and found out about wrappers like Zinc and Shared Objects. However, can you still help me with the statements needed to create and append data to the file(s), (the way I described in my last post), within flash and prior to saving it or them?
    I learned that:
    Actionscript Code:
    _xml.firstChild.firstChild.attributes.theChecked = "Yes";
    would insert an attribute the Checked = "Yes", but I am not sure how to make it work to add it to the selected or displayed item.
    Any help would be greatly appreciated.

  12. #12
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Great that you solved the first problem, but the second one requires communication with other language, such as PHP. You'll have to give thorough description of what you want to accomplish, and what information you want to append to the XML file, in order for me to try and write a script
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  13. #13
    Member
    Join Date
    Aug 2009
    Posts
    44
    I haven't totally solved the first problem since I still need to save a file locally ( which is also needed for the second part). The XML file that I uploaded has four attributes for each node. The actual file has a lot more nodes than the sample. Assuming the user clicks on a button causing 50 of them to be marked as theChecked="Yes" (this is what I haven't figured out totally to get it to work with arrays); the next step would be to transfer and save an XML or a comma separated file, which lists those fifty items, on the PC to be used at later time. It's like when a high score file for a game is saved locally on the PC.
    I actually need only two attributes theWord and theMeaning for the generated file.

    Now, would it be easier to do everything using AS 2 and then use a wrapper or Shared Objects or to use PHP which I understand needs to use a server.

    Is this clear enough as far as what the code has to achieve?

  14. #14
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Wait a second! You want to change the XML file by changing an attribute to "Yes", to check if the user has clicked on a button, and then check the XML file whether to change the text colors or not? If you only want this for each individual user, so that the information is only saved on their computer, you can use SharedObject, and store variables on the local user's computer, within Flash, no PHP or anything. Let me know and I'll write it out for you
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  15. #15
    Member
    Join Date
    Aug 2009
    Posts
    44
    Yes, that's it for step #1. Then I want to be able to use only the items marked "Yes" to be displayed in a list and/or manipulated. It would be great if you write it out for me.

  16. #16
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    For Step 1:

    make 4 buttons, and position them on the 4 textfields, and give each an instance name. For instance, btn1, btn2, btn3 and btn4. Then, change this function on the Top of your pile of code:

    Actionscript Code:
    function showText(num)
    {
        myText_txt.text = wordArray[num].Word;
        myText_txt1.text = wordArray[num].Synonym;
        myText_txt2.text = wordArray[num].Meaning;
        myText_txt3.text = wordArray[num].Example;
    } // End of the function

    to THIS:

    Actionscript Code:
    for(i=1;i<5;i++){
        _root["btn"+i]._alpha = 0;
    }
    savedTexts = SharedObject.getLocal("saveText");

    defaultColor = 0xFFFF00; // yellow
    changeColor = 0xFF0000; // red

    function changeColorFunction(){
        if(colorText == true){
            myText_txt.textColor = changeColor;
            myText_txt1.textColor = changeColor;
            myText_txt2.textColor = changeColor;
            myText_txt3.textColor = changeColor;
        } else {
            myText_txt.textColor = defaultColor;
            myText_txt1.textColor = defaultColor;
            myText_txt2.textColor = defaultColor;
            myText_txt3.textColor = defaultColor;
        }
    }

    function btnClick(mc, num){
        mc.onPress = function(){
            if(savedTexts.data["var"+num] == undefined){
                savedTexts.data["var"+num] = 1;
                colorText = true;
                changeColorFunction();
            }
        }
    }

    function showText(num)
    {
        colorText = false;
        if(savedTexts.data["var"+num] != undefined){
            colorText = true;
        }
        for(i=1;i<5;i++){
            btnClick(_root["btn"+i], num);
        }
        myText_txt.text = wordArray[num].Word;
        myText_txt1.text = wordArray[num].Synonym;
        myText_txt2.text = wordArray[num].Meaning;
        myText_txt3.text = wordArray[num].Example;
       
        changeColorFunction();
    } // End of the function

    Then I want to be able to use only the items marked "Yes" to be displayed in a list and/or manipulated
    What do you mean? Do you want all the colored texts to be saved into a new file when a button is pressed? You can do this manually, by pressing a button, and it will automatically be copied to your clipboard, and then you can paste it into Notepad or something!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  17. #17
    Member
    Join Date
    Aug 2009
    Posts
    44
    Thanks Nig 13 this works great. What I meant by:
    Then I want to be able to use only the items marked "Yes" to be displayed in a list and/or manipulated.
    is to actually "load" only the items marked "Yes" and display them in text fields.Let's say I add another button that will start a movie (a form) similar to the one we already have, but that displays only the items marked "Yes" in the text fields and leaves out the rest of the items. Do I load the same words.xml and have to write code to extract the items marked "Yes". Is this the way to do it? If so, what would the code be.
    I greatly appreciate what you have done so far and hope that I am not being too much of a pain. You are really helping me out tremendously.Thanks.

    PS I hope this is clear enough. If not I am ready to try again.

  18. #18
    Registered User
    Join Date
    Dec 2011
    Posts
    2
    The file exceed the 300k.

  19. #19
    Registered User
    Join Date
    Dec 2011
    Posts
    2
    It would be great if you write it out for me.

  20. #20
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    please send the new FLA file, and include the button and the form that you want, and I will see what I can do accordingly
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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