...

View Full Version : frameName instead of frame#



Kirl
01-08-2009, 12:32 PM
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.


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

gnomeontherun
01-08-2009, 05:44 PM
_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)


this._currentframe = "hover";

Then you code should work...let me know.

Kirl
01-09-2009, 12:27 AM
That didn't work unfortunatly. :(

gnomeontherun
01-09-2009, 11:35 AM
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.

Kirl
01-09-2009, 01:44 PM
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!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum