Set in a material way interactive and engaging event with a plan:
1 2 3 4 5 6 7 8
| BitmapAssetMaterial = new BitmapAssetMaterial ( "foto1" ) ; var mymaterial: BitmapAssetMaterial BitmapAssetMaterial = new ("photo1"); ; mymaterial. interactive = true; Plane = new Plane ( my_material , 200 , 100 , 0 , 0 ) ; var myplane: Plane = new Plane (my_material, 200, 100, 0, 0); ( InteractiveScene3DEvent . OBJECT_PRESS , myplane. addEventListener (InteractiveScene3DEvent. OBJECT_PRESS, e : InteractiveScene3DEvent ) : void { function (e: InteractiveScene3DEvent): void { / / Todo } ); |
Continued ...
per capire quando il nostro MovieClip è disegnato effettivamente sulla stage: As we have seen several times in the constructor of a class that extends MovieClip may be necessary to add the event ADDED_TO_STAGE to understand when our MovieClip is actually drawn on the Stage:
Continued ...
In Actionscript 3.0 you must use addEventListener() to intercept any event:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| / ** * Given a MovieClip mc, you set events and handlers * / ( MouseEvent . CLICK , on_click ) ; mc. addEventListener ( MouseEvent . CLICK, on_click); ( MouseEvent . ROLL_OVER , on_roll_over ) ; mc. addEventListener ( MouseEvent . ROLL_OVER, on_roll_over); ( MouseEvent . ROLL_OUT , on_roll_out ) ; mc. addEventListener ( MouseEvent . ROLL_OUT, on_roll_out); / ** * Functions hander for the above events * / e : MouseEvent ) : void { on_click function (e: MouseEvent ): void { / / Click } e : MouseEvent ) : void { on_roll_over function (e: MouseEvent ): void { / / Roll over } e : MouseEvent ) : void { on_roll_out function (e: MouseEvent ): void { / / Roll-out } |
Continued ...
I draw inspiration by the excellent tutorial Napolux , Flex 3, Adobe AIR and the API Feedburner , which shows how to write a simple application (or widgets) using Flex 3 Adobe AIR, to show how to accomplish the same thing using Adobe Flash CS3. If you wish, and you can also use the extension for creating Adobe AIR applications. It is not necessary for the purposes of this tutorial, complete the application as an AIR executable, you can use the proposed code as a simple Flash movie to be "affixed" to your Web pages
Continued ...
I had already spoken in Flash CS3: The new event handling . I'll be back on the issue sublists for the difference of this new approach compared to previous versions of ActionScript. Schematically we have a general situation of this type:

Any object that supports events, ultimately exposing itself the addEventListener (). In the documentation, among other things, we read:
What's new for event listeners in ActionScript 3.0
[...] To add event listeners in ActionScript 2.0 is sometimes uses addListener () and sometimes addEventListener (), whereas in ActionScript 3.0 using addEventListener () in all situations.
[..]
Event management, then, is standardized at the level of real listeners. All the "features" of listening, in fact, have the following structure:
1 2 3
| eventObject : EventType ) : void { eventResponse function (eventObject: EventType): void { / / The actions in response to the events are defined here. } |
o una sua sottoclasse. EvenType is always an object of class Event or a subclass. . This allows for more informations specific to the particular event in addition to handling standard properties such as target or currentTarget .
An important difference with previous versions of ActionScript, with respect to the listener, is that:
In ActionScript 2.0, event listeners can be either functions, methods or objects, whereas in ActionScript 3.0, event listeners can be only functions or methods.
In short, having used for some 'time to event structure from earlier versions of Flash, I must say that this new approach is really nice. It's a bit 'that development with Actionscript 3.0 and, after a small initial loss (just to regain what was taken for granted) now I can not understand how could I bear the "old" method of the events of the previous versions.
Continued ...
Finally with ActionScript 3.0 no longer have two different management of events as they did before ActionScript 2.0 (see: Event management: similarities between Flash and Javascript ). The method addEventListener() , ubiquitous in the new architecture allows to manage new and exceptionally clean all possible events, even personal ones. The new organization in the package allows you to import the events that we serve and treat everyone equally:
Continued ...
One of the strengths of Adobe Flash lies in the choice of the ECMAScript (ECMA-products - E uropean C omputer A ssociation anufacturers M) as the standard scripting. ActionScript and JavaScript, in fact, both stem from a higher standard as they are extremely similar. This is one of the reasons for which many ActionScript programmers develop very easily in JavaScript and vice versa.
ActionScript has always had a management "double" of events that often has confused some developers. In MovieClip, for example, you can set an event by simply declaring a function to the properties of the event, for example:
Method 1
1 2 3
| ( ) { mio_mc. onRelease = function () { "Click sul MovieClip" ) ; trace ("Click on the MovieClip"); } |
Other objects, in contrast, require a different handling of the event that you want to monitor, requiring the classical listener, an object designed for this task. For example, the Mouse object can be controlled in this way:
Method 2
1 2 3 4 5
| Object = new Obejct ( ) ; MouseListener var: Object = new Obejct (); ( ) { MouseListener. onMouseMove = function () { "Mouse in moto" ) ; trace ("Mouse in motion"); } addListener ( mouseListener ) ; Mouse . addListener (MouseListener); |
The components have a further variant, as the Loader component:
Method 3
1 2 3 4 5
| Object = new Object ( ) ; loaderListener var: Object = new Object (); = function ( evt : Object ) { loaderListener. complete = function (evt: Object ) { "Caricamento completato" ) ; trace ("Upload completed"); }; ( "complete" , loaderListener ) ; myLoader_ldr. addEventListener ("complete", loaderListener); |
Why these differences? The reason, indeed, is very simple. Method 1, the most immediate, is used when the event to "intercept" is unique, that is when it makes no sense to "take" several functions one after all ' other. Methods 2 and 3, however, create the "lists" of "listeners" and are extremely useful and powerful because they allow you to attach virtually infinite number of functions to a particular event.
The same thing happens in JavaScript and can be seen in libraries as a prototype . The convenient observe () method, available from the event, allows you to fit a function to an event object. For example:
1
| window , 'load' , function ( ) { alert ( "Finestra caricata" ) ; } ) ; Event. Observe (window, 'load', function () {alert ("Window loaded");}); |
In this case we have attached our function that displays an alert to the load event of the window object. We could only repeat the statement and attach additional event:
1 2
| window , 'load' , function ( ) { alert ( "Finestra caricata - 1" ) ; } ) ; Event. Observe (window, 'load', function () {alert ("Window loaded - 1");}); window , 'load' , function ( ) { alert ( "Finestra caricata - 2" ) ; } ) ; Event. Observe (window, 'load', function () {alert ("Window loaded - 2");}); |
This feature, also common in ActionScript, it is extremely versatile, especially in JavaScript, is the key to the creation of many "widgets" and extensions (see the classic snap ) now proliferating on the Web The ability to tag along, in fact , for events that are already controlled by other functions, can be non-intrusive (Unobtrusive) and then, in practice, to add functions to those already present.
Continued ...
Latest Comments
Robert : I rispsoto your questions with pleasure. The idea is really great. I am looking for a solution ...
Sting : @ Darius - you can see an example here: http://www.fight4fun.it/ clicking on: MAPS I hope ...
vik : Giustappunto I'm working on a project and the client asked me to show all the news (which are CPT) in ...
Giovambattista Fazioli : @ paso: absolutely. Simply identifying the field [cci] input [/ cci] you want to ...
paso : Hello I would like to request a service, you can use the datepicker with cform7 I spiegp best I can implement ...