|
keyCode: Every keyboard button has a numerical key code value. You don't need to remember them of course. For example, use this movie to find the key's corresponding value. 1. Draw a rectangle and convert it into a movie clip (press F8). First of all, open up your application and in the first frame we are going to make the sound object that will be played. First we need our logo to listen for the mouse over and mouse out events we do this by first giving our logo an event listener which will make it come active if you like. Inside the parameters we declare what type event we want it to listen for in this case we need a MouseEvent so we type MouseEvent allowing us to access the MouseEvent class. Then we declare what kind of MouseEvent is needed, we give them MOUSE_OVER and MOUSE_OUT respectively and finally we give both a unique name of our choice in this case we have used onHover and onOut. Let's go through the code; Most of us want to know what is going on in the world or in our local area, for that we look to newspapers, the television and the web to inform us what is happening. The news consists of a collection of ?events? that have occurred recently, they are labelled 'events' because they are important moments in time that other people want or need to know about.
myClip.onEnterFrame=goRight; And that will create the same exact previous result. However, we can now reuse this listener function for more than one object without fear of breaking the code because of the smart reference to our event target:
You can still use the old Flash 5 Event model in Flash MX for the sake of backwards compatibility, it is not officially deprecated by Macromedia, but in my opinion you should consider it to be. There are absolutely no advantages that can be gained from using the old event model.
You will notice that in the second movie the animation is a lot smoother when you drag the spheres. How does it works ? Without updateAfterEvent the only way to smoothen a jerky animation running in 12 frames per second is to raise the frame rate of the movie, this has been done and will still be done by numerous Flash developers and designers. But the smart way is to use updateAfterEvent which force the screen to refresh independently on the frame rate instead of refreshing it at every frame. As you can see in the definition given in the Actionscript 2.0 language reference updateAfterEvent does work with the onMouseMove listener. Here is the code for both movies If you run this Flash Movie, you will notice that you have a new mouse cursor moving with your mouse. However depending upon your framerate it can be quite choppy and will appear to lag behind. Just for the sake of this example set your framerate to 12 fps, you will now notice the lag for sure. This lag occurs, because the code that set's the position of the movieclip executes whenever the mouse moves, but the stage only re-renders itself 12 times every second. We need the stage to re-render itself and update the position of our movieclip visually on the stage, everytime the mouse is moved. updateAfterEvent to the rescue: |
| w__ww_.j_a__v_a___2s.___c_o__m | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |