A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Calling a variable from inside a movieclip AS3 in Flash CS4

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    4

    Calling a variable from inside a movieclip AS3 in Flash CS4

    I am trying to trace a variable string from inside a movieclip which is inside another movieclip on the main timeline using:

    trace(VariableString);

    and also

    trace(stage.VariableString);

    Neither work

    The variable is an input textfield and traces fine when it is on the main timeline but will not work from inside the movieclip. I am using Actionscript 3 in Flash CS4.

    I appreciate this has probably been discussed previously on this forum but I cannot find a difinitve answer that seems to work.

    Thanks

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Actionscript Code:
    trace(MovieClip(root).VariableString);
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    Thanks for the quick reply, however this just gives an error 1180: Call to a possibly undefined method MovieClip. trace(MovieClip(root).VariableString);

    When I trace this on the main timeline this works: trace(VariableString);

    Does it make any difference if inside the MovieClip, I am using the Textinput component?
    If so why would it make a difference once I am inside a MovieClip.

    I am very very confused with this. Thanks again for the help.

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Don't tell me you put the code INSIDE the Textinput component movieclip? That won't work, you'll have to put it in a normal movieclip!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    I think I had better explain a little better.

    On Keyfrme1 I have a MovieClip1 containing a text input component. I have created a variable on keyframe 1 using:

    var VariableString1:String = new String();

    When clicking on a separate button this happens:
    VariableString1 = MovieClip1.text;

    I can trace this correctly on the main timeline using:
    trace(VariableString1);



    However, if I try to trace this from another keyframe inside a movieclip2 which is inside another movieclip3 using:

    trace(MovieClip1(root).VariableString1);
    I just get the error 1180 call to a possibly undefined method MovieClip1

    Sorry if this is not very clear but I am getting very confused with this.
    Thanks again

  6. #6
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    oh, lol, MovieClip(root) should stay like that, you're not supposed to change MovieClip to the name of your clip :P

    Just this:

    Actionscript Code:
    trace(MovieClip(root).VariableString1);
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  7. #7
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    Fantastic it works, thank you for all your help.

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