├── .gitignore ├── LICENSE ├── NOTICE ├── README.md ├── actionscript └── src │ └── com │ └── freshplanet │ └── ane │ └── AirDatePicker │ └── AirDatePicker.as ├── android ├── AndroidManifest.xml ├── libs │ ├── FlashRuntimeExtensions.jar │ └── android-support-v4.jar └── src │ └── com │ └── freshplanet │ └── datePicker │ ├── DatePickerActivity.java │ ├── Extension.java │ ├── ExtensionContext.java │ └── functions │ ├── AirDatePickerDisplayDatePicker.java │ ├── AirDatePickerRemoveDatePicker.java │ ├── ClearMaxDateFunction.java │ ├── ClearMinDateFunction.java │ ├── SetMaxDateFunction.java │ └── SetMinDateFunction.java ├── bin ├── AirDatePicker.ane └── AirDatePicker_noSupportClasses.ane ├── build ├── build.xml ├── example.build.config ├── extension.xml └── platform.xml └── ios ├── AirDatePicker.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── AirDatePicker ├── AirDatePicker-Prefix.pch ├── AirDatePicker.h ├── AirDatePicker.m └── FlashRuntimeExtensions.h /.gitignore: -------------------------------------------------------------------------------- 1 | # General 2 | temp 3 | build.config 4 | 5 | # Flash Builder 6 | actionscript/bin 7 | .actionScriptProperties 8 | .flexLibProperties 9 | 10 | # Eclipse 11 | .settings 12 | .project 13 | 14 | # Android 15 | android/bin 16 | android/gen 17 | android/res 18 | android/lint.xml 19 | .classpath 20 | proguard-project.txt 21 | project.properties 22 | 23 | # Xcode 24 | xcuserdata 25 | 26 | # OS X 27 | Icon 28 | Thumbs.db 29 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Freshplanet (http://freshplanet.com | opensource@freshplanet.com) 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Air Native Extension for Date Picker (iOS + Android) 2 | ====================================== 3 | 4 | This is an [Air native extension](http://www.adobe.com/devnet/air/native-extensions-for-air.html) for using native date pickers on iOS and Android. It has been developed by [FreshPlanet](http://freshplanet.com). 5 | 6 | 7 | Installation 8 | --------- 9 | 10 | The ANE binary (AirAlert.ane) is located in the *bin* folder. You should add it to your application project's Build Path and make sure to package it with your app (more information [here](http://help.adobe.com/en_US/air/build/WS597e5dadb9cc1e0253f7d2fc1311b491071-8000.html)). 11 | 12 | 13 | Usage 14 | ----- 15 | 16 | If you are going to be targeting Android, add the DatePickerActivity to your AIR application configuration file: 17 | 18 | ```xml 19 | 20 | 21 | ``` 22 | 23 | ```actionscript 24 | // Required params 25 | var currentDate : Date = new Date(); 26 | var callback : Function = function( selectedDate:String ) : void { 27 | trace("selected date = ", selectedDate.toString()); 28 | } 29 | // Native extension call 30 | AirDatePicker.instance.displayDatePicker(currentDate, callback); 31 | ``` 32 | For iPad you can define custom positioning of the picker. 33 | 34 | For more information, please look at the Actionscript documentation in [AirDatePicker.as](https://github.com/freshplanet/ANE-DatePicker/blob/master/actionscript/src/com/freshplanet/ane/AirDatePicker/AirDatePicker.as). 35 | 36 | 37 | Build script 38 | --------- 39 | 40 | Should you need to edit the extension source code and/or recompile it, you will find an ant build script (build.xml) in the *build* folder: 41 | 42 | cd /path/to/the/ane/build 43 | mv example.build.config build.config 44 | #edit the build.config file to provide your machine-specific paths 45 | ant 46 | 47 | 48 | Authors 49 | ------ 50 | 51 | This ANE has been written by [Daniel Rodriguez](http://www.linkedin.com/in/danielrodriguezc/). It belongs to [FreshPlanet Inc.](http://freshplanet.com) and is distributed under the [Apache Licence, version 2.0](http://www.apache.org/licenses/LICENSE-2.0). 52 | 53 | 54 | 55 | Join the FreshPlanet team - GAME DEVELOPMENT in NYC 56 | ------ 57 | 58 | We are expanding our mobile engineering teams. 59 | 60 | FreshPlanet is a NYC based mobile game development firm and we are looking for senior engineers to lead the development initiatives for one or more of our games/apps. We work in small teams (6-9) who have total product control. These teams consist of mobile engineers, UI/UX designers and product experts. 61 | 62 | 63 | Please contact Tom Cassidy (tcassidy@freshplanet.com) or apply at http://freshplanet.com/jobs/ 64 | -------------------------------------------------------------------------------- /actionscript/src/com/freshplanet/ane/AirDatePicker/AirDatePicker.as: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2012 Freshplanet (http://freshplanet.com | opensource@freshplanet.com) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | ////////////////////////////////////////////////////////////////////////////////////// 18 | 19 | package com.freshplanet.ane.AirDatePicker 20 | { 21 | import flash.events.EventDispatcher; 22 | import flash.events.StatusEvent; 23 | import flash.external.ExtensionContext; 24 | import flash.geom.Rectangle; 25 | import flash.system.Capabilities; 26 | 27 | public class AirDatePicker extends EventDispatcher 28 | { 29 | // --------------------------------------------------------------------------------------// 30 | // // 31 | // PUBLIC API // 32 | // // 33 | // --------------------------------------------------------------------------------------// 34 | 35 | public static const EVENT_CHANGE:String = "CHANGE"; 36 | public static const EVENT_UPDATE:String = "UPDATE"; 37 | 38 | private var _minimumDate:Date; 39 | private var _maximumDate:Date; 40 | 41 | /** AirDatePicker is supported on iOS and Android devices. */ 42 | public static function get isSupported() : Boolean 43 | { 44 | return Capabilities.manufacturer.indexOf("iOS") != -1 || Capabilities.manufacturer.indexOf("Android") != -1; 45 | } 46 | 47 | public function AirDatePicker() 48 | { 49 | if (!_instance) 50 | { 51 | _context = ExtensionContext.createExtensionContext(EXTENSION_ID, null); 52 | if (!_context) 53 | { 54 | throw Error("ERROR - Extension context is null. Please check if extension.xml is setup correctly."); 55 | return; 56 | } 57 | _context.addEventListener(StatusEvent.STATUS, onStatus); 58 | 59 | _instance = this; 60 | } 61 | else 62 | { 63 | throw Error("This is a singleton, use getInstance(), do not call the constructor directly."); 64 | } 65 | } 66 | 67 | public static function getInstance() : AirDatePicker 68 | { 69 | return _instance ? _instance : new AirDatePicker(); 70 | } 71 | 72 | 73 | /** 74 | * Display a Date (month, day, year) picker, using a Native implementation.

75 | * 76 | * For Apple devices we rely on the iOS SDK's UIDatePicker. For Android, we rely on a DialogFragment 77 | * containing a custom DatePickerDialog.

78 | * 79 | * Android devices should define the DatePickerActivity's theme as @android:style/Theme.Holo.Dialog to 80 | * present the Activity as a true Dialog.

