A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: passing values of variables between movieclips

  1. #1
    Senior Member
    Join Date
    Feb 2000
    Posts
    226

    Post

    This is probably an easy one for you guys,

    A while ago I was struggling to pass the value of a variable from one movieclip to another within a single Flash movie (or, in other words, manipulating a certain movieclips through a variable change in another clip).

    I thought I had solved that problem but right now I’m in a similar situation and I can’t get the job done! Using the If statement and tell target goto doesn’t do the job.

    Can somebody help?

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

    Thumbs up

    Yes, that should be quite easy to do. You can actually reference any variables in any movie clips from anywhere in the movie. All you need is the correct path. While the concept of Paths is nothing new in the world of computers.. I believe it could still use some clarification. Actually, the Flash Help has an entire page dedicated to this subject. However, I found that page very confusing when I first read it.. and I was already quite familiar with the concept of paths! So instead of sending folks to their Flash Help file, and further confusing them , I have taken the liberty of putting together my own little "article" on Flash Paths (or "Specifying Targets" as the Flash Help puts it)... May I have better luck than Macromedia

    <hr>

    Paths
    -----

    Flash Movies have an internal structure similar to the "tree structure" of folders on your computer's hard drive. You can think of each movie as the drive, and each movie clip instance is a folder. Or, if you prefer, think of it in Internet terms.. the movie is the domain (www.domain.com) and each movie clip is a folder. If you are familiar with the syntax of either of those systems, then you are all set, Flash has pretty much the same syntax:

    <UL TYPE=SQUARE>
    <LI>The / character separates folders.

    <LI>If the path begins with the / character, it refers to the root, or highest level as seen from the current location. In flash, that is the main movie (outside all the movie clips).

    <LI>Double dots .. refer to the parent folder.
    </UL>

    The : character, on the other hand, is used only in Flash. It separates the path from the variable name.

    You may also have seen "_level0" used in Flash movies. That is akin to saying "C:\" or "http://www.domain.com/". It refers to the main movie, by name. This is sometimes necessary because Flash allows you to load multiple movies into the same Flash player (the ever popular "Load Movie" command). Movies are loaded into different levels, each with a number, beginning at 0. The movies may be referenced by their level numbers as in "_level2", which refers to the main timeline of the movie that is loaded in level2.


    Some examples:

    /mclip1

    That is the path to the movie clip instance called "mclip1". That movie clip is located directly on the root, or main movie; hence the "/" at the beginning. The statement:

    /mclip1/mclip2

    refers to the movie clip instance called "mclip2" which is located within the movie clip instance called "mclip1". Now let's say you are currently in "mclip2", and you want to target another movie clip called "mclip3" which is also inside "mclip1". There are two ways to do that:

    /mclip1/mclip3

    which starts at the root, and includes the complete path to "mclip3". Or you can do it this way:

    ../mclip3

    which refers to "mclip3" in the parent clip, which is "mclip1".

    Now those are all movie clips, but what about variables? Variables behave much like files in folders. They can reside in the root (main movie), or they can reside inside folders (movie clips). Let's say you want to refer to the variable called "variable1" which is in the movie clip "mclip2". Here's how you would do it:

    /mclip1/mclip2:variable1

    And what if simply want to get to a variable in the main movie, but you are inside a movie clip?

    /:varname

    It's that simple.

    <hr>

    Sorry if that was more info than you wanted, but I hope you find some of it useful. Oh, and if you happen to have any suggestions that would help me improve that "article", please let me know.. since it's not the first, and I'm sure it won't be the last time that someone asks that question...


    <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>

  3. #3
    Member
    Join Date
    Mar 2000
    Posts
    32

    Post

    i got the one movie to work (thanks to this information), there are 2 versions of the scrolling text i was working on. the one that works is a single click = +/- 1 line of scrolling text. the one that doesnt work uses a movie clip so that you can hold the button down and it will keep scrolling. ive checked almost everything in the mc as well as the buttons.

    question though, if i refer to a mc as "clip1" is it the same as "../clip1" (since thats how it works with www addys)? also the same regarding variable names with ":variable1" vs "../:variable1". i couldnt get it to work with variables, so i basically have that part answered, but what about mc instances?

  4. #4
    Senior Member
    Join Date
    Feb 2000
    Posts
    226

    Post

    Hi Scott,

    Thanks again, That was helpful!

    I was thinking along the line of paths, it was “:” that did the job. Perhaps you have some tips where I can find Flash scripting tutorials. I’m quite into Flash but when it comes to this sort of details I think the Flash help file isn’t actually very helpful!



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

    Post

    Sasha,
    Just like paths on the web, "../" references the parent folder. So, "../Clip1" will check the parent "folder" for a movie clip called "Clip1". Whereas "Clip1" will check the &lt;i&gt;current&lt;/i&gt; folder for a clip called "Clip1".

    If you are still having trouble with that scrolling, let me know. I have succesfully used movie clips for repeat scrolling (on my own site). Maybe I can help.


    raoul,
    I agree that Flash's own Help file is often less then helpful. I have often found http://www.moock.org/webdesign/flash/index.html to be helpful.. but beyond that, I do not know of any good reference for Flash ActionScripting. Sorry

    Of course.. there is always this message board..

    &lt;hr&gt;

    Oh, and.. sorry for the delay folks.

  6. #6
    Senior Member
    Join Date
    Feb 2000
    Posts
    226

    Post

    Thanks Scott, you're right about the moock site, it is good and very helpfull!

    btw. would you mind having a look on my question about preloaders I basically solved the second question although I would like to know a bit more about the SetTimer function. But I still can't figure out how to deal with my first question about running a preloader with a 'if Frame is loaded statement' and meanwhile giving the user the possibility to jump to loaded parts of the main movie?

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