dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: attachMovie and retrieving variables within MovieClip

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jan 2001
    Posts
    105

    attachMovie and retrieving variables within MovieClip

    Hi All,

    I'm having a slight problem I'm hoping someone has the answer to.

    In one frame I'm attaching a MovieClip to the stage:
    _root.attachMovie("Button0004", "newbutton",525);
    trace("textfieldx is equal to "+_root.newbutton.textfieldx);


    The trace doesn't return a value for _root.newbutton.textfieldx

    But when I put the trace on a button and press it afterwards, it returns the correct value.

    textfieldx is defined within the MovieClip "Button0004". I would think I would be able to access the value textfieldx as soon as I attach the movie.

    Any thoughts on why it's not working directly after the movie is attached?

    Thanks much.
    Mario Cascio
    Webpromotion, Inc.
    http://www.webpromotion.com

    Royalty Free 3D Flash Animation
    http://www.webpromotion.com/fp01.html

  2. #2
    Senior Member
    Join Date
    Apr 2003
    Location
    St. Louis
    Posts
    104
    did you try using .text?

    trace("textfieldx is equal to "+_root.newbutton.textfieldx.text);

    which is basically saying:
    trace("textfieldx is equal to "+_root.movieclip.textfieldInstance.value);
    Ben

  3. #3
    Senior Member
    Join Date
    Jan 2001
    Posts
    105
    StunnedGrowth,
    Thanks for the idea, but that doesn't seem to work.

    If it helps, in the MovieClip I'm attaching, the first frame contains:
    textfieldx = "4";

    Which is the value I'm trying to retrieve.
    Mario Cascio
    Webpromotion, Inc.
    http://www.webpromotion.com

    Royalty Free 3D Flash Animation
    http://www.webpromotion.com/fp01.html

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    105
    Anyone else have any ideas why I can't retrieve the value in the attached movieclip?

    I've been struggling with this one for over 10 hours now.
    Mario Cascio
    Webpromotion, Inc.
    http://www.webpromotion.com

    Royalty Free 3D Flash Animation
    http://www.webpromotion.com/fp01.html

  5. #5
    Senior Member
    Join Date
    Jan 2001
    Posts
    105
    OK,

    After putting a trace in the attached MovieClip, I'm noticing that the MovieClip is getting attached after the trace on the root level.

    To make it more clear - on a button I placed the following script:
    on (release) {
    _root.attachMovie("ButtonTest", "newbutton",528);
    trace("textfieldx is equal to "+_level0.newbutton.textfieldx);
    }

    Then in the MovieClip "ButtonTest" I also placed a trace in the first frame:
    trace("ButtonTest textfieldx = "+textfieldx + " " + this);

    The trace in the attached MovieClip appears after the trace on the button I'm pressing.

    That's why the variable doesn't contain any values.

    So now the question is how can I work around this?
    Mario Cascio
    Webpromotion, Inc.
    http://www.webpromotion.com

    Royalty Free 3D Flash Animation
    http://www.webpromotion.com/fp01.html

  6. #6
    Senior Member
    Join Date
    Apr 2003
    Location
    St. Louis
    Posts
    104
    I got to thinking about this, and you cannot target dynamic textfields inside button symbols. Now, there is a work around, which involves a little leg work. Basically you need to seperate the textfield from the button. I made a fla to show you how I got around it. I'm sure there are other ways of approaching this, but this is how I do it.

    I only put in url's for 3 buttons if you test this and change the number of buttons built, but you could add more if you wanted to.
    Attached Files Attached Files
    Ben

  7. #7
    Junior Member
    Join Date
    Apr 2003
    Posts
    28
    Thanx a lot StunnedGrowth!!!
    You've saved me a few hours of knocking my head against my keyboard

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