dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Populating dynamic text within a MC?

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Posts
    21

    Populating dynamic text within a MC?

    I'm trying to set up a dynamic text box inside a MC that is animated at the root level.

    The problem is, the text box won't import the text unless it's on the root level. I tried targeting paths and everything and still no go.
    Is it not possible to import text when a text box isn't on root level?
    ::Too::MuCh::GiNsEng::

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Yes it's possible, and IMHO, probably remains a path problem in your case, unless since you mentioned an animated mc, you might need to embed the font used in your textfields. Have you tried it? And also made sure your text color is not the same color as your mc's background?

  3. #3
    Junior Member
    Join Date
    Jul 2002
    Posts
    21

    Path Problem...

    I think it must be a path problem. The font is embeded and the font colour is set properly too. Here's what I have scripted in the main timeline, frame 1:

    _root.homeMC.txtbox1.loadVariablesNum("content.txt ", 0);

    I also tried scripting this in the MC. Still nothing!

    Any ideas?
    ::Too::MuCh::GiNsEng::

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    You shouldn't be using loadVariablesNum("content.txt", 0); (I prefer the new LoadVars() object!)... But something like:

    loadVariables("content.txt", "path_to_your_variable");

    BTW what is the name of your textfield's variable?

  5. #5
    Junior Member
    Join Date
    Jul 2002
    Posts
    21
    Still not working... My text box variable name is "itnethome" and the instance name is "txtbox1"... Do I have to include the variable name in the path?
    ::Too::MuCh::GiNsEng::

  6. #6
    Senior Member
    Join Date
    Apr 2001
    Posts
    109

    Try this

    Code:
    // root of movie
    
    loadVariablesnum("content.txt",0);
    // This loads all variables in to flash _root.
     
    _root.yourMCName.TextBoxInstanceName.text = the variable in the content.txt that you want to apear;
    // Just name the text fields Instance name NOT the var name.
    That should do it, You have to leave the var field blank in the textBox properties to doit this way.
    This will load that var in the Content.txt file to that mc and then the instance name of that text box.

    There is a much better way though, The loadVars() object : )(MX only)
    This would be:

    Code:
    myData = new loadVars();
    myData.load("http://www.angelfire.com/realm/andrue-1/content.txt",0);
    
    myData.onload = function(success) {
    if (success) {
     _root.MCname.textInstanceName.text = this.content;
    }else{
     trace ("error loading text file...");
    }
    }
    Download the FLA here.

    rightClick me and choose save as

  7. #7
    Junior Member
    Join Date
    Jul 2002
    Posts
    21
    The second script works great, Thanks! But what do I do if I want to populate more than one text box each with different content.
    I know the variables will resolve themselves with the old method but do I have to define a new vaiable in the "if (success)" condition for every text box in the scene?
    ::Too::MuCh::GiNsEng::

  8. #8
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Use a new LoadVars() object for each textfield.

  9. #9
    Junior Member
    Join Date
    Jul 2002
    Posts
    21
    Thanks oldnewbie... You saved my forehead from another serious thrashing against the wall!
    ::Too::MuCh::GiNsEng::

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