|
Here are some useful codes if you are programming ios applications in Flash CS 5.5 or Flex. Basicly it's my own as3 library of code. Feel free to use these.
|
|
function fl_evennumber(numero:int):Boolean { return (numero % 2 != 0); }
Usage: var xx= fl_evennumber(4); trace (xx) returns true or false |
|
import flash.system.Capabilities; import flash.display.StageOrientation; var startOrientation:String = stage.orientation; if (startOrientation == StageOrientation.DEFAULT || startOrientation == StageOrientation.UPSIDE_DOWN) {stage.setOrientation(StageOrientation.ROTATED_RIGHT);} else {stage.setOrientation(startOrientation);} stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChangeListener); function orientationChangeListener(e:StageOrientationEvent) {if (e.afterOrientation == StageOrientation.DEFAULT || e.afterOrientation == StageOrientation.UPSIDE_DOWN) {e.preventDefault();}} |
|
var_x = randomNumber(1,100); // generates a number between 1 and 100 function randomNumber(low, high):Number {return Math.floor(Math.random() * (1+high-low)) + low;} Adress movieClip by name, dynamical: this["mc" + variableX].alpha = 0; this["mc" + variableX].addEventListener(MouseEvent.CLICK, fl_function); |
|
var timerat:Timer = new Timer(3000,0); // Interval 3 seconds, loop forever timerat.addEventListener(TimerEvent.TIMER, fl_timer); timerat.start(); function fl_timer(event:TimerEvent):void { var flipperanim:Tween = new Tween(Object(this).mc,"alpha",Strong.easeOut,0,1,2,true); } |
|
import flash.system.Capabilities; import flash.display.StageQuality; var scrsize = String(flash.system.Capabilities.screenResolutionY); var camera = String(flash.system.Capabilities.hasVideoEncoder); var masterString:String = String(flash.system.Capabilities.os); masterString = String(masterString.indexOf("iPad1")); if (masterString!="-1") {stage.quality = StageQuality.LOW; // It’s an iPad1! } |
|
iOS adds a glare effect to the icon. You do not need to apply the effect to your source image. To remove this default glare effect, add the following to the InfoAdditions element in the application descriptor(xml) file:
<InfoAdditions> <![CDATA[ <key>UIPrerenderedIcon</key> <true/> ]]> </InfoAdditions> |
|
clearAll();
function clearAll():void { while (mc.numChildren>0) {mc.removeChildAt(0);} removeChild(mc); System.gc(); // Garbage collection SoundMixer.stopAll(); // Stop all sounds } |
|
var watersong:Aquatrip; var sndChannel:SoundChannel; watersong=new Aquatrip(); sndChannel = watersong.play(); |
|
import flash.display.StageQuality; stage.quality = StageQuality.LOW; stage.quality = StageQuality.MEDIUM; stage.quality = StageQuality.HIGH; stage.quality = StageQuality.BEST; |
|
|
|
|