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.
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.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.