A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Variable reverting to onLoad() value.

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    2

    Variable reverting to onLoad() value.

    Hi there. Would you all be able to help me with a very confusing question I have?

    Basically, I have an onEnterFrame variable, time_mod, that I can change through button presses to either 1, 2 or 4. This controls how fast time progresses. In onLoad() this value is initially set to 1.

    Now, here is the problem, when I click a button and change the time_mod value (which I confirm using trace(time_mod); I find the value changes for that moment. But the next onEnterFrame, the time_mod value is reverted back to the initially value. I am just very confused and wondering if there is a fundamental error in this approach.

    Thank you for taking a look at this.


    PHP Code:
    function onEnterFrame()
        {
                
    t_count += 1;
                
    time_base_m time_base/time_mod;
                
                if (
    t_count >= time_base_m)
                {
                    
    t_count 0;
                    
    time += 1;
                }
                
                
    _root.Town.OneX.onPress=function()
                {
                
    time_mod 1;
                }
                
                
    _root.Town.TwoX.onPress=function()
                {
                
    time_mod 2;
                }
                
                
    _root.Town.FourX.onPress=function()
                {
                
    time_mod 4;
                }
            } 

  2. #2
    Junior Member
    Join Date
    Apr 2013
    Posts
    2
    Ok, so I've been digging into this problem for a few hours now. It turns out the variable in the button function is different from the variable in the .as script. So I need to figure out a way to pass the variable from the button to the .as class script. Any suggestions?

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