Results 1 to 9 of 9

Thread: dynamic _y for text field as per previous text field's height

  1. #1
    32
    posts
    Registered User

    dynamic _y for text field as per previous text field's height



    i have xml text i read into a MC with 3 text fields. i create a new MC for different XML nodes with attachMovie and position these MCs on stage with a FOR loop. This all works great

    my problem is that one of the text fields in the MC will have varying length and so the _y of the following MC will depend on that. i've tried a few things but can't get it to work

    Does anyone know how to approach this? How can you read the height of the text field, well, not the field but the vertical space used by the dynamic text?

    thanks very much, any help/tips/etc would be fantastic!

  2. #2
    32
    posts
    Registered User
    this is my loop by the way....

    txt3 will have varying height.

    --------------------------

    for (var i = 0; i<news.length; i++) {
    item = Container.attachMovie("newi", "newi"+i, i);
    item.txt1 =this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
    item.txt2= this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
    item.txt3 = this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue;
    item._x = 80;

    item._y = ???????;

    }

    ----------------------------


    ... in case it can clarify things a bit

    Still no joy!

    Cheers!

  3. #3
    Hi,

    You can give properties like:

    yourTextFieldName.multiline = true;
    yourTextFieldName.autoSize = true;
    yourTextFieldName.wordWrap = true;

    and then insert your text inside the textField.

    MovieClip_Name.yourTextFieldName.text = this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue;

    Thats it !!!!


    ------------
    aShIsH

    Quote Originally Posted by Mona
    this is my loop by the way....

    txt3 will have varying height.

    --------------------------

    for (var i = 0; i<news.length; i++) {
    item = Container.attachMovie("newi", "newi"+i, i);
    item.txt1 =this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
    item.txt2= this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
    item.txt3 = this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue;
    item._x = 80;

    item._y = ???????;

    }

    ----------------------------


    ... in case it can clarify things a bit

    Still no joy!

    Cheers!

  4. #4
    32
    posts
    Registered User


    Thank you for your reply aShIsH!!

    I have thought well about what you've said - so I don't reply foolishly but there is no guaratee of that!

    My text fields are loading well, so that's not the problem. Where i am having difficulty is in positioning each MC (which is made up of the 3 text fields) underneath each other, and considering the vertical space that the one above needs (the one created in the previous iteration of the loop).

    So as item.txt3 could have 3 lines, or 7 lines, I have to position the next ITEM MC accordingly (in the next iteration of the loop). And I can't figure out how to assign the _y property of the ITEM for this.

    Does this make any sense at all???

    Thanks lots for your help!

  5. #5
    Hey Mona,

    Got u now

    here is attached one smaple file for u, i hope this may give some hint....if not let me know...

    ---------
    aShIsH

    You must be loading your MC sequetially. Assuming that I would suggest

    Quote Originally Posted by Mona


    Thank you for your reply aShIsH!!

    I have thought well about what you've said - so I don't reply foolishly but there is no guaratee of that!

    My text fields are loading well, so that's not the problem. Where i am having difficulty is in positioning each MC (which is made up of the 3 text fields) underneath each other, and considering the vertical space that the one above needs (the one created in the previous iteration of the loop).

    So as item.txt3 could have 3 lines, or 7 lines, I have to position the next ITEM MC accordingly (in the next iteration of the loop). And I can't figure out how to assign the _y property of the ITEM for this.



    Does this make any sense at all???

    Thanks lots for your help!
    Attached Files Attached Files

  6. #6
    32
    posts
    Registered User
    Thank you aShIsH !!!

    But it seems to be a F2004 file, is it? I am working with FMX



    Is there a way to Save As MX from 2004 - if you haven't used any particular 2004 features?

    thanks!

    (sorry, I should have specified that earlier...)

  7. #7
    Hey Mona,

    I should be sorry for that not you, since i am loging into mx forum and sending u file of mx 2004

    Here is ur MX version file:

    ----------
    aShIsH

    Quote Originally Posted by Mona
    Thank you aShIsH !!!

    But it seems to be a F2004 file, is it? I am working with FMX



    Is there a way to Save As MX from 2004 - if you haven't used any particular 2004 features?

    thanks!

    (sorry, I should have specified that earlier...)
    Attached Files Attached Files

  8. #8
    32
    posts
    Registered User


    you're DA BOMB!!

    What you've sent makes sense, I am going to make some changes to my file and hopefully it should work! Although I had used ._height before but didn't manage to do it.

    I'll let you know how I get on...

    THANK YOU!!

  9. #9
    Hey,

    Thanks and wish you the best luck

    ----------
    aShIsH




    Quote Originally Posted by Mona


    you're DA BOMB!!

    What you've sent makes sense, I am going to make some changes to my file and hopefully it should work! Although I had used ._height before but didn't manage to do it.

    I'll let you know how I get on...

    THANK YOU!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012