A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Matching Variables question

  1. #1
    Member
    Join Date
    Jul 2008
    Posts
    30

    Matching Variables question

    hi, I'm trying to get a dynamic text box to stop going higher when it reaches a number defined by another dynamic text box, ex. text box 1 starts at Zero, and text box 2 starts at 25, whenever you click a button, text box 1 goes higher, but can't go higher than text box 2.

    This is the code I have that doesn't seem to be working:

    if(_root.A >= _root.B);{
    _root.A == _root.B;
    }


    Thanks in advance

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Try
    PHP Code:
    if (_root.>= _root.B) {_root._root.B;} 

  3. #3
    Member
    Join Date
    Jul 2008
    Posts
    30
    that hasn't worked, sorry :\ No error or anything, it just keeps going up

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    attach your file or link to it, perhaps post your full code

  5. #5
    Member
    Join Date
    Jul 2008
    Posts
    30
    variables.fla

    This is the file

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Simple, for your coding practices as well do this,

    remove the code off of the button , give the button an instance name of "button" no quotes.

    and put this under your A and B variables on the timeline;

    PHP Code:
    var A:Number 0;
    var 
    B:Number 25;

    button.onRelease = function()
    {
        
    _root.+= 5;
        if (
    _root.>= _root.B)
        {
            
    _root._root.B;
        }
    }; 
    or if you want to do it the button method put this on the button itself and remove the if statement from the timeline
    PHP Code:
    on (release) {
        
    _root.+= 5;
        if (
    _root.>= _root.B)
        {
            
    _root._root.B;
        }


  7. #7
    Member
    Join Date
    Jul 2008
    Posts
    30
    thanks, It's always something stupidly simple like that

  8. #8
    Registered User
    Join Date
    Mar 2013
    Posts
    2
    That is a nice start to it.

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