iphoneRotateInterface command in mobile apps

Colin Holgate coiin at verizon.net
Wed Oct 6 10:06:23 EDT 2010

On Oct 6, 2010, at 9:21 AM, paolo mazza wrote:

> I have to'inform you that opening a mobile application in the iPad the
> platform is "iPhone" so
> In our Rev_mobile applications we have to' write
> if the environment is "iPhone" then
>  iphoneRotateInterface "landscape left"
> end if

The iPhone simulator reports "mobile", so you could do this to take care of both cases:

   if the environment is "iPhone" or the environment is "mobile" then
      iphoneRotateInterface "landscape left"
   end if

Is there an orientation change event that we can use, or can we read the current orientation? Really, you would not use the above line if the user happens to be holding the iPad in "landscape right" at the time. That would be enough to get an App rejected by Apple.

Here's the logic I'm using in Flash, for an App that needs to be in landscape:

var startOrientation:String=stage.orientation;
if (startOrientation=="default"||startOrientation=="upsideDown") {
} else {

So, if the device is in either portrait, then I use "landscape left" (which in Flash terms mean that the stage needs to be rotated right). If the device is already landscape, then I set the stage to match the current orientation, allowing a "landscape right" kinda person to carry on working like they want to.

In Flash there is also a change event, and on the change event you can prevent portrait if you want to. My routine looks like this:

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChangeListener);
function orientationChangeListener(e:StageOrientationEvent) {
   if (e.afterOrientation=="default"||e.afterOrientation=="upsideDown") {

In Flash things are usually passed on, so there's no need to do the equivalent of a pass for the system to go ahead and do the orientation change, the preventDefault will stop the change before it happens.

LiveCode needs to have the same abilities as Flash does for handling orientation.

More information about the Use-livecode mailing list