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
    Regular Coder
    Join Date
    Jan 2006
    Posts
    243
    Thanks
    14
    Thanked 2 Times in 2 Posts

    frameName instead of frame#

    I have a working playhead navigation that relies on the frame nr's, but because I expect to be changing the frames a lot during development it would be easier if I use frame names instead. But when I change the frameNr's in my code to the given frame names it stops functioning.

    Below is the relevant code, the names ("hover, "rest") were previously frameNr's.

    Code:
    if( ball._visible && ball.hitTest(_xmouse, _ymouse))
    {
    	if(ball._currentframe == "hover")	ball.stop();
    	else					ball.play();
    }
    else if(ball._currentframe != "rest") ball.play();

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    _currentFrame returns only the number, so comparing with text will always fail. There is a workaround though.

    On the frames "hover, "rest", make a new layer for actions. Then put this code (change the name, but it must be put on any frame you label to access in AS)

    Code:
    this._currentframe = "hover";
    Then you code should work...let me know.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    Regular Coder
    Join Date
    Jan 2006
    Posts
    243
    Thanks
    14
    Thanked 2 Times in 2 Posts
    That didn't work unfortunatly.

  • #4
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    AS3 has a property currentLabel which you can use, if you are up to the challenge of making AS3 compliant code.

    It seems that AS2 doesn't have anything that really can do this (an oversight on the part of developers), but there are some other ideas. For instance, you could save the labels and frame numbers in an array and then test against that. Therefore any changes you make you only need to change in the array once.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #5
    Regular Coder
    Join Date
    Jan 2006
    Posts
    243
    Thanks
    14
    Thanked 2 Times in 2 Posts
    I haven't really looked into AS3 yet, I'm not sure I can use either because I'm publishing as flash 7 to make it compatible with other devices as well.

    Thanks for the suggestions though!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •