A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: problem accessing TextInput.text in attached mc

  1. #1
    Member
    Join Date
    Sep 2003
    Posts
    39

    problem accessing TextInput.text in attached mc

    Hi...

    I'm attaching a movie clip with a simple form inside, and trying to set the 'text' property for the fields within:

    Code:
     
    mybutton.onPress = function() {
    var o:MovieClip = attachMovie('mc','mc',100);
    o._x = 100;
    o._y = 100;
    o.myTextInputField.text = 'blahblah'; 
    o.myTextInputField._x = 150;
    }
    and trying to do this from within button's onPress

    I'm able to set the field's _x property fine, but for some reason I can't access the text property. If I drop the mc directly inside the stage, instead of doing it dynamically, I can access the text property fine.

    ah, I'm using the v2 TextInput field, exporting to flash 6.

    Any ideas why this is? This has gotten me stuck for a couple of hours already... Any insights would be greatly appreciated.

    best
    3rdw0rld3r
    Last edited by 3rdw0rld3r; 10-06-2003 at 11:50 AM.

  2. #2
    Member
    Join Date
    Sep 2003
    Posts
    39

    update

    I'm also able to do a

    Code:
    trace(o.myTextInputField.text);
    afterwards, and I get the rigth text! why doesn't it show up on the field itself??

  3. #3
    Senior Member
    Join Date
    Jul 2003
    Posts
    130
    ...needs an embedded font maybe?...

    Also, this syntax works?
    var o:MovieClip = attachMovie('mc','mc',100);

    ...never seen that before, interesting...

  4. #4
    Member
    Join Date
    Sep 2003
    Posts
    39
    hi xmiinc, thanks for responding

    embedded font? I may have seen something about this at flash-coders... why would they be needed?

    if I just drop the mc on the stage, the text property is assigned with no problems...

    about the syntax, attachMovieClip returns an instance to the movie attached... the typing is just for AS2 compliance

  5. #5
    Member
    Join Date
    Sep 2003
    Posts
    39
    I tried embedding the fonts

    Code:
    _global.styles.TextInput.fontFamily = "Verdana";
    _global.styles.TextInput.embedFonts = true;
    but that didn't do it...

  6. #6
    Senior Member
    Join Date
    Jul 2003
    Posts
    130
    Whoa Nellie!...how did you get to those lines you posted? embedFonts is a TextField property and a few things need to happen before you can use it (maybe you did, but I can't tell from the post). Before that, lemme back up: I'm guessing embedFonts b/c too often issues of text not appearing-especially on dynamically loaded elements-seem to be solved by embedding fonts. Other than that, I'm just guessing. But that brings me to another question regarding the code you've posted: I'm not seeing you create a myTextInputField(), does v2 make this a default property of a MC, or have you missed something? Finally, in order to get embedFonts to work (in my pre-v2 world), you need to have:
    1. exported a font symbol into the Library (using the dropdown Library menu)
    2. declare that font using TextFormat()
    PHP Code:
        myTextFormat = new TextFormat("Times New Roman"200x000000);
        
    my_txt.setTextFormat(myTextFormat); 
    Only after doing the above will you know whether or not embedFont is part of your solution.

    Of course, if you've already done all this...nevermind.

  7. #7
    Member
    Join Date
    Sep 2003
    Posts
    39
    no, I haven't tried this yet, going to give it a go and see what happens, thanks for the suggestion.

    the lines I got from a post at flash-coders, seemed to me like a nice shortcut but I guess I was fooling myself if I thought it'd be that easy!

    But that brings me to another question regarding the code you've posted: I'm not seeing you create a myTextInputField(), does v2 make this a default property of a MC, or have you missed something?
    why would I need this function? I'm not sure I follow what property you mean... I'm actually more well versed on the v2 api than v1, as I've started playing with mx only a month ago and jumped right into AS2...

    The mc I'm attaching contains the field, and the field has just been dragged into it - it's not dynamically generated. I dragged it and named it, that's all.

  8. #8
    Member
    Join Date
    Sep 2003
    Posts
    39
    ok, so I embedded the font I'm using (Century Gothic), set the global style to it (with code I posted earlier). Doesn't look like I need setTextFormat, as the text input fields I had dropped on the stage automatically display it fine.

    but... when attaching the mc with the fields, I still don't see the text.

  9. #9
    Member
    Join Date
    Sep 2003
    Posts
    39
    also tried activating embedFonts on the text input instance directly, but no joy...

    I'm starting to think that perhaps font embedding is not the issue

  10. #10
    Junior Member
    Join Date
    Dec 2002
    Posts
    12
    ever find a solution?
    The sand sinks beneath our feet for He has placed the logic in motion.
    God - the ultimate OOP

  11. #11

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