A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: updating var

  1. #1
    Senior Member gordonart's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    267

    updating var

    I have this code in an mc.


    //////
    function musikstil(a,b){
    a.onRollOver = function(){
    a.gotoAndStop("over");
    }
    a.onRollOut = function(){
    a.gotoAndStop(1);
    }
    a.onRelease = function(){
    b.gotoAndStop(b._currentframe + 10);
    if(b._currentframe == 60){
    b.gotoAndStop(1);
    }
    trace(_global.valA);
    }
    }

    /////
    musikstil(stil1.val,stil1);

    I want to change the value of _global.valA in the different frames in b, like putting "_global.valA = 1" in frame 30 but the trace only seems to remember the value I had put in the startframe 1.

    What am I missing?

    /Mattias
    Mattias Gordon
    illustrator/ animator

  2. #2
    Senior Member
    Join Date
    Apr 2009
    Posts
    117
    try working with all your script on one frame if you can on your main timeline, not on a MC or Button etc, it keeps your whole scripts more tidy and problems are easier to find etc etc, if you put it all on your main frame, you need to use tellTarget and then vars can be changed like

    var a:Number = 1;

    i dont exactly see what your doing anyway, it looks like when youve clicked one button you need it to go onto button b, why not just use
    btnapressed = true;
    inside the brackets where a is pressed and then
    if(btnapressed) {
    //allow btn b to be pressed
    }

  3. #3
    Senior Member gordonart's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    267
    I have a button(a). When you click on that button a mc(b) will goto different "holds". So with the a-button you can select different frames ( with names ). One one of the names are the right one.
    So I am trying to find a good way to know that the right name is selected by the button.
    There will be four more buttons like this and also a button where you click and give you the answer if you selected the right names with the buttons.
    Mattias Gordon
    illustrator/ animator

  4. #4
    Senior Member
    Join Date
    Mar 2010
    Posts
    157
    it might just be the fact that you keep looping through the declaration of the variable, setting it to its begin value every frame.

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