Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Cool Controlling Variables Within Flash

    Ok I am relatively new to actionscript.
    It is only a game of pong, but basically I have collision detection and when the ball hits the object I want it to speed up.

    I have the collision detection (sort of) working:


    onClipEvent (enterFrame) {
    if (_root.ball, hitTest(_root.object)) {
    trace("Hit");
    } else {
    trace("Miss");
    }
    }
    When 'ball' hits 'object' flash prints "Hit" in the output window, BUT, it does not print "Miss" when it is not hitting the object.

    Anyway thats not what I am asking.
    The 'ball' contains the variable:

    this.fullspeed=25;
    All I want to do is double it to 50, so if I change the collision to the following it should work:

    onClipEvent (enterFrame) {
    if (_root.ball, hitTest(_root.object)) {
    ball.fullspeed=50;
    } else {
    trace("Miss");
    }
    }
    But alas it does not seem to work. I can't figure out how to control the variables in one object from another, as the variables do not seem to be global, if that makes sense.

    Thanks for your help,
    Dan

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Did you try putting
    Code:
    _root.ball.fullspeed=50;
    This will make sure the reference is correct.

  • Users who have thanked gnomeontherun for this post:

    Psirus (05-29-2008)

  • #3
    New Coder
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    That worked thank you.

    How about having a variable coming through a third party program using 'flash server'
    It brings a variable through onto the actionscript on the first frame, which is not assigned to an object.

    How can I grab this variable for another object?

  • #4
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    You need to explain more about what your third party system is, perhaps an example and some code if you can?

  • #5
    New Coder
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Ok I have come across another problem. I am fine with your help now, thank you for that

    Ill make a new thread about 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
    •