A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Help ... dynamic text in MC

  1. #1
    Junior Member
    Join Date
    Dec 2002
    Posts
    3

    Help ... dynamic text in MC

    So I'm duplicating movie clips and giving a dynamic text field inside a value based on some XML input. So the following code works:

    mcParentClip.duplicateMovieClip("mcChild1", 1);
    mcChild1.txtField = "blah blah";

    However, I cannot make the following code work:
    function myDuplicateClip(num){
    varName = "mcChild"+num;
    mcParentClip.duplicateMovieClip(varName,num);
    eval(varName).txtField = "blah blah";
    }

    I've tried a few different variations, but nothing's worked... and I've spent 3 hours trying different solutions and researching, etc.. Help would be greatly appreciated!!

  2. #2
    Senior Member
    Join Date
    Jul 2002
    Posts
    461
    the code looks ok but you didn't include how you call the function.
    eg:
    myDuplicateClip(5)

    aside from that it could be a path problem depending on which timeline the function is declared.

    hope that helps

  3. #3
    Junior Member
    Join Date
    Dec 2002
    Posts
    3
    Originally posted by gaz_b
    the code looks ok but you didn't include how you call the function.
    eg:
    myDuplicateClip(5)

    aside from that it could be a path problem depending on which timeline the function is declared.

    hope that helps
    Yeah, you got the calling syntax right. My timelines are straight... I think I'm using the eval function wrong.

  4. #4
    Senior Member
    Join Date
    Jul 2002
    Posts
    461
    well eval works differently in MX so maybe that is the problem.

    your eval statement :
    eval(varName).txtField = "blah blah";

    can also be written as:
    relative eg:
    this[varName].txtField = "blah blah";
    or absolute eg:
    _root[varName].txtField = "blah blah";

    hope that helps

  5. #5
    Junior Member
    Join Date
    Dec 2002
    Posts
    3
    Hey thanks a ton. It was really hard to find that information in any reference or tutorials. Thanks for helping me out, even though I'm ot a regular member of this community!


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