actionscript-3

How to suppress Flash migration warnings (1090)

有些话、适合烂在心里 提交于 2019-12-21 09:22:12
问题 In Flash Professional CS4, I get "migration issue" warnings when I use mouse/keyboard input handler names such as onMouseDown, onKeyUp, etc., even though I have added event listeners for them. These names are perfectly legal for functions, but since these were automatically fired in ActionScript 2.0, we are now (albeit sensibly) warned that their use is no longer automatic in AS3. I understand the purpose of the warnings, but they aren't useful for me. I want to suppress these warnings, but

Send array from Flash (AS3) to JavaScript

蹲街弑〆低调 提交于 2019-12-21 09:22:11
问题 Is it possible to send an array from Flash (AS3) to JavaScript using an ExternalInterface call? I currently am calling a function multiple times from a 'for each' loop inside Flash but it goes too fast for the JavaScript to keep up. My idea is to create an array of the attributes, pass that to the JavaScript function and then to loop through that in the JavaScript. Thanks, Josh 回答1: Further to the suggestion of using JSON, this should be faster for small arrays and wouldn't require the use of

as3 Vector with init values

梦想的初衷 提交于 2019-12-21 09:16:14
问题 I want to instantiate a Vector.<Number> with two values of 1.0 You might think I would do Vector.<Number>(1.0, 1.0); but that only traces 0 Is what I'm trying to do possible? If so, how? Or am I stapled to the routine of using .push ? 回答1: This one is even shorter: var vec:Vector.<Number> = new <Number>[1.0, 1.0]; 来源: https://stackoverflow.com/questions/8864773/as3-vector-with-init-values

Why does delete( DictionaryInstance[ key ] ); fail?

妖精的绣舞 提交于 2019-12-21 08:15:11
问题 My app uses a Dictionary protected _categoryToValueDict:Dictionary = new Dictionary(); to map something to something else. Now, at a certain point in the application, I need to remove a certain key from the Dictionary . I implemented this simple method: public function setCategoryNoValue( cat:TAModelCategory ):void { // delete( _categoryToValueDict[ cat ] ); var old:Dictionary = _categoryToValueDict; _categoryToValueDict = new Dictionary(); for ( var key:* in old ) { if ( key != cat ) {

Difference between stage.width and stage.stageWidth

倖福魔咒の 提交于 2019-12-21 07:13:21
问题 In actionscript 3 (as3) What is the difference between calling stage.width and stage.stageWidth This was something I remember I got confused about in the past (Adobe's api docs are an artform in obfuscation :) ). Thought I should post it on stackoverflow. 回答1: stageWidth is basically width of the player window. You probably need this number if you want to know size of your scene. stage.width is calculated as any other width in actionscript. This means, it is width of bounding box around child

Invert and convert slider value

时光总嘲笑我的痴心妄想 提交于 2019-12-21 06:36:37
问题 I currently have a vertical slider that is controlled by the user using startDrag. The puck is restricted in movement by a track movieclip that is 115px high. private function init():void { puck.y = (track.height-puck.height)/2; puck.buttonMode = true; puck.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown); } private function sendNewValue():void { trace(Math.round(puck.y-track.y+(puck.height/2))); var newVal:Number = ; //need some math magic here dispatchEvent(new ToolEvent(ToolEvent.SCALE

in flex, dynamically load Sound object from encoded bytes

雨燕双飞 提交于 2019-12-21 06:28:20
问题 I have a legacy file format that contains sounds embedded in it (in various encodings). I would like to be able to play these sounds in Flash (Air?) by reading the sound bytes out of the file and instantiating a Sound object with them. If the sound is unencoded (e.g., raw pcm), I've found that I can use the new flex 4 SampleDataEvent.SAMPLE_DATA event to play the sound. However, if the sound is encoded (e.g., mp3), then I'm at a loss. The sound expected by SampleDataEvent.SAMPLE_DATA has to

AS3 Components in Flash Designer

青春壹個敷衍的年華 提交于 2019-12-21 06:15:30
问题 In an ActionScript 2 project I can create a new MovieClip, right-click on it on the library and select "Component Definition" to add parameters that can be referenced inside the MovieClip. This parameters can be easily changed in the MovieClips's properties. Now, I'm working on an ActionScript 3 project but haven't been able to figure out a way to obtain the values passed in those parameters. I defined a parameter named "textToDisplay" but when I write the following in the Actions for the

Javascript to flash via ExternalInterface

…衆ロ難τιáo~ 提交于 2019-12-21 06:06:14
问题 I'm wondering if someone could look over my code. I'm trying to pass a dummy variable from javascript to actionscript 3 with the following code: HTML: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="music_player" width="500" height="375" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"> <param name="movie" value="music_player.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="#869ca7" /> <param name="allowScriptAccess"

Actionscript3: how can I access elements on the stage from external classes?

孤街浪徒 提交于 2019-12-21 06:06:12
问题 I have an external class in a .as file, my problem is that I can't access elements on the stage. Code like stage.txtfield.text or this.parent.txtfield.text does not work. The txtfield is the instace name of a Dynamic Text field. 回答1: It depends a bit on the external class. If it extends DisplayObject (or any grandchild of DisplayObject), you will be able access with the stage property as soon as it is added to the display list (which is when it's added to the stage or any other