AS2 to AS3 - I'm lost

I am trying to bring my site up to AS3, but I can’t figure it out.
Here’s the code for my MC’s in AS2.
Any idea of how to convert it?
Thanks!

//--------------BUTTON FUNCTIONS----------------//
function rollover(movieName) {
if (currentPlace != movieName) {
eval(movieName).gotoAndPlay(“over”);
}
}
function rollout(movieName) {
if (currentPlace != movieName) {
eval(movieName).gotoAndPlay(“out”);
}
}
function stick(movieName) {
currentPage = 1;
if (currentPlace != movieName) {
eval(currentPlace).gotoAndPlay(“nextSection”);
eval(currentPlace).enabled = true;
}
currentPlace = movieName;
eval(currentPlace).gotoAndPlay(“released”);
eval(currentPlace).enabled = false;
}
//----------------------------------------------//

//-------------BUTTON ROLLOVERS and ROLLOUTS----------------------//
menu_one_mc.onRollOver = function() {
rollover(“menu_one_mc”);
};
menu_one_mc.onRollOut = function() {
rollout(“menu_one_mc”);
};
//----------------------------------------------//

You should have stopped using eval a long time ago - it’s been deprecated since at least Flash 6 from memory, possibly earlier. In AS2, this[currentPlace] would work just fine. Anyway, the easiest way to transition from AS2 to AS3 is to forget almost everything you know about AS2 and start learning anew :wink:

You’ll need to look at how to use event listeners, the MouseEvent class in combination with a listener on the stage and the display list in order to replicate that code there. There’s a lot to learn, and it isn’t going to happen overnight. AS3 is a real time investment. Start simply, then work your knowledge up. Trying to just transition huge swathes of code will only lead to frustration this early in the game :slight_smile:

Then there’s stronger typecasting, using classes and methods, encapsulating your code and a whole lot more. I’d suggest you have a read through Senocular’s epic Tip of the Day thread, and also search for articles on AS3 for beginners. Books are also good, I’d recommend Essential Actionscript 3 by Colin Moock. Fun times ahead!

I had the same problem as you also. I pretty much learnt AS2 a few months before switching to AS3 as I wanted a ground knowledge in the old code.

I found O’Reillys Learning Actionscript 3.0 A beginners guide helpful.

Converting your code from AS2 to AS3 will be a challenge. The languages are much different. Learning AS3 is worth the effort though, it is a much more powerful language than previous versions, uses a different code base from previous languages and with the changes comes dramatic improvements in performance of the language which leads to performance improvements in your applications.

This makes the learning curve a little steeper for a new user but once you get the fundementals down there is a lot of power there for the developer. The change from AS2 to AS3 is the biggest change the language has undergone since its original inception.

This (the Kirupa Forums) is an excellent resource for gathering information. I have found the members here to extremely helpful and friendly as I have gathered information on the many changes.

If I can help you in anyway let me know. I would be glad to assist you as you begin to work through the transistion. I have put together a group of video tutorials on AS3 fundementals that may get you started. These are very basic overviews on different aspects of the language and how the syntax is used. There are many sites out there developing tuts on AS3 as the language becomes more popular.

The Kirupa Forums also have some really good tutorials on the different aspects of Flash CS3. Good luck and I will see you in the forums.

Mike
www.focusonflash.com

I’m experiencing the same… but it’s all good in the end. In fact learning AS2 from scratch was for me much more painful than migrating to AS3.

After having faced a few small projects in AS3 it’s obvious that it’s like passing from a bicycle to a Car. More complicated, but much more powerful.

The programmers at work make jokes about it. They say now I’m learning a real language :slight_smile: