Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I avoid a VerifyError when testing code using mobile-specific classes in AIR/AS3?
    primarykey
    data
    text
    <p>I'm an experienced AS3 developer doing AIR development for the first time in order to create an iPhone app. I'm trying to account for variable device orientations using the StageOrientationEvent and related classes, and I'm getting a VerifyError when trying to test on a desktop machine, presumably because orientation-related classes are mobile-device specific.</p> <p>The Adobe docs for the iPhone packager imply that it's possible to test an app containing mobile-specific code, as long as you use flags like Stage.supportsOrientationChange to test for capabilities before actually using them. Unfortunately, it seems like AIR is checking for unacceptable classes at startup, so the check is useless.</p> <p>How can I test this app on the desktop without commenting out mobile-specific code every time I switch devices?</p> <p>The relevant code:</p> <pre><code>package { import flash.display.Sprite; import flash.display.Stage; import flash.display.StageAlign; import flash.display.StageOrientation; import flash.display.StageScaleMode; import flash.events.Event; import flash.events.StageOrientationEvent; public class Main extends Sprite { public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); if (Stage.supportsOrientationChange) { stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, onOrientationChange); } } private function onOrientationChange(event:StageOrientationEvent):void { switch (event.afterOrientation) { case StageOrientation.DEFAULT: //ignore. Landscape. break; case StageOrientation.ROTATED_RIGHT: stage.setOrientation(StageOrientation.ROTATED_RIGHT); break; case StageOrientation.ROTATED_LEFT: stage.setOrientation(StageOrientation.ROTATED_LEFT); break; case StageOrientation.UPSIDE_DOWN: //ignore. Landscape. break; } } } } </code></pre> <p>And the error I get: </p> <pre><code>[Fault] exception, information=VerifyError: Error #1014: Class flash.events::StageOrientationEvent could not be found. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload