actionscript-3

Generic events and additional parameters in Actionscript 3.0?

不打扰是莪最后的温柔 提交于 2019-12-31 03:55:10
问题 Assuming the following pattern: someObjectInstance.addEventListener(MyDisplayObject.EVENT_CONSTANT, _handleMyEvent); private function _handleMyEvent( event:Event = null ):void { // Event handler logic... } If I wanted to add a required parameter to the handler function am I able to do this and still use a "generic" event and event listener? Or am I correct in assuming that I need to create a custom event class that has the parameter in it and reference that through the event object passed

Game logic and game loops in ActionScript 3

試著忘記壹切 提交于 2019-12-31 03:46:09
问题 I am making a Shooting game in flash actionscript 3 and have some questions about the flow of logic and how to smartly use the OOPs concepts. There are mainly 3 classes: Main Class: Initializes the objects on the screen. Enemy Class: For moving the enemies around on the screen. Bullet Class: For shooting. What I want to do is find out if the Enemy has been hit by a bullet and do things which must be done as a result ... What I am doing right now is that I have a ENTER_FRAME event in which i

AS3: URLStream saving files to desktop?

六眼飞鱼酱① 提交于 2019-12-31 02:49:36
问题 i found a few scripts online and combined them to this. I want to download files from the web to my local harddrive. Any idea what i'm doing wrong? var fs:FileStream; var stream:URLStream; var _output:Boolean = false; init(); startDownload('http://www.teachenglishinasia.net/files/u2/purple_lotus_flower.jpg'); function init() { stream = new URLStream(); stream.addEventListener(ProgressEvent.PROGRESS, _dlProgressHandler); stream.addEventListener(Event.COMPLETE, _dlCompleteHandler); stream

Typed AS3 JSON Encoder and Decoder?

[亡魂溺海] 提交于 2019-12-31 02:09:25
问题 I need to encode and Decode AS3 Objects in a typed manner. http://code.google.com/p/as3corelib/ only supports untyped encoding and decoding. http://code.google.com/p/ason/ supports some kind of typed objects but is not very robust, e.g. it fails on Date Objects. Any Recommendations ? To make it clear: It MUST be JSON and it MUST be strong typed and robust. 回答1: JSON is built in in AS3. The preferred method to transmit data over the wire is AMF, which does provide you typed objects. If you

actionscript 3 sleep?

天大地大妈咪最大 提交于 2019-12-31 01:50:10
问题 I have a simple actionscript function var string:String = "TEXT REMOVED"; var myArray:Array = string.split(""); addEventListener(Event.ENTER_FRAME, frameLooper); function frameLooper(event:Event):void { if(myArray.length > 0) { text1.appendText(myArray.shift()); }else{ removeEventListener(Event.ENTER_FRAME, frameLooper); } } And I want to have it sleep after calling the framelooper so it is a little bit slower. How could I do this? btw, I'm fairly new and found this code on a tutorial, it's a

ComboBox Text Formatting through AS3

人盡茶涼 提交于 2019-12-31 01:11:09
问题 I am developing an AIR application and I need to change the font size of the text that is displayed in the dropDown List as well as the main text on the comboBox. My ComboBox is quite big in size but the text displayed in it is very small. I tried using the setStyle method by passing a TextFormat into it like : cmbEmployee.setStyle("textFormat", txtform); but it didn't work. Although the same method works well with a TextField. Can somebody help ? 回答1: A ComboBox is a container that contains

Accessing child/nested movie clips with JSFL AS3 CS5.5

元气小坏坏 提交于 2019-12-31 01:02:51
问题 How can I access a movie clip's children (specifically child movie clips) in jsfl? I am already at the instance level from flash.documents[0].timelines[0].layers[0].frames[0].elements[0].instance I've found this documentation but not much else. Thanks in advance. 回答1: The thing to remember in JSFL is that elements on stage are also items in the library, so it doesn't matter how many times you have something nested, it's still a clip in the library, and often that's the thing you want to work

AS3 Setting width and height of a Sprite Container

老子叫甜甜 提交于 2019-12-30 17:26:27
问题 Ok, my mind is boggling over this issue im having. I know this might seem like such an easy issue and I can't understand why I cant figure it out but none the less I can't and I've just about given up. Here's the issue: I have a sprite container which is supposed to hold a bunch of thumbnails to videos. I am able to populate the container with all the videos and the whole works but obviously if I add a bunch of videos its going to exceed the size of the flash document so I need to add a

Is it OK to have multiple assertions in a unit test when testing complex behavior?

巧了我就是萌 提交于 2019-12-30 15:03:12
问题 Here is my specific scenario. I have a class QueryQueue that wraps the QueryTask class within the ArcGIS API for Flex. This enables me to easily queue up multiple query tasks for execution. Calling QueryQueue.execute() iterate through all the tasks in my queue and call their execute method. When all the results have been received and processed QueryQueue will dispatch the completed event. The interface to my class is very simple. public interface IQueryQueue { function get inProgress()

Dynamic Object Initiation As3

人盡茶涼 提交于 2019-12-30 15:02:01
问题 I notice in older version of flash you can create an instance of a dynamic class. I am creating a game that will have many different classes that can be displayed on the stage but can very from time to time. How would I go about calling them dynamically. for example var newObject = new ["DynamicObject"](); ?? Is this possible in As3 ?? 回答1: I think there are 2 ways you can do that: 1.Using ApplicationDomain.getDefinition('DynamicTemplate') something like: var DynamicClass:Class = this