actionscript

What is the best standard style for a toString implementation? [closed]

人走茶凉 提交于 2019-11-27 11:57:04
问题 We have a lot of objects for which we like to implement a simple toString to output attributes of the object. Some of these attributes may be complex objects themselves. Is there any standard, or simply just a best practice for a style? I'm thinking something like: [SimpleClassName] { prop1:value, prop2:value } In which case a nested value would look like: [SimpleClassName] { prop1:value, prop2:[NestedObject] { prop3:value}} We are using Java but I find myself asking the same question in most

Static Actionscript code analysis possibilities

青春壹個敷衍的年華 提交于 2019-11-27 11:07:28
I want to see class, function and variable/property, dependencies visually, like NDepend , but for ActionScript 2 or AS3 code. Any programs or ideas? Use doxygen in some way? FlexUnit? Kevin Boyd Update Nov 2018: It would appear that Structure101 ( new download page ) no longer has an ActionScript variant. Original answer, links outdated: Download Structure101g and select the Actionscript flavor after installing the software. I've confirmed that it is able to map out class level and even function call dependencies in Flex/AS3 projects, and generate a visual map of the same. Take a look at the

Using 'File' to save scene object locations to rebuild later in AS3

混江龙づ霸主 提交于 2019-11-27 09:54:03
I am attempting to use the 'File' function in ActionScript 3 to save the following information: I have varying draggable display objects in the scene, the amount and type can vary. I want to save the amount and their position and then load them back in a future session. I am struggling to use File to save anything, I have searched the Adobe documentation and cannot get my head round how to use it. I have not yet developed any code using it. Any help would be appreciated. Thank you. You are trying to write a DisplayObject into the file directly, this is prevented by Flash engine due to the way

Custom Composite Control not rendering correctly for only 0.5-1 sec after being added back into a VGROUP

我怕爱的太早我们不能终老 提交于 2019-11-27 08:48:53
问题 I am moving away from MXML and have built a custom component control within ActionScript . I have the control displaying correctly. The problem comes after I remove it from the display list and add it back in again with the .addElement(control) method. Here is the code that adds it back in again. private function displayParameters(parameters:ArrayCollection):void{ for(var index:int = 0; index<parameters.length; index++){ if(parameters[index] is ReportControl){ var control:ReportControl =

Flash client XMLSocket not connecting to server

前提是你 提交于 2019-11-27 08:18:31
问题 I have a Flash client that I want to connect to a server. Both are using localhost and port 50000 so there shouldn't be any cross-domain problems. I also set Access Network Only in the publishing settings. When I call the XMLSocket connect, the server seems to get a new connection. But, the XMLSocket.onConnect callback is not called with success=true. Any ideas on what may be wrong? Here's the ActionScript for creating the socket. function myOnConnect(success) { if (success) { trace (

Randomize or shuffle an array

青春壹個敷衍的年華 提交于 2019-11-27 08:18:27
问题 Say I have an array: myList:Array = new Array(); myList = [1,2,3,4,5,6,7,8,9]; myRandomList:Array = new Array(); for (var i:uint = 0; i < myList; i++) { var item:Number = Math.floor(Math.random() * myList.length-1) + 1; myRandomList.push(item); } The only thing is, I'd like myRandomList to not have any duplicate numbers...is there a way to select a random number from the first list and then SUBTRACT it so I don't select that number twice? UPDATE: I just saw this method of shuffling an array

How to pass ByteArray to C code in alchemy?

余生长醉 提交于 2019-11-27 08:03:31
问题 I want to pass a byte array object from flex code to C code.How to do that? 回答1: Passing a ByteArray from Flex to C++ http://nexus.zteo.com/blog/2008/12/22/adobe-alchemy-passing-a-bytearray-from-flex-to-c/ 回答2: Multiple approaches outlined here: http://blog.debit.nl/2009/03/using-bytearrays-in-actionscript-and-alchemy/ 回答3: You can use AMF to pass an ActionScript ByteArray. So you're set on the Actionscript side. On the server side, there are slim pickings for AMF server implementations in C+

ActionScript 3.0 + Calculate timespan between two dates?

我怕爱的太早我们不能终老 提交于 2019-11-27 07:52:30
In ActionScript 3.0, is there an automatic way to calculate the number of days, hours, minutes and seconds between two specified dates? Basicly, what I need is the ActionScript equivalent of the .NET Timespan class. Any idea? I created an ActionScript TimeSpan class with a similar API to System.TimeSpan to fill that void, but there are differences due to the lack of operator overloading. You can use it like so: TimeSpan.fromDates(later, earlier).totalDays; Below is the code for the class (sorry for the big post - I won't include the Unit Tests ;) /** * Represents an interval of time */ public

Flash as3 How do I remove duplicates in an array?

梦想的初衷 提交于 2019-11-27 07:02:20
问题 Hi I just have an array of names (strings) in flash, and I want to make sure that any duplicates from the array are removed, or at least that a function is performed only once per reocurring value in the array. 回答1: More cat skinning: var a:Array = ["Tom", "John", "Susan", "Marie", "Tom", "John", "Tom", "Eva"]; a.sort(); var i:int = 0; while(i < a.length) { while(i < a.length+1 && a[i] == a[i+1]) { a.splice(i, 1); } i++; } 回答2: Many ways. You can sort the array and iterate over it ignoring

Using ExternalInterface in Flash

别来无恙 提交于 2019-11-27 06:18:52
问题 I'm trying to edit some flash to make an external javascript function call, but with no success. Here's my actionscript 2.0 code: //testing external .js calls import flash.external.ExternalInterface; //attempting to make external js call ExternalInterface.call("createPlaylist","It's my Life!"); and here's my javascript; function createPlaylist(mess){ alert("called createPlaylist: " + mess); } I've seen lots of examples and I'm mainly confused about the use of ExternalInterface.addCallback . I