ActionScript 3.0 onEnterFrame
Posted by Matthew Hancock
Tutorials, Resources April 30th, 2007 at 4:47 pmIn ActionScript 3.0, the frame event model has been changed from the ActionScript 2.0 version quite a bit. In ActionScript 2.0, if you wanted to perform a task every time you entered a frame, you would type
onEnterFrame = function(){
trace("Do Something");
}
In ActionScript 3.0, you must use an event listener format to perform a frame event. For example…
addEventListener(Event.ENTER_FRAME,myFunction);
function myFunction(event:Event) {
trace("Do Something");
}
It’s a little more complicated than the old way, but ActionScript 3.0 opens up a whole new world of programming possibilities.

May 14th, 2007 at 11:13 pm
I agree, it opens up way more doors. It will just take me a bit of time to get used too it. On the bright side I’m feeling more and more like a real programmer with 3.0. lol.
June 17th, 2007 at 1:44 am
Now AS is more complicated, good for programmers, bad for designer
December 26th, 2007 at 11:46 am
I think it will just be like the days of the dot notation switch, there is a learning curve but eventually the designer and the programmer will meet in the middle. I think what Adobe has to do now is stop moving forward for awhile and let us all catch up. If anyone remembers Director, this is what killed Director. Macromedia kept coming out with the “New and Improved methods” before you knew it the books were 12 inches thick and eventually people said screw this!!! and when to something SIMPLE and FAST which at the time was Flash. So I agree AS3 is better, but if AS4 comes out and it again is completely different - I will drop Flash like a bad habit and never look back. and start using SIMPLE and FAST which right now looks like it’s going to be Microsoft’s Blend, Visual Studio and Silverlight (WPF) Trinity.
April 7th, 2008 at 1:43 pm
I have developed out in silverlight and with version 1.0, it is not ready to compete at the level with flash. It doesn’t have anything equivalent to the flash movie clip for example. Reusing a single storyboard on multiple buttons etc requires custom javascript to modify the storybaord’s targets to match whatever you rolled over. It is all doable, but it version 1.0 isn’t quite there yet. I look forward to when it is there though because silverlight has promise. I for one am really curious to see how the battle between Flex and Silverlight is going to shape up.
May 30th, 2008 at 6:44 pm
can you help me with a code? iam trying to make a button wich expands when mouse roll on it and collapses when mouse is rolled out :\ thx for help
this.stop();
import flash.events.*;
var rewind = 2
this.addEventListener(Event.ENTER_FRAME, enterf);
function enterf(e:Event){
if(rewind == 1){
prevFrame();
}
}
this.addEventListener(MouseEvent.MOUSE_OVER , over)
function over(event:MouseEvent){
var rewind = 2;
play();
}
this.addEventListener(MouseEvent.MOUSE_OUT , out)
function out(event:MouseEvent){
var rewind = 1;
}
May 30th, 2008 at 6:46 pm
btw .. the problem was that button stops expanding and dont collapsing :\