PlayerGlobalToJS AIR app AIR application to create JS stubs from 'playerglobal.swc' classes and provide implementations of selected class members in JS through 'shadow' interfaces.
Signed-off-by: Erik de Bruin <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/83c26c9d Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/83c26c9d Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/83c26c9d Branch: refs/heads/develop Commit: 83c26c9d00a0ffd115abebf29bf35c0a8f777999 Parents: 911f644 Author: Erik de Bruin <[email protected]> Authored: Fri Oct 31 17:00:09 2014 +0100 Committer: Erik de Bruin <[email protected]> Committed: Fri Oct 31 17:02:00 2014 +0100 ---------------------------------------------------------------------- .../src/PlayerGlobalToJS-app.xml | 232 +++++++ .../PlayerGlobalToJS/src/PlayerGlobalToJS.mxml | 660 +++++++++++++++++++ .../src/assets/vf2js/display/DisplayObject.js | 173 +++++ .../vf2js/display/DisplayObjectContainer.js | 110 ++++ .../assets/vf2js/display/InteractiveObject.js | 33 + .../src/assets/vf2js/display/LoaderInfo.js | 125 ++++ .../src/assets/vf2js/display/MovieClip.js | 115 ++++ .../src/assets/vf2js/display/Sprite.js | 33 + .../src/assets/vf2js/display/Stage.js | 210 ++++++ .../src/assets/vf2js/events/Event.js | 136 ++++ .../src/assets/vf2js/events/EventDispatcher.js | 154 +++++ .../src/assets/vf2js/events/ProgressEvent.js | 75 +++ .../src/assets/vf2js/events/TimerEvent.js | 72 ++ .../assets/vf2js/system/ApplicationDomain.js | 77 +++ .../src/assets/vf2js/system/Capabilities.js | 98 +++ .../src/assets/vf2js/utils/Timer.js | 182 +++++ .../assets/vf2js/utils/getDefinitionByName.js | 53 ++ .../utils/PlayerGlobalToJS/src/nl/ixms/Utils.as | 44 ++ .../src/nl/ixms/enums/MemberType.as | 62 ++ .../PlayerGlobalToJS/src/nl/ixms/vo/Clazz.as | 489 ++++++++++++++ .../src/nl/ixms/vo/ClazzMemberTypeLists.as | 11 + .../PlayerGlobalToJS/src/nl/ixms/vo/JSDoc.as | 111 ++++ .../PlayerGlobalToJS/src/shadowInterfaces.as | 16 + .../src/vf2js/display/IDisplayObject.as | 27 + .../vf2js/display/IDisplayObjectContainer.as | 12 + .../src/vf2js/display/IInteractiveObject.as | 8 + .../src/vf2js/display/ILoaderInfo.as | 21 + .../src/vf2js/display/IMovieClip.as | 17 + .../src/vf2js/display/ISprite.as | 8 + .../src/vf2js/display/IStage.as | 26 + .../PlayerGlobalToJS/src/vf2js/events/IEvent.as | 15 + .../src/vf2js/events/IEventDispatcher.as | 15 + .../src/vf2js/events/IProgressEvent.as | 9 + .../src/vf2js/events/ITimerEvent.as | 9 + .../src/vf2js/system/IApplicationDomain.as | 10 + .../src/vf2js/system/ICapabilities.as | 17 + .../PlayerGlobalToJS/src/vf2js/utils/ITimer.as | 14 + .../src/vf2js/utils/IgetDefinitionByName.as | 8 + 38 files changed, 3487 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/PlayerGlobalToJS-app.xml ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/PlayerGlobalToJS-app.xml b/vf2js/utils/PlayerGlobalToJS/src/PlayerGlobalToJS-app.xml new file mode 100644 index 0000000..efd4a3e --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/PlayerGlobalToJS-app.xml @@ -0,0 +1,232 @@ +<?xml version="1.0" encoding="utf-8" standalone="no"?> +<application xmlns="http://ns.adobe.com/air/application/15.0"> + +<!-- Adobe AIR Application Descriptor File Template. + + Specifies parameters for identifying, installing, and launching AIR applications. + + xmlns - The Adobe AIR namespace: http://ns.adobe.com/air/application/3.1 + The last segment of the namespace specifies the version + of the AIR runtime required for this application to run. + + minimumPatchLevel - The minimum patch level of the AIR runtime required to run + the application. Optional. +--> + + <!-- A universally unique application identifier. Must be unique across all AIR applications. + Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. --> + <id>PlayerGlobalToJS</id> + + <!-- Used as the filename for the application. Required. --> + <filename>PlayerGlobalToJS</filename> + + <!-- The name that is displayed in the AIR application installer. + May have multiple values for each language. See samples or xsd schema file. Optional. --> + <name>PlayerGlobalToJS</name> + + <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade. + Values can also be 1-part or 2-part. It is not necessary to have a 3-part value. + An updated version of application must have a versionNumber value higher than the previous version. Required for namespace >= 2.5 . --> + <versionNumber>0.0.1</versionNumber> + + <!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. --> + <!-- <versionLabel></versionLabel> --> + + <!-- Description, displayed in the AIR application installer. + May have multiple values for each language. See samples or xsd schema file. Optional. --> + <!-- <description></description> --> + + <!-- Copyright information. Optional --> + <!-- <copyright></copyright> --> + + <!-- Publisher ID. Used if you're updating an application created prior to 1.5.3 --> + <!-- <publisherID></publisherID> --> + + <!-- Settings for the application's initial window. Required. --> + <initialWindow> + <!-- The main SWF or HTML file of the application. Required. --> + <!-- Note: In Flash Builder, the SWF reference is set automatically. --> + <content>[This value will be overwritten by Flash Builder in the output app.xml]</content> + + <!-- The title of the main window. Optional. --> + <!-- <title></title> --> + + <!-- The type of system chrome to use (either "standard" or "none"). Optional. Default standard. --> + <!-- <systemChrome></systemChrome> --> + + <!-- Whether the window is transparent. Only applicable when systemChrome is none. Optional. Default false. --> + <!-- <transparent></transparent> --> + + <!-- Whether the window is initially visible. Optional. Default false. --> + <!-- <visible></visible> --> + + <!-- Whether the user can minimize the window. Optional. Default true. --> + <!-- <minimizable></minimizable> --> + + <!-- Whether the user can maximize the window. Optional. Default true. --> + <!-- <maximizable></maximizable> --> + + <!-- Whether the user can resize the window. Optional. Default true. --> + <!-- <resizable></resizable> --> + + <!-- The window's initial width in pixels. Optional. --> + <!-- <width></width> --> + + <!-- The window's initial height in pixels. Optional. --> + <!-- <height></height> --> + + <!-- The window's initial x position. Optional. --> + <!-- <x></x> --> + + <!-- The window's initial y position. Optional. --> + <!-- <y></y> --> + + <!-- The window's minimum size, specified as a width/height pair in pixels, such as "400 200". Optional. --> + <!-- <minSize></minSize> --> + + <!-- The window's initial maximum size, specified as a width/height pair in pixels, such as "1600 1200". Optional. --> + <!-- <maxSize></maxSize> --> + + <!-- The initial aspect ratio of the app when launched (either "portrait" or "landscape"). Optional. Mobile only. Default is the natural orientation of the device --> + + <!-- <aspectRatio></aspectRatio> --> + + <!-- Whether the app will begin auto-orienting on launch. Optional. Mobile only. Default false --> + + <!-- <autoOrients></autoOrients> --> + + <!-- Whether the app launches in full screen. Optional. Mobile only. Default false --> + + <!-- <fullScreen></fullScreen> --> + + <!-- The render mode for the app (either auto, cpu, gpu, or direct). Optional. Default auto --> + + <!-- <renderMode></renderMode> --> + + <!-- Whether or not to pan when a soft keyboard is raised or lowered (either "pan" or "none"). Optional. Defaults "pan." --> + <!-- <softKeyboardBehavior></softKeyboardBehavior> --> + <autoOrients>false</autoOrients> + <fullScreen>false</fullScreen> + <visible>false</visible> + </initialWindow> + + <!-- We recommend omitting the supportedProfiles element, --> + <!-- which in turn permits your application to be deployed to all --> + <!-- devices supported by AIR. If you wish to restrict deployment --> + <!-- (i.e., to only mobile devices) then add this element and list --> + <!-- only the profiles which your application does support. --> + <!-- <supportedProfiles>desktop extendedDesktop mobileDevice extendedMobileDevice</supportedProfiles> --> + + <!-- The subpath of the standard default installation location to use. Optional. --> + <!-- <installFolder></installFolder> --> + + <!-- The subpath of the Programs menu to use. (Ignored on operating systems without a Programs menu.) Optional. --> + <!-- <programMenuFolder></programMenuFolder> --> + + <!-- The icon the system uses for the application. For at least one resolution, + specify the path to a PNG file included in the AIR package. Optional. --> + <!-- <icon> + <image16x16></image16x16> + <image32x32></image32x32> + <image36x36></image36x36> + <image48x48></image48x48> + <image57x57></image57x57> + <image72x72></image72x72> + <image114x114></image114x114> + <image128x128></image128x128> + </icon> --> + + <!-- Whether the application handles the update when a user double-clicks an update version + of the AIR file (true), or the default AIR application installer handles the update (false). + Optional. Default false. --> + <!-- <customUpdateUI></customUpdateUI> --> + + <!-- Whether the application can be launched when the user clicks a link in a web browser. + Optional. Default false. --> + <!-- <allowBrowserInvocation></allowBrowserInvocation> --> + + <!-- Listing of file types for which the application can register. Optional. --> + <!-- <fileTypes> --> + + <!-- Defines one file type. Optional. --> + <!-- <fileType> --> + + <!-- The name that the system displays for the registered file type. Required. --> + <!-- <name></name> --> + + <!-- The extension to register. Required. --> + <!-- <extension></extension> --> + + <!-- The description of the file type. Optional. --> + <!-- <description></description> --> + + <!-- The MIME content type. --> + <!-- <contentType></contentType> --> + + <!-- The icon to display for the file type. Optional. --> + <!-- <icon> + <image16x16></image16x16> + <image32x32></image32x32> + <image48x48></image48x48> + <image128x128></image128x128> + </icon> --> + + <!-- </fileType> --> + <!-- </fileTypes> --> + + <!-- iOS specific capabilities --> + <!-- <iPhone> --> + <!-- A list of plist key/value pairs to be added to the application Info.plist --> + <!-- <InfoAdditions> + <![CDATA[ + <key>UIDeviceFamily</key> + <array> + <string>1</string> + <string>2</string> + </array> + <key>UIStatusBarStyle</key> + <string>UIStatusBarStyleBlackOpaque</string> + <key>UIRequiresPersistentWiFi</key> + <string>YES</string> + ]]> + </InfoAdditions> --> + <!-- A list of plist key/value pairs to be added to the application Entitlements.plist --> + <!-- <Entitlements> + <![CDATA[ + <key>keychain-access-groups</key> + <array> + <string></string> + <string></string> + </array> + ]]> + </Entitlements> --> + <!-- Display Resolution for the app (either "standard" or "high"). Optional. Default "standard" --> + <!-- <requestedDisplayResolution></requestedDisplayResolution> --> + <!-- </iPhone> --> + + <!-- Specify Android specific tags that get passed to AndroidManifest.xml file. --> + <!--<android> --> + <!-- <manifestAdditions> + <![CDATA[ + <manifest android:installLocation="auto"> + <uses-permission android:name="android.permission.INTERNET"/> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> + <uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch"/> + <application android:enabled="true"> + <activity android:excludeFromRecents="false"> + <intent-filter> + <action android:name="android.intent.action.MAIN"/> + <category android:name="android.intent.category.LAUNCHER"/> + </intent-filter> + </activity> + </application> + </manifest> + ]]> + </manifestAdditions> --> + <!-- Color depth for the app (either "32bit" or "16bit"). Optional. Default 16bit before namespace 3.0, 32bit after --> + <!-- <colorDepth></colorDepth> --> + <!-- </android> --> + <!-- End of the schema for adding the android specific tags in AndroidManifest.xml file --> + +</application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/PlayerGlobalToJS.mxml ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/PlayerGlobalToJS.mxml b/vf2js/utils/PlayerGlobalToJS/src/PlayerGlobalToJS.mxml new file mode 100755 index 0000000..4b2a97c --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/PlayerGlobalToJS.mxml @@ -0,0 +1,660 @@ +<?xml version="1.0" encoding="utf-8"?> +<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + creationComplete="creationCompleteHandler(event)"> + + <fx:Script><![CDATA[ + + import flash.utils.Dictionary; + import flash.utils.getQualifiedClassName; + + import mx.events.FlexEvent; + import mx.utils.StringUtil; + + import nl.ixms.Utils; + import nl.ixms.enums.MemberType; + import nl.ixms.vo.Clazz; + import nl.ixms.vo.JSDoc; + + import org.as3commons.reflect.Accessor; + import org.as3commons.reflect.Constant; + import org.as3commons.reflect.Method; + import org.as3commons.reflect.Parameter; + import org.as3commons.reflect.Type; + import org.as3commons.reflect.Variable; + + include './shadowInterfaces.as'; + + + + //---------------------------------------------------------------------- + // + // Constants + // + //---------------------------------------------------------------------- + + private const ACTION_UNIMPLEMENTED:String = + 'console.log(\'VF2JS Error: call to unimplemented class member ({0})\');'; + + + + //---------------------------------------------------------------------- + // + // Properties + // + //---------------------------------------------------------------------- + + //-------------------------------------- + // catalogXML_ + //-------------------------------------- + + private var catalogXML_:XMLList; + + //-------------------------------------- + // classes_ + //-------------------------------------- + + private var classes_:Dictionary; + + //-------------------------------------- + // functions_ + //-------------------------------------- + + private var functions_:Dictionary; + + //-------------------------------------- + // outputRoot_ + //-------------------------------------- + + private var outputRoot_:File; + + + + //---------------------------------------------------------------------- + // + // Methods + // + //---------------------------------------------------------------------- + + //-------------------------------------- + // createOutputDirectory + //-------------------------------------- + + private function createOutputDirectory():void { + outputRoot_ = + new File(File.applicationDirectory.nativePath).resolvePath( + '../out'); + + if (outputRoot_.exists) { + outputRoot_.deleteDirectory(true); + } + + outputRoot_.createDirectory(); + + File.applicationDirectory.resolvePath('assets/vf2js').copyTo( + outputRoot_.resolvePath('vf2js')); + } + + //-------------------------------------- + // creationCompleteHandler + //-------------------------------------- + + private function creationCompleteHandler(event:FlexEvent):void { + var clazz:Clazz, + clsAccessor:Accessor, + clsConstant:Constant, + clsMemberName:MemberType, + clsMemberTypeNames:Array, + clsMemberType:String, + clsMemberValue:Object, + clsField:Object, + clsMembers:Dictionary, + clsType:Type, + clsVariable:Variable, + funczion:Object, + i:int, + j:int, + key:String, + m:int, + n:int, + p:int, + parameter:Parameter, + parameters:Array, + parameterNames:Array, + q:int; + + clsMemberTypeNames = [ + MemberType.STATIC_CONSTANT, + MemberType.STATIC_VARIABLE, + MemberType.STATIC_PROPERTY, + MemberType.STATIC_METHOD, + MemberType.CONSTANT, + MemberType.VARIABLE, + MemberType.PROPERTY, + MemberType.METHOD ]; + + createOutputDirectory(); + + readCatalogXML(); + + parseClasses(); + + // VERY special case + functions_['mx.core.mx_internal'] = 'mx.core.mx_internal'; + + for (key in functions_) { + clazz = new Clazz(null); + + clazz.qName = key; + + if (key.split('.').length > 1) { + clazz.name = clazz.qName.substring( + clazz.qName.lastIndexOf('.') + 1, clazz.qName.length); + } else { + continue; + } + + clazz.startOutput(); + + writeClassFile(clazz); + } + + for (key in classes_) { + clazz = Clazz(classes_[key]); + + clsType = clazz.type; + if (clsType && + clsType.fullName && + clsType.fullName !== 'Object') { + + clsMembers = parseClassMembers(clazz); + + clazz.startOutput(); + + // Member stubs + for (var count:int = 0, total:int = clsMemberTypeNames.length; count < total; count++) { + clsMemberName = clsMemberTypeNames[count]; + if (clsMembers[clsMemberName].length > 0) { + + clazz.addMajorBlockComment( + clsMemberName.toString().toUpperCase().replace('_', ' ')); + + for (j = 0, m = clsMembers[clsMemberName].length; j < m; j++) { + if (clsMembers[clsMemberName][j] is Constant || + clsMembers[clsMemberName][j] is Variable) { + clsField = clsMembers[clsMemberName][j]; + clsMemberType = + Utils.parseType(flash.utils.getQualifiedClassName( + clsField.type.clazz)); + + clazz.output += JSDoc.emitJSDoc( + JSDoc.FIELD, + clsField.name, + clsMemberType); + + clazz.output += + clazz.qName + + '.' + + ((clsField.isStatic) ? '' : 'prototype.') + + clsField.name; + + clsMemberValue = clsField.getValue(); + if (clsMemberValue) { + clazz.output += ' = '; + + if (clsMemberType === 'Array') { + clazz.output += '['; + for (var k:int = 0, l:int = clsMemberValue.length; k < l; k++) { + if (k > 0) { + clazz.output += ', '; + } + clazz.output += '\'' + clsMemberValue[k] + '\''; + } + clazz.output += ']'; + } else { + clazz.output += + ((clsMemberType === 'string') ? '\'' : '') + + clsMemberValue + + ((clsMemberType === 'string') ? '\'' : ''); + } + } + + clazz.output += Clazz.MEMBER_SEPARATOR; + } else if (clsMembers[clsMemberName][j] is Accessor) { + clsField = clsMembers[clsMemberName][j]; + clsMemberType = + Utils.parseType(flash.utils.getQualifiedClassName( + clsField.type.clazz)); + + clazz.output += JSDoc.emitJSDoc( + JSDoc.METHOD, + clsField.name, + '', clsMemberType); + + clazz.output += + clazz.qName + + '.' + + ((clsField.isStatic) ? '' : 'prototype.') + + 'get_' + clsField.name + ' = ' + + 'function() {\n' + + ' ' + getImplementation( + clazz, clsField, 'get_', true) + '\n' + + '}'; + + if (Accessor(clsField).writeable) { + clazz.output += Clazz.MEMBER_SEPARATOR; + + parameter = new Parameter(null, 0); + + clazz.output += JSDoc.emitJSDoc( + JSDoc.FIELD, + clsField.name); + + clazz.output += + clazz.qName + + '.' + + ((clsField.isStatic) ? '' : 'prototype.') + + 'set_' + clsField.name + ' = ' + + 'function(value) {\n' + + ' ' + getImplementation( + clazz, clsField, 'set_') + '\n' + + '}'; + } + + /* + clazz.output += JSDoc.emitJSDoc( + JSDoc.FIELD, + clsField.name, + clsMemberType); + + clazz.output += + clazz.qName + + '.' + + ((clsField.isStatic) ? '' : 'prototype.') + + clsField.name + + ';\n\n'; + + clazz.output += + 'Object.defineProperty(' + clazz.qName + ((clsField.isStatic) ? '' : '.prototype') + ', \'' + clsField.name + '\', {\n' + + ' get: function() {\n' + + ' ' + StringUtil.substitute(ACTION_UNIMPLEMENTED, [clazz.qName + '::' + clsField.name]) + '\n' + + ' }'; + if (Accessor(clsField).writeable) { + clazz.output += + ',\n set: function(value) {\n' + + ' ' + StringUtil.substitute(ACTION_UNIMPLEMENTED, [clazz.qName + '::' + clsField.name]) + '\n' + + ' }'; + } + clazz.output += + '\n})'; + */ + + clazz.output += Clazz.MEMBER_SEPARATOR; + } else if (clsMembers[clsMemberName][j] is Method) { + clsField = clsMembers[clsMemberName][j]; + + parameters = Method(clsField).parameters; + + parameterNames = []; + for (i = 0, n = parameters.length; i < n; i++) { + parameterNames.push(((parameters[i].isOptional) ? 'opt_' : '') + 'arg' + i); + } + + var returnType:String = Utils.parseType(Method(clsField).returnType.fullName); + if (returnType === 'void') { + returnType = ''; + } + + clazz.output += JSDoc.emitJSDoc( + JSDoc.METHOD, + clsField.name, + parameters, + returnType); + + clazz.output += + clazz.qName + + '.' + + ((clsField.isStatic) ? '' : 'prototype.') + + clsField.name + + ' = function(' + + parameterNames.join(', ') + + ') {'; + if (!clazz.type.isInterface) { + clazz.output += '\n ' + getImplementation( + clazz, clsField, '', + (returnType !== ''), + parameterNames.join(', ')) + '\n'; + } + clazz.output += '}'; + + clazz.output += Clazz.MEMBER_SEPARATOR; + } + } + } + } + + writeClassFile(clazz); + } + } + + this.exit(); + } + + //-------------------------------------- + // getImplementation + //-------------------------------------- + + private function getImplementation(clazz:Clazz, + clsField:Object, + prefix:String = '', + returns:Boolean = false, + parameters:String = ''):String { + var compositeClazzMembers:Array, + hasImplementation:Boolean = false, + i:int, + isStatic:Boolean, + implementation:String, + memberName:String; + + if (clazz.compositeClazz) { + if (clsField is Accessor) { + memberName = Accessor(clsField).name; + isStatic = Accessor(clsField).isStatic; + + compositeClazzMembers = clazz.compositeClazz.accessors; + + for (i = compositeClazzMembers.length - 1; i > -1; i--) { + if (compositeClazzMembers[i].name === memberName) { + hasImplementation = true; + + break; + } + } + + if (hasImplementation) { + implementation = ((returns) ? 'return ' : '') + + ((isStatic) ? clazz.compositeClazzName + '.' : 'this.$_implementation.') + + prefix + memberName + '();'; + } else { + implementation = + StringUtil.substitute(ACTION_UNIMPLEMENTED, + [clazz.qName + '::' + prefix + memberName]); + } + } else if (clsField is Method) { + memberName = Method(clsField).name; + isStatic = Method(clsField).isStatic; + + compositeClazzMembers = clazz.compositeClazz.methods; + + for (i = compositeClazzMembers.length - 1; i > -1; i--) { + if (compositeClazzMembers[i].name === memberName) { + hasImplementation = true; + + break; + } + } + + if (hasImplementation) { + implementation = ((returns) ? 'return ' : '') + + ((isStatic) ? clazz.compositeClazzName + '.' : 'this.$_implementation.') + + memberName + '(' + parameters + ');'; + } else { + implementation = + StringUtil.substitute(ACTION_UNIMPLEMENTED, + [clazz.qName + '::' + memberName]); + + if (returns) { + implementation += + '\n\n return null; // placeholder to appease gjslint'; + } + } + } + } + + return implementation; + } + + //-------------------------------------- + // parseClassMembers + //-------------------------------------- + + private function parseClassMembers(clazz:Clazz):Dictionary { + var clsField:Object, + clsFieldsArray:Array, + clsMembers:Dictionary, + clsMethod:Method, + clsMethodsArray:Array, + clsType:Type, + i:int, + n:int; + + clsMembers = new Dictionary(); + clsMembers[MemberType.STATIC_CONSTANT] = []; + clsMembers[MemberType.STATIC_VARIABLE] = []; + clsMembers[MemberType.STATIC_PROPERTY] = []; + clsMembers[MemberType.STATIC_METHOD] = []; + clsMembers[MemberType.CONSTANT] = []; + clsMembers[MemberType.VARIABLE] = []; + clsMembers[MemberType.PROPERTY] = []; + clsMembers[MemberType.METHOD] = []; + + clsType = clazz.type; + + clsFieldsArray = clsType.fields; + for (i = 0, n = clsFieldsArray.length; i < n; i++) { + clsField = clsFieldsArray[i]; + if (clsField.declaringType.name === clsType.name) { + if (clsField is Constant && clsField.name !== 'length') { + if (clsField.isStatic) { + clsMembers[MemberType.STATIC_CONSTANT].push(clsField); + } else { + clsMembers[MemberType.CONSTANT].push(clsField); + } + } else if (clsField is Variable) { + if (clsField.isStatic) { + clsMembers[MemberType.STATIC_VARIABLE].push(clsField); + } else { + clsMembers[MemberType.VARIABLE].push(clsField); + } + } else if (clsField is Accessor) { + if (clsField.isStatic) { + clsMembers[MemberType.STATIC_PROPERTY].push(clsField); + } else { + clsMembers[MemberType.PROPERTY].push(clsField); + } + } + } + } + + clsMethodsArray = clsType.methods; + for (i = 0, n = clsMethodsArray.length; i < n; i++) { + clsMethod = clsMethodsArray[i]; + if (clsMethod.declaringType.name === clsType.name) { + if (clsMethod.isStatic) { + clsMembers[MemberType.STATIC_METHOD].push(clsMethod); + } else { + clsMembers[MemberType.METHOD].push(clsMethod); + } + } + } + + return clsMembers; + } + + //-------------------------------------- + // parseClasses + //-------------------------------------- + + private function parseClasses():void { + var addClazz:Function, className:String, classType:Type, + clazz:Clazz, exclude:Boolean, excludeFunctionPackageArr:Array, + excludeTopLevelClassArr:Array, pkg:String, pkgArr:Array, i:int, + interfaceName:String, interfaceNamesArray:Array, interfaceType:Type, + isClazz:Function, j:int, jsEquivArr:Array, m:int, n:int, + namespaceArray:Array, superClassName:String, + superClassNamesArray:Array, superClassType:Type; + + addClazz = function (name:String, type:Type):void { + var result:Clazz; + + result = new Clazz(type); + result.name = type.name; + result.qName = Utils.cleanClassQName(type.fullName); + + if (excludeTopLevelClassArr.indexOf(name) === -1) { + classes_[name] = result; + } + } + + isClazz = function (clazzName:String):Boolean { + var clazzNameArr:Array, firstCharCode:Number; + + clazzNameArr = clazzName.split('.'); + if (clazzNameArr && clazzNameArr.length > 0) { + clazzName = clazzNameArr[clazzNameArr.length - 1]; + } + firstCharCode = clazzName.charCodeAt(0); + + return firstCharCode >= 65 && firstCharCode <= 90; + } + + // ToDo (erikdebruin): these classes have an JS counterpart, and we + // want to only add those members that are not + // in the JS implementation, or override those + // with a different implementation. + excludeTopLevelClassArr = [ + 'Array', 'Boolean', 'Date',/* 'Error',*/ 'EvalError', 'Function', + 'JSON', 'Math', 'Number', 'QName', 'RangeError', + 'ReferenceError', 'RegExp', 'String', 'SyntaxError', + 'TypeError' ]; + + excludeFunctionPackageArr = [ + 'avmplus', 'avm2.intrinsics.memory', 'bugzilla', + 'flash.debugger', 'flash.media', 'flash.profiler', + 'flash.sampler', 'watson' ]; + + jsEquivArr = [ + 'decodeURI', 'decodeURIComponent', 'encodeURI', + 'encodeURIComponent', 'escape', 'isFinite', + 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape' ]; + + classes_ = new Dictionary(); + + functions_ = new Dictionary(); + + for (i = 0, n = catalogXML_.length() - 1; i < n; i++) { + className = Utils.cleanClassQName(catalogXML_[i].@id); + try + { + if (!classes_[className]) { + classType = Type.forName(className); + if (classType && classType.fullName) { + namespaceArray = className.split('.'); + if (namespaceArray.length === 1 || + namespaceArray[0] === 'flash') { + + addClazz(className, classType); + + superClassNamesArray = classType.extendsClasses; + m = superClassNamesArray.length; + for (j = 0; j < m; j++) { + superClassName = Utils.cleanClassQName( + superClassNamesArray[j]); + if (!classes_[superClassName]) { + superClassType = Type.forName( + superClassName); + if (superClassType) { + addClazz(superClassName, + superClassType); + } + } + } + + // fetch class' interfaces + interfaceNamesArray = classType.interfaces; + m = interfaceNamesArray.length; + for (j = 0; j < m; j++) { + interfaceName = interfaceNamesArray[j]; + if (!classes_[interfaceName]) { + interfaceType = Type.forName( + interfaceName); + if (interfaceType) { + addClazz(interfaceName, + interfaceType); + } + } + } + } + } else { // "function Classes" + pkgArr = className.split('.'); + if (pkgArr.length > 1) { + pkgArr.pop(); + } + pkg = pkgArr.join('.'); + + exclude = pkg.charAt(0) === '_' || + excludeFunctionPackageArr.indexOf(pkg) > -1 || + jsEquivArr.indexOf(pkg) > -1; + + if (!isClazz(className) && !exclude) { + functions_[className] = className; + } + } + } + } + catch (err:Error) { /* eat Type.forName() exceptions */ } + } + } + + //-------------------------------------- + // readCatalogXML + //-------------------------------------- + + private function readCatalogXML():void { + var file:File, stream:FileStream, xml:XML; + + file = File.applicationDirectory.resolvePath( + 'assets/catalog_15.xml'); + + stream = new FileStream(); + stream.open(file, FileMode.READ); + xml = new XML( + stream.readUTFBytes(stream.bytesAvailable).replace( + /xmlns=".*"/, "")); + stream.close(); + + catalogXML_ = xml..script.children(); + } + + //-------------------------------------- + // writeClassFile + //-------------------------------------- + + private function writeClassFile(clazz:Clazz):void { + var file:File, + fileStream:FileStream, + clazzQName:String, + packagePath:String; + + clazzQName = clazz.qName; + + packagePath = (clazzQName.indexOf('.') > -1) ? clazzQName : ''; + packagePath = packagePath.substring(0, packagePath.lastIndexOf('.')); + packagePath = packagePath.replace(/\./g, '/'); + if (packagePath !== '') { + packagePath = packagePath + '/'; + } + + fileStream = new FileStream(); + file = outputRoot_.resolvePath(packagePath + clazz.name + '.js'); + fileStream.open(file, FileMode.WRITE); + fileStream.writeUTFBytes(clazz.output); + fileStream.close(); + } + + ]]></fx:Script> + + <fx:Declarations /> + +</s:WindowedApplication> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/DisplayObject.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/DisplayObject.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/DisplayObject.js new file mode 100644 index 0000000..17805e3 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/DisplayObject.js @@ -0,0 +1,173 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.display.DisplayObject' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.display.DisplayObject'); + +goog.require('flash.display.DisplayObject'); +goog.require('flash.display.DisplayObjectContainer'); +goog.require('flash.display.IBitmapDrawable'); +goog.require('flash.display.LoaderInfo'); +goog.require('vf2js.events.EventDispatcher'); + + + +/** + * @constructor + * @struct + * @extends {vf2js.events.EventDispatcher} + * @implements {flash.display.IBitmapDrawable} + */ +vf2js.display.DisplayObject = function() { + vf2js.display.DisplayObject.base(this, 'constructor'); +}; +goog.inherits(vf2js.display.DisplayObject, vf2js.events.EventDispatcher); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.display.DisplayObject.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'DisplayObject', qName: 'vf2js.display.DisplayObject'}], + interfaces: [flash.display.IBitmapDrawable] }; + + +//------------------------------------------------------------------------------ +// +// PROPERTIES +// +//------------------------------------------------------------------------------ + + +/** + * loaderInfo + * + * @return {flash.display.LoaderInfo} + */ +vf2js.display.DisplayObject.prototype.get_loaderInfo = function() { + return window['apache-flex_loaderInfo']; +}; + + +/** + * parent_ + * + * @type {flash.display.DisplayObjectContainer} + */ +vf2js.display.DisplayObject.prototype.parent_; + + +/** + * parent + * + * @param {flash.display.DisplayObjectContainer} value The parent container. + */ +vf2js.display.DisplayObject.prototype.set_parent = function(value) { + this.parent_ = value; +}; + + +/** + * parent + * + * @return {flash.display.DisplayObjectContainer} + */ +vf2js.display.DisplayObject.prototype.get_parent = function() { + return this.parent_ +}; + + +/** + * root + * + * @return {flash.display.DisplayObject} + */ +vf2js.display.DisplayObject.prototype.get_root = function() { + return window['apache-flex_system-manager']; +}; + + +/** + * stage + * + * @return {flash.display.Stage} + */ +vf2js.display.DisplayObject.prototype.get_stage = function() { + return window['apache-flex_stage']; +}; + + +/** + * scaleX_ + * + * @type {number} + */ +vf2js.display.DisplayObject.prototype.scaleX_; + + +/** + * scaleX + * + * @return {number} + */ +vf2js.display.DisplayObject.prototype.get_scaleX = function() { + return scaleX_; +}; + + +/** + * scaleX + * + * @param {number} value The new value. + */ +vf2js.display.DisplayObject.prototype.set_scaleX = function(value) { + this.scaleX_ = value; +}; + + +/** + * scaleY_ + * + * @type {number} + */ +vf2js.display.DisplayObject.prototype.scaleY_; + + +/** + * scaleY + * + * @return {number} + */ +vf2js.display.DisplayObject.prototype.get_scaleY = function() { + return scaleY_; +}; + + +/** + * scaleY + * + * @param {number} value The new value. + */ +vf2js.display.DisplayObject.prototype.set_scaleY = function(value) { + this.scaleY_ = value; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/DisplayObjectContainer.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/DisplayObjectContainer.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/DisplayObjectContainer.js new file mode 100644 index 0000000..5c24e8b --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/DisplayObjectContainer.js @@ -0,0 +1,110 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.display.DisplayObjectContainer' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.display.DisplayObjectContainer'); + +goog.require('vf2js.display.InteractiveObject'); + + + +/** + * @constructor + * @struct + * @extends {vf2js.display.InteractiveObject} + */ +vf2js.display.DisplayObjectContainer = function() { + vf2js.display.DisplayObjectContainer.base(this, 'constructor'); + + this.children_ = []; +}; +goog.inherits(vf2js.display.DisplayObjectContainer, vf2js.display.InteractiveObject); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.display.DisplayObjectContainer.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'DisplayObjectContainer', qName: 'vf2js.display.DisplayObjectContainer'}], + interfaces: [] }; + + +//------------------------------------------------------------------------------ +// +// PROPERTIES +// +//------------------------------------------------------------------------------ + + +/** + * children_ + * + * @private + * + * @type {Array.<flash.display.DisplayObject>} + */ +vf2js.display.DisplayObjectContainer.prototype.children_; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * addChildAt + * + * @param {flash.display.DisplayObject} arg0 Argument 0 + * @param {number} arg1 Argument 1 + * + * @return {flash.display.DisplayObject} + */ +vf2js.display.DisplayObjectContainer.prototype.addChildAt = function(arg0, arg1) { + arg0.$_implementation.set_parent(this); + + this.children_[arg1] = arg0; + + this.dispatchEvent(new flash.events.Event(flash.events.Event.ADDED)); + + return arg0; +}; + + +/** + * addChild + * + * @param {flash.display.DisplayObject} arg0 Argument 0 + * + * @return {flash.display.DisplayObject} + */ +vf2js.display.DisplayObjectContainer.prototype.addChild = function(arg0) { + arg0.$_implementation.set_parent(this); + + this.children_.push(arg0); + + this.dispatchEvent(new flash.events.Event(flash.events.Event.ADDED)); + + return arg0; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/InteractiveObject.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/InteractiveObject.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/InteractiveObject.js new file mode 100644 index 0000000..211c8f3 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/InteractiveObject.js @@ -0,0 +1,33 @@ +/** + * @fileoverview 'vf2jsvf2js.display.InteractiveObject' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.display.InteractiveObject'); + +goog.require('vf2js.display.DisplayObject'); + + + +/** + * @constructor + * @struct + * @extends {vf2js.display.DisplayObject} + */ +vf2js.display.InteractiveObject = function() { + vf2js.display.InteractiveObject.base(this, 'constructor'); +}; +goog.inherits(vf2js.display.InteractiveObject, vf2js.display.DisplayObject); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.display.InteractiveObject.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'InteractiveObject', qName: 'vf2js.display.InteractiveObject'}], + interfaces: [] } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/LoaderInfo.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/LoaderInfo.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/LoaderInfo.js new file mode 100644 index 0000000..611ae00 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/LoaderInfo.js @@ -0,0 +1,125 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.display.LoaderInfo' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.display.LoaderInfo'); + +goog.require('vf2js.events.EventDispatcher'); + + + +/** + * @constructor + * @struct + * @extends {vf2js.events.EventDispatcher} + */ +vf2js.display.LoaderInfo = function() { + vf2js.display.LoaderInfo.base(this, 'constructor'); +}; +goog.inherits(vf2js.display.LoaderInfo, vf2js.events.EventDispatcher); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.display.LoaderInfo.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'LoaderInfo', qName: 'vf2js.display.LoaderInfo'}], + interfaces: [flash.events.IEventDispatcher] }; + + +//------------------------------------------------------------------------------ +// +// PROPERTIES +// +//------------------------------------------------------------------------------ + + +/** + * width + * + * @return {number} + */ +vf2js.display.LoaderInfo.prototype.get_width = function() { + return 1024; +}; + + +/** + * bytesLoaded + * + * @return {number} + */ +vf2js.display.LoaderInfo.prototype.get_bytesLoaded = function() { + return 1; +}; + + +/** + * height + * + * @return {number} + */ +vf2js.display.LoaderInfo.prototype.get_height = function() { + return 768; +}; + + +/** + * url + * + * @return {string} + */ +vf2js.display.LoaderInfo.prototype.get_url = function() { + console.log('vf2js.display.LoaderInfo.get_url'); + + return document.location.url; +}; + + +/** + * bytesTotal + * + * @return {number} + */ +vf2js.display.LoaderInfo.prototype.get_bytesTotal = function() { + return 1; +}; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * dispatchEvent + * + * @param {Event} arg0 Argument 0 + * + * @return {boolean} + */ +vf2js.display.LoaderInfo.prototype.dispatchEvent = function(arg0) { + return vf2js.display.LoaderInfo.base(this, 'dispatchEvent', arg0); +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/MovieClip.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/MovieClip.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/MovieClip.js new file mode 100644 index 0000000..331ccc2 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/MovieClip.js @@ -0,0 +1,115 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.display.MovieClip' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.display.MovieClip'); + +goog.require('vf2js.display.Sprite'); + + + +/** + * @constructor + * @struct + * @extends {flash.display.Sprite} + */ +vf2js.display.MovieClip = function() { + vf2js.display.MovieClip.base(this, 'constructor'); +}; +goog.inherits(vf2js.display.MovieClip, vf2js.display.Sprite); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.display.MovieClip.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'MovieClip', qName: 'vf2js.display.MovieClip'}], + interfaces: [] }; + + +//------------------------------------------------------------------------------ +// +// PROPERTIES +// +//------------------------------------------------------------------------------ + + +/** + * framesLoaded + * + * @return {number} + */ +vf2js.display.MovieClip.prototype.get_framesLoaded = function() { + return 2; +}; + + +/** + * currentFrame_ + * + * @type {number} + */ +vf2js.display.MovieClip.prototype.currentFrame_ = 1; + + +/** + * currentFrame + * + * @return {number} + */ +vf2js.display.MovieClip.prototype.get_currentFrame = function() { + return this.currentFrame_; +}; + + +/** + * totalFrames + * + * @return {number} + */ +vf2js.display.MovieClip.prototype.get_totalFrames = function() { + return 2; +}; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * nextFrame + */ +vf2js.display.MovieClip.prototype.nextFrame = function() { + this.currentFrame_++; +}; + + +/** + * stop + */ +vf2js.display.MovieClip.prototype.stop = function() { + // DO NOTHING, WE'RE NOT ON A TIMELINE +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/Sprite.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/Sprite.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/Sprite.js new file mode 100644 index 0000000..c55f032 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/Sprite.js @@ -0,0 +1,33 @@ +/** + * @fileoverview 'vf2jsvf2js.display.InteractiveObject' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.display.Sprite'); + +goog.require('vf2js.display.DisplayObjectContainer'); + + + +/** + * @constructor + * @struct + * @extends {vf2js.display.DisplayObjectContainer} + */ +vf2js.display.Sprite = function() { + vf2js.display.Sprite.base(this, 'constructor'); +}; +goog.inherits(vf2js.display.Sprite, vf2js.display.DisplayObjectContainer); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.display.InteractiveObject.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'Sprite', qName: 'vf2js.display.Sprite'}], + interfaces: [] } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/Stage.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/Stage.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/Stage.js new file mode 100644 index 0000000..6837d83 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/display/Stage.js @@ -0,0 +1,210 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.display.Stage' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.display.Stage'); + +goog.require('flash.display.DisplayObjectContainer'); +goog.require('flash.display.StageAlign'); + + + +/** + * @constructor + * @struct + * @extends {flash.display.DisplayObjectContainer} + */ +vf2js.display.Stage = function() { + vf2js.display.Stage.base(this, 'constructor'); +}; +goog.inherits(vf2js.display.Stage, flash.display.DisplayObjectContainer); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.display.Stage.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'Stage', qName: 'vf2js.display.Stage'}], + interfaces: [] }; + + +//------------------------------------------------------------------------------ +// +// PROPERTIES +// +//------------------------------------------------------------------------------ + + +/** + * align_ + * + * @private + * + * @type {string} + */ +vf2js.display.Stage.prototype.align_ = flash.display.StageAlign.TOP; + + +/** + * align + * + * @return {string} + */ +vf2js.display.Stage.prototype.get_align = function() { + return this.align_; +}; + + +/** + * align + * + * @type {undefined} + */ +vf2js.display.Stage.prototype.set_align = function(value) { + this.align_ = value; +}; + + +/** + * quality_ + * + * @private + * + * @type {string} + */ +vf2js.display.Stage.prototype.quality_; + + +/** + * quality + * + * @return {string} + */ +vf2js.display.Stage.prototype.get_quality = function() { + return this.quality_; +}; + + +/** + * quality + * + * @param {string} value The new value. + */ +vf2js.display.Stage.prototype.set_quality = function(value) { + this.quality_ = value; +}; + + +/** + * scaleMode_ + * + * @private + * + * @type {string} + */ +vf2js.display.Stage.prototype.scaleMode_; + + +/** + * scaleMode + * + * @return {string} + */ +vf2js.display.Stage.prototype.get_scaleMode = function() { + return this.scaleMode_; +}; + + +/** + * scaleMode + * + * @param {string} value The new value. + */ +vf2js.display.Stage.prototype.set_scaleMode = function(value) { + this.scaleMode_ = value; +}; + + +/** + * stageHeight + * + * @return {number} + */ +vf2js.display.Stage.prototype.get_stageHeight = function() { + return 768; +}; + + +/** + * stageWidth + * + * @return {number} + */ +vf2js.display.Stage.prototype.get_stageWidth = function() { + return 1024; +}; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * addEventListener + * + * @param {string} arg0 Argument 0 + * @param {Function} arg1 Argument 1 + * @param {boolean=} opt_arg2 Argument 2 (optional) + * @param {number=} opt_arg3 Argument 3 (optional) + * @param {boolean=} opt_arg4 Argument 4 (optional) + */ +vf2js.display.Stage.prototype.addEventListener = function(arg0, arg1, opt_arg2, opt_arg3, opt_arg4) { + vf2js.display.Stage.base(this, 'addEventListener', arg0, arg1, opt_arg2, opt_arg3, opt_arg4); +}; + + +/** + * dispatchEvent + * + * @param {Event} arg0 Argument 0 + * + * @return {boolean} + */ +vf2js.display.Stage.prototype.dispatchEvent = function(arg0) { + return vf2js.display.Stage.base(this, 'dispatchEvent', arg0); +}; + + +/** + * hasEventListener + * + * @param {string} arg0 Argument 0 + * + * @return {boolean} + */ +vf2js.display.Stage.prototype.hasEventListener = function(arg0) { + return vf2js.display.Stage.base(this, 'hasEventListener', arg0); +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/Event.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/Event.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/Event.js new file mode 100644 index 0000000..94f0426 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/Event.js @@ -0,0 +1,136 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.events.Event' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.events.Event'); + + + +/** + * @constructor + * @struct + * @param {string} arg0 Argument 0 + * @param {boolean=} opt_arg1 Argument 1 (optional) + * @param {boolean=} opt_arg2 Argument 2 (optional) + */ +vf2js.events.Event = function(arg0, opt_arg1, opt_arg2) { + this._type = arg0; + + opt_arg1 = (opt_arg1 !== undefined) ? opt_arg1 : false; + this._bubbles = opt_arg1; + + opt_arg2 = (opt_arg2 !== undefined) ? opt_arg2 : false; + this._cancelable = opt_arg2; +}; + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.events.Event.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'Event', qName: 'vf2js.events.Event'}], + interfaces: [] }; + + +//------------------------------------------------------------------------------ +// +// PROPERTIES +// +//------------------------------------------------------------------------------ + + +/** + * _bubbles + * + * @private + * + * @type{boolean} + */ +vf2js.events.Event.prototype._bubbles; + + +/** + * bubbles + * + * @return {boolean} + */ +vf2js.events.Event.prototype.get_bubbles = function() { + return this._bubbles; +}; + + +/** + * _cancelable + * + * @private + * + * @type{boolean} + */ +vf2js.events.Event.prototype._cancelable; + + +/** + * cancelable + * + * @return {boolean} + */ +vf2js.events.Event.prototype.get_cancelable = function() { + return this._cancelable; +}; + + +/** + * _type + * + * @private + * + * @type{string} + */ +vf2js.events.Event.prototype._type; + + +/** + * type + * + * @return {string} + */ +vf2js.events.Event.prototype.get_type = function() { + return this._type; +}; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * toString + * + * @return {string} + */ +vf2js.events.Event.prototype.toString = function() { + return '[Event type=' + this._type + ' bubbles=' + this._bubbles + ' cancelable=' + this._cancelable + ']'; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/EventDispatcher.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/EventDispatcher.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/EventDispatcher.js new file mode 100644 index 0000000..01f1d32 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/EventDispatcher.js @@ -0,0 +1,154 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.events.EventDispatcher' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.events.EventDispatcher'); + +goog.require('goog.events.EventTarget'); + + + +/** + * @constructor + * @struct + * @param {IEventDispatcher=} opt_arg0 Argument 0 (optional) + */ +vf2js.events.EventDispatcher = function(opt_arg0) { + this.eventTarget_ = new goog.events.EventTarget(); + + this.listeners_ = []; +}; + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.events.EventDispatcher.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'EventDispatcher', qName: 'vf2js.events.EventDispatcher'}], + interfaces: [] }; + + +//------------------------------------------------------------------------------ +// +// PROPERTIES +// +//------------------------------------------------------------------------------ + + +/** + * listeners_ + * + * @private + * + * @type {Array.<string>} + */ +vf2js.events.EventDispatcher.prototype.listeners_; + + +/** + * eventTarget_ + * + * @private + * + * @type {goog.events.EventTarget} + */ +vf2js.events.EventDispatcher.prototype.eventTarget_; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * dispatchEvent + * + * @param {Event} arg0 Argument 0 + * + * @return {boolean} + */ +vf2js.events.EventDispatcher.prototype.dispatchEvent = function(arg0) { + console.log('$ dispatchEvent: ' + arg0.get_type()); + + return this.eventTarget_.dispatchEvent(arg0.get_type()); +}; + + +/** + * addEventListener + * + * @param {string} arg0 Argument 0 + * @param {Function} arg1 Argument 1 + * @param {boolean=} opt_arg2 Argument 2 (optional) + * @param {number=} opt_arg3 Argument 3 (optional) + * @param {boolean=} opt_arg4 Argument 4 (optional) + */ +vf2js.events.EventDispatcher.prototype.addEventListener = function(arg0, arg1, opt_arg2, opt_arg3, opt_arg4) { + console.log('Listen for event: ' + arg0); + + if (!this.hasEventListener(arg0)) { + this.listeners_.push(arg0); + + this.eventTarget_.listen(arg0, arg1); + } +}; + + +/** + * hasEventListener + * + * @param {string} arg0 Argument 0 + * + * @return {boolean} + */ +vf2js.events.EventDispatcher.prototype.hasEventListener = function(arg0) { + return this.listeners_.indexOf(arg0) > -1; +}; + + +/** + * removeEventListener + * + * @param {string} arg0 Argument 0 + * @param {Function} arg1 Argument 1 + * @param {boolean=} opt_arg2 Argument 2 (optional) + */ +vf2js.events.EventDispatcher.prototype.removeEventListener = function(arg0, arg1, opt_arg2) { + console.log('Unlisten event: ' + arg0); + + this.listeners_.splice(this.listeners_.indexOf(arg0), 1); + + this.eventTarget_.unlisten(arg0, arg1); +}; + + +/** + * toString + * + * @return {string} The string + */ +vf2js.events.EventDispatcher.prototype.toString = function() { + //return this.toString(); +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/ProgressEvent.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/ProgressEvent.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/ProgressEvent.js new file mode 100644 index 0000000..d9c00c0 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/ProgressEvent.js @@ -0,0 +1,75 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.events.ProgressEvent' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.events.ProgressEvent'); + +goog.require('vf2js.events.Event'); + + + +/** + * @constructor + * @struct + * @extends {vf2js.events.Event} + * @param {string} arg0 Argument 0 + * @param {boolean=} opt_arg1 Argument 1 (optional) + * @param {boolean=} opt_arg2 Argument 2 (optional) + * @param {Number=} opt_arg3 Argument 3 (optional) + * @param {Number=} opt_arg4 Argument 4 (optional) + */ +vf2js.events.ProgressEvent = function(arg0, opt_arg1, opt_arg2, opt_arg3, opt_arg4) { + vf2js.events.ProgressEvent.base(this, 'constructor', arg0, opt_arg1, opt_arg2, opt_arg3, opt_arg4); +}; +goog.inherits(vf2js.events.ProgressEvent, vf2js.events.Event); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.events.ProgressEvent.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'ProgressEvent', qName: 'vf2js.events.ProgressEvent'}], + interfaces: [] }; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * toString + * + * @return {string} + */ +vf2js.events.ProgressEvent.prototype.toString = function() { + var /** @type {string} */ result; + + result = vf2js.events.TimerEvent.base(this, 'toString'); + result = result.replace('[Event ', '[ProgressEvent '); + result = result.replace(']', ' bytesLoaded=value bytesTotal=value]'); + + return result; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/TimerEvent.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/TimerEvent.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/TimerEvent.js new file mode 100644 index 0000000..9c9da37 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/events/TimerEvent.js @@ -0,0 +1,72 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.events.TimerEvent' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.events.TimerEvent'); + +goog.require('vf2js.events.Event'); + + + +/** + * @constructor + * @struct + * @extends {flash.events.Event} + * @param {string} arg0 Argument 0 + * @param {boolean=} opt_arg1 Argument 1 (optional) + * @param {boolean=} opt_arg2 Argument 2 (optional) + */ +vf2js.events.TimerEvent = function(arg0, opt_arg1, opt_arg2) { + vf2js.events.TimerEvent.base(this, 'constructor', arg0, opt_arg1, opt_arg2); +}; +goog.inherits(vf2js.events.TimerEvent, vf2js.events.Event); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.events.TimerEvent.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'TimerEvent', qName: 'vf2js.events.TimerEvent'}], + interfaces: [] }; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * toString + * + * @return {string} + */ +vf2js.events.TimerEvent.prototype.toString = function() { + var /** @type {string} */ result; + + result = vf2js.events.TimerEvent.base(this, 'toString'); + result = result.replace('[Event ', '[TimerEvent '); + + return result; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/system/ApplicationDomain.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/system/ApplicationDomain.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/system/ApplicationDomain.js new file mode 100644 index 0000000..9e4eab4 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/system/ApplicationDomain.js @@ -0,0 +1,77 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.system.ApplicationDomain' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.system.ApplicationDomain'); + + + +/** + * @constructor + * @struct + * @param {ApplicationDomain=} opt_arg0 Argument 0 (optional) + */ +vf2js.system.ApplicationDomain = function(opt_arg0) {}; + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.system.ApplicationDomain.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'ApplicationDomain', qName: 'vf2js.system.ApplicationDomain'}], + interfaces: [] }; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * getDefinition + * + * @param {string} arg0 Argument 0 + * + * @return {Object} + */ +vf2js.system.ApplicationDomain.prototype.getDefinition = function(arg0) { + var fullName; + + fullName = arg0.replace(/::/gi, '.'); + + return eval('new ' + fullName + '()'); +}; + + +/** + * hasDefinition + * + * @param {string} arg0 Argument 0 + * + * @return {boolean} + */ +vf2js.system.ApplicationDomain.prototype.hasDefinition = function(arg0) { + return true; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/system/Capabilities.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/system/Capabilities.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/system/Capabilities.js new file mode 100644 index 0000000..4f349a8 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/system/Capabilities.js @@ -0,0 +1,98 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.system.Capabilities' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.system.Capabilities'); + + + +/** + * @constructor + * @struct + */ +vf2js.system.Capabilities = function() {}; + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.system.Capabilities.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'Capabilities', qName: 'vf2js.system.Capabilities'}], + interfaces: [] }; + + +//------------------------------------------------------------------------------ +// +// STATIC PROPERTIES +// +//------------------------------------------------------------------------------ + + +/** + * language + * + * @return {string} + */ +vf2js.system.Capabilities.get_language = function() { + return 'en'; +}; + + +/** + * playerType + * + * @return {string} + */ +vf2js.system.Capabilities.get_playerType = function() { + return 'PlugIn'; +}; + + +/** + * screenDPI + * + * @return {Number} + */ +vf2js.system.Capabilities.get_screenDPI = function() { + return 72; +}; + + +/** + * version + * + * @return {string} + */ +vf2js.system.Capabilities.get_version = function() { + return 'MAC 15,0,0,0'; +}; + + +/** + * os + * + * @return {string} + */ +vf2js.system.Capabilities.get_os = function() { + return 'Mac OS 10.9.5'; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/utils/Timer.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/utils/Timer.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/utils/Timer.js new file mode 100644 index 0000000..1246c2e --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/utils/Timer.js @@ -0,0 +1,182 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.utils.Timer' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.utils.Timer'); + +goog.require('vf2js.events.EventDispatcher'); +goog.require('flash.events.IEventDispatcher'); + + + +/** + * @constructor + * @struct + * @extends {vf2js.events.EventDispatcher} + * @param {Number} arg0 Argument 0 + * @param {number=} opt_arg1 Argument 1 (optional) + */ +vf2js.utils.Timer = function(arg0, opt_arg1) { + vf2js.utils.Timer.base(this, 'constructor'); + + this._delay = arg0; + + opt_arg1 = (opt_arg1 !== undefined) ? opt_arg1 : 10; + this._repeatCount = opt_arg1; + + this._currentCount = 0; +}; +goog.inherits(vf2js.utils.Timer, vf2js.events.EventDispatcher); + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.utils.Timer.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'Timer', qName: 'vf2js.utils.Timer'}], + interfaces: [flash.events.IEventDispatcher] }; + + +//------------------------------------------------------------------------------ +// +// PROPERTIES +// +//------------------------------------------------------------------------------ + + +/** + * _currentCount + * + * @private + * + * @type {number} + */ +vf2js.utils.Timer.prototype._currentCount; + + +/** + * _delay + * + * @private + * + * @type {number} + */ +vf2js.utils.Timer.prototype._delay; + + +/** + * delay + * + * @return {number} + */ +vf2js.utils.Timer.prototype.get_delay = function() { + return this._delay; +}; + + +/** + * delay + * + * @type {number} + */ +vf2js.utils.Timer.prototype.set_delay = function(value) { + this._delay = value; +}; + + +/** + * _repeatCount + * + * @private + * + * @type {number} + */ +vf2js.utils.Timer.prototype._repeatCount; + + +//------------------------------------------------------------------------------ +// +// METHODS +// +//------------------------------------------------------------------------------ + + +/** + * _timerEventHandler + * + * @private + */ +vf2js.utils.Timer.prototype._timerEventHandler = function() { + this.dispatchEvent(new flash.events.TimerEvent(flash.events.TimerEvent.TIMER)); + + if (this._running) { + if (this._repeatCount > 0) { + this._currentCount++; + + //console.log("### HERE (dispatch) " + this._currentCount); + if (this._currentCount <= this._repeatCount) { + setTimeout(goog.bind(this._timerEventHandler, this), this._delay); + } else { + this.reset(); + } + } else { + setTimeout(goog.bind(this._timerEventHandler, this), this._delay); + } + } +}; + + +/** + * start + */ +vf2js.utils.Timer.prototype.start = function() { + this._running = true; + + setTimeout(goog.bind(this._timerEventHandler, this), this._delay); + + console.log("$ Timer start"); +}; + + +/** + * reset + */ +vf2js.utils.Timer.prototype.reset = function() { + this.stop(); + + this._currentCount = 0; + + console.log("$ Timer reset"); +}; + + +/** + * stop + */ +vf2js.utils.Timer.prototype.stop = function() { + this._running = false; + + console.log("$ Timer stop"); +}; + + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/utils/getDefinitionByName.js ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/utils/getDefinitionByName.js b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/utils/getDefinitionByName.js new file mode 100644 index 0000000..65a2466 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/assets/vf2js/utils/getDefinitionByName.js @@ -0,0 +1,53 @@ +/** + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview 'vf2js.utils.getDefinitionByName' + * + * @author [email protected] (Erik de Bruin) + */ + +'use strict'; + +goog.provide('vf2js.utils.getDefinitionByName'); + + + +/** + * @constructor + * @struct + * @param {string} value The qName of the class. + * @return {Object} A reference to the class. + */ +vf2js.utils.getDefinitionByName = function(value) { + var fullName; + + fullName = value.replace(/::/gi, '.'); + + console.log('VF2JS (vf2js.utils.getDefinitionByName): ' + fullName); + + return eval(fullName + '.prototype'); +}; + + +/** + * Metadata + * + * @type {Object.<string, Array.<Object>>} + */ +vf2js.utils.getDefinitionByName.prototype.FLEXJS_CLASS_INFO = + { names: [{ name: 'getDefinitionByName', qName: 'vf2js.utils.getDefinitionByName'}], + interfaces: [ ] }; + + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/nl/ixms/Utils.as ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/nl/ixms/Utils.as b/vf2js/utils/PlayerGlobalToJS/src/nl/ixms/Utils.as new file mode 100644 index 0000000..6f54db5 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/nl/ixms/Utils.as @@ -0,0 +1,44 @@ +package nl.ixms +{ +public final class Utils +{ + public static function cleanClassQName(classQName:String):String { + return classQName. + replace(/\//g, '.'). + replace(/:/g, '.'). + replace(/\.\./g, '.'); + } + + public static function parseType(type:String):String { + var result:String; + + switch (type) { + case 'int' : + case 'uint' : + result = 'number'; + + break; + + case 'Boolean' : + case 'String' : + result = type.toLowerCase(); + + break; + + default : + if (type.indexOf('.') > 0) { + result = Utils.cleanClassQName(type); + } else { + result = type; + } + + break; + } + + return result; + } + + public function Utils() {} + +} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/83c26c9d/vf2js/utils/PlayerGlobalToJS/src/nl/ixms/enums/MemberType.as ---------------------------------------------------------------------- diff --git a/vf2js/utils/PlayerGlobalToJS/src/nl/ixms/enums/MemberType.as b/vf2js/utils/PlayerGlobalToJS/src/nl/ixms/enums/MemberType.as new file mode 100644 index 0000000..77848b8 --- /dev/null +++ b/vf2js/utils/PlayerGlobalToJS/src/nl/ixms/enums/MemberType.as @@ -0,0 +1,62 @@ +package nl.ixms.enums +{ + +public class MemberType +{ + + //-------------------------------------------------------------------------- + // + // Class constants + // + //-------------------------------------------------------------------------- + + public static const CONSTANT:MemberType = new MemberType("constants"); + public static const METHOD:MemberType = new MemberType("methods"); + public static const PROPERTY:MemberType = new MemberType("properties"); + public static const STATIC_CONSTANT:MemberType = new MemberType("static_constants"); + public static const STATIC_METHOD:MemberType = new MemberType("static_methods"); + public static const STATIC_PROPERTY:MemberType = new MemberType("static_properties"); + public static const STATIC_VARIABLE:MemberType = new MemberType("static_variables"); + public static const VARIABLE:MemberType = new MemberType("variables"); + + + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + public function MemberType(stringValue:String) { + this.stringValue = stringValue; + } + + + + //-------------------------------------------------------------------------- + // + // Variables + // + //-------------------------------------------------------------------------- + + private var stringValue:String; + + + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + + //---------------------------------- + // toString + //---------------------------------- + + public function toString():String { + return stringValue; + } + +} + +}
