From Flash 5 to MX

Here’s the case:

I found some code that works great with Flash 5, but I can’t get it to work with MX:

onClipEvent (enterFrame) {
	if(Selection.getFocus() == null || Selection.getFocus() != "_level0.mytext")
	{
		if(_currentFrame > 0)
		{
			prevFrame();
		}
		return;
	}
	if(_currentFrame < _totalframes)
	{
		play();
	} else {
		stop();
	}
}

I’m not that good at actionscripting, so I can’t quite figure it out!

The script is used to play a movieclip when selecting a input textbox (with a var name of “mytext”)

Could someone please translate it into MX code!? :sigh:

try this instead

selection.onEnterFrame = function() {if(Selection.getFocus() == null || Selection.getFocus() != “_level0.mytext”)
{
if(_currentFrame > 0)
{
prevFrame();
}
return;
}
if(_currentFrame < _totalframes)
{
play();
} else {
stop();
}
}

Grim

Hmmm…
I get the following error applying that piece of code to my MC:

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: Statement must appear within on/onClipEvent handler
     selection.onEnterFrame = function() {if(Selection.getFocus() == null || Selection.getFocus() != "_level0.mytext")

:frowning:

Why do you need return; there??? I think that is causing the problem… That code itself should be working fine whether it is used in F5 or FMX…

Take a look at this, perhaps that would help! The test01.swf is saved as a flash 5 file!

File works just fine on my FMX… What seems to be the problem??? :wink:

Because it’s still in flash 5, but try to export the .fla to a Flash MX .swf file - THATS the problem! then, it won’t work!! :wink:

Now I get it… :wink:

Click on the text field… You see ‘mytext’ in the Variable area??? Remove ‘mytext’ from there, and put it in the instance name area which is right below the drop down box that says ‘Input Text’…
Go to export setting, and set it to export to Flash 6…
Run the movie to test…

I think this is what you want… Let me know… :wink:

hehe… so simple - THATS it!

THX mate! <:}

:wink:

Hmmm… but that brings up a new question:
I want to put it inside a movieclip - but then it wont work… again! :*(
Has it something to do with _level1.mytext

Um… Then, I guess, you should tell the exact path like this???

_level1.yourMCInstanceName.mytext

***… I tried that, but it won’t do the trick! :(

Sorry mate, something went worng the first time - you where right! IT WORKS! :slight_smile:

It’s working just fine to me???

Oh… Okay… :wink: