From 127b4308fd6e0efcb7ec70d78e7a425ccb794011 Mon Sep 17 00:00:00 2001 From: wdamien Date: Mon, 25 Feb 2013 12:03:22 -0700 Subject: [PATCH] Updates to match the latest version of CreateJS (EaseJS v0.6, PreloadJS v0.3, SoundJS v0.4, and TweenJS v0.4). Also fixed the easeljs-tests.ts so it compiles correctly. --- easeljs/easeljs-tests.ts | 32 ++++++---- easeljs/easeljs.d.ts | 116 +++++++++++++++++++++++++++++------ preloadjs/preloadjs.d.ts | 62 +++++++++++++------ soundjs/soundjs.d.ts | 129 +++++++++++++++++++++++++++++++++++---- tweenjs/tweenjs.d.ts | 33 +++++++++- 5 files changed, 309 insertions(+), 63 deletions(-) diff --git a/easeljs/easeljs-tests.ts b/easeljs/easeljs-tests.ts index 956908434..678e335a1 100644 --- a/easeljs/easeljs-tests.ts +++ b/easeljs/easeljs-tests.ts @@ -1,16 +1,19 @@ /// function test_simple() { - var canvas = document.getElementById('canvas'); - var stage = new Stage(canvas); - var shape = new Shape(); + var canvas = document.getElementById('canvas'); + var stage = new createjs.Stage(canvas); + var shape = new createjs.Shape(); shape.graphics.beginFill('rgba(255,0,0,1)').drawRoundRect(0, 0, 120, 120, 10); stage.addChild(shape); stage.update(); } function test_animation() { - var ss = new SpriteSheet({ + var canvas = document.getElementById('canvas'); + var stage = new createjs.Stage(canvas); + + var ss = new createjs.SpriteSheet({ "frames": { "width": 200, "numFrames": 64, @@ -26,28 +29,31 @@ function test_animation() { ss.getAnimation("run").next = "jump"; ss.getAnimation("jump").next = "run"; - var bitmapAnimation = new BitmapAnimation(ss); + var bitmapAnimation = new createjs.BitmapAnimation(ss); bitmapAnimation.scaleY = bitmapAnimation.scaleX = .4; bitmapAnimation.gotoAndPlay("run"); - Ticker.setFPS(60); - Ticker.addListener(stage); + createjs.Ticker.setFPS(60); + createjs.Ticker.addListener(stage); stage.addChild(bitmapAnimation); } function test_graphics() { - var g = new Graphics(); + var canvas = document.getElementById('canvas'); + var stage = new createjs.Stage(canvas); + + var g = new createjs.Graphics(); g.setStrokeStyle(1); - g.beginStroke(Graphics.getRGB(0, 0, 0)); - g.beginFill(Graphics.getRGB(255, 0, 0)); + g.beginStroke(createjs.Graphics.getRGB(0, 0, 0)); + g.beginFill(createjs.Graphics.getRGB(255, 0, 0)); g.drawCircle(0, 0, 3); - var s = new Shape(g); + var s = new createjs.Shape(g); s.x = 100; s.y = 100; stage.addChild(s); stage.update(); - var myGraphics: Graphics; - myGraphics.beginStroke("#F00").beginFill("#00F").drawRect(20, 20, 100, 50).draw(myContext2D); + var myGraphics: createjs.Graphics; + myGraphics.beginStroke("#F00").beginFill("#00F").drawRect(20, 20, 100, 50).draw(canvas.getContext('2d')); } \ No newline at end of file diff --git a/easeljs/easeljs.d.ts b/easeljs/easeljs.d.ts index a19c285b9..e26026772 100644 --- a/easeljs/easeljs.d.ts +++ b/easeljs/easeljs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for EaselJS 0.5 +// Type definitions for EaselJS 0.6 // Project: http://www.createjs.com/#!/EaselJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -27,6 +27,7 @@ module createjs { cacheCanvas: HTMLCanvasElement; cacheID: number; compositeOperation: string; + cursor: string; filters: Filter[]; hitArea: DisplayObject; id: number; @@ -53,6 +54,7 @@ module createjs { clone(): DisplayObject; draw(ctx: CanvasRenderingContext2D, ignoreCache?: bool): void; getCacheDataURL(): string; + getChildByName(name: string): DisplayObject; getConcatenatedMatrix(mtx: Matrix2D): Matrix2D; getMatrix(matrix: Matrix2D): Matrix2D; getStage(): Stage; @@ -61,6 +63,7 @@ module createjs { isVisible(): bool; localToGlobal(x: number, y: number): Point; localToLocal(x: number, y: number, target: DisplayObject): Point; + set(props: Object): DisplayObject; setTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX: number, regY: number): DisplayObject; setupContext(ctx: CanvasRenderingContext2D): void; toString(): string; @@ -68,12 +71,22 @@ module createjs { updateCache(compositeOperation: string): void; // events - onClick: (event: MouseEvent) => any; - onDoubleClick: (event: MouseEvent) => any; - onMouseOut: (event: MouseEvent) => any; - onMouseOver: (event: MouseEvent) => any; - onPress: (event: MouseEvent) => any; - onTick: () => any; + click: (event: MouseEvent) => any; + dblClick: (event: MouseEvent) => any; + mouseout: (event: MouseEvent) => any; + mouseover: (event: MouseEvent) => any; + mousedown: (event: MouseEvent) => any; + tick: () => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } @@ -142,6 +155,7 @@ module createjs { advance(): void; cache(): void; clone(): BitmapAnimation; + getBounds(): Rectangle; gotoAndPlay(frameOrAnimation: string): void; gotoAndPlay(frameOrAnimation: number): void; play(): void; @@ -149,9 +163,23 @@ module createjs { updateCache(): void; // events - onAnimationEnd: (reference: BitmapAnimation, animationEnded: string) => any; + onAnimationEnd: (event: Object) => any; } + export class ButtonHelper { + // properties + target: Object; + overLabel: string; + outLabel: string; + downLabel: string; + play: bool; + + // methods + constructor(target: MovieClip, outLabel: string, overLabel: string, downLabel: string, play: bool, hitArea: DisplayObject, hitLabel: string); + constructor(target: BitmapAnimation, outLabel: string, overLabel: string, downLabel: string, play: bool, hitArea: DisplayObject, hitLabel: string); + setEnabled(value: bool); + toString(): string; + } export class BoxBlurFilter extends Filter { // properties @@ -209,8 +237,7 @@ module createjs { } - export class Command - { + export class Command { // methods constructor (f, params, path); exec(scope: any): void; @@ -252,6 +279,31 @@ module createjs { } + export class EaselJS { + // properties + version: string; + buildDate: string; + } + + + export class EventDispatcher { + // properties + + // methods + static initialize(target: Object): void; + + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; + toString(): string; + } + + export class Graphics { // properties BASE_64: Object; @@ -263,7 +315,7 @@ module createjs { // methods arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: bool): Graphics; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): Graphics; - beginBitmapFill(image: Object, repetition?: string): Graphics; + beginBitmapFill(image: Object, repetition?: string, matrix?: Matrix2D): Graphics; beginBitmapStroke(image: Object, repetition?: string): Graphics; beginFill(color: string): Graphics; beginLinearGradientFill(colors: string[], ratios: number[], x0: number, y0: number, x1: number, y1: number): Graphics; @@ -285,20 +337,36 @@ module createjs { drawRoundRectComplex(x: number, y: number, width: number, height: number, radiusTL: number, radiusTR: number, radiusBR: number, radisBL: number): Graphics; endFill(): Graphics; endStroke(): Graphics; + isEmpty(): bool; static getHSL(hue: number, saturation: number, lightness: number, alpha?: number): string; static getRGB(red: number, green: number, blue: number, alpha?: number): string; lineTo(x: number, y: number): Graphics; moveTo(x: number, y: number): Graphics; quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): Graphics; rect(x: number, y: number, width: number, height: number): Graphics; - setStrokeStyle(thickness: number, caps?: string, joints?: string, miter?: number): Graphics; // caps and joints can be a string or number - setStrokeStyle(thickness: number, caps?: number, joints?: string, miter?: number): Graphics; - setStrokeStyle(thickness: number, caps?: string, joints?: number, miter?: number): Graphics; - setStrokeStyle(thickness: number, caps?: number, joints?: number, miter?: number): Graphics; + setStrokeStyle(thickness: number, caps?: string, joints?: string, miter?: number, ignoreScale?: bool): Graphics; // caps and joints can be a string or number + setStrokeStyle(thickness: number, caps?: number, joints?: string, miter?: number, ignoreScale?: bool): Graphics; + setStrokeStyle(thickness: number, caps?: string, joints?: number, miter?: number, ignoreScale?: bool): Graphics; + setStrokeStyle(thickness: number, caps?: number, joints?: number, miter?: number, ignoreScale?: bool): Graphics; toString(): string; } + export class Log { + // properties + static NONE: number; + static ERROR: number; + static WARNING: number; + static TRACE: number; + static ALL: number; + static level: number; + + // methods + static out(message: string, details: string, level: number); + static addKeys(keys: Object); + static log(message: string, details: string, level: number); + } + export class Matrix2D { // properties a: number; @@ -363,6 +431,8 @@ module createjs { export class MovieClip extends Container { // properties actionsEnabled: bool; + autoReset: bool; + currentFrame: number; static INDEPENDENT: string; loop: bool; mode: string; @@ -453,6 +523,7 @@ module createjs { getAnimation(name: string): SpriteSheetAnimation; getAnimations(): string[]; getFrame(frameIndex: number): Object; + getFrameBounds(frameIndex: number); getNumFrames(animation: string): number; toString(): string; @@ -467,16 +538,22 @@ module createjs { maxWidth: number; maxHeight: number; padding: number; + progress: number; spriteSheet: SpriteSheet; + timeSlice: number; // methods addFrame(source: DisplayObject, sourceRect?: Rectangle, scale?: number, setupFunction?: () => any, setupParams?: any[], setupScope?: Object): any; //HERE returns number or null addMovieClip(source: MovieClip, sourceRect?: Rectangle, scale?: number): void; build(): void; - buildAsync(callback?: (reference: SpriteSheetBuilder) => any, timeSlice?: number): void; + buildAsync(timeSlice?: number): void; clone(): SpriteSheetBuilder; stopAsync(): void; toString(): string; + + // events + complete: (event: Object) => any; + onProgress: (event: Object) => any; } @@ -502,14 +579,15 @@ module createjs { constructor (canvas: HTMLCanvasElement); clone(): Stage; enableMouseOver(frequency: number): void; + enableDOMEvents(enable: bool): void; toDataURL(backgroundColor: string, mimeType: string): string; update(): void; clear(): void; + handleEvent(evt: Object): void; // events - onMouseDown: (event: MouseEvent) => any; - onMouseMove: (event: MouseEvent) => any; - onMouseUp: (event: MouseEvent) => any; + stagemousemove: (event: MouseEvent) => any; + stagemouseup: (event: MouseEvent) => any; } diff --git a/preloadjs/preloadjs.d.ts b/preloadjs/preloadjs.d.ts index fd044e968..4edbe81ae 100644 --- a/preloadjs/preloadjs.d.ts +++ b/preloadjs/preloadjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for PreloadJS 0.2 +// Type definitions for PreloadJS 0.3 // Project: http://www.createjs.com/#!/PreloadJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -18,39 +18,57 @@ module createjs { progress: number; // methods - cancel(): void; - getItem(): Object; + close(): void; + getItem(value: string): Object; load(): void; + toString(): string; // events - onComplete: () => any; - onError: () => any; - onFileLoad: () => any; - onFileProgress: () => any; - onLoadStart: () => any; - onProgress: () => any; + complete: (event: Object) => any; + error: (event: Object) => any; + fileload: (event: Object) => any; + fileprogress: (event: Object) => any; + loadStart: (event: Object) => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } + export class PreloadJS { + version: string; + buildDate: string; + } - export class PreloadJS extends AbstractLoader { - constructor (useXHR2?: bool); + export class LoadQueue extends AbstractLoader { + constructor (useXHR?: bool); // properties + static BINARY: string; static CSS: string; static IMAGE: string; static JAVASCRIPT: string; static JSON: string; - maintainScriptOrder: bool; - next: PreloadJS; static SOUND: string; - stopOnError: bool; + static SVG: string; static TEXT: string; - static TIMEOUT_TIME: number; - useXHR: bool; + static LOAD_TIMEOUT: number; static XML: string; + maintainScriptOrder: bool; + next: LoadQueue; + stopOnError: bool; + useXHR: bool; + // methods BrowserDetect(): Object; + init(useXHR?: bool): void; close(): void; getResult(value: string): Object; initialize(useXHR: bool): void; @@ -60,7 +78,14 @@ module createjs { loadFile(file: string, loadNow: bool): void; loadManifest(manifest: Object[], loadNow: bool): void; loadManifest(manifest: string[], loadNow: bool): void; + getItem(value: string): Object; + getResult(value: string, rawResult?: bool): Object; + removeAll(): void; + remove(idsOrUrls: string): void; + remove(idsOrUrls: Array): void; + reset(): void; setMaxConnections(value: number): void; + setUseXHR(value: bool): void; setPaused(value: bool): void; } @@ -68,10 +93,13 @@ module createjs { export class TagLoader extends AbstractLoader { constructor (item: Object, srcAttr: string, useXHR: bool); constructor (item: string, srcAttr: string, useXHR: bool); + getResult(): HTMLImageElement; + getResult(): HTMLAudioElement; } export class XHRLoader extends AbstractLoader { constructor (file: Object); + getResult(rawResult?: bool); } -} \ No newline at end of file +} diff --git a/soundjs/soundjs.d.ts b/soundjs/soundjs.d.ts index 7355b34b7..a00d33775 100644 --- a/soundjs/soundjs.d.ts +++ b/soundjs/soundjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for SoundJS 0.3 +// Type definitions for SoundJS 0.4 // Project: http://www.createjs.com/#!/SoundJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -19,33 +19,95 @@ module createjs { // methods create(src: string): SoundInstance; + preload(src: string, instance: Object): void; static generateCapabilities(): void; static isSupported(): bool; - register(src: string, instances: number): Object; + isPreloadStarted(src: string): bool; + register(src: string, instances: Number): Object; + setVolume(value: Number): bool; + getVolume(): Number; + setMute(isMuted: bool): Boolean; + toString(): string; + + // Flash API + unregisterPreloadInstance(flashId: string): void; + unregisterSoundInstance(flashId: string): void; + flashLog(data: string): void; + handleSoundEvent(flashId: string, method: string): void; + handlePreloadEvent(flashId: string, method: string): void; + handleEvent(method: string): void; + handleErrorEvent(error: string): void; } export class HTMLAudioPlugin { // properties static capabilities: Object; static MAX_INSTANCES: number; + static AUDIO_READY: string; + static AUDIO_ENDED: string; + static AUDIO_ERROR: string; + static AUDIO_STALLED: string; + capabilities:Object; + defaultNumChannels: number; // methods create(src: string): SoundInstance; static generateCapabilities(): void; static isSupported(): bool; register(src: string, instances: number): Object; + isPreloadStarted(src: string): bool; + preload(src: string, instance: Object): void; + toString(): string; + } + + export class WebAudioPlugin { + // properties + static capabilities: Object; + static MAX_INSTANCES: number; + static AUDIO_READY: string; + static AUDIO_ENDED: string; + static AUDIO_ERROR: string; + static AUDIO_STALLED: string; + arrayBuffers: ArrayBuffer[]; + capabilities:Object; + defaultNumChannels: number; + dynamicsCompressorNode: Object; + gainNode: Object; + volume: number; + context: any; + WebAudioLoader(src: string, owner: Object): Function; + + // methods + create(src: string): SoundInstance; + static generateCapabilities(): void; + static isSupported(): bool; + setVolume(value: Number): bool; + getVolume(): number; + register(src: string, instances: number): Object; + isPreloadStarted(src: string): bool; + preload(src: string, instance: Object): void; + isPreloadComplete(src : string): bool; + removeFromPreload(src: string); + setMute(value: number): bool; + toString(): string; } export class SoundInstance { - constructor (src: string); + constructor (src: string, owner: string, flash: string); // properties muted: bool; owner: HTMLAudioPlugin; + offset: number; paused: bool; + delay: number; + pan: number; + duration: number; playState: string; + delayTimeoutId: number; src: string; uniqueId: any; //HERE string or number + volume: number; // methods getDuration(): number; @@ -62,15 +124,26 @@ module createjs { stop(): bool; // events - onComplete: () => any; - onLoop: () => any; - onPlayFailed: () => any; - onPlayInterrupted: () => any; - onReady: () => any; + complete: () => any; + loop: () => any; + failed: () => any; + interrupted: () => any; + succeeded: () => any; + ready: () => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } - export class SoundJS { + export class Sound { // properties static activePlugin: Object; static AUDIO_TIMEOUT: number; @@ -85,23 +158,57 @@ module createjs { static PLAY_INITED: string; static PLAY_INTERRUPTED: string; static PLAY_SUCCEEDED: string; + static SUPPORTED_EXTENSIONS: Array; + static EXTENSION_MAP: Object; + static defaultInterruptBehavior: string; // methods static checkPlugin(initializeDefault: bool): bool; + static createInstance(src: string): SoundInstance; static getCapabilities(): Object; static getCapability(key: string): any; //HERE can return string | number | bool static getInstanceById(uniqueId: string): SoundInstance; + static getMute(): number; static getMasterVolume(): number; static getSrcFromId(value: string): string; + static getVolume(): number; static isReady(): bool; static pause(id: string): void; - static play(value: string, interrupt?: string, delay?: number, offset?: number, loop?: number, volume?: number, pan?: number): SoundInstance; + static play(src: string, interrupt?: string, delay?: number, offset?: number, loop?: number, volume?: number, pan?: number): SoundInstance; static registerPlugin(plugin: Object): bool; static registerPlugins(plugins: Object[]): bool; + static registerSound(src: Object, id: string, data: Object, preload?: bool): Object; + static registerManifest(manifest: Array); static resume(id: string): void; static setMasterVolume(value: number): bool; static setMute(isMuted: bool, id: string): bool; static setVolume(value: number, id?: string): bool; - static stop(id?: string): bool; + static stop(): bool; + + // events + loadComplete: () => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } + + export class BrowserDetect { + // properties + static isFirefox: bool; + static isOpera: bool; + static isChrome: bool; + static isIOS: bool; + static isAndroid: bool; + static isBlackberry: bool; + + // methods + static init(); + } } diff --git a/tweenjs/tweenjs.d.ts b/tweenjs/tweenjs.d.ts index 31499c910..82e9fd25c 100644 --- a/tweenjs/tweenjs.d.ts +++ b/tweenjs/tweenjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for TweenJS 0.3 +// Type definitions for TweenJS 0.4 // Project: http://www.createjs.com/#!/TweenJS // Definitions by: Pedro Ferreira // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -12,6 +12,13 @@ module createjs { + export class TweenJS { + // properties + version: string; + buildDate: string; + } + + export class CSSPlugin { // properties static cssSuffixMap: Object; @@ -128,6 +135,26 @@ module createjs { wait(duration: number): void; // events - onChange: (instance: Tween) => any; + change: (event) => any; + + // EventDispatcher mixins + addEventListener(type: string, listener: (eventObj: Object) => bool): Function; + addEventListener(type: string, listener: (eventObj: Object) => bool): Object; + removeEventListener(type: string, listener: (eventObj: Function) => bool): void; + removeEventListener(type: string, listener: (eventObj: Object) => bool): void; + removeAllEventListeners(type: string): void; + dispatchEvent(eventObj: string, target: Object): bool; + dispatchEvent(eventObj: Object, target: Object): bool; + hasEventListener(type: string): bool; } -} \ No newline at end of file + + + export class MotionGuidePlugin { + // properties + static priority: number; + + //methods + static install(): Object; + + } +}