dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Remember my variable..?

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Posts
    14

    Remember my variable..?

    Hey

    Simple problem:

    STEP 1
    =====
    I have the following code in a mc (location= _root.mc1)

    ------------
    var = i;
    i = 0;
    ------------

    STEP 2
    =====

    If the user presses the right button, i becomes 1. (at the end, everything should be like a lock to enter the page).

    STEP 3
    =====

    So once the user pressed the right button, and i becomes 1, he can access the page.

    In another MC, (that is in a different location) lets say (location = _root.mc2) i want to call that variable "i" again. But Flash doens't remember that "i" now is 1, because it's in a different MC on a different level that "i" became "1".

    In the last MC i have something like this to.
    -----------
    if (i=1) {
    _root.mc3.gotoAndPlay("access")
    };


    did i make myself clear? why flash doesn't remember my variable in another MC..? How can I solve this problem?

    Any help is apreciated. Thanks you.

  2. #2
    Junior Member
    Join Date
    Jul 2004
    Posts
    23
    Try to make your i var = _global maybe...

    At your _root.mc1 use: _global.i =0;

  3. #3
    Interested User Rohm's Avatar
    Join Date
    Aug 2004
    Location
    Sweden
    Posts
    214
    If I get you right

    you should write

    _root.mc1.i to get the variable from ie mc2

    so...
    if (_root.mc1.i == 1) {
    _root.mc3.gotoAndPlay("access")
    };

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,811
    it's because if you don't add a target path then it just assumes that it's this.i If you want to target the older i you need to create an absolute path of
    if(_root.mc1.i ==1){ _root.mc3.gotoAndPlay("access")
    }
    or you could try a relative path of if(this._parent.mc1.i == 1){
    to get the path right you can just go to the cross hair button while in the actions window.
    .

  5. #5
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,811
    one other quick note: if you do if(i = 1) this will make i = 1. using one = changes the value. using two == checks the value. Getting this wrong would also cause problems of changing it instead of checking it.
    .

  6. #6
    Junior Member
    Join Date
    Feb 2006
    Posts
    14

    thanks

    u guys are great.. many thanks for the quick response.
    sirus

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