To create a custom context menu in Flex 4, fetching the captions from an XML file.
Solution
Custom items in a context menu can be added the same way in Flex 4 as they are in Flex 3 - by declaring your own ContextMenuItem(s) and adding them to your context menu. The ContextMenuItem can be given a caption as well as an event listener. The captions can be fetched from an XML file using HTTPService.
I want a TextArea with a prompt string that displays when the TextArea first displays, automatically disappears when user clicks in the TextArea and reappears if the user clicks outside the TextArea without entering anything.
Solution
Create a custom MXML component as shown in the details.
I'm trying to get a random number between 1-3 to return non-repeating 3 times. There are 3 spaces and 3 variables that are to be placed and i need the order to be selected at random each time they are called. I'm thinking a non-repeating random number generator between the range of 1-3 would be best, however i do not know how to write a random number generator with a range included within itself.
Solution
This code takes a start and end value (both int) and generates an array. From there it shuffles the array into a random order and returns the shuffled array. This returned array can then be used in a simple for..loop for whatever you need without worrying about repeated values. Just make a call to the function each time you need a new series. This example could be modified to take an array of values instead of a start and end value.
In your AIR Application you want to export data from the connected local SQLite database in SQL syntax to use it in other SQL databases without using a third format like CSV or XML.
Solution
Use the FileReference to create a .sql file which you can use for batch import into another SQL database.
In order to deploy the DSC the most easy way is to have a Workbench installed. But there are also ways to deploy a DSC without having WorkBench by our side. In Java, we do so by the help of LC SDK jars, namely adobe-livecycle.jar and adobe-usermanagement-client.jar. Now, what if we want to deploy a DSC from a FLEX UI on a Livecycle Server, running somewhere remote, let say by the click of a button on an AIR App. But in Flex we can't use SDK jars, hence the creation of ServiceClientFacory is impossible.
Solution
Flex exposes remoting endpoint which can be used to communicate with LiveCycle via LCDS. The adobe-remoting-provider.swc whihc is used to facilitate the communication, can be found at the LiveCycle installed location, \\Adobe LiveCycle ES2\LiveCycle_ES_SDK\misc\DataServices\Client-Libraries.
When you develop applications inside the Flash IDE you can see all the trace output inside Trace panel of IDE. However, there are lots of cases when you need to test your applications in browser and not as a standalone application. This makes impossible reading trace output and makes debugging your applications hard.
Solution
To see trace output outside the Flash IDE you need external application. In this article we will use applications called Vizzy.
I'm trying to get a random number between 1-3 to return non-repeating 3 times. There are 3 spaces and 3 variables that are to be placed and i need the order to be selected at random each time they are called. I'm thinking a non-repeating random number generator between the range of 1-3 would be best, however i do not know how to write a random number generator with a range included within itself.
Solution
This code takes a start and end value (both int) and generates an array. From there it shuffles the array into a random order and returns the shuffled array. This returned array can then be used in a simple for..loop for whatever you need without worrying about repeated values. Just make a call to the function each time you need a new series. This example could be modified to take an array of values instead of a start and end value.
What if you are creating an application that compile size matters and you want to use JSON strings to get data into your application. JSON stands for JavaScript object notation, it is a more condense data format then XML and is able to define different types of data not just Strings. You can use the Adobe Core Lib classes to parse this information but these classes add a little extra weight to your application and in some apps this isn't ok but there is another way.
Solution
Because JSON is just a subset of JavaScript objects ExternalInterface can just send these objects as Strings to JavaScript within your browser and the JavaScript interpreter will send an ActionScript Object back to you with the correct types. I have also noticed that this information is parsed faster and more reliably then the standard version but remember that this is only helps you with decoding. If you would like to create a JSON string from an Object you will have to use something else.
Sometimes when you develop your flash project there's a need to make a final test before you upload swf to the website. The most convenient way for that is to launch your application locally inside a web browser rather then pressing Test Movie in Flash IDE to make sure everything works as expected. You open your project in a browser window and it loads but does not work.
Solution
To analyze possible failure reason you need a trace tool that will show you debug content of flash player. When application works by running in Flash IDE and does not work in a browser then most probably this is a security sandbox violation.
Placing DisplayObjects (eg. MovieClips and Sprites) in a grid can be cumbersome. You can keep a counter for the current column number and every time it reaches the maximum amount of columns reset it to zero and at the same time increase the row number. Then after a calculation you get the right coordinates.
Solution
By using the integer counter of the loop with the modulus and divider operands, you can make a much faster solution which, if you know what it does, is actually more maintainable and more legible than using two separate counters.
This site is produced in partnership with
O'Reilly.