A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Please help. trying to pass variables from MC to MC.

  1. #1
    Member
    Join Date
    Feb 2000
    Posts
    34

    Post

    If you reference the varible this way:

    /:ballpos

    "ballpos" is a varible in the main movie. To reference a varible inside a movie clip, you would want to do this:

    /mclip1:ballpos

    Where the varible "ballpos" is inside mclip1. Or if you have a movie clip inside a movie clip:

    /mclip1/mclip2:ballpos

  2. #2
    Member
    Join Date
    Mar 2000
    Posts
    57

    Red face

    I moved the code to the MC where the variable resides so I would not have this problem. The only problem now is that the loop keeps returning 0 for resident1
    Before it was only returning a 6, which at least made me think that the loop was running, but after changing stuff it only returns a 0 so I think I broke it completely hehe. Man I wish I had some professional help with this, it is driving me crazy.
    Is there a good tutorial for loops anywhere?
    They seem simple enough, but I always have problems with them.

  3. #3
    Member
    Join Date
    Mar 2000
    Posts
    57

    Post

    OK, I think I have it all figured out except the thing I originally posted about.
    I am trying to set a variable in one MC from another MC. The way I have it is this:
    Set Variable: /code:"ballpos" & resident2 = firsttarget
    This does not work. It gives me an error when I click OK. If it were simply:
    Set Variable: /code:ballpos2 or 3 or whatever it would work, but adding that variable (resident2) to the variable name screws it up. How do I write this?

  4. #4
    Member
    Join Date
    Mar 2000
    Posts
    57

    Angry

    I have been having enormous difficulties figuring out how to pass variables from MC to MC and different parts of the movie. There doesnt seem to be any type of global variable, which is a shame, but since you can supposedly reference any variable from anywhere just by including its path, all seemed well, until it didnt seem to work heh.
    Here is the one specific problem I am having right now (and most of the problems I have encountered seem to be fixed simply by getting the syntax correct). Anyway, in one movie clip, I have a variable called 'ballpos1', 'ballpos2' etc... up to 'ballpos6'. In another movie clip, I have a loop that is trying to reference those variables using "ballpos" & num (where num is my loop variable). using this I would expect my loop to count through all my ballpos variables. the exact code is like this:
    Loop While (num <= 6)
    If ("ballpos" & num = btargets)
    Set Variable: "resident1" = num
    End If
    Set Variable: "num" = num + 1
    End Loop

    That is how I have it right now. Since the ballpos variables are in another movie clip, I would suppose I would need to reference it somehow by saying:
    /:"ballpos" & num
    However this doesnt work.
    Anyone know how to reference this variable??? In addidtion (hehe) for some reason "resident1" always ends up as 6, instead of catching when ballpos is equal to btargets and setting resident1 to that number. get it? Any help would be greatly appreciated and you can e-mail me at:
    mshumway@financialfusion.com
    THANKS!!!

  5. #5
    Senior Member
    Join Date
    Feb 2000
    Posts
    195

    Wink

    Try this:

    Set Variable: Eval("/code:ballpos" & resident2) = firsttarget

    The Eval command will process the statement, and attempt to evaluate it as if it were a variable.



    <EMBED src="/cgi-bin/ubb/Members/sigs/00000205.swf" quality=high WIDTH=500 HEIGHT=50 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> </EMBED>

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