actionscript-3

What's happening when I use for(i in object) in AS3?

醉酒当歌 提交于 2019-12-18 07:40:26
问题 To iterate over the properties of an Object in AS3 you can use for(var i:String in object) like this: Object: var object:Object = { thing: 1, stuff: "hats", another: new Sprite() }; Loop: for(var i:String in object) { trace(i + ": " + object[i]); } Result: stuff: hats thing: 1 another: [object Sprite] The order in which the properties are selected however seems to vary and never matches anything that I can think of such as alphabetical property name, the order in which they were created, etc.

Is it impossible with Flash to get the Instance Creator?

我与影子孤独终老i 提交于 2019-12-18 07:33:04
问题 I want to add a listener to the parent of a slider which is receiving the event from a non-gui class the EventDispatcherManager. So I tried to get the parent of the slider which should return the main class but it doesn't work. How to get the object (here main class) which instantiates an other (here a slider class) ? package { import fl.controls.Slider; import fl.events.SliderEvent; import flash.events.*; internal class EventDispatcherManager extends EventDispatcher { public function

Saving and Loading files from an Android mobile Device using Flash Actionscript 3.0

心已入冬 提交于 2019-12-18 07:25:07
问题 Im making a Test Maker App for both Desktop and Android. I was able to save and load in Desktop but failed on Android. I can ONLY save my file, but i cannot load my saved file. The Android device says "No files were found". It doesnt even open a file browser. The type of saving and loading that im doing is the type where the user can actually look for his project and open it. Im currently using FileReference to do this. It works on Desktop but not on Android Mobile. Can somebody help me with

how to work registerClassAlias() method for custom mxml components

微笑、不失礼 提交于 2019-12-18 07:14:31
问题 I have flex mxml custom component(Graphic).According to requirement a need to copy them as copy or cut operation.but problem in the registerClassAlias() method,how it will work for custom graphic or Group(or UIComponents) components. var className:String = getQualifiedClassName(zorder.getItemAt(0)); _saveIn.clear(); registerClassAlias(className, zorder.getItemAt(0) as Class); _saveIn = SharedObject.getLocal("save"); _saveIn.data.value1 = new ByteArray(); _saveIn.data.value1.writeObject(zorder

Inherited a class from EventDispatcher in Flash but custom event not received

好久不见. 提交于 2019-12-18 05:26:07
问题 I have a custom event that is dispatched when a slider is moved but I receive no event from inherited dispatcher class I created whereas I followed the same syntax as solution for My flash custom event doesn't trigger Event class: package { import flash.events.Event; public class CustomEvent extends Event { public static const ON_DISPATCHER_EVENT = "onDispatcherEvent"; public var value:Number; public function CustomEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false):void {

Passing a variable between frames with actionscript 3

柔情痞子 提交于 2019-12-18 05:11:07
问题 I am new to actionscript 3.0 and I'm experiencing difficulty trying to pass a variable that is created and set in frame 1 to a dynamic text box that is added to the stage in frame 4. on frame 1 the variable is set from information entered by the user: var input_dia = ""; input_dia = pdia_input.text; and should be displayed in a dynamic text box on frame 4: dia_alert.text=input_dia; I'm receiving the following error: 1120: Access of undefined property input_dia. 回答1: You have to imagine - the

Passing a variable between frames with actionscript 3

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 05:11:06
问题 I am new to actionscript 3.0 and I'm experiencing difficulty trying to pass a variable that is created and set in frame 1 to a dynamic text box that is added to the stage in frame 4. on frame 1 the variable is set from information entered by the user: var input_dia = ""; input_dia = pdia_input.text; and should be displayed in a dynamic text box on frame 4: dia_alert.text=input_dia; I'm receiving the following error: 1120: Access of undefined property input_dia. 回答1: You have to imagine - the

Best way to get the color where a mouse was clicked in AS3

别等时光非礼了梦想. 提交于 2019-12-18 04:44:07
问题 I have an image (mx) and i want to get the uint of the pixel that was clicked. Any ideas? 回答1: Here's an even simpler implementation. All you do is take a snapshot of the stage using the draw() method of bitmapData, then use getPixel() on the pixel under the mouse. The advantage of this is that you can sample anything that's been drawn to the stage, not just a given bitmap. import flash.display.Bitmap; import flash.display.BitmapData; import flash.events.*; stage.addEventListener(MouseEvent

actionscript 3 init()

不打扰是莪最后的温柔 提交于 2019-12-18 04:08:38
问题 I have often seen an init() within the constructor of AS3 classes, sometimes even being the only code in the constructor. Why would it be useful to do this, if you could simply use the constructor function itself to initialize a class? package { import flash.display.Sprite; public class Example extends Sprite { public function Example() { init(); } public function init ( ):void { //initialize here } } } 回答1: In ActionScript 3, constructor code is always interpreted rather than compiled. I

can an actionscript function find out its own name?

Deadly 提交于 2019-12-18 03:35:43
问题 given the following function A(b:Function) { } If function A(), can we determine the name of the function being passed in as parameter 'b' ? Does the answer differ for AS2 and AS3 ? 回答1: I use the following: private function getFunctionName(e:Error):String { var stackTrace:String = e.getStackTrace(); // entire stack trace var startIndex:int = stackTrace.indexOf("at ");// start of first line var endIndex:int = stackTrace.indexOf("()"); // end of function name return stackTrace.substring