守望者--AIR技术交流

标题: IOS解压缩ANE工具 [打印本页]

作者: 破晓    时间: 2015-1-22 11:47
标题: IOS解压缩ANE工具
Native Utils - iOS Air Native Extension

author: Paweł Meller

This extension currently provides access to:

Settings Bundle


docs on developer.apple.com

Usage:

  1. //Add Settings.bundle (yes, on windows it is a directory) to your application and include it in building options
  2. if(NativeUtils.isSupported)
  3. {
  4.     var nativeUtils:NativeUtils=new NativeUtils();
  5. //you should alwas load defaults before accesing the values, this will not override any values, that are already set
  6. //if you don't load the defaults the application may crash when trying to access a value, that was not set
  7.     nativeUtils.settings.loadSettingsDefaults();
  8. //if you want to retrieve a string:
  9.     var mySetting:String=nativeUtils.settings.getStringValue("settingKeyFromBundle");
  10. //if you want to retrieve a number:
  11.     var mySetting:Number=nativeUtils.settings.getNumberValue("settingKeyFromBundle");
  12. //if you want to retrieve an int:
  13.     var mySetting:Int=nativeUtils.settings.getIntValue("settingKeyFromBundle");
  14. //if you want to retrieve a Boolean:
  15.     var mySetting:Number=nativeUtils.settings.getBooleanValue("settingKeyFromBundle");
  16. //you can also set the values by using
  17.     nativeUtils.settings.setStringValue("settingKeyFromBundle","my value");
  18.     nativeUtils.settings.setNumberValue("settingKeyFromBundle",.52);
  19.     nativeUtils.settings.setIntValue("settingKeyFromBundle",134);
  20.     nativeUtils.settings.setBooleanValue("settingKeyFromBundle",true);
  21. //in iOS >5 synchronize should be called automatically, but you can also do this manually to commit the changes
  22.     nativeUtils.settings.synchronize()
  23. }
复制代码
UnzipA simple unzipping function - had to do this, because all of the zip libraries for as3 that i found had problems with unpacking large files on iPad 1 source: githubUsage:
  1. var _nativeUtils:NativeUtils;
  2. if(NativeUtils.isSupported)
  3. {
  4. if(!_nativeUtils)
  5. _nativeUtils=new NativeUtils();
  6. _nativeUtils.addEventListener(NativeUtilsZipEvent.PROGRESS,unpackProgress);
  7. _nativeUtils.addEventListener(NativeUtilsZipEvent.COMPLETE,unpackComplete);
  8. _nativeUtils.unzipFile(path,File.applicationStorageDirectory.nativePath);
  9. }
复制代码

Progress And Complete:
  1. //Event Listeners:
  2. private function unpackProgress(e:NativeUtilsZipEvent)
  3. {
  4. //gives progress of unzipping (0-100)
  5. trace(e.percentage);
  6. }
  7. private function unpackComplete(e:NativeUtilsZipEvent):void
  8. {
  9. _nativeUtils.removeEventListener(NativeUtilsZipEvent.PROGRESS,unpackProgress);
  10. _nativeUtils.removeEventListener(NativeUtilsZipEvent.COMPLETE,unpackComplete);
  11. }
复制代码
Ever wanted to do trace on iOS without connecting to debugger? Now you can, install a system console (i'm using this one) and see every trace from your application.Usage:
  1. var nativeUtils:NativeUtils=new NativeUtils();
  2. nativeUtils.nslog("Your message");
复制代码

[attach]581[/attach]相关链接:https://github.com/memeller/iOSNativeUtilities






欢迎光临 守望者--AIR技术交流 (http://www.airmyth.com/)