02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Enabling auto orientation with Adobe AIR

Everything we will be working on in this title is going to work for all mobile devices there not specific per device but per capabilities. We will start by seeing again how to configure and publish your application. In part one we go in detail into the steps involved when creating your application using Adobe AIR.

Our first step before we can start coding is we need to configure our application to listen into the orientation events. By default our application when we create it will only work in one mode but wouldn't auto-orient at all! We first need to change the configurations and enable our application to auto configure. So the first step in our training will be to setup and prepare our application to be enabled to auto-rotate. Once in the debugger we are not done yet we will need to enable orientation in the debugger as well. Once we follow all these steps our application will automatically auto-orient its content every time we move our device.

Video Transcript

00:00Welcome welcome welcome welcome welcome. So we're going to talk about in this video about orientation
00:05And why is that important when you're working with your mobile device?
00:08It really depends on its orientation and you want to know how to configure if it's going to be portrait or landscape
00:14Or if you want it to automatically be both now by default
00:19Adobe air when you when you and set it up and configure it will only work in portrait
00:25Now if you choose if you choose iOS or Android doesn't really matter the default is portrait now the way you change that
00:33Configuration is you have two methods of doing that and I want to show you both the methods
00:38so let me show you first that how it actually looks like if we look at our source files for a second and
00:44In our source files you'll note that as soon as we created an application
00:48We'll have also an XML file if you open up that XML file
00:53You'll see that the file itself basically has description and information of the application itself
00:58You'll note also that this description and information is actually also if you go in your file again and go into your flash
01:06file
01:07Air 3.6 for Android setting or whatever version of air you're in and by the way if you're working if you don't see
01:14This just make sure that you watch our first course on
01:17Androids on air in general so you'll know how to get to these configurations based on your version of flash
01:24So I'm going to go right ahead into the air 3.6 for Android setting now you might be working on iOS
01:29But same implies if you're working on iOS now notice the aspect ratio in our general tab in the general tab
01:37You'll see that our default is portrait
01:39But we could set it also to be landscape and we could also send it to auto now
01:44Only if we set it to auto does the auto orientation actually work the the audio orientation actually has events that are triggered
01:52They will not be triggered at all if you don't figure both set the auto orientation to get that information
01:58And to set your aspect ratio to be out automatically configured if you don't do that
02:04You're not even going to get the event so that's really really important
02:07So make sure that you go into your aspect ratio and set it to be auto and your auto
02:12Orientation and set it to be a plus on it as well configure it all right, and we're going to click on okay
02:18Once we do that and we click on to publish our application, and I'm going to debug it in our
02:24Launcher in our air launcher, so I'm going to click on debug movie and then in air debug launcher so that we rebuild to see oh
02:33First of all we don't have any action script
02:35So it's telling giving us an error a silly error telling us that there's nothing to debug which is true
02:40So instead of debugging we're going to go into our control
02:42Test movie, and we're going to make sure that we're going to test it in the air debug launcher
02:47Alright as soon as we add some code. We'll be able to start debugging it so notice how our application first of all
02:52It's in an auto orient now if I bring my
02:56My simulator around and I actually come here and I start moving it around
03:01You'll see that first of all in the simulator itself
03:04You're not seeing anything
03:05But it actually will work if you take it into a device the reason is is because you have to go into your
03:11Configurations in the simulator as well and click on auto orientation if you don't do that then it's not going to configure it now
03:19The reason for it is simple although the application is capable of listening to our audio orientation
03:24The device itself needs to enable it if you don't set that device itself to enable it
03:30Then you won't see it so and it's same same applies for your application on your phone
03:34so make sure that you're actually your configuration and your phone is set to be out of
03:39Auto-orient because of it
03:40It's not then flash won't be able to recognize it air won't be able to recognize it either and make sure that application itself is published
03:47with the auto orientation
03:49configurations
03:49Capable of being in portrait or landscape and not either because if there are one of the two it would again not trigger anything
03:56So now that we set our auto configuration
03:59We could then go back and start rotating our z-axis and notice when we rotate our z-axis. We're
04:05Automatically or
04:08auto-orienting our application

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!