81 | * 82 | * @param date An AS3 Date object used to show a certain date by default in the picker. 83 | * @param callback A callback function of the folllowing form: 84 | * function myCallback( selectedDate : String ): void. The selectedDate parameter 85 | * will contain the selected date in the following format: yyyy-mm-dd 86 | * @param anchor (optional) On the iPad, the UIDatePicker is displayed in a popover that 87 | * doesn't cover the whole screen. This parameter is the anchor from which the 88 | * popover will be presented. For example, it could be the bounds of the button 89 | * on which the user clicked to display the image picker. Note that you should 90 | * use absolute stage coordinates. Example: var anchor:Rectangle = 91 | * myButton.getBounds(stage); 92 | * 93 | * @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Date.html 94 | * @see http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDatePicker_Class/Reference/UIDatePicker.html 95 | * @see http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPopoverController_class/Reference/Reference.html 96 | * @see http://developer.android.com/reference/android/app/DatePickerDialog.html 97 | * @see http://developer.android.com/guide/topics/ui/controls/pickers.html 98 | * @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Date.html 99 | * 100 | **/ 101 | public function displayDatePicker( date : Date, callback : Function, anchor : Rectangle = null ) : void 102 | { 103 | if (!isSupported) return; 104 | 105 | _callback = callback; 106 | 107 | var month : Number = date.month + 1; // as3 date: january[0], ..., december[11] 108 | 109 | if (anchor != null) 110 | { 111 | _context.call("AirDatePickerDisplayDatePicker", date.fullYear.toString(), month.toString(), date.date.toString(), anchor); 112 | } 113 | else 114 | { 115 | _context.call("AirDatePickerDisplayDatePicker", date.fullYear.toString(), month.toString(), date.date.toString()); 116 | } 117 | } 118 | 119 | public function setMinimumDate( date:Date ) : void 120 | { 121 | if(date) { 122 | _context.call("setMinimumDate", date.time); 123 | } else { 124 | _context.call("clearMinimumDate"); 125 | } 126 | } 127 | 128 | 129 | public function setMaximumDate( date:Date ) : void 130 | { 131 | if(date) { 132 | _context.call("setMaximumDate", date.time); 133 | } else { 134 | _context.call("clearMaximumDate"); 135 | } 136 | } 137 | 138 | public function clearMaximumDate() : void 139 | { 140 | _context.call("clearMinimumDate"); 141 | } 142 | 143 | /** Dismisses the DatePicker from the screen. */ 144 | public function removeDatePicker( ) : void 145 | { 146 | if (!isSupported) return; 147 | 148 | _context.call("AirDatePickerRemoveDatePicker"); 149 | } 150 | 151 | 152 | // --------------------------------------------------------------------------------------// 153 | // // 154 | // PRIVATE API // 155 | // // 156 | // --------------------------------------------------------------------------------------// 157 | 158 | private static const EXTENSION_ID : String = "com.freshplanet.AirDatePicker"; 159 | 160 | private static var _instance : AirDatePicker; 161 | 162 | private var _context : ExtensionContext; 163 | 164 | private var _callback : Function = null; 165 | 166 | 167 | private function onStatus( event : StatusEvent ) : void 168 | { 169 | if (event.code == EVENT_CHANGE) 170 | { 171 | if (_callback !== null) 172 | { 173 | var newDate : String = event.level as String; 174 | trace("[AirDatePicker] new date from Native Extension : ",newDate); 175 | _callback(newDate); 176 | } 177 | else 178 | { 179 | trace("Error: There is no callback, cannot return the picked date"); 180 | } 181 | } 182 | if(this.hasEventListener(StatusEvent.STATUS)) 183 | { 184 | this.dispatchEvent(event); 185 | } 186 | } 187 | } 188 | } -------------------------------------------------------------------------------- /android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/libs/FlashRuntimeExtensions.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freshplanet/ANE-DatePicker/23cf991f1c1dcbec5265b8117bc24567b2bbd713/android/libs/FlashRuntimeExtensions.jar -------------------------------------------------------------------------------- /android/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freshplanet/ANE-DatePicker/23cf991f1c1dcbec5265b8117bc24567b2bbd713/android/libs/android-support-v4.jar -------------------------------------------------------------------------------- /android/src/com/freshplanet/datePicker/DatePickerActivity.java: -------------------------------------------------------------------------------- 1 | package com.freshplanet.datePicker; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Calendar; 5 | import java.util.GregorianCalendar; 6 | 7 | import android.app.DatePickerDialog; 8 | import android.app.Dialog; 9 | import android.content.Context; 10 | import android.os.Bundle; 11 | import android.support.v4.app.DialogFragment; 12 | import android.support.v4.app.FragmentActivity; 13 | import android.util.Log; 14 | import android.view.Window; 15 | import android.widget.DatePicker; 16 | 17 | public class DatePickerActivity extends FragmentActivity 18 | { 19 | private static final String TAG = "[AirDatePicker] - DatePickerActivity"; 20 | 21 | public static final String YEAR = "year"; 22 | public static final String MONTH = "month"; 23 | public static final String DAY = "day"; 24 | 25 | public static final String MIN_DATE = "minDate"; 26 | public static final String MAX_DATE = "maxDate"; 27 | 28 | /** Every Activity invoked by the Native Extension. Allows us to kill everything. */ 29 | private static ArrayList activities = new ArrayList(); 30 | 31 | 32 | /** Our picker. */ 33 | private DialogFragment datePickerFragment; 34 | 35 | //-----------------------------------------------------// 36 | // ACTIVITY API 37 | //-----------------------------------------------------// 38 | 39 | @Override 40 | protected void onCreate(Bundle savedInstanceState) 41 | { 42 | Log.d(TAG, "Entering onCreate"); 43 | 44 | super.onCreate(savedInstanceState); 45 | 46 | this.requestWindowFeature(Window.FEATURE_NO_TITLE); 47 | 48 | activities.add(this); 49 | 50 | Bundle extras = this.getIntent().getExtras(); 51 | Bundle args = new Bundle(); 52 | 53 | args.putInt(YEAR, extras.getInt(YEAR)); 54 | args.putInt(MONTH, extras.getInt(MONTH)); 55 | args.putInt(DAY, extras.getInt(DAY)); 56 | 57 | if(extras.containsKey(MIN_DATE)) { 58 | args.putLong(MIN_DATE, extras.getLong(MIN_DATE)); 59 | } 60 | 61 | if(extras.containsKey(MAX_DATE)) { 62 | args.putLong(MAX_DATE, extras.getLong(MAX_DATE)); 63 | } 64 | 65 | datePickerFragment = new DatePickerFragment(); 66 | datePickerFragment.setArguments(args); 67 | datePickerFragment.show(getSupportFragmentManager(), "datePicker"); 68 | 69 | Log.d(TAG, "Exiting onCreate"); 70 | } 71 | 72 | @Override 73 | public void onDestroy() 74 | { 75 | Log.d(TAG, "Entering onDestroy"); 76 | 77 | super.onDestroy(); 78 | 79 | this.datePickerFragment.dismiss(); 80 | 81 | activities.remove(this); 82 | 83 | Log.d(TAG, "Exiting onDestroy"); 84 | } 85 | 86 | //-----------------------------------------------------// 87 | // DISPOSE LOGIC 88 | //-----------------------------------------------------// 89 | 90 | public static void dispose() 91 | { 92 | Log.d(TAG, "Entering dispose"); 93 | 94 | for (DatePickerActivity activity:activities) 95 | { 96 | activity.finish(); 97 | } 98 | 99 | Log.d(TAG, "Exiting dispose"); 100 | } 101 | 102 | //-----------------------------------------------------// 103 | // DIALOG FRAGMENT 104 | //-----------------------------------------------------// 105 | 106 | public static class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener 107 | { 108 | private static final String TAG = "[AirDatePicker] - DatePickerFragment"; 109 | 110 | //-----------------------------------------------------// 111 | // DIALOG CREATION 112 | //-----------------------------------------------------// 113 | 114 | public Dialog onCreateDialog(Bundle savedInstanceState) 115 | { 116 | Log.d(TAG, "Entering onCreateDialog"); 117 | Bundle args = this.getArguments(); 118 | int year = args.getInt(YEAR); 119 | int month = args.getInt(MONTH); 120 | int day = args.getInt(DAY); 121 | 122 | AirDatePickerDialog picker = new AirDatePickerDialog( getActivity(), this, year, month, day); 123 | 124 | if(args.containsKey(MIN_DATE)) { 125 | picker.getDatePicker().setMinDate(args.getLong(MIN_DATE)); 126 | } 127 | 128 | if(args.containsKey(MAX_DATE)) { 129 | picker.getDatePicker().setMaxDate(args.getLong(MAX_DATE)); 130 | } 131 | 132 | if (android.os.Build.VERSION.SDK_INT >= 11) 133 | { 134 | picker.getDatePicker().setCalendarViewShown(false); 135 | } 136 | Log.d(TAG, "Exiting onCreateDialog"); 137 | return picker; 138 | } 139 | 140 | //-----------------------------------------------------// 141 | // DatePickerDialog.OnDateSetListener IMPLEMENTATION 142 | //-----------------------------------------------------// 143 | 144 | public void onDateSet(DatePicker view, int year, int month, int date) 145 | { 146 | Log.d(TAG, "Entering onDateSet"); 147 | 148 | 149 | month = month + 1; // compensate Date representation differences between AS3 and Android 150 | String formattedDate = year + "-" + month + "-" + date; 151 | Extension.context.dispatchStatusEventAsync("CHANGE", formattedDate); 152 | 153 | DatePickerActivity.dispose(); 154 | 155 | Log.d(TAG, "Exiting onDateSet"); 156 | } 157 | 158 | //-----------------------------------------------------// 159 | // CUSTOM DATE PICKER DIALOG 160 | //-----------------------------------------------------// 161 | 162 | /** 163 | * AirDatePickerDialog overrides onDateChanged() and reports every 164 | * date change back to the ActionScript side of the Native Extension 165 | */ 166 | private class AirDatePickerDialog extends DatePickerDialog 167 | { 168 | private static final String TAG = "[AirDatePicker] - MyDatePickerDialog"; 169 | 170 | // There is a bug in the Android API where the dateChange listener is triggered twice. 171 | // This is a workaround for this problem. (store the previous date.) 172 | // 173 | // @see http://stackoverflow.com/questions/12436073/datepicker-ondatechangedlistener-called-twice 174 | private String currentDate = "-1"; 175 | 176 | public AirDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) { 177 | super(context, callBack, year, monthOfYear, dayOfMonth); 178 | } 179 | 180 | @Override 181 | protected void onStop() 182 | { 183 | Log.d(TAG, "Entering onStop"); 184 | 185 | // removes the current stored date 186 | currentDate = "-1"; 187 | 188 | DatePickerActivity.dispose(); 189 | 190 | Log.d(TAG, "Exiting onStop"); 191 | } 192 | 193 | @Override 194 | public void onDateChanged(DatePicker view, int year, int month, int day) 195 | { 196 | Log.d(TAG, "Entering onDateChanged"); 197 | 198 | // Send the new Date back to the AS3 side of the Native Extension 199 | month = month + 1; // compensate Date representation differences between AS3 and Android 200 | String formattedDate = year + "-" + month + "-" + day; 201 | if ( currentDate.equals(formattedDate) == false ) { 202 | currentDate = formattedDate; 203 | Extension.context.dispatchStatusEventAsync("UPDATE", formattedDate); 204 | } 205 | 206 | Log.d(TAG, "Exiting onDateChanged"); 207 | } 208 | }; 209 | 210 | } 211 | 212 | } 213 | -------------------------------------------------------------------------------- /android/src/com/freshplanet/datePicker/Extension.java: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2012 Freshplanet (http://freshplanet.com | opensource@freshplanet.com) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | ////////////////////////////////////////////////////////////////////////////////////// 18 | 19 | package com.freshplanet.datePicker; 20 | 21 | import com.adobe.fre.FREContext; 22 | import com.adobe.fre.FREExtension; 23 | 24 | public class Extension implements FREExtension 25 | { 26 | public static ExtensionContext context; 27 | 28 | public FREContext createContext(String extId) 29 | { 30 | context = new ExtensionContext(); 31 | return context; 32 | } 33 | 34 | public void initialize() { } 35 | 36 | public void dispose() 37 | { 38 | context = null; 39 | } 40 | 41 | public static void log(String message) 42 | { 43 | context.dispatchStatusEventAsync("LOGGING", message); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /android/src/com/freshplanet/datePicker/ExtensionContext.java: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2012 Freshplanet (http://freshplanet.com | opensource@freshplanet.com) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | ////////////////////////////////////////////////////////////////////////////////////// 18 | 19 | package com.freshplanet.datePicker; 20 | 21 | import java.util.Date; 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | import android.content.Intent; 26 | import android.util.Log; 27 | 28 | import com.adobe.fre.FREContext; 29 | import com.adobe.fre.FREFunction; 30 | import com.freshplanet.datePicker.functions.AirDatePickerDisplayDatePicker; 31 | import com.freshplanet.datePicker.functions.AirDatePickerRemoveDatePicker; 32 | import com.freshplanet.datePicker.functions.ClearMaxDateFunction; 33 | import com.freshplanet.datePicker.functions.ClearMinDateFunction; 34 | import com.freshplanet.datePicker.functions.SetMaxDateFunction; 35 | import com.freshplanet.datePicker.functions.SetMinDateFunction; 36 | 37 | public class ExtensionContext extends FREContext 38 | { 39 | private static final String TAG = "[AirDatePicker] - ExtensionContext"; 40 | 41 | private Date minDate; 42 | private Date maxDate; 43 | 44 | // Public API 45 | 46 | @Override 47 | public void dispose() { } 48 | 49 | //-----------------------------------------------------// 50 | // EXTENSION API 51 | //-----------------------------------------------------// 52 | 53 | @Override 54 | public Map getFunctions() 55 | { 56 | Map functionMap = new HashMap(); 57 | 58 | functionMap.put("AirDatePickerDisplayDatePicker", new AirDatePickerDisplayDatePicker()); 59 | functionMap.put("AirDatePickerRemoveDatePicker", new AirDatePickerRemoveDatePicker()); 60 | functionMap.put("setMinimumDate", new SetMinDateFunction()); 61 | functionMap.put("setMaximumDate", new SetMaxDateFunction()); 62 | functionMap.put("clearMinimumDate", new ClearMinDateFunction()); 63 | functionMap.put("clearMaximumDate", new ClearMaxDateFunction()); 64 | return functionMap; 65 | } 66 | 67 | //-----------------------------------------------------// 68 | // DATE PICKER API 69 | //-----------------------------------------------------// 70 | 71 | public void displayDatePicker(int year, int month, int day) 72 | { 73 | Log.d(TAG, "Entering displayDatePicker"); 74 | 75 | Intent displayDatePickerIntent = new Intent(getActivity().getApplicationContext(), DatePickerActivity.class ); 76 | displayDatePickerIntent.putExtra(DatePickerActivity.YEAR, year); 77 | displayDatePickerIntent.putExtra(DatePickerActivity.MONTH, month - 1); // compensates Date difference between AS3 and Android 78 | displayDatePickerIntent.putExtra(DatePickerActivity.DAY, day); 79 | if(minDate != null) { 80 | displayDatePickerIntent.putExtra(DatePickerActivity.MIN_DATE, minDate.getTime()); 81 | } 82 | if(maxDate != null) { 83 | displayDatePickerIntent.putExtra(DatePickerActivity.MAX_DATE, maxDate.getTime()); 84 | } 85 | getActivity().startActivity(displayDatePickerIntent); 86 | 87 | Log.d(TAG, "Exiting displayDatePicker"); 88 | } 89 | 90 | public void removeDatePicker() 91 | { 92 | Log.d(TAG, "Entering removeDatePicker"); 93 | 94 | DatePickerActivity.dispose(); 95 | 96 | Log.d(TAG, "Exiting removeDatePicker"); 97 | } 98 | 99 | 100 | public void setMinDate(Date date) 101 | { 102 | minDate = date; 103 | } 104 | 105 | public void setMaxDate(Date date) 106 | { 107 | maxDate = date; 108 | } 109 | 110 | 111 | } 112 | -------------------------------------------------------------------------------- /android/src/com/freshplanet/datePicker/functions/AirDatePickerDisplayDatePicker.java: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2012 Freshplanet (http://freshplanet.com | opensource@freshplanet.com) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | ////////////////////////////////////////////////////////////////////////////////////// 18 | 19 | package com.freshplanet.datePicker.functions; 20 | 21 | import android.annotation.TargetApi; 22 | import android.util.Log; 23 | 24 | import com.adobe.fre.FREContext; 25 | import com.adobe.fre.FREFunction; 26 | import com.adobe.fre.FREObject; 27 | import com.freshplanet.datePicker.ExtensionContext; 28 | 29 | @TargetApi(14) 30 | public class AirDatePickerDisplayDatePicker implements FREFunction 31 | { 32 | private static final String TAG = "[AirDatePicker] - AirDatePickerDisplayDatePicker"; 33 | 34 | public FREObject call(FREContext context, FREObject[] args) 35 | { 36 | Log.d(TAG, "Entering call"); 37 | 38 | String year = null; 39 | String month = null; 40 | String day = null; 41 | try 42 | { 43 | year = args[0].getAsString(); 44 | month = args[1].getAsString(); 45 | day = args[2].getAsString(); 46 | } 47 | catch (Exception e) 48 | { 49 | e.printStackTrace(); 50 | return null; 51 | } 52 | 53 | ((ExtensionContext) context).displayDatePicker( Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day) ); 54 | 55 | Log.d(TAG, "Exiting call"); 56 | 57 | return null; 58 | } 59 | } -------------------------------------------------------------------------------- /android/src/com/freshplanet/datePicker/functions/AirDatePickerRemoveDatePicker.java: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2012 Freshplanet (http://freshplanet.com | opensource@freshplanet.com) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | ////////////////////////////////////////////////////////////////////////////////////// 18 | 19 | package com.freshplanet.datePicker.functions; 20 | 21 | import com.adobe.fre.FREContext; 22 | import com.adobe.fre.FREFunction; 23 | import com.adobe.fre.FREObject; 24 | import com.freshplanet.datePicker.ExtensionContext; 25 | 26 | public class AirDatePickerRemoveDatePicker implements FREFunction { 27 | 28 | public FREObject call(FREContext context, FREObject[] args) { 29 | 30 | ((ExtensionContext) context).removeDatePicker(); 31 | 32 | return null; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /android/src/com/freshplanet/datePicker/functions/ClearMaxDateFunction.java: -------------------------------------------------------------------------------- 1 | package com.freshplanet.datePicker.functions; 2 | 3 | import com.adobe.fre.FREContext; 4 | import com.adobe.fre.FREFunction; 5 | import com.adobe.fre.FREObject; 6 | import com.freshplanet.datePicker.Extension; 7 | 8 | public class ClearMaxDateFunction implements FREFunction { 9 | 10 | @Override 11 | public FREObject call(FREContext arg0, FREObject[] arg1) { 12 | if(Extension.context != null) { 13 | Extension.context.setMaxDate(null); 14 | } 15 | return null; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /android/src/com/freshplanet/datePicker/functions/ClearMinDateFunction.java: -------------------------------------------------------------------------------- 1 | package com.freshplanet.datePicker.functions; 2 | 3 | import com.adobe.fre.FREContext; 4 | import com.adobe.fre.FREFunction; 5 | import com.adobe.fre.FREObject; 6 | import com.freshplanet.datePicker.Extension; 7 | 8 | public class ClearMinDateFunction implements FREFunction { 9 | 10 | @Override 11 | public FREObject call(FREContext arg0, FREObject[] arg1) { 12 | if (Extension.context != null) { 13 | Extension.context.setMinDate(null); 14 | } 15 | return null; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /android/src/com/freshplanet/datePicker/functions/SetMaxDateFunction.java: -------------------------------------------------------------------------------- 1 | package com.freshplanet.datePicker.functions; 2 | 3 | import java.util.Date; 4 | 5 | import android.util.Log; 6 | 7 | import com.adobe.fre.FREContext; 8 | import com.adobe.fre.FREFunction; 9 | import com.adobe.fre.FREObject; 10 | import com.freshplanet.datePicker.Extension; 11 | 12 | public class SetMaxDateFunction implements FREFunction { 13 | 14 | @Override 15 | public FREObject call(FREContext arg0, FREObject[] arg1) { 16 | // TODO Auto-generated method stub 17 | if ((arg1.length == 1) && Extension.context != null) { 18 | FREObject as3date = arg1[0]; 19 | if(as3date == null) { 20 | Extension.context.setMaxDate(null); 21 | } else { 22 | try { 23 | Extension.context.setMaxDate(new Date((long) as3date.getAsDouble())); 24 | } catch (Exception e) { 25 | Log.e("AirDatePicker", "error in SetMinDateFunction.call", e); 26 | Extension.context.setMaxDate(null); 27 | } 28 | } 29 | } 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /android/src/com/freshplanet/datePicker/functions/SetMinDateFunction.java: -------------------------------------------------------------------------------- 1 | package com.freshplanet.datePicker.functions; 2 | 3 | import java.util.Date; 4 | 5 | import android.util.Log; 6 | 7 | import com.adobe.fre.FREContext; 8 | import com.adobe.fre.FREFunction; 9 | import com.adobe.fre.FREObject; 10 | import com.freshplanet.datePicker.Extension; 11 | 12 | public class SetMinDateFunction implements FREFunction { 13 | 14 | @Override 15 | public FREObject call(FREContext arg0, FREObject[] arg1) { 16 | // TODO Auto-generated method stub 17 | if ((arg1.length == 1) && Extension.context != null) { 18 | FREObject as3date = arg1[0]; 19 | if(as3date == null) { 20 | Extension.context.setMinDate(null); 21 | } else { 22 | try { 23 | Extension.context.setMinDate(new Date((long) as3date.getAsDouble())); 24 | } catch (Exception e) { 25 | Log.e("AirDatePicker", "error in SetMinDateFunction.call", e); 26 | Extension.context.setMinDate(null); 27 | } 28 | } 29 | } 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /bin/AirDatePicker.ane: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freshplanet/ANE-DatePicker/23cf991f1c1dcbec5265b8117bc24567b2bbd713/bin/AirDatePicker.ane -------------------------------------------------------------------------------- /bin/AirDatePicker_noSupportClasses.ane: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freshplanet/ANE-DatePicker/23cf991f1c1dcbec5265b8117bc24567b2bbd713/bin/AirDatePicker_noSupportClasses.ane -------------------------------------------------------------------------------- /build/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /build/example.build.config: -------------------------------------------------------------------------------- 1 | name = AirDatePicker 2 | 3 | includeSupportClasses=true 4 | 5 | flex.sdk = /Applications/Adobe Flash Builder 4.7/sdks/4.6.0/ 6 | 7 | bin.ext = 8 | 9 | ios.sdkversion = iphoneos 10 | 11 | android.sdk = /path/to/your/android-sdk/platforms/android-16 -------------------------------------------------------------------------------- /build/extension.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | com.freshplanet.AirDatePicker 21 | 1.0 22 | 23 | 24 | 25 | libAirDatePicker.a 26 | AirDatePickerInitializer 27 | AirDatePickerFinalizer 28 | 29 | 30 | 31 | 32 | 33 | libAirDatePicker.jar 34 | com.freshplanet.datePicker.Extension 35 | com.freshplanet.datePicker.Extension 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /build/platform.xml: -------------------------------------------------------------------------------- 1 | 2 | 6.0 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ios/AirDatePicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6552214316EE75BF007B3931 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6552214216EE75BF007B3931 /* Foundation.framework */; }; 11 | 6552214816EE75BF007B3931 /* AirDatePicker.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6552214716EE75BF007B3931 /* AirDatePicker.h */; }; 12 | 6552214A16EE75BF007B3931 /* AirDatePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6552214916EE75BF007B3931 /* AirDatePicker.m */; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXCopyFilesBuildPhase section */ 16 | 6552213D16EE75BF007B3931 /* CopyFiles */ = { 17 | isa = PBXCopyFilesBuildPhase; 18 | buildActionMask = 2147483647; 19 | dstPath = "include/${PRODUCT_NAME}"; 20 | dstSubfolderSpec = 16; 21 | files = ( 22 | 6552214816EE75BF007B3931 /* AirDatePicker.h in CopyFiles */, 23 | ); 24 | runOnlyForDeploymentPostprocessing = 0; 25 | }; 26 | /* End PBXCopyFilesBuildPhase section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 6552213F16EE75BF007B3931 /* libAirDatePicker.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAirDatePicker.a; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 6552214216EE75BF007B3931 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 31 | 6552214616EE75BF007B3931 /* AirDatePicker-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AirDatePicker-Prefix.pch"; sourceTree = ""; }; 32 | 6552214716EE75BF007B3931 /* AirDatePicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AirDatePicker.h; sourceTree = ""; }; 33 | 6552214916EE75BF007B3931 /* AirDatePicker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AirDatePicker.m; sourceTree = ""; }; 34 | 65AAF70716EE764E00F5239E /* FlashRuntimeExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FlashRuntimeExtensions.h; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 6552213C16EE75BF007B3931 /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | 6552214316EE75BF007B3931 /* Foundation.framework in Frameworks */, 43 | ); 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | /* End PBXFrameworksBuildPhase section */ 47 | 48 | /* Begin PBXGroup section */ 49 | 6552213616EE75BF007B3931 = { 50 | isa = PBXGroup; 51 | children = ( 52 | 6552214416EE75BF007B3931 /* AirDatePicker */, 53 | 6552214116EE75BF007B3931 /* Frameworks */, 54 | 6552214016EE75BF007B3931 /* Products */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | 6552214016EE75BF007B3931 /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 6552213F16EE75BF007B3931 /* libAirDatePicker.a */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | 6552214116EE75BF007B3931 /* Frameworks */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 6552214216EE75BF007B3931 /* Foundation.framework */, 70 | ); 71 | name = Frameworks; 72 | sourceTree = ""; 73 | }; 74 | 6552214416EE75BF007B3931 /* AirDatePicker */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 6552214716EE75BF007B3931 /* AirDatePicker.h */, 78 | 6552214916EE75BF007B3931 /* AirDatePicker.m */, 79 | 6552214516EE75BF007B3931 /* Supporting Files */, 80 | ); 81 | path = AirDatePicker; 82 | sourceTree = ""; 83 | }; 84 | 6552214516EE75BF007B3931 /* Supporting Files */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 65AAF70716EE764E00F5239E /* FlashRuntimeExtensions.h */, 88 | 6552214616EE75BF007B3931 /* AirDatePicker-Prefix.pch */, 89 | ); 90 | name = "Supporting Files"; 91 | sourceTree = ""; 92 | }; 93 | /* End PBXGroup section */ 94 | 95 | /* Begin PBXNativeTarget section */ 96 | 6552213E16EE75BF007B3931 /* AirDatePicker */ = { 97 | isa = PBXNativeTarget; 98 | buildConfigurationList = 6552214D16EE75BF007B3931 /* Build configuration list for PBXNativeTarget "AirDatePicker" */; 99 | buildPhases = ( 100 | 6552213B16EE75BF007B3931 /* Sources */, 101 | 6552213C16EE75BF007B3931 /* Frameworks */, 102 | 6552213D16EE75BF007B3931 /* CopyFiles */, 103 | ); 104 | buildRules = ( 105 | ); 106 | dependencies = ( 107 | ); 108 | name = AirDatePicker; 109 | productName = AirDatePicker; 110 | productReference = 6552213F16EE75BF007B3931 /* libAirDatePicker.a */; 111 | productType = "com.apple.product-type.library.static"; 112 | }; 113 | /* End PBXNativeTarget section */ 114 | 115 | /* Begin PBXProject section */ 116 | 6552213716EE75BF007B3931 /* Project object */ = { 117 | isa = PBXProject; 118 | attributes = { 119 | LastUpgradeCheck = 0460; 120 | ORGANIZATIONNAME = FreshPlanet; 121 | }; 122 | buildConfigurationList = 6552213A16EE75BF007B3931 /* Build configuration list for PBXProject "AirDatePicker" */; 123 | compatibilityVersion = "Xcode 3.2"; 124 | developmentRegion = English; 125 | hasScannedForEncodings = 0; 126 | knownRegions = ( 127 | en, 128 | ); 129 | mainGroup = 6552213616EE75BF007B3931; 130 | productRefGroup = 6552214016EE75BF007B3931 /* Products */; 131 | projectDirPath = ""; 132 | projectRoot = ""; 133 | targets = ( 134 | 6552213E16EE75BF007B3931 /* AirDatePicker */, 135 | ); 136 | }; 137 | /* End PBXProject section */ 138 | 139 | /* Begin PBXSourcesBuildPhase section */ 140 | 6552213B16EE75BF007B3931 /* Sources */ = { 141 | isa = PBXSourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | 6552214A16EE75BF007B3931 /* AirDatePicker.m in Sources */, 145 | ); 146 | runOnlyForDeploymentPostprocessing = 0; 147 | }; 148 | /* End PBXSourcesBuildPhase section */ 149 | 150 | /* Begin XCBuildConfiguration section */ 151 | 6552214B16EE75BF007B3931 /* Debug */ = { 152 | isa = XCBuildConfiguration; 153 | buildSettings = { 154 | ALWAYS_SEARCH_USER_PATHS = NO; 155 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 156 | CLANG_CXX_LIBRARY = "libc++"; 157 | CLANG_ENABLE_OBJC_ARC = YES; 158 | CLANG_WARN_CONSTANT_CONVERSION = YES; 159 | CLANG_WARN_EMPTY_BODY = YES; 160 | CLANG_WARN_ENUM_CONVERSION = YES; 161 | CLANG_WARN_INT_CONVERSION = YES; 162 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 163 | COPY_PHASE_STRIP = NO; 164 | GCC_C_LANGUAGE_STANDARD = gnu99; 165 | GCC_DYNAMIC_NO_PIC = NO; 166 | GCC_OPTIMIZATION_LEVEL = 0; 167 | GCC_PREPROCESSOR_DEFINITIONS = ( 168 | "DEBUG=1", 169 | "$(inherited)", 170 | ); 171 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 172 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 173 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 174 | GCC_WARN_UNUSED_VARIABLE = YES; 175 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 176 | ONLY_ACTIVE_ARCH = YES; 177 | SDKROOT = iphoneos; 178 | }; 179 | name = Debug; 180 | }; 181 | 6552214C16EE75BF007B3931 /* Release */ = { 182 | isa = XCBuildConfiguration; 183 | buildSettings = { 184 | ALWAYS_SEARCH_USER_PATHS = NO; 185 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 186 | CLANG_CXX_LIBRARY = "libc++"; 187 | CLANG_ENABLE_OBJC_ARC = YES; 188 | CLANG_WARN_CONSTANT_CONVERSION = YES; 189 | CLANG_WARN_EMPTY_BODY = YES; 190 | CLANG_WARN_ENUM_CONVERSION = YES; 191 | CLANG_WARN_INT_CONVERSION = YES; 192 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 193 | COPY_PHASE_STRIP = YES; 194 | GCC_C_LANGUAGE_STANDARD = gnu99; 195 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 196 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 197 | GCC_WARN_UNUSED_VARIABLE = YES; 198 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 199 | SDKROOT = iphoneos; 200 | VALIDATE_PRODUCT = YES; 201 | }; 202 | name = Release; 203 | }; 204 | 6552214E16EE75BF007B3931 /* Debug */ = { 205 | isa = XCBuildConfiguration; 206 | buildSettings = { 207 | DSTROOT = /tmp/AirDatePicker.dst; 208 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 209 | GCC_PREFIX_HEADER = "AirDatePicker/AirDatePicker-Prefix.pch"; 210 | OTHER_LDFLAGS = "-ObjC"; 211 | PRODUCT_NAME = "$(TARGET_NAME)"; 212 | SKIP_INSTALL = YES; 213 | }; 214 | name = Debug; 215 | }; 216 | 6552214F16EE75BF007B3931 /* Release */ = { 217 | isa = XCBuildConfiguration; 218 | buildSettings = { 219 | DSTROOT = /tmp/AirDatePicker.dst; 220 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 221 | GCC_PREFIX_HEADER = "AirDatePicker/AirDatePicker-Prefix.pch"; 222 | OTHER_LDFLAGS = "-ObjC"; 223 | PRODUCT_NAME = "$(TARGET_NAME)"; 224 | SKIP_INSTALL = YES; 225 | }; 226 | name = Release; 227 | }; 228 | /* End XCBuildConfiguration section */ 229 | 230 | /* Begin XCConfigurationList section */ 231 | 6552213A16EE75BF007B3931 /* Build configuration list for PBXProject "AirDatePicker" */ = { 232 | isa = XCConfigurationList; 233 | buildConfigurations = ( 234 | 6552214B16EE75BF007B3931 /* Debug */, 235 | 6552214C16EE75BF007B3931 /* Release */, 236 | ); 237 | defaultConfigurationIsVisible = 0; 238 | defaultConfigurationName = Release; 239 | }; 240 | 6552214D16EE75BF007B3931 /* Build configuration list for PBXNativeTarget "AirDatePicker" */ = { 241 | isa = XCConfigurationList; 242 | buildConfigurations = ( 243 | 6552214E16EE75BF007B3931 /* Debug */, 244 | 6552214F16EE75BF007B3931 /* Release */, 245 | ); 246 | defaultConfigurationIsVisible = 0; 247 | defaultConfigurationName = Release; 248 | }; 249 | /* End XCConfigurationList section */ 250 | }; 251 | rootObject = 6552213716EE75BF007B3931 /* Project object */; 252 | } 253 | -------------------------------------------------------------------------------- /ios/AirDatePicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/AirDatePicker/AirDatePicker-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'AirDatePicker' target in the 'AirDatePicker' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #define DEFINE_ANE_FUNCTION(fn) FREObject (fn)(FREContext context, void* functionData, uint32_t argc, FREObject argv[]) 9 | #endif 10 | -------------------------------------------------------------------------------- /ios/AirDatePicker/AirDatePicker.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2012 Freshplanet (http://freshplanet.com | opensource@freshplanet.com) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | ////////////////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "FlashRuntimeExtensions.h" 20 | 21 | @interface AirDatePicker : NSObject 22 | 23 | @property (nonatomic, retain) UIDatePicker *datePicker; 24 | 25 | + (AirDatePicker *)sharedInstance; 26 | - (void) showDatePickerPhone:(NSDate*)date; 27 | - (void) showDatePickerPad:(NSDate*)date anchor:(CGRect)anchor; 28 | - (void) removeDatePicker; 29 | 30 | @end 31 | 32 | // C interface 33 | DEFINE_ANE_FUNCTION(AirDatePickerDisplayDatePicker); 34 | DEFINE_ANE_FUNCTION(AirDatePickerRemoveDatePicker); 35 | 36 | // ANE setup 37 | void AirDatePickerContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctionsToTest, const FRENamedFunction** functionsToSet); 38 | void AirDatePickerContextFinalizer(FREContext ctx); 39 | void AirDatePickerInitializer(void** extDataToSet, FREContextInitializer* ctxInitializerToSet, FREContextFinalizer* ctxFinalizerToSet); 40 | void AirDatePickerFinalizer(void* extData); -------------------------------------------------------------------------------- /ios/AirDatePicker/AirDatePicker.m: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright 2012 Freshplanet (http://freshplanet.com | opensource@freshplanet.com) 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | ////////////////////////////////////////////////////////////////////////////////////// 18 | 19 | #import "AirDatePicker.h" 20 | 21 | FREContext AirDatePickerCtx = nil; 22 | 23 | @interface AirDatePicker () 24 | 25 | @property (nonatomic,retain) UIPopoverController *popover; 26 | 27 | -(void)dateChanged:(id)sender; 28 | 29 | @end 30 | 31 | @implementation AirDatePicker 32 | 33 | @synthesize popover = _popover; 34 | @synthesize datePicker = _datePicker; 35 | 36 | #pragma mark - Singleton 37 | 38 | static AirDatePicker *sharedInstance = nil; 39 | static NSDate *minimumDate = nil; 40 | static NSDate *maximumDate = nil; 41 | 42 | + (AirDatePicker *)sharedInstance 43 | { 44 | if (!sharedInstance) 45 | { 46 | sharedInstance = [[super allocWithZone:NULL] init]; 47 | } 48 | return sharedInstance; 49 | } 50 | 51 | + (id)allocWithZone:(NSZone *)zone 52 | { 53 | return [self sharedInstance]; 54 | } 55 | 56 | - (id)copy 57 | { 58 | return self; 59 | } 60 | 61 | #pragma mark - UIDatePicker 62 | 63 | -(void) showDatePickerPhone:(NSDate *)date 64 | { 65 | NSLog(@"[AirDatePicker] entering showDatePickerPhone"); 66 | UIView *rootView = [[[[UIApplication sharedApplication] keyWindow] rootViewController] view]; 67 | 68 | self.datePicker = [[UIDatePicker alloc] init]; 69 | self.datePicker.datePickerMode = UIDatePickerModeDate; 70 | 71 | if(minimumDate != nil) { 72 | self.datePicker.minimumDate = minimumDate; 73 | } 74 | 75 | if(maximumDate != nil) { 76 | self.datePicker.maximumDate = maximumDate; 77 | } 78 | 79 | self.datePicker.hidden = NO; 80 | self.datePicker.date = date; 81 | [self.datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged]; 82 | 83 | CGRect datePickerFrame = self.datePicker.frame; 84 | datePickerFrame.origin.y = rootView.bounds.size.height - datePickerFrame.size.height; 85 | self.datePicker.frame = datePickerFrame; 86 | 87 | [rootView addSubview:self.datePicker]; 88 | NSLog(@"[AirDatePicker] exiting showDatePickerPhone"); 89 | } 90 | 91 | - (void) showDatePickerPad:(NSDate*)date anchor:(CGRect)anchor 92 | { 93 | self.datePicker=[[UIDatePicker alloc] initWithFrame:CGRectMake(0,0,300,216)]; 94 | self.datePicker.datePickerMode = UIDatePickerModeDate; 95 | 96 | if(minimumDate != nil) { 97 | self.datePicker.minimumDate = minimumDate; 98 | } 99 | 100 | if(maximumDate != nil) { 101 | self.datePicker.maximumDate = maximumDate; 102 | } 103 | 104 | self.datePicker.hidden = NO; 105 | self.datePicker.date = date; 106 | [self.datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged]; 107 | 108 | 109 | UIView *rootView = [[[[UIApplication sharedApplication] keyWindow] rootViewController] view]; 110 | UIViewController *popoverViewController = [[UIViewController alloc] init]; 111 | UIView *popoverView = [[UIView alloc] init]; 112 | [popoverView addSubview:self.datePicker]; 113 | popoverViewController.view = popoverView; 114 | 115 | CGRect anchory = CGRectMake(anchor.origin.x, anchor.origin.y, 300, 216); 116 | 117 | self.popover = [[UIPopoverController alloc] initWithContentViewController:popoverViewController]; 118 | self.popover.popoverContentSize = CGSizeMake(300, 216); 119 | self.popover.delegate = self; 120 | self.popover.passthroughViews = [NSArray arrayWithObject:rootView]; 121 | [self.popover presentPopoverFromRect:anchory inView:rootView permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; 122 | } 123 | 124 | - (void) removeDatePicker 125 | { 126 | if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) 127 | { 128 | [self.popover dismissPopoverAnimated:YES]; 129 | self.popover.delegate = nil; 130 | self.popover = nil; 131 | } 132 | else 133 | { 134 | [self.datePicker removeFromSuperview]; 135 | } 136 | } 137 | 138 | #pragma mark - UIPopoverControllerDelegate 139 | 140 | - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController 141 | { 142 | if (self.popover) 143 | { 144 | [self.popover dismissPopoverAnimated:YES]; 145 | self.popover = nil; 146 | } 147 | } 148 | 149 | #pragma mark - UIAlertViewDelegate 150 | 151 | - (void)dateChanged:(id) sender 152 | { 153 | // Use date picker to write out the date in a %Y-%m-%d format 154 | NSDateFormatter *df = [[NSDateFormatter alloc] init]; 155 | [df setDateFormat:@"yyy-MM-dd"]; 156 | NSString *formatedDate = [df stringFromDate:self.datePicker.date]; 157 | 158 | // send data to actionscript 159 | FREDispatchStatusEventAsync(AirDatePickerCtx, (const uint8_t *)"CHANGE", (const uint8_t *)[formatedDate UTF8String]); 160 | } 161 | 162 | @end 163 | 164 | 165 | #pragma mark - C interface 166 | 167 | DEFINE_ANE_FUNCTION(AirDatePickerDisplayDatePicker) 168 | { 169 | uint32_t stringLength; 170 | 171 | NSString *year = nil; 172 | NSString *month = nil; 173 | NSString *day = nil; 174 | 175 | // Retrieve year 176 | const uint8_t *yearString; 177 | if (FREGetObjectAsUTF8(argv[0], &stringLength, &yearString) == FRE_OK) 178 | { 179 | year = [NSString stringWithUTF8String:(char *)yearString]; 180 | } 181 | 182 | // Retrieve month 183 | const uint8_t *monthString; 184 | if (FREGetObjectAsUTF8(argv[1], &stringLength, &monthString) == FRE_OK) 185 | { 186 | month = [NSString stringWithUTF8String:(char *)monthString]; 187 | } 188 | 189 | // Retrieve day 190 | const uint8_t *dayString; 191 | if (FREGetObjectAsUTF8(argv[2], &stringLength, &dayString) == FRE_OK) 192 | { 193 | day = [NSString stringWithUTF8String:(char *)dayString]; 194 | } 195 | 196 | // Build an NSDate instance from the AS3 data. 197 | NSDateFormatter *df = [[NSDateFormatter alloc] init]; 198 | [df setDateFormat:@"MM/dd/yyyy"]; // According to the tr35-10 standard, date format should be MMMM/dd/yyyy. 199 | NSDate *date = [df dateFromString:[NSString stringWithFormat:@"%@/%@/%@",month,day,year]]; 200 | 201 | // Extract Anchor for UIPopoverController (iPad only) or default to top right corner 202 | CGRect anchor; 203 | if (argc > 3) 204 | { 205 | // Extract Anchor properties 206 | FREObject anchorObject = argv[3]; 207 | FREObject anchorX, anchorY, anchorWidth, anchorHeight, thrownException; 208 | FREGetObjectProperty(anchorObject, (const uint8_t *)"x", &anchorX, &thrownException); 209 | FREGetObjectProperty(anchorObject, (const uint8_t *)"y", &anchorY, &thrownException); 210 | FREGetObjectProperty(anchorObject, (const uint8_t *)"width", &anchorWidth, &thrownException); 211 | FREGetObjectProperty(anchorObject, (const uint8_t *)"height", &anchorHeight, &thrownException); 212 | 213 | // Convert anchor properties to double 214 | double x, y, width, height; 215 | FREGetObjectAsDouble(anchorX, &x); 216 | FREGetObjectAsDouble(anchorY, &y); 217 | FREGetObjectAsDouble(anchorWidth, &width); 218 | FREGetObjectAsDouble(anchorHeight, &height); 219 | 220 | // make a CGRect type 221 | CGFloat scale = [[UIScreen mainScreen] scale]; 222 | anchor = CGRectMake(x/scale, y/scale, width/scale, height/scale); 223 | 224 | NSLog(@"[AirDatePicker] x, y, width, height = %f %f %f %f", anchor.origin.x, anchor.origin.y, anchor.size.width, anchor.size.height); 225 | } 226 | else 227 | { 228 | UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController]; 229 | anchor = CGRectMake(rootViewController.view.bounds.size.width - 100, 0, 100, 1); // Default anchor: Top right corner 230 | } 231 | 232 | // show date picker for iPad/iPhone 233 | if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) 234 | { 235 | [[AirDatePicker sharedInstance] showDatePickerPad:date anchor:anchor]; 236 | } 237 | else 238 | { 239 | [[AirDatePicker sharedInstance] showDatePickerPhone:date]; 240 | } 241 | 242 | 243 | return nil; 244 | } 245 | 246 | DEFINE_ANE_FUNCTION(AirDatePickerRemoveDatePicker) 247 | { 248 | [[AirDatePicker sharedInstance] removeDatePicker]; 249 | 250 | return nil; 251 | } 252 | 253 | DEFINE_ANE_FUNCTION(setMinDate) 254 | { 255 | NSLog(@"Entering setMinDate"); 256 | if(argc == 1) { 257 | double millis; 258 | FREResult result = FREGetObjectAsDouble(argv[0], &millis); 259 | if (result == FRE_OK) { 260 | minimumDate = [NSDate dateWithTimeIntervalSince1970:(millis * 0.001)]; 261 | } else { 262 | NSLog(@"Problem setting minimum date:"); 263 | switch (result) { 264 | case FRE_TYPE_MISMATCH: 265 | NSLog(@" -> FRE_TYPE_MISMATCH"); 266 | break; 267 | case FRE_WRONG_THREAD: 268 | NSLog(@" -> FRE_WRONG_THREAD"); 269 | break; 270 | case FRE_INVALID_ARGUMENT: 271 | NSLog(@" -> FRE_INVALID_ARGUMENT"); 272 | break; 273 | case FRE_INVALID_OBJECT: 274 | NSLog(@" -> FRE_INVALID_OBJECT"); 275 | break; 276 | } 277 | } 278 | } 279 | NSLog(@"Exiting setMinDate"); 280 | return nil; 281 | } 282 | 283 | DEFINE_ANE_FUNCTION(clearMinDate) 284 | { 285 | minimumDate = NULL; 286 | return nil; 287 | } 288 | 289 | DEFINE_ANE_FUNCTION(setMaxDate) 290 | { 291 | NSLog(@"Entering setMaxDate"); 292 | if(argc == 1) { 293 | double millis; 294 | FREResult result = FREGetObjectAsDouble(argv[0], &millis); 295 | if (result == FRE_OK) { 296 | maximumDate = [NSDate dateWithTimeIntervalSince1970:(millis * 0.001)]; 297 | } else { 298 | NSLog(@"Problem setting maximum date"); 299 | switch (result) { 300 | case FRE_TYPE_MISMATCH: 301 | NSLog(@" -> FRE_TYPE_MISMATCH"); 302 | break; 303 | case FRE_WRONG_THREAD: 304 | NSLog(@" -> FRE_WRONG_THREAD"); 305 | break; 306 | case FRE_INVALID_ARGUMENT: 307 | NSLog(@" -> FRE_INVALID_ARGUMENT"); 308 | break; 309 | case FRE_INVALID_OBJECT: 310 | NSLog(@" -> FRE_INVALID_OBJECT"); 311 | break; 312 | } 313 | } 314 | } 315 | NSLog(@"Exiting setMaxDate"); 316 | return nil; 317 | } 318 | 319 | DEFINE_ANE_FUNCTION(clearMaxDate) 320 | { 321 | maximumDate = NULL; 322 | return nil; 323 | } 324 | 325 | 326 | #pragma mark - ANE setup 327 | 328 | void AirDatePickerContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctionsToTest, const FRENamedFunction** functionsToSet) 329 | { 330 | // Register the links btwn AS3 and ObjC. (dont forget to modify the nbFuntionsToLink integer if you are adding/removing functions) 331 | NSInteger nbFuntionsToLink = 6; 332 | *numFunctionsToTest = nbFuntionsToLink; 333 | 334 | FRENamedFunction* func = (FRENamedFunction*) malloc(sizeof(FRENamedFunction) * nbFuntionsToLink); 335 | 336 | func[0].name = (const uint8_t*) "AirDatePickerDisplayDatePicker"; 337 | func[0].functionData = NULL; 338 | func[0].function = &AirDatePickerDisplayDatePicker; 339 | 340 | func[1].name = (const uint8_t*) "AirDatePickerRemoveDatePicker"; 341 | func[1].functionData = NULL; 342 | func[1].function = &AirDatePickerRemoveDatePicker; 343 | 344 | func[2].name = (const uint8_t*) "setMinimumDate"; 345 | func[2].functionData = NULL; 346 | func[2].function = &setMinDate; 347 | 348 | func[3].name = (const uint8_t*) "setMaximumDate"; 349 | func[3].functionData = NULL; 350 | func[3].function = &setMaxDate; 351 | 352 | func[4].name = (const uint8_t*) "clearMinimumDate"; 353 | func[4].functionData = NULL; 354 | func[4].function = &clearMinDate; 355 | 356 | func[5].name = (const uint8_t*) "clearMaximumDate"; 357 | func[5].functionData = NULL; 358 | func[5].function = &clearMaxDate; 359 | 360 | *functionsToSet = func; 361 | 362 | AirDatePickerCtx = ctx; 363 | } 364 | 365 | void AirDatePickerContextFinalizer(FREContext ctx) { } 366 | 367 | void AirDatePickerInitializer(void** extDataToSet, FREContextInitializer* ctxInitializerToSet, FREContextFinalizer* ctxFinalizerToSet) 368 | { 369 | *extDataToSet = NULL; 370 | *ctxInitializerToSet = &AirDatePickerContextInitializer; 371 | *ctxFinalizerToSet = &AirDatePickerContextFinalizer; 372 | } 373 | 374 | void AirDatePickerFinalizer(void* extData) { } -------------------------------------------------------------------------------- /ios/AirDatePicker/FlashRuntimeExtensions.h: -------------------------------------------------------------------------------- 1 | // ADOBE CONFIDENTIAL 2 | // 3 | // Copyright 2011 Adobe Systems Incorporated All Rights Reserved. 4 | // 5 | // NOTICE: All information contained herein is, and remains the property of 6 | // Adobe Systems Incorporated and its suppliers, if any. The intellectual and 7 | // technical concepts contained herein are proprietary to Adobe Systems 8 | // Incorporated and its suppliers and may be covered by U.S. and Foreign 9 | // Patents, patents in process, and are protected by trade secret or copyright 10 | // law. Dissemination of this information or reproduction of this material 11 | // is strictly forbidden unless prior written permission is obtained from 12 | // Adobe Systems Incorporated. 13 | 14 | // AdobePatentID="P969E1" 15 | 16 | #ifdef WIN32 17 | typedef unsigned __int32 uint32_t; 18 | typedef unsigned __int8 uint8_t; 19 | typedef __int32 int32_t; 20 | #else 21 | #include 22 | #endif 23 | 24 | #ifndef FRNATIVEEXTENSIONS_H_ 25 | #define FRNATIVEEXTENSIONS_H_ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | typedef void * FREContext; 32 | typedef void * FREObject; 33 | 34 | /* Initialization *************************************************************/ 35 | 36 | /** 37 | * Defines the signature for native calls that can be invoked via an 38 | * instance of the AS ExtensionContext class. 39 | * 40 | * @return The return value corresponds to the return value 41 | * from the AS ExtensionContext class call() method. It defaults to 42 | * FRE_INVALID_OBJECT, which is reported as null in AS. 43 | */ 44 | 45 | typedef FREObject (*FREFunction)( 46 | FREContext ctx, 47 | void* functionData, 48 | uint32_t argc, 49 | FREObject argv[] 50 | ); 51 | 52 | typedef struct FRENamedFunction_ { 53 | const uint8_t* name; 54 | void* functionData; 55 | FREFunction function; 56 | } FRENamedFunction; 57 | 58 | /** 59 | * Defines the signature for the initializer that is called each time 60 | * a new AS ExtensionContext object is created. 61 | * 62 | * @param extData The extension client data provided to the FREInitializer function as extDataToSet. 63 | * 64 | * @param ctxType Pointer to the contextType string (UTF8) as provided to the AS createExtensionContext call. 65 | * 66 | * @param ctx The FREContext being initialized. 67 | * 68 | * @param numFunctionsToSet The number of elements in the functionsToSet array. 69 | * 70 | * @param functionsToSet A pointer to an array of FRENamedFunction elements. 71 | */ 72 | 73 | typedef void (*FREContextInitializer)( 74 | void* extData , 75 | const uint8_t* ctxType , 76 | FREContext ctx , 77 | uint32_t* numFunctionsToSet, 78 | const FRENamedFunction** functionsToSet 79 | ); 80 | 81 | /** 82 | * Defines the signature for the finalizer that is called each time 83 | * an ExtensionContext instance is disposed. 84 | */ 85 | 86 | typedef void (*FREContextFinalizer)( 87 | FREContext ctx 88 | ); 89 | 90 | /** 91 | * The initialization function provided by each extension must conform 92 | * to the following signature. 93 | * 94 | * @param extDataToSet Provided for the extension to store per-extension instance data. 95 | * For example, if the extension creates 96 | * globals per-instance, it can store a pointer to them here. 97 | * 98 | * @param ctxInitializerToSet Must be set to a pointer to a function 99 | * of type FREContextInitializer. Will be invoked whenever 100 | * the ActionScript code creates a new context for this extension. 101 | * 102 | * @param ctxFinalizerToSet Must be set to a pointer to a function 103 | * of type FREContextFinalizer. 104 | */ 105 | 106 | typedef void (*FREInitializer)( 107 | void** extDataToSet , 108 | FREContextInitializer* ctxInitializerToSet, 109 | FREContextFinalizer* ctxFinalizerToSet 110 | ); 111 | 112 | /** 113 | * Called iff the extension is unloaded from the process. Extensions 114 | * are not guaranteed to be unloaded; the runtime process may exit without 115 | * doing so. 116 | */ 117 | 118 | typedef void (*FREFinalizer)( 119 | void* extData 120 | ); 121 | 122 | /* Result Codes ***************************************************************/ 123 | /** 124 | * These values must not be changed. 125 | */ 126 | 127 | typedef enum { 128 | FRE_OK = 0, 129 | FRE_NO_SUCH_NAME = 1, 130 | FRE_INVALID_OBJECT = 2, 131 | FRE_TYPE_MISMATCH = 3, 132 | FRE_ACTIONSCRIPT_ERROR = 4, 133 | FRE_INVALID_ARGUMENT = 5, 134 | FRE_READ_ONLY = 6, 135 | FRE_WRONG_THREAD = 7, 136 | FRE_ILLEGAL_STATE = 8, 137 | FRE_INSUFFICIENT_MEMORY = 9, 138 | FREResult_ENUMPADDING = 0xfffff /* will ensure that C and C++ treat this enum as the same size. */ 139 | } FREResult; 140 | 141 | /* Context Data ************************************************************/ 142 | 143 | /** 144 | * @returns FRE_OK 145 | * FRE_WRONG_THREAD 146 | * FRE_INVALID_ARGUMENT If nativeData is null. 147 | */ 148 | 149 | FREResult FREGetContextNativeData( FREContext ctx, void** nativeData ); 150 | 151 | /** 152 | * @returns FRE_OK 153 | * FRE_INVALID_ARGUMENT 154 | * FRE_WRONG_THREAD 155 | */ 156 | 157 | FREResult FRESetContextNativeData( FREContext ctx, void* nativeData ); 158 | 159 | /** 160 | * @returns FRE_OK 161 | * FRE_WRONG_THREAD 162 | * FRE_INVALID_ARGUMENT If actionScriptData is null. 163 | */ 164 | 165 | FREResult FREGetContextActionScriptData( FREContext ctx, FREObject *actionScriptData ); 166 | 167 | /** 168 | * @returns FRE_OK 169 | * FRE_WRONG_THREAD 170 | */ 171 | 172 | FREResult FRESetContextActionScriptData( FREContext ctx, FREObject actionScriptData ); 173 | 174 | /* Primitive Types ************************************************************/ 175 | /** 176 | * These values must not be changed. 177 | */ 178 | 179 | typedef enum { 180 | FRE_TYPE_OBJECT = 0, 181 | FRE_TYPE_NUMBER = 1, 182 | FRE_TYPE_STRING = 2, 183 | FRE_TYPE_BYTEARRAY = 3, 184 | FRE_TYPE_ARRAY = 4, 185 | FRE_TYPE_VECTOR = 5, 186 | FRE_TYPE_BITMAPDATA = 6, 187 | FRE_TYPE_BOOLEAN = 7, 188 | FRE_TYPE_NULL = 8, 189 | FREObjectType_ENUMPADDING = 0xfffff /* will ensure that C and C++ treat this enum as the same size. */ 190 | } FREObjectType; 191 | 192 | /** 193 | * @returns FRE_OK 194 | * FRE_INVALID_OBJECT 195 | * FRE_WRONG_THREAD 196 | * FRE_INVALID_ARGUMENT If objectType is null. 197 | */ 198 | 199 | FREResult FREGetObjectType( FREObject object, FREObjectType *objectType ); 200 | 201 | /** 202 | * @return FRE_OK 203 | * FRE_TYPE_MISMATCH 204 | * FRE_INVALID_OBJECT 205 | * FRE_INVALID_ARGUMENT 206 | * FRE_WRONG_THREAD 207 | */ 208 | 209 | FREResult FREGetObjectAsInt32 ( FREObject object, int32_t *value ); 210 | FREResult FREGetObjectAsUint32( FREObject object, uint32_t *value ); 211 | FREResult FREGetObjectAsDouble( FREObject object, double *value ); 212 | FREResult FREGetObjectAsBool ( FREObject object, uint32_t *value ); 213 | 214 | /** 215 | * @return FRE_OK 216 | * FRE_INVALID_ARGUMENT 217 | * FRE_WRONG_THREAD 218 | */ 219 | 220 | FREResult FRENewObjectFromInt32 ( int32_t value, FREObject *object ); 221 | FREResult FRENewObjectFromUint32( uint32_t value, FREObject *object ); 222 | FREResult FRENewObjectFromDouble( double value, FREObject *object ); 223 | FREResult FRENewObjectFromBool ( uint32_t value, FREObject *object ); 224 | 225 | /** 226 | * Retrieves a string representation of the object referred to by 227 | * the given object. The referenced string is immutable and valid 228 | * only for duration of the call to a registered function. If the 229 | * caller wishes to keep the the string, they must keep a copy of it. 230 | * 231 | * @param object The string to be retrieved. 232 | * 233 | * @param length The size, in bytes, of the string. Includes the 234 | * null terminator. 235 | * 236 | * @param value A pointer to a possibly temporary copy of the string. 237 | * 238 | * @return FRE_OK 239 | * FRE_TYPE_MISMATCH 240 | * FRE_INVALID_OBJECT 241 | * FRE_INVALID_ARGUMENT 242 | * FRE_WRONG_THREAD 243 | */ 244 | 245 | FREResult FREGetObjectAsUTF8( 246 | FREObject object, 247 | uint32_t* length, 248 | const uint8_t** value 249 | ); 250 | 251 | /** 252 | * Creates a new String object that contains a copy of the specified 253 | * string. 254 | * 255 | * @param length The length, in bytes, of the original string. Must include 256 | * the null terminator. 257 | * 258 | * @param value A pointer to the original string. 259 | * 260 | * @param object Receives a reference to the new string object. 261 | * 262 | * @return FRE_OK 263 | * FRE_INVALID_ARGUMENT 264 | * FRE_WRONG_THREAD 265 | */ 266 | 267 | FREResult FRENewObjectFromUTF8( 268 | uint32_t length, 269 | const uint8_t* value , 270 | FREObject* object 271 | ); 272 | 273 | /* Object Access **************************************************************/ 274 | 275 | /** 276 | * @param className UTF8-encoded name of the class being constructed. 277 | * 278 | * @param thrownException A pointer to a handle that can receive the handle of any ActionScript 279 | * Error thrown during execution. May be null if the caller does not 280 | * want to receive this handle. If not null and no error occurs, is set an 281 | * invalid handle value. 282 | * 283 | * @return FRE_OK 284 | * FRE_TYPE_MISMATCH 285 | * FRE_INVALID_OBJECT 286 | * FRE_INVALID_ARGUMENT 287 | * FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from calling this method. 288 | * In this case, thrownException will be set to the handle of the thrown value. 289 | * FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released. 290 | * FRE_NO_SUCH_NAME 291 | * FRE_WRONG_THREAD 292 | */ 293 | 294 | FREResult FRENewObject( 295 | const uint8_t* className , 296 | uint32_t argc , 297 | FREObject argv[] , 298 | FREObject* object , 299 | FREObject* thrownException 300 | ); 301 | 302 | /** 303 | * @param propertyName UTF8-encoded name of the property being fetched. 304 | * 305 | * @param thrownException A pointer to a handle that can receive the handle of any ActionScript 306 | * Error thrown during getting the property. May be null if the caller does not 307 | * want to receive this handle. If not null and no error occurs, is set an 308 | * invalid handle value. 309 | * 310 | * @return FRE_OK 311 | * FRE_TYPE_MISMATCH 312 | * FRE_INVALID_OBJECT 313 | * FRE_INVALID_ARGUMENT 314 | * 315 | * FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from getting this property. 316 | * In this case, thrownException will be set to the handle of the thrown value. 317 | * 318 | * FRE_NO_SUCH_NAME If the named property doesn't exist, or if the reference is ambiguous 319 | * because the property exists in more than one namespace. 320 | * 321 | * FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released. 322 | * 323 | * FRE_WRONG_THREAD 324 | */ 325 | 326 | FREResult FREGetObjectProperty( 327 | FREObject object , 328 | const uint8_t* propertyName , 329 | FREObject* propertyValue , 330 | FREObject* thrownException 331 | ); 332 | 333 | /** 334 | * @param propertyName UTF8-encoded name of the property being set. 335 | * 336 | * @param thrownException A pointer to a handle that can receive the handle of any ActionScript 337 | * Error thrown during method execution. May be null if the caller does not 338 | * want to receive this handle. If not null and no error occurs, is set an 339 | * invalid handle value. 340 | * 341 | * 342 | * @return FRE_OK 343 | * FRE_TYPE_MISMATCH 344 | * FRE_INVALID_OBJECT 345 | * FRE_INVALID_ARGUMENT 346 | * FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from getting this property. 347 | * In this case, thrownException will be set to the handle of the thrown value. 348 | * 349 | * FRE_NO_SUCH_NAME If the named property doesn't exist, or if the reference is ambiguous 350 | * because the property exists in more than one namespace. 351 | * 352 | * FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released. 353 | * 354 | * FRE_READ_ONLY 355 | * FRE_WRONG_THREAD 356 | */ 357 | 358 | FREResult FRESetObjectProperty( 359 | FREObject object , 360 | const uint8_t* propertyName , 361 | FREObject propertyValue , 362 | FREObject* thrownException 363 | ); 364 | 365 | /** 366 | * @param methodName UTF8-encoded null-terminated name of the method being invoked. 367 | * 368 | * @param thrownException A pointer to a handle that can receive the handle of any ActionScript 369 | * Error thrown during method execution. May be null if the caller does not 370 | * want to receive this handle. If not null and no error occurs, is set an 371 | * invalid handle value. 372 | * 373 | * @return FRE_OK 374 | * FRE_TYPE_MISMATCH 375 | * FRE_INVALID_OBJECT 376 | * FRE_INVALID_ARGUMENT 377 | * FRE_ACTIONSCRIPT_ERROR If an ActionScript exception results from calling this method. 378 | * In this case, thrownException will be set to the handle of the thrown value. 379 | * 380 | * FRE_NO_SUCH_NAME If the named method doesn't exist, or if the reference is ambiguous 381 | * because the method exists in more than one namespace. 382 | * 383 | * FRE_ILLEGAL_STATE If a ByteArray or BitmapData has been acquired and not yet released. 384 | * 385 | * FRE_WRONG_THREAD 386 | */ 387 | 388 | FREResult FRECallObjectMethod ( 389 | FREObject object , 390 | const uint8_t* methodName , 391 | uint32_t argc , 392 | FREObject argv[] , 393 | FREObject* result , 394 | FREObject* thrownException 395 | ); 396 | 397 | /* BitmapData Access **********************************************************/ 398 | 399 | typedef struct { 400 | uint32_t width; /* width of the BitmapData bitmap */ 401 | uint32_t height; /* height of the BitmapData bitmap */ 402 | uint32_t hasAlpha; /* if non-zero, pixel format is ARGB32, otherwise pixel format is _RGB32, host endianness */ 403 | uint32_t isPremultiplied; /* pixel color values are premultiplied with alpha if non-zero, un-multiplied if zero */ 404 | uint32_t lineStride32; /* line stride in number of 32 bit values, typically the same as width */ 405 | uint32_t* bits32; /* pointer to the first 32-bit pixel of the bitmap data */ 406 | } FREBitmapData; 407 | 408 | typedef struct { 409 | uint32_t width; /* width of the BitmapData bitmap */ 410 | uint32_t height; /* height of the BitmapData bitmap */ 411 | uint32_t hasAlpha; /* if non-zero, pixel format is ARGB32, otherwise pixel format is _RGB32, host endianness */ 412 | uint32_t isPremultiplied; /* pixel color values are premultiplied with alpha if non-zero, un-multiplied if zero */ 413 | uint32_t lineStride32; /* line stride in number of 32 bit values, typically the same as width */ 414 | uint32_t isInvertedY; /* if non-zero, last row of pixels starts at bits32, otherwise, first row of pixels starts at bits32. */ 415 | uint32_t* bits32; /* pointer to the first 32-bit pixel of the bitmap data */ 416 | } FREBitmapData2; 417 | 418 | /** 419 | * Referenced data is valid only for duration of the call 420 | * to a registered function. 421 | * 422 | * @return FRE_OK 423 | * FRE_TYPE_MISMATCH 424 | * FRE_INVALID_OBJECT 425 | * FRE_INVALID_ARGUMENT 426 | * FRE_WRONG_THREAD 427 | * FRE_ILLEGAL_STATE 428 | */ 429 | 430 | FREResult FREAcquireBitmapData( 431 | FREObject object , 432 | FREBitmapData* descriptorToSet 433 | ); 434 | 435 | /** 436 | * Referenced data is valid only for duration of the call 437 | * to a registered function. 438 | * 439 | * Use of this API requires that the extension and application must be packaged for 440 | * the 3.1 namespace or later. 441 | * 442 | * @return FRE_OK 443 | * FRE_TYPE_MISMATCH 444 | * FRE_INVALID_OBJECT 445 | * FRE_INVALID_ARGUMENT 446 | * FRE_WRONG_THREAD 447 | * FRE_ILLEGAL_STATE 448 | */ 449 | 450 | FREResult FREAcquireBitmapData2( 451 | FREObject object , 452 | FREBitmapData2* descriptorToSet 453 | ); 454 | 455 | /** 456 | * BitmapData must be acquired to call this. Clients must invalidate any region 457 | * they modify in order to notify AIR of the changes. Only invalidated regions 458 | * are redrawn. 459 | * 460 | * @return FRE_OK 461 | * FRE_INVALID_OBJECT 462 | * FRE_WRONG_THREAD 463 | * FRE_ILLEGAL_STATE 464 | * FRE_TYPE_MISMATCH 465 | */ 466 | 467 | FREResult FREInvalidateBitmapDataRect( 468 | FREObject object, 469 | uint32_t x , 470 | uint32_t y , 471 | uint32_t width , 472 | uint32_t height 473 | ); 474 | /** 475 | * @return FRE_OK 476 | * FRE_WRONG_THREAD 477 | * FRE_ILLEGAL_STATE 478 | * FRE_TYPE_MISMATCH 479 | */ 480 | 481 | FREResult FREReleaseBitmapData( FREObject object ); 482 | 483 | /** 484 | * Referenced data is valid only for duration of the call 485 | * to a registered function. 486 | * 487 | * @return FRE_OK 488 | * FRE_TYPE_MISMATCH 489 | * FRE_INVALID_OBJECT 490 | * FRE_WRONG_THREAD 491 | */ 492 | 493 | /* ByteArray Access ***********************************************************/ 494 | 495 | typedef struct { 496 | uint32_t length; 497 | uint8_t* bytes; 498 | } FREByteArray; 499 | 500 | /** 501 | * Referenced data is valid only for duration of the call 502 | * to a registered function. 503 | * 504 | * @return FRE_OK 505 | * FRE_TYPE_MISMATCH 506 | * FRE_INVALID_OBJECT 507 | * FRE_INVALID_ARGUMENT 508 | * FRE_WRONG_THREAD 509 | * FRE_ILLEGAL_STATE 510 | */ 511 | 512 | FREResult FREAcquireByteArray( 513 | FREObject object , 514 | FREByteArray* byteArrayToSet 515 | ); 516 | 517 | /** 518 | * @return FRE_OK 519 | * FRE_INVALID_OBJECT 520 | * FRE_ILLEGAL_STATE 521 | * FRE_WRONG_THREAD 522 | */ 523 | 524 | FREResult FREReleaseByteArray( FREObject object ); 525 | 526 | /* Array and Vector Access ****************************************************/ 527 | 528 | /** 529 | * @return FRE_OK 530 | * FRE_INVALID_OBJECT 531 | * FRE_INVALID_ARGUMENT 532 | * FRE_ILLEGAL_STATE 533 | * FRE_TYPE_MISMATCH 534 | * FRE_WRONG_THREAD 535 | */ 536 | 537 | FREResult FREGetArrayLength( 538 | FREObject arrayOrVector, 539 | uint32_t* length 540 | ); 541 | 542 | /** 543 | * @return FRE_OK 544 | * FRE_INVALID_OBJECT 545 | * FRE_TYPE_MISMATCH 546 | * FRE_ILLEGAL_STATE 547 | * FRE_INVALID_ARGUMENT If length is greater than 2^32. 548 | * 549 | * FRE_READ_ONLY If the handle refers to a Vector 550 | * of fixed size. 551 | * 552 | * FRE_WRONG_THREAD 553 | * FRE_INSUFFICIENT_MEMORY 554 | */ 555 | 556 | FREResult FRESetArrayLength( 557 | FREObject arrayOrVector, 558 | uint32_t length 559 | ); 560 | 561 | /** 562 | * If an Array is sparse and an element that isn't defined is requested, the 563 | * return value will be FRE_OK but the handle value will be invalid. 564 | * 565 | * @return FRE_OK 566 | * FRE_ILLEGAL_STATE 567 | * 568 | * FRE_INVALID_ARGUMENT If the handle refers to a vector and the index is 569 | * greater than the size of the array. 570 | * 571 | * FRE_INVALID_OBJECT 572 | * FRE_TYPE_MISMATCH 573 | * FRE_WRONG_THREAD 574 | */ 575 | 576 | FREResult FREGetArrayElementAt( 577 | FREObject arrayOrVector, 578 | uint32_t index , 579 | FREObject* value 580 | ); 581 | 582 | /** 583 | * 584 | * @return FRE_OK 585 | * FRE_INVALID_OBJECT 586 | * FRE_ILLEGAL_STATE 587 | * 588 | * FRE_TYPE_MISMATCH If an attempt to made to set a value in a Vector 589 | * when the type of the value doesn't match the Vector's item type. 590 | * 591 | * FRE_WRONG_THREAD 592 | */ 593 | 594 | FREResult FRESetArrayElementAt( 595 | FREObject arrayOrVector, 596 | uint32_t index , 597 | FREObject value 598 | ); 599 | 600 | /* Callbacks ******************************************************************/ 601 | 602 | /** 603 | * Causes a StatusEvent to be dispatched from the associated 604 | * ExtensionContext object. 605 | * 606 | * Dispatch happens asynchronously, even if this is called during 607 | * a call to a registered function. 608 | * 609 | * The ActionScript portion of this extension can listen for that event 610 | * and, upon receipt, query the native portion for details of the event 611 | * that occurred. 612 | * 613 | * This call is thread-safe and may be invoked from any thread. The string 614 | * values are copied before the call returns. 615 | * 616 | * @return FRE_OK In all circumstances, as the referenced object cannot 617 | * necessarily be checked for validity on the invoking thread. 618 | * However, no event will be dispatched if the object is 619 | * invalid or not an EventDispatcher. 620 | * FRE_INVALID_ARGUMENT If code or level is NULL 621 | */ 622 | 623 | FREResult FREDispatchStatusEventAsync( 624 | FREContext ctx , 625 | const uint8_t* code , 626 | const uint8_t* level 627 | ); 628 | 629 | #ifdef __cplusplus 630 | } 631 | #endif 632 | 633 | #endif /* #ifndef _FLASH_RUNTIME_EXTENSIONS_H_ */ 634 | --------------------------------------------------------------------------------