Eric Jacobsson
Eric Jacobsson

Reputation: 39

AS3 iOS prevent "animated" orientation change

I am working in flash CS5.5 on an app for iOS. I want to get the ipad/iphone to stop animating the orientationChange and just change it directly, is this possible?

I thought this was a solution but it didnt help AS3 - iOS force landscape mode only?.

Upvotes: 0

Views: 1422

Answers (2)

john.k.doe
john.k.doe

Reputation: 7563

have you tried the SO answer: Disable orienation change rotation animation ?

the code from that answer that goes in the view-controller that is the home for your flash CS5.5 or air 3.5 is:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    [UIView setAnimationsEnabled:YES];
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    [UIView setAnimationsEnabled:NO];

    return TRUE;  /* Your original orientation booleans, in case you prevent one of the orientations */
}

that code makes use of native iOS UIViewController functions that can be overridden. you would have to have a native iOS objective C class that overrides UIViewController, and then you could insert the code above. calls are made when the device is rotated to these as part of view controller life cycle.

Upvotes: 2

James Tomasino
James Tomasino

Reputation: 3581

If you try setting Stage.autoOrients = false;, the flash.events.StageOrientationEvent.ORIENTATION_CHANGE will never fire. That's helpful for disabling orientation changes altogether, but not for your issue. While I haven't tried it myself, you may be able to listen to the event:

flash.events.StageOrientationEvent.ORIENTATION_CHANGING

You may be able to call event.preventDefault() in that listener to stop the actual rotation from occuring. Then you can manually set it yourself:

Stage.setOrientation(StageOrientation.ROTATED_RIGHT);

Upvotes: 3

Related Questions