00:00
00:00
Newgrounds Background Image Theme

DegasTyson54 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS3: Flex: MXML Event

126 Views | 0 Replies
New Topic Respond to this Topic

AS3: Flex: MXML Event

----------------------

AS3: Main

----------------------

Note: this is intended for those who are already well versed in AS3 code


I think every one of you wanted to add event binding to objects without addEventListener, maybe let's create a start file:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
        <![CDATA[

        ]]>
    </fx:Script>
</s:Application>

Now let’s add a regular button and add a MouseEvent for clicking on it:

<s:Button label="click me" click="trace('click!!!')"/>

as you can see that MXML Events are set thanks to attributes, in a button the click attribute is responsible for, and for example buttonDown is responsible for clicking on the button, but buttonUp does not exist, but in general there are a lot of attributes

iu_1159721_9946875.png

There are attributes for almost all MXML elements, for example initialize which every object has, also the same for add and and remove, they also give access to functions similar to HTML such as:

<s:TextInput text="focus me" focusIn="trace('focus!!!')"/>

as you can see, when you click on TextInput, focusing occurs, you can focus in many different ways, as an example, pressing the TAB button switches to other TextInputs. If you are an application developer, then this must be taken into account, because not all people have a bear and Mouse cursor


to find all MXML Events you need to go to https://flex.apache.org/asdoc/ and find any element there, after you go to Events in the element’s documentation and expand you will see almost all the elements, but don’t forget that that some may not be written, such as click


Summary

today you learned about Events in MXML, how they are created and their number, also how to find out which Events are in which


That's all for now, thanks for your attention, this is made for AS3 Main: Tutorials and Resources