dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Vars not updating constantly

  1. #1
    Member
    Join Date
    Oct 2005
    Location
    Santa Barbara, California, USA
    Posts
    61

    [AS2, but in CS3] Vars not updating constantly

    I have variables some of which have values derived from dynamic text boxes with instance names. Then some var = (calculations) and some "if" statments. Finally a final value is derived and passed to a movie. The problem is that my trace statments show that the values are calculated once, then no more. Does this need to be in a onEnterFrame function? I tried that but it didn't work, although I made have made a typo.

    Here's the code. If the solution is still obscure I can add the rest, or even a .fla.

    Thanks a lot, I'm struggling but moving forward on this project.

    PHP Code:
    var sunTime 0;
    sunTime = (sunMinutes+(sunHours*60));
    trace ("a"+sunTime);
        if (
    ampmthing true) {
            
    sunTime sunTime+720;
            
    trace ("b"+sunTime);
        }    
        
    sunTime sunTime-300;
        
    trace ("c"+sunTime);    
        if (
    sunTime<0) {
            
    sunTime = (sunTime+1440);
            
    trace ("d"+sunTime);
        };
    trace ("e"+sunTime);
    _parent.sun.gotoAndStop(sunTime
    Last edited by Creative Action; 10-17-2007 at 04:41 PM. Reason: Change Header

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I don't understand exactly your script but you have errors:
    if (ampmthing = true) {
    must be
    if (ampmthing == true) {
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Member
    Join Date
    Oct 2005
    Location
    Santa Barbara, California, USA
    Posts
    61

    Not that again, arghhhhhh!

    Thank you cancerinform (in the wrong forum too I realized). I will change that now.

    Delayed response due to another project.

  4. #4
    Member
    Join Date
    Oct 2005
    Location
    Santa Barbara, California, USA
    Posts
    61

    Back to the drawing board

    Good catch, but still doesn't work. Here's the whole piece of code, which works except for sending the sun movie to the correct position based on the digital clock readout. Some stupid mistake I'm sure. I'm a rank amateur, wrote this mostly on my own, so it might look a little dumb.

    PHP Code:
    stop();

    var 
    mrotate 0;
    var 
    sunMinutes 0;
    var 
    sunHours 0;

    //Move hands to analog minutes
    minutesB.onPress = function() {
        var 
    mth 0;
        var 
    mxmin 104;
        var 
    mymin 91.5;
        
    minutesB._x mxmin;
        
    minutesB._y mymin;
        
    minutesB.onEnterFrame = function() {
            
    mth Math.atan2(_ymouse-mymin_xmouse-mxmin);
            
    mrotate mth*180/Math.PI;
            
    minutesB._rotation mrotate;
        };
    };

    //Sets digital minutes
    minutesB.onMouseUp = function() {
        
    delete minutesB.onEnterFrame;

        if (
    mrotate<0) {
            
    displayMinutes_txt.text Math.round((mrotate+360)/6);

        } else {
            
    displayMinutes_txt.text Math.round(mrotate/6);
        }
        
    //variable for movie timeline
        
    sunMinutes displayMinutes_txt.text;

        if (
    displayMinutes_txt.text<10) {
            
    displayMinutes_txt.text "0"+displayMinutes_txt.text;
        }
    };

    //Move hands to analog hours
    hoursB.onPress = function() {
        var 
    hth 0;
        var 
    hxmin 104;
        var 
    hymin 91.5;
        
    hoursB._x hxmin;
        
    hoursB._y hymin;
        
    hoursB.onEnterFrame = function() {
            
    hth Math.atan2(_ymouse-hymin_xmouse-hxmin);
            
    hrotate hth*180/Math.PI;
            
    hoursB._rotation hrotate;
        };
    };
    //Sets digtal hours
    hoursB.onRelease = function() {
        
    delete hoursB.onEnterFrame;

        if (
    hrotate<0) {
            
    displayHours_txt.text Math.round((hrotate+360)/30);
            
        } else {
            
    displayHours_txt.text Math.round(hrotate/30);
        }

    //variable for movie timeline    
        
    sunHours displayHours_txt.text;

        if (
    displayHours_txt.text<10) {
            
    displayHours_txt.text "0"+displayHours_txt.text;
        }
    };


    //Manual switching beteen AM and PM
    ampmmov.onRelease = function() {

        if (
    ampmthing == false) {
            
    displayAmPm_txt.text "pm";
            
    ampmthing true;
        } else {
            
    displayAmPm_txt.text "am";
            
    ampmthing false;
        }

    };

    //Code that moves playhead to correct movie frame

    var sunTime 0;
    trace ("aa"+sunTime);

    sunTime = (sunMinutes+(sunHours*60));
    trace ("a"+sunTime);

        if (
    ampmthing == true) {
            
    sunTime sunTime+720;
            
    trace ("b"+sunTime);
        }
        
        
    sunTime sunTime-300;
        
    trace ("c"+sunTime);
        
        if (
    sunTime<0) {
            
    sunTime = (sunTime+1440);
            
    trace ("d"+sunTime);
        };

    trace ("e"+sunTime);


    _parent.sun.gotoAndStop(sunTime

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