A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: help - going insane?! variableHELL...HELP!!!PLEASE!!!

  1. #1
    Senior Member
    Join Date
    Nov 2000
    Location
    London - UK
    Posts
    191

    help - going insane?! variableHELL...HELP!!!PLEASE!!!

    please...anybody... have some mercy on me.....!!!!!!!!!!!
    I'm trying to finally bite the bullet and learn AS properly as far as my poor little brain will take me - now I'm so stuck - it's driving me insane...
    Just when I thought I was getting it - this dilemma...
    I've set up variables for the x and y position of a butterfly movieclip, then using these for 4 directional buttons which move the clip along usng the given value - everything works fine when I set the value to a set number.
    I also have a dynamic text box in place, displaying the x and y position of the clip - working fine with the set value as well.

    So far so good...
    Now I'm trying to have 2 input fields there for the user to be able to change the x and y value. At the moment I've got a button in place to set the variables value.

    The strange thing is that my script work just fine for 2 button (up/-y and down/-x) - but the other 2 do the oddest thing and I'm just so stuck :'(
    The value seems to go through but instead of adding - it just adds them at the end of whichever y postion is currently there, ie when the y position reads 200 - after the change of value to eg 20 - the y position reads 20020 (instead of the correct y poisition: 220).
    So something must be wrong in my script, it currently is:

    on(release){
    _root.butterfly._x -= _root.x;
    updateAfterEvent();
    }
    =>for working button

    on(release){
    _root.butterfly._x += _root.x;
    updateAfterEvent();
    }
    => for misfunctioning button

    And I'm still new to variables - just playing around with them, trying to understand... scared of maths as well... so it's just freaking me out now... am I stupid ? Or don't I see the complexity yet???

    Any help, any tips... - I've attached the file - just in case I was talking jibberish...

    Hoping for a light at the end of this tunnel.....
    Prisca
    ___carpe_diem___

  2. #2
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    The variables you get from a textfield is a string. and using the add operator with a number and a string the string context precedance so Flash thinks you want to add them as strings.

    With the minus-operator there is only a numeral context so thats why the up/left buttons work.

    with the add buttons you need to convert the strings to numbers first using the Number()-action.
    like this:

    Code:
    _root.butterfly._x += Number(_root.x);
    /Mirandir

  3. #3
    Senior Member
    Join Date
    Nov 2000
    Location
    London - UK
    Posts
    191

    THANK YOU THANK YOU THANK YOU :) :) :)

    Mirandir,
    thanks so much for your help!!! Very much appreciated

    I'm still so new to the whole concept of variables that I just end up in the fog somewhere, not knowing where to go.... so you've sne t me on my way now
    Thanks
    Prisca
    ___carpe_diem___

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