Start learning with our library of video tutorials taught by experts. Get started

Flex 4.6 and AIR 3.0 New Features for Mobile Apps
Illustration by Don Barnett

Controlling view hierarchy


From:

Flex 4.6 and AIR 3.0 New Features for Mobile Apps

with James Talbot

Video: Controlling view hierarchy

We're going to explore a little bit more about the SplitViewNavigator. So I'm starting where we left off in the last movie, and as you remember, when I run the application, the SplitViewNavigator that we created earlier, this is perfect for landscape mode. So you will see when I actually do a run configuration and I test this on a mobile application, okay, we are going to of course test this on an iPad, so I am going to say Apple iOS, I am going to say iPad, and you should see that I have my Apple iPad here.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
Flex 4.6 and AIR 3.0 New Features for Mobile Apps
1h 49m Intermediate Jan 30, 2012

Viewers: in countries Watching now:

Join James Talbot, as he reviews the new features in Adobe Flex, Flash Builder, and AIR for mobile application developers. This course covers the Spark components for building mobile user interfaces in the Flex SDK, and the AIR support for native extensions, which enable applications to use parts of the host operating systems that were previously unavailable. The course also describes new testing and network monitoring capabilities available with Flash Builder 4.6, and the ability for Android applications to be deployed without relying on a separate runtime.

Topics include:
  • Controlling adaptable tablet layouts
  • Controlling view hierarchy
  • Using 16-bit and 32-bit render modes
  • Using the Date Picker, Scroller, and List components
  • Adding a splash screen to a mobile app
  • Using native extensions for iOS and Android
  • Testing with FlexUnit on Wi-Fi
  • Packaging the application for release
Subjects:
Developer Mobile Apps
Software:
AIR Flash Builder Flex
Author:
James Talbot

Controlling view hierarchy

We're going to explore a little bit more about the SplitViewNavigator. So I'm starting where we left off in the last movie, and as you remember, when I run the application, the SplitViewNavigator that we created earlier, this is perfect for landscape mode. So you will see when I actually do a run configuration and I test this on a mobile application, okay, we are going to of course test this on an iPad, so I am going to say Apple iOS, I am going to say iPad, and you should see that I have my Apple iPad here.

I click here and the information is displayed in the Detail view. This works perfectly in landscape mode. Now, what happens if the end user rotates the device and goes into portrait mode? We need to worry about this as developers. So there are a couple things that we can do to make our lives much easier. The first thing we can do is you can add a layout tag directly to the SplitViewNavigator. So for example, just like you can add a layout tag to your application, I can just simply say s:layout and I can instantiate a VerticalLayout instance right there, and this will lay out my application vertically.

Now this isn't going to give me the exact results that I want. So here I am going to hit Save, and watch what happens. You'll see that it's handling it if it's in vertical mode, but this is not exactly what we want it to look like to the end user, right? If you are trying to view your email in portrait mode, this is not how you want this to look. So you can see the Detail view at the bottom, and you can see it up here, but there's all this dead real estate space here, and this is not exactly what we want and how we want this to work. So let's make some modification, because we have much less screen width to work with.

The first thing we can do is if the user goes into portrait mode, we can automatically have it hide this left view. So there's a property here on our SplitViewNavigator simply called autoHideFirstViewNavigator, which in this case is our leftNav, and if we just set this to true, it'll automatically hide that. So let's do that, and now watch what happens when you we are still in vertical layout mode or in portrait mode, as you see, but then you'll see that it automatically takes up the appropriate amount of real estate and it puts it into Detail view. But of course, we don't have our list of devices anymore.

So that's not what we want to happen either, but again, you'll see that it automatically does this when it receives an orientation to portrait mode. Of course this could be sent automatically by the application as well, but we are just doing this for testing purposes. So there's no way to actually navigate to a different item in our list. So what might be better, if we go to portrait mode, and this is just a technique, but we might want to have our list of devices actually pop out into a popout when the user actually clicks on a button, for example.

So this again is just a technique, but can be very useful for tablet-based applications and is an accepted design pattern in developing tablet-based applications. So let's go ahead and try to do that. So what I am going to do is I am going to go back to my ViewNavigator here and I am just going to get rid of my closing tag and I am going to add in a navigation content onto my second ViewNavigator. So I will add in the navigationContent property that you see there, and let's put a button in here.

So here I will just say s:Button, just like so, and I will assign it an id, and let's call this listButton, and then I'll say the label is equal to List of Devices or whatever you like. Here I will just say List of Devices, and then I will say click, and we are going to reference our SplitViewNavigator, so I will say svn, right, that's my id. And then I will just say svn and we will utilize this method here called showFirstViewNavigatorInPopUp, like so. Then we will reference our listButton that we just created the id for, and that will pop open this leftNav in a navigation control when the user clicks on this button that says, "List of Devices." So, let's close off our button tag--don't forget your end quote there--just like so, close off your navigation tag, and then don't forget to close off the ViewNavigator tag as well, just like so. That will close off your ViewNavigator tag up at the top.

So now let's explore what that does. So note we are still in of course VerticalLayout, so we are still in portrait mode. So this is how it's going to look when we are in portrait mode on the tablet. Okay, you will see the list of devices. There's our Detail view. Now we pop that out and that really sort of maximizes our real estate. So I can click here and you can see that that pops that out when the user wanted to, by clicking on that button and gives just a great result there. Now, we probably don't want this button to appear when we go back into landscape mode, so, for example, if the user rotates the tablet to the other direction. So what we want to do is we will add some States management and we will set this button visibility to false when we go back to landscape mode.

So one way to determine how to update the state is to add a resize event, and remember, we saw this in the first video, but this is a practical application of how we can build applications designed specifically for tablets, utilizing the Flex framework. So we are going to add a resize event handler, and we are going to check the width and height, and then we'll update the state accordingly. So here I am going to close this off. I am going to go back to my application up here. And just like we did earlier, I'm going to add in a resize event. So I will say resize, and then I will generate my resizeHandler.

You will see it automatically creates this method stub, just like we learned before, right, it creates this application1 resizeHandler. And now I want to find out if I do happen to switch back to landscape mode. So again, this is going to be called every time the application resizes, which happens of course when the user moves the tablet in different directions. So here I am going to say if the width is greater than the height, which means of course, we are back into landscape mode, so I am going to say if width is greater than height, like so, I'm going to simply say this.currentState is equal to landscape, just like so. Close that.

Then we will add in an else statement, and then I'll say this.currentState is equal to portrait. And then that would put it into the portrait state and we could utilize those different techniques. So again, this is just an example, and of course, I'd have to go through and create the different states, but you saw how to do that in the first video in this series. And this is just a great way of actually being able to really adapt and adapt the SplitViewNavigator directly to either landscape or portrait mode on the device.

There are currently no FAQs about Flex 4.6 and AIR 3.0 New Features for Mobile Apps.

 
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.

Upgrade to download 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.
Upgrade now


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 Upgrade now

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 preferencesfrom 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.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

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.