Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Using the SpinnerList component

From: Flex 4.6 and AIR 3.0 New Features for Mobile Apps

Video: Using the SpinnerList component

The SpinnerList control displays a list of items that wraps around an animated wheel. The item in the center is always the selected item. The list can be spun by upward and downward throws, or by dragging up or down to select items, or the end user can simply click to choose an item. This component must be placed inside of the SpinnerList container, and this provides the chrome and layout for the component. Now, the SpinnerList also uses an item renderer and other typical Flex conventions.

Using the SpinnerList component

The SpinnerList control displays a list of items that wraps around an animated wheel. The item in the center is always the selected item. The list can be spun by upward and downward throws, or by dragging up or down to select items, or the end user can simply click to choose an item. This component must be placed inside of the SpinnerList container, and this provides the chrome and layout for the component. Now, the SpinnerList also uses an item renderer and other typical Flex conventions.

So let's explore how to use this. First thing I'm going to do is just create a brand-new Flex mobile project, and let's just call this project SpinnerList. Okay, you can choose whatever location you like. This doesn't have any dependencies. We'll use the Flex 4.6 SDK. Let's create a blank application here instead of a view-based, and we won't target the BlackBerry tablet OS for now. We'll say Next. We just leave all the defaults here and then just go ahead and click Finish. Okay.

And here's our SpinnerList application. And let's just add in a layout so we're controlling this in a vertical fashion. So, I'm just going to say s:layout, and I'm going to create a VerticalLayout, instantiate that right there, like we've done earlier, and then I'm going to simply just say paddingTop is equal to 40 pixels. We'll say the paddingBottom, well let's add in a buffer of 5 pixels and then for the paddingLeft, I'll also add in a buffer of 5 pixels there. And then the paddingRight, again 5 pixels, gap is equal to 10 pixels, and then the horizontalAlign is equal to center, and then the verticalAlign is equal to the top there, just like so. Close that.

Make sure your layout tag is closed of course. And now let's add in a SpinnerList control. So, here I'm just going to say spark and I'll say SpinnerList. First of all, let's add a SpinnerListContainer like you see there, and let's make this width is equal to, let's make our SpinnerListControl 200 pixels, just like so. And then inside of the SpinnerListContainer just place a SpinnerList. So, here I'm going to simply say s:SpinnerList, and then I'll say width is equal to 100%, like so. And then I'll specify the dataProvider and then inside of that-- and make sure, I forgot to put in my spark namespace, that'll cause me some problems, so make sure you put in your spark namespace, just like so.

Make sure I close that. Sorry! Adding in the wrong place there. So, there's my spark dataProvider, and then create an ArrayCollection inside of that dataProvider, just like so. And then let's use our code snippet to avoid the typing. So, I'm going to go back to my Exercise Files up here. I'm going to go to my code snippets. I can utilize the same code snippet, the rtf here, and I will just simply copy that and I'll just simply go back to Flash Builder and paste that right back in there.

Make sure that your last fx string is closed off. And then you have your list of different devices, just to save yourself some typing. Now, we should able to see these displayed inside of the SpinnerList. So, here I'm going to simply hit Save, and then I'm going to set up my run configuration here. I'll say Mobile Application, again Apple iOS. Let's do the iPad, and I'll click on Run. We should see our new SpinnerList container, and look at that. So, you can see the new SpinnerList container with the items that we had selected.

Now, the SpinnerList control itself works like almost every other Flex component you've already worked with and have learned about in all of the lynda.com courses. If we are displaying complex data, we can use a label field or a label function to display the properties in the complex data structure, instead of the simple strings that we're utilizing in this example. We can also access any items that the user has selected via the selected index and the selected items properties. Again, these are all covered in the basic lynda.com courses. We can also place multiple spinner applications inside of a single spinner container and we can simply just copy and paste here.

So, for example, if I just go over here and I take my SpinnerList here, I can place multiple SpinnerLists here. I'll just copy this SpinnerList and I'll place it inside of the container. There you'll see that. And let's just make sure that I set this, the width here, I'm going to set this to, say, 400 pixels. And let's make this take up half of the screen size real estate, and I'll set this up here.

So I hit Save. And then you'll see now I will have multiple SpinnerList controls, just like so, that take up that amount of real estate. And you can also add style tags directly to your SpinnerList controls as well, just like a normal Flex component. So for example, if I go up here and I add in a style tag, I can use CSS classes to customize my controls. So for example, I'll say fx:Style, just like so.

So, you'll see there right, I have my namespace there, and let's reference my spinner. So here I'll just say spark and I'll simply say SpinnerListItemRenderer, just, like so. And then I'll just define my CSS class here, and I can put my paddingTop. We'll say, :15. I can define colors, fonts, all this, and then we'll say paddingBottom.

Don't need the equal sign there, of course. So, I'll say paddingBottom. Let's define 15 again, and I'll say paddingLeft:15, and then I'll define paddingRight:15, just like so. So, there's my SpinnerLlist. I'll click on Save, and let's go ahead and just test that. You should see that this is now applied to our spinner controls, right, and you'll notice of course, we now have the spinning.

We now have the padding inside of both of the spinning controls, because we applied it directly to that class that affects all of the spinning components. So again, the SpinnerList provides a very familiar interface for tablet users and really utilizes design patterns that have been established in tablet applications.

Show transcript

This video is part of

Image for Flex 4.6 and AIR 3.0 New Features for Mobile Apps
Flex 4.6 and AIR 3.0 New Features for Mobile Apps

21 video lessons · 4305 viewers

James Talbot
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Flex 4.6 and AIR 3.0 New Features for Mobile Apps.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.