Wednesday, 15 February 2012

flash - Actionscript three older target not working? -



flash - Actionscript three older target not working? -

this code works fine in actionscript 3 when target 10.3 , when target flash player 9, gives me error scene 1,

layer 'layer 1', frame 1, line 7 1119: access of perchance undefined property l through reference static type class.

anyone know how can prepare works in flash player 9? tried changing keyboard.(keycode#) , trying apparently flash player 9 keycode syntax? tried failing. cannot find solution online, got ideas? thanks

var ldown:boolean = false; var sdown:boolean = false; var ddown:boolean = false; stage.addeventlistener(keyboardevent.key_down, onkeyboarddown); function onkeyboarddown(e:keyboardevent):void { if (e.keycode == keyboard.l) { ldown = true; } if (ldown == true) { if (e.keycode == keyboard.s) { sdown = true; } } if (sdown == true) { if (e.keycode == keyboard.d) { ddown = true; } } if (ddown == true) { trace("ehhh"); } }

i intrigued in question because looking @ documentation, keyboard , constants available flash player 9+, have said, cannot access constants a-z via keyboard when targeting flash player 9. have access other constants f1, home, numpad_*, etc.

as alter flash player version 10 or greater, able access a-z constants.

i have tried find reason this, @ stage can assume documentation invalid , constants aren't available until flash player 10.

fortunately, workaround pretty straightforward in instance: create own constants character codes a-z:

package { public class keycodes { public static const a:uint = 65; public static const b:uint = 66; public static const c:uint = 67; public static const d:uint = 68; public static const e:uint = 69; public static const f:uint = 70; public static const g:uint = 71; public static const h:uint = 72; public static const i:uint = 73; public static const j:uint = 74; public static const k:uint = 75; public static const l:uint = 76; public static const m:uint = 77; public static const n:uint = 78; public static const o:uint = 79; public static const p:uint = 80; public static const q:uint = 81; public static const r:uint = 82; public static const s:uint = 83; public static const t:uint = 84; public static const u:uint = 85; public static const v:uint = 86; public static const w:uint = 87; public static const x:uint = 88; public static const y:uint = 89; public static const z:uint = 90; } }

to utilize class, paste contents .as file in same directory fla, then:

if(e.keycode == keycodes.a) // etc

i in process of trying find exact reason this.

actionscript-3 flash actionscript

No comments:

Post a Comment