A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: path and variable names... why can't I get this one straight

  1. #1
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234

    path and variable names... why can't I get this one straight

    I always have trouble with this, but this time I realy can't figure it out:

    Code:
    myButton.mySubback.createTextField(mainMenu[i][c][0]+'_text', menu_startDepth, myButton._x, menu_Ystart+myButton.tekst._height*c, 0, 0);
    with (myButton.mySubback[mainMenu[i][c][0]+'_text']) {
    How do I 'reach' mainMenu[i][c][0]+'_text'] nested in MC myButton's child mySubback?

    Cheers
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  2. #2
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    Code:
    with(_root[myButton][mySubback][mainMenu[i][c][0]+'_text'])
    should do it.

    zlatan
    New sig soon

  3. #3
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234
    No avail Any other solutions?

    Like your sketch app though
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  4. #4
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    The easiest way is to assign the text field path to a temporary variable when you create it. Using the createTextField method returns a path to the newly created field:

    var newField:TextField = myButton.mySubback.createTextField(mainMenu[i][c][0]+'_text', menu_startDepth, myButton._x, menu_Ystart+myButton.tekst._height*c, 0, 0);
    newField.text = "Some Text";

    If that doesn't work, you've most likely made a mistake in your code. Make sure myButton.mySubback exists, and make sure mainMenu[i][c][0]+'_text' is returning a string. I'm not sure what menu_startDepth is, but make sure that it is defined and that nothing else exists at that depth.

    Hope this helps.

  5. #5
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    Quote Originally Posted by dmonkey
    The easiest way is to assign the text field path to a temporary variable when you create it..
    Unfortunately, that will only work in Flash 8...in earlier versions createTextField() does not return a reference to the newly created text field...

    K.

  6. #6
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Oh! Thats a bit annoying. If your code above isn't working, then the text field probably isn't being created in the first place. Do some debugging.

  7. #7
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234
    Quote Originally Posted by dmonkey
    Hi,

    The easiest way is to assign the text field path to a temporary variable when you create it. Using the createTextField method returns a path to the newly created field:
    I've tried that. It's the same way as I created myButton. didn't understand why it didn't work for textfield, do no though. Thanx Deadbeat!

    I'll try to do some debugging and let you guys know!

    Cheers
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  8. #8
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234
    Had to remove myButton as mySubback was create like this:

    Code:
    mySubback = myButton.createEmptyMovieClip(mainMenu[i][0][0]+'_subback', menu_startDepth);
    Thanx u guys!

    Cheers
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

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