Archive for the 'ActionScript' Category

28
Aug

Creating a component instance by class name in ActionScript 3.0

The following example shows how you can create a new Flex component instance by using its class name by calling the getDefintionByName() method.

Full code after the jump.

Continue reading ‘Creating a component instance by class name in ActionScript 3.0′

28
Aug

Parsing XML nodes and Objects with dashes in their names in ActionScript 3.0

The following example shows how you can parse an XML node with a dash in its node name (<font-family />) as well as parsing an Object with a dash in it’s identifier using the square bracket notation ([]).

Full code after the jump.

Continue reading ‘Parsing XML nodes and Objects with dashes in their names in ActionScript 3.0′

27
Aug

Using a clipboard menu in Flex with Flash Player 10

The following example shows how you can set a clipboard menu and specify custom clipboard items on a context menu by setting the contextMenu and clipboardItems properties.

Full code after the jump.

Continue reading ‘Using a clipboard menu in Flex with Flash Player 10′

26
Aug

Adding a link to context menu in Flash Player 10

The following example shows how you can add a custom link to a context menu in Flex Gumbo and Flash Player 10 by setting the link and contextMenu properties.

Full code after the jump.

Continue reading ‘Adding a link to context menu in Flash Player 10′

23
Aug

Setting the node indentation level when calling the toXMLString() method in ActionScript 3.0

The following example shows how you can set the amount of indentation used when calling the toXMLString() method by setting the static XML.prettyIndent property in ActionScript.

Full code after the jump.

Continue reading ‘Setting the node indentation level when calling the toXMLString() method in ActionScript 3.0′

22
Aug

Ignoring comments in an XML file in ActionScript 3.0

The following example shows how you can ignore comment tags (<!-- … -->) in an XML document by setting the static XML.ignoreComments property.

Full code after the jump.

Continue reading ‘Ignoring comments in an XML file in ActionScript 3.0′

22
Aug

Determining the XML class’s settings in ActionScript 3.0

The following example shows how you can get the XML class’s current settings by calling the static XML.settings() method.

Full code after the jump.

Continue reading ‘Determining the XML class’s settings in ActionScript 3.0′

20
Aug

Determining if an item is listening for a specific event

The following example shows how you can check whether a Flex Button control is listening for a specific event (FlexEvent.BUTTON_DOWN) by using the hasEventListener() and willTrigger() methods.

According to the Flex 3 documentation for the EventDispatcher class’s hasEventListener() method (link):

The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter.

Full code after the jump.

Continue reading ‘Determining if an item is listening for a specific event’

13
Jun

Looping over an Array using the every() method in Flex

The following example shows how you can loop over an Array in ActionScript 3.0 using the Array class’s every() method.

Full code after the jump.

Continue reading ‘Looping over an Array using the every() method in Flex’

21
Apr

Looping over each item in an Array in ActionScript 3.0

The following example shows how you can loop over an Array object and modify items using the Array class’s forEach() method.

Full code after the jump.

Continue reading ‘Looping over each item in an Array in ActionScript 3.0′

07
Apr

Skewing an Image control in Flex

The following example shows how you can skew a Flex Image control vertically and horizontally using the Transform and Matrix classes.

Full code after the jump.

Continue reading ‘Skewing an Image control in Flex’

11
Mar

Returning values from JavaScript in your Flex applications using the ExternalInterface API

In a previous example, “Calling JavaScript functions from your Flex applications using the ExternalInterface API”, we saw how we could call JavaScript functions from our Flex application.

The following example shows us how we can return a value from a JavaScript function call and use the data in our Flex application.

Full code after the jump.

Continue reading ‘Returning values from JavaScript in your Flex applications using the ExternalInterface API’

11
Mar

Calling ActionScript functions from your HTML templates using the ExternalInterface API

In a previous example, “Calling JavaScript functions from your Flex applications using the ExternalInterface API”, we saw how you could call JavaScript methods from our Flex applications using the static ExternalInterface.call() method.

The following example shows you how you can call ActionScript methods in our Flex applications from JavaScript using the static ExternalInterface.addCallback() method and a bit of JavaScript.

Full code after the jump.

Continue reading ‘Calling ActionScript functions from your HTML templates using the ExternalInterface API’

10
Mar

Checking to see if the ExternalInterface API is available in Flex

The following example shows how you can check to see whether your Flex application is in a container that supports the ExternalInterface API.

Full code after the jump.

Continue reading ‘Checking to see if the ExternalInterface API is available in Flex’

09
Mar

Calling JavaScript functions from your Flex applications using the ExternalInterface API

The following example shows how you can call a JavaScript function from your Flex applications using the ExternalInterface class and the static ExternalInterface.call() method.

Full code after the jump.

Continue reading ‘Calling JavaScript functions from your Flex applications using the ExternalInterface API’