What is the difference between actionscript 2 and 3
The inclusion of sealed classes and few namespaces are the examples among other things. I agree that there are many more features to be discussed. But I hope whatever is here, that would be very helpful to know the topic. ActionScript started as a sequential programming language, and as the language developed it became a practical programming language.
There were many advanced and new features in ActionScript 2. Apart from these features, there were two major improvements that came with ActionScript 2. This version has changed the way of scripting on Flash platform. Hence, ActionScript 3 is carrying nearly more than 5 times classes and 4 times packages than ActionScript 2. This analysis indicates a big difference between two.
Apart from the above theoretical explanation, I am giving some practical examples here. Please read carefully:. Because you are trying to store a Number in a variable which you specified was a String. The advantage of typing variables is that, in general, it makes your code a little easier to read, the player can run your code faster, and the compiler can find some errors when you compile your content.
Note: Unlike in ActionScript 2, in ActionScript 3 if you attempt to call the function without any arguments, you will get an error. Note: We specify the return type as void, which means that the function does not return a value. If you try to call the function in ActionScript 3 and pass it a Number instead of a String, you will get an error.
Note: The Math. In ActionScript 3, the root property refers to the main timeline of the SWF in which the content originates. In most cases, these will be the same in either version of ActionScript. Below is a close illustration of the difference between AS2. You can see how AS3. Note: Both examples use the following XML contained in a file called contacts. Note: in the above ActionScript 3 video example you will need two buttons and one video in the same directory where your swf file is stored.
But in ActionScript 3. Copy and paste above code and follow the instructions given in Note and see the result. The child is added to the front top of all other children in this Display Object Container instance.
You can not register a single object as the child of more than one container. If you add an object that is already a child of a object than automatically previous object will de-register its child from the display list. Note: here Ball is the base class of the object. You can define base class of any object by pressing F8. OOP in the AS3 treats differently with the code absolutely. The things you can get away within ActionScript 2, throw error in AS3. It means, you can enhance your productivity using this version as it debug faster that the earlier one.
Here I do not want to write package and classes with the public-private modifiers types of structure, because that can only be discussed only in class-room. There we will discuss about polymorphism, encapsulation, inheritance and prototyping in details. In ActionScript 2. AS2 does not have any specific method or class to handle timer related events successfully. In AS2 we use getTimer method that displays time in milliseconds that have elapsed since the swf file started playing. Astonishing enhancement for the timer related functions and properties you may notice in this version of Flash script.
There is a special Timer class that has its own properties, methods, and events. Unlike AS2 we can control various timer states and trigger your timer on specific time and stop it also. That rubbish underscore has removed from the properties and some of them have major changes. See the given below list, here I am giving few properties:.
This is not a new topic to you now. When you were working with the AS2 version, you handled the events in completely different way. In AS3 event handling and number of events are undeniably diverse. So, the diversification among the events of these two versions also make AS3 event handling a special subject to know. There are three types of events in my knowledge:. This is honestly the biggest difference and it is really easy to learn.
To do something every frame you need the following code in AS3. The first line is an eventlistener. AS3 uses eventlisteners to listen for events.
When you add one the flash program you are making will react whenever that event occurs. If you want to stop it from reacting you can use removeEventListener with the same arguments.
The second argument is the function to call when the event happens. It can have whatever name you want. Here is an example of an eventlistener that will call a function whenever a mage is clicked on. You are commenting using your WordPress. You are commenting using your Google account. You are commenting using your Twitter account. Connect and share knowledge within a single location that is structured and easy to search. Besides the library changes, Actionscript 3 is compiled for and run on a completely different virtual machine AVM2 , which was re-written from the ground up.
It reportedly executes compiled AS3 code up to 10 times faster than code script compiled for the AVM1 virtual machine. You should check out this doc for a list of differences between AS2 and AS3 as they can't be explained any better on SO :. In AS3 you can structure and organise your application a lot more strategically. It's faster, neater and far more recommended than AS2. The main difference is that you can develop flash applications with a much stronger OOP influence than in AS2.
AS3 makes it much easier to utilise third party code such as Greensock's Tweenlite, Papervision 3D and box2d. In AS2 you would have to use prototype to messily achieve what a class can do for you in AS3.
Though there is more code in creating your own class, you can now extend this class and simply call flip from within it to run the flip method. In AS2, you would have to be in the same scope as your MovieClip.
Here's the AS2 and AS3 comparison for creating a MovieClip, adding it to the stage and then making use of your flip function:. However, that most of the AS2 code has direct AS3 equivalents and in the case of timeline code that names are usually the same e. As Flash evolved over the years, so did Actionscript. The latest improvement is the move from AS 2. Rather than simply trying to improve AS 2. The resulting software, though still very similar to AS 2.
Probably the most celebrated change in AS 3. The general perception is that AS 3. Although some may dispute these numbers, all are in agreement that AS 3. Another change in AS 3.
0コメント