Preventing the default auto orientation from happening
Fair enough Ben, you know how to listen in on the event but what if you really don't want your device to rotate at all you want it to do something else or have a custom change that you control on your own. That's our next step so hold your horses and join us as we talk about how you can prevent the default way of action so you can control it on your own.
Video Transcript
00:00All right, so the first step that we want to do is we want to stop the default orientation
00:04from happening.
00:05And again, I don't know how stable the Debugger launcher application is going to be when you're
00:09running your app.
00:11So make sure that you ought to run it on a real application to see how it actually
00:14works on a real application.
00:16So again, I'm going to go into my ActionScript and I'm going to just find my changing orientation.
00:21And what I want to do is I want to go into my changing and I want to prevent the default
00:26from happening.
00:27To do that, I just have to call the preventDefault method.
00:30And by doing that, I'm basically terminating the actual orientation change that was going
00:36to happen.
00:37Now, if I wanted to do that, and I basically save that and I click on Debug and I debug
00:42my moving using the Adobe launcher, again, it's going to reload the application, it's
00:47going to take it a few seconds until it's ready.
00:49Once our launcher is ready, we'll try to orient it.
00:52So again, I'm going to go right here, click on the auto orient, and I'm going to try
00:56to rotate.
00:57And notice how when we're rotating our application, we'll see that it's changing, but it is changing
01:03even though we asked it not to change at all, right?
01:06Contrary to that, if we would go to our application and actually test the application directly
01:11reopen, if we go to our application and we debug our application directly with our
01:17USB, once we configured to prevent the default from happening, it actually will work.
01:23So we're just going to give it a second here to load up.
01:31And again, so now that it's running, our default is going to be prevented, but you won't
01:35be able to see us, I'm going to disconnect the cable again, and let you see it just
01:39live here for a second.
01:40So you see how when I change my orientation, it's not going to change.
01:44So it's really, really important when you're actually doing your testing and debugging
01:48and really when you really want to try to prevent things to double check and make
01:52sure that you're always testing it on a real device.
01:55It's so, so critical.
01:56Okay, so I'm going to comment that out because actually, I don't mind the default
02:01from happening.
02:01I don't mind my screen rotating because I actually want it to rotate.
02:05But what I do want to do is I want to go into it and continue modifying whenever
02:10the changing is done.
02:13So I'm going to leave that and I'm not going to change the default.
02:15I'm going to comment it out, enabling you to do that.
02:18In the next video, what we're going to do is we're going to go into the element
02:21that changed and maybe go and resize it and reposition it based on the change
02:25that has just occurred.
02:27All right, so let's do that in the next video.
