A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: "Variable" Help please

  1. #1
    Member MoonRise's Avatar
    Join Date
    Sep 2004
    Location
    Greenville SC
    Posts
    121

    "Variable" Help please

    Are variables that are defined in the Parent (root) movie inheritable down to the child movie. IE ButtonPushed = False (or True) is defined in Parent (root). Child movie has "if(ButtonPushed){ code here}

    Please let me know if I'm on the right path.

    Thanks!
    MoonRise

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Quote Originally Posted by MoonRise
    Are variables that are defined in the Parent (root) movie inheritable down to the child movie. IE ButtonPushed = False (or True) is defined in Parent (root). Child movie has "if(ButtonPushed){ code here}

    Please let me know if I'm on the right path.

    Thanks!
    The answer is yes, when referencing between movies you just have to append the movie it's in..

    in the child movie you'd refer to the variable as parent.myvariable or if you are sure the movie is not loaded into another one you can use root. to refer to a variable in a child movie append the child movie name ie.

    mychild.variablename

    here's where it gets tricky though if you want to get the same variable from another child movie you append parent to that to get

    parent.mychild.variablename

  3. #3
    Member MoonRise's Avatar
    Join Date
    Sep 2004
    Location
    Greenville SC
    Posts
    121

    Thanks - but also help!

    Quote Originally Posted by blanius
    The answer is yes, when referencing between movies you just have to append the movie it's in..

    in the child movie you'd refer to the variable as parent.myvariable or if you are sure the movie is not loaded into another one you can use root. to refer to a variable in a child movie append the child movie name ie.

    mychild.variablename

    here's where it gets tricky though if you want to get the same variable from another child movie you append parent to that to get

    parent.mychild.variablename

    BLanius,

    Thanks a bunch. I thought I wasn't crazy on that. I also learned NOT to set a variable through a button click. That didn't work for some reason. I did find a way to let the resulting screen from the button click to set the variable and everything else feel into place. Now, I need to set another variable in that child movie back to zero, but from the root. This is the error I get:
    "Cannot assign property 'mycntr' to undefined variable on line 2 DedicationType.mycntr=0"

    "DedicationType" is the child movie, and "mycntr" is the variable inside that child movie. I can think of another way to make it work. I just want to understand a little more about variable passing. Did I follow you correctly on the Child Movie variable? The "root" part worked great! Thanks for your help.
    MoonRise

  4. #4
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    where is the code trying to set DedicationType? try changing to root.DedicationType.mycntr

  5. #5
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    From the help file
    A movie element will have its own set of variables, independent of the variables in the parent movie. The value of each variable will persist, even when the movie stops or loops.

    Objects in flash do not have a center position, and they do not have velocity or
    acceleration. 3D Flash Animator makes these features available by exporting two flash objects for each movie element. The first flash object controls the position and velocity,and the second flash object controls the center.The second object also contains the frames of the movie element.

    When you use a script to control the position of movie element, or to show or hide the element,then you should use the 'element' function to get a handle to the first flash object.

    element("my child movie").x = 100;
    element("my child movie").y = 100;
    element("my child movie").show();


    But when you are using a script to control the playing of frames, such as playing or stopping a movie element, then you must use the "movie" property to get a handle to the second object.
    element("my child movie").movie.stop();
    You must also use the "movie" property to gain access to the variables of the movie element.

    element("my child movie").movie.variable_name = "value";

    Main movie

    The main movie is available from any script using the variable 'root'.
    You can access any of the main movie's variables, or control the frames of the main movie.


    root.variable_name = "value";
    root.play();
    Last edited by blanius; 08-27-2005 at 03:32 PM.

  6. #6
    Member MoonRise's Avatar
    Join Date
    Sep 2004
    Location
    Greenville SC
    Posts
    121

    Hooray!! and OOPs!

    Thanks! I didn't listen to my own advice - READ THE HELP FILES!. Oh well. I've been able to complete a good majority of what I'm working on. Since you've been so good at helping:

    Home Site

    It will give an Adult Warning page first, but what I'm working on isn't that bad. Maybe some language like *ss.

    There will be a Menu bar above that is a part of the Host system. Click on Hide Menu for best view. Also 1024 X 768 screen.

    Also, Click on TAKO INFORMATION when the button appears. This will lead you to where I have the variables. You may recognize some of it. It is from my older site and it is with the Typewriter sound that I was working on 8 months back (maybe a lot longer).
    Last edited by MoonRise; 08-27-2005 at 04:42 PM. Reason: Additional Info
    MoonRise

  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Dude I was going to look at it but couldn't sit through that LONGGGGGGG intro again. If you MUST have a painfully long intro the least you could do is give the option to skip it.


    NOOOOOOOO Oh man I went back and waited it out then tried to get back to your menu and the intro ran again AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!! ! not again.

    You gotta fix that if you expect anyone to ever see the inside of your site and want them to ever come back to your site.
    Last edited by blanius; 08-28-2005 at 09:00 AM.

  8. #8
    Member MoonRise's Avatar
    Join Date
    Sep 2004
    Location
    Greenville SC
    Posts
    121

    :)

    Quote Originally Posted by blanius
    Dude I was going to look at it but couldn't sit through that LONGGGGGGG intro again. If you MUST have a painfully long intro the least you could do is give the option to skip it.


    NOOOOOOOO Oh man I went back and waited it out then tried to get back to your menu and the intro ran again AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!! ! not again.

    You gotta fix that if you expect anyone to ever see the inside of your site and want them to ever come back to your site.
    Thanks for the feed back. I'll look into a "Skip Intro" feature. Maybe move the "Replay Into" button to limit the "accidental" rplay of it. Funny though. I get a lot of "Wow that was great!", but then again that is usually family.
    Last edited by MoonRise; 08-28-2005 at 09:34 AM. Reason: none
    MoonRise

  9. #9
    Member MoonRise's Avatar
    Join Date
    Sep 2004
    Location
    Greenville SC
    Posts
    121

    Ok,

    Quote Originally Posted by blanius
    Dude I was going to look at it but couldn't sit through that LONGGGGGGG intro again. If you MUST have a painfully long intro the least you could do is give the option to skip it.


    NOOOOOOOO Oh man I went back and waited it out then tried to get back to your menu and the intro ran again AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!! ! not again.

    You gotta fix that if you expect anyone to ever see the inside of your site and want them to ever come back to your site.
    OK. That took some time. Thought it would be easier than that. SKIP INTO is now a feature. Thanks! Want people to get to what they want a little quicker. The "Tako Infomation" is still the same though. There is a reason why I "force" some one to sit through that a while before giving the option to quit, I don't own that "Intellectual Property" and feel obligated to give that company "time". Any way, BLAnius, thanks for the input and help.
    MoonRise

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