ThinkDigit Home
Subscribe to the Newsletter
Search
 
SKOAR!       / SHOPPING
 
 
News / Features / Downloads / Channel 5
 
 
Creating an image gallery app with Flash Builder 4 in 10 steps
 
Posted by
Kshitij Sobti
3
565
Posted on: Jul 01, 2010 22:17:13 IST

 
 
 

Creating the Flex Gallery

Our Flex application needs only to load this XML file and use the list of images from it to populate the gallery. Simple! The execution is even simpler. For the most part this can be done entirely in declarative code. What this means is that we can do most of the coding in MXML – which is similar to XML / HTML. Declarative programming means that we simply declare all the user interface elements, and define some relations and the application works as expected instead of actually coding everything. You can read up on our previous article at thinkdigit.com/www.thinkdigit.com/d/adobefc for a better idea.

In fact, a functional gallery – which simply displays thumbnails – can be created entirely in declerative MXML code, the only ActionScript code we will require is for popping up the image when we click on its thumbnail in the gallery, and even that is minimal.

STEP 1: First of all you will need to create a new Flash Builder project. You can create either a Web project for viewing in your browser with the Flash plugin, or you can create Desktop project which will run in Adobe AIR. We are creating a Desktop project, however since we are not using any desktop specific features, you can use the same code for a Web project.

Create a new Desktop or Web project.

 

STEP 2: From the folder where you have exported the gallery to Flex, copy all the files and folders – there should be an index.xml file, and an images and thumbnails folder – to the “src” folder in you Flex project. Your Flex project will probably be in C:Users<username>Adobe Flash Builder 4<project name> (or C:Users<username>Adobe Flash Builder 4 Plug-in<project name> if you have the Flash Builder Eclipse plugin installed). You can also drag and drop these files into the Package Explorer view in Flash Builder.

STEP 3: First of all we need to load the XML index into our application. We do this using the XML tag in MXML. Add the following inside the <fx:Declarations> tag:

<fx:XML  id="indexXML"  source="index.xml"  />

 

Here we are declaring an XML object called indexXML, and using the file “index.xml” as a source. For our list image gallery though we will need a list of all images from this.

STEP 4: We will now extract a list of all images from this XML file. With support for E4X in ActionScript and Flex, this is very simple.

We have our XML object indexXML, we can directly access the “images” tag inside this as: indexXML.images

If we needed to access the album name we could simply access it as: indexXML.albumName

If we access indexXML.images.image it will return a list of all image elements inside the images tag. We can directly pull this into an XMLListCollection, which can be directly used in the list we will add in the next step. Add the code which follows inside the <fx:Declarations> after the indexXML declaration:

<s:XMLListCollection  id="index"  source="{indexXML.images.image}"  />

This will enable us to access a list of all images in the indexXML via the “index” object.

< Previous
  |  
Next >
 
To discuss this article visit its forum entry here

 






 
 
 
Latest Features
 
 
 
 
Comments 3comments
 
Posted by Frinnaravease on Dec 17,2011
 
Today, considering the Canada Goose Jacket fast life-style that everyone is having, credit cards have a big demand in the economy. Persons throughout every arena are using the credit card and people who not using the credit cards have lined up to apply for one in particular. Thanks for sharing your ideas about credit cards. In these days of austerity and relative stress and anxiety about having debt, some people balk contrary to the idea of making use of a credit card to make acquisition of merchandise and also pay for a holiday, preferring, instead just to rely on the actual tried along with trusted way of making payment - raw cash. However, if you possess the cash on hand to make the purchase fully, then, paradoxically, that is the best time for them to use the card for several motives. One thing is that often one of the most typical incentives for making use of your cards is a cash-back or rebate supply. Generally, you'll get 1-5% back for various purchases. Depending on the credit cards, you may get 1% back again on most expenses, and 5% in return on expenditures made from convenience stores, gas stations, grocery stores and also 'member merchants'. Thanks for these guidelines. One thing I should also believe is that often credit cards supplying a 0% rate often entice consumers along with zero rate, instant authorization and easy internet balance transfers, however beware of the main factor that may void your own 0% easy neighborhood annual percentage rate as well as throw you out into the bad house quickly. Thanks for your concepts. One thing we have noticed is banks in addition to financial institutions have in mind the spending patterns of consumers as well as understand that most of the people max outside their cards around the vacations. They properly take advantage of this Canada Goose Jacket fact and start flooding your inbox and snail-mail box along with hundreds of Zero APR card offers shortly when the holiday season closes. Knowing that when you are like 98% of the American public, you'll leap at the one opportunity to consolidate personal credit card debt and switch balances to 0 apr interest rates credit cards.
 
Posted by Fusswipsper on Dec 15,2011
 
Thanks for the ideas timberland shoes you have shared here. In addition, I believe there are numerous factors that keep your car insurance policy premium lower. One is, to consider buying autos that are inside the good set of car insurance businesses. Cars that happen to be expensive tend to be more at risk of being lost. Aside from that insurance is also depending on the value of your automobile, so the more costly it is, then higher the particular premium you pay. I have observed that car insurance organizations know the automobiles which are susceptible to accidents along with other risks. Additionally they know what type of cars are susceptible to higher risk plus the higher risk they've already the higher the premium charge. Understanding the straightforward basics connected with car insurance will let you choose the right kind of insurance policy timberland boots uk that will take care of your needs in case you become involved in an accident. Many thanks for sharing the particular ideas with your blog. Thanks alot : ) for your post. I would really like to say that the expense of car insurance varies greatly from one insurance plan to another, simply because there are so many different issues which give rise to the overall cost. One example is, the make and model of the motor vehicle will have a significant bearing on the price tag. A reliable old family car will have a lower priced premium compared to a flashy sports vehicle. Thanks for the several tips provided on this website. I have observed that many insurance firms offer timberland boots customers generous savings if they favor to insure several cars with them. A significant quantity of households have several cars these days, especially those with more aged teenage young children still residing at home, plus the savings upon policies can certainly soon begin. So it makes sense to look for a great deal. One thing I'd like to say is that car insurance cancelling is a horrible experience and if you're doing the right things being a driver you'll not get one. Some people do get the notice that they have been officially dumped by their own insurance company and many have to scramble to get added insurance from a cancellation. Inexpensive auto insurance rates are usually hard to get after the cancellation. Understanding the main reasons concerning the auto insurance canceling can help motorists prevent completely losing in one of the most crucial privileges out there. Thanks for the tips shared by means of your blog.
 
Posted by Josh on Jul 29,2010
 
I'm on step 5, just trying to get xml data to display in my list. Nothing appears. I don't know how to tell that my app is properly connecting/seeing/pulling from my xml file. Do I need to create a data service? If so an XML or HTTP service? I notice you have not yet your list still pulls the data from the xml file
 
 



 
 

 
 
 
 
Newsletter Subscription
 
 
 
 
 
 
 
 
 
 
 
 
 
 
http://devworks.thinkdigit.com