actionscript

RegEx to match comma separated numbers with optional decimal part

拜拜、爱过 提交于 2019-11-27 05:21:39
I've a regex that matches comma separated numbers with an optional two digit decimal part in a given multiline text. /(?<=\s|^)\d{1,3}(,\d{3})*(\.\d{2})?(?=\s|$)/m It matches strings like 1, 12, 12.34, 12,345.67 etc successfully. How can I modify it to match a number with only the decimal part like .23 ? EDIT: Just to clarify - I would like to modify the regex so that it matches 12 , 12.34 and .34 And I am looking for 'stand alone' valid numbers. i.e., number-strings whose boundaries are either white space or start/end of line/string. This: \d{1,3}(,\d{3})*(\.\d\d)?|\.\d\d matches all of the

Can Flash action script read and write local file system?

喜欢而已 提交于 2019-11-27 04:42:27
问题 I think it can only access the network but not local file system, but from internet some people said it can in the newest version, can anybody confirm? It can reach arbitrarily file or just a specific location? Thanks. Bin 回答1: In general, an SWF from a web-server cannot read files from the client machine. But it can upload user-selected files from the client machine to the server. An operating-system specific dialog box prompts the user to select the file to be uploaded to the server. Hence

How to deal with Number precision in Actionscript?

戏子无情 提交于 2019-11-27 01:03:57
I have BigDecimal objects serialized with BlazeDS to Actionscript. Once they hit Actionscript as Number objects, they have values like: 140475.32 turns into 140475.31999999999998 How do I deal with this? The problem is that if I use a NumberFormatter with precision of 2, then the value is truncated to 140475.31 . Any ideas? Fraser This is my generic solution for the problem (I have blogged about this here ) : var toFixed:Function = function(number:Number, factor:int) { return Math.round(number * factor)/factor; } For example: trace(toFixed(0.12345678, 10)); //0.1 Multiply 0.12345678 by 10 ;

Flex 3 - how to support HTTP Authentication URLRequest?

谁说胖子不能爱 提交于 2019-11-27 00:45:15
I have a Flex file upload script that uses URLRequest to upload files to a server. I want to add support for http authentication (password protected directories on the server), but I don't know how to implement this - I assume I need to extend the class somehow, but on how to I'm a little lost. I tried to modify the following (replacing HTTPService with URLRequest), but that didn't work. private function authAndSend(service:HTTPService):void{ var encoder:Base64Encoder = new Base64Encoder(); encoder.encode("someusername:somepassword"); service.headers = {Authorization:"Basic " + encoder

Unzip and save files using as3?

廉价感情. 提交于 2019-11-26 21:51:19
问题 I have a list of zip and rar files in a local folder. All I need to do is to extract the contents of the zip as well as rar files and to save them in a folder with the same name of the respective archive file. Since I am new to as3, I have no clue for this. Is there any Library for this??? Thanks in advance... 回答1: There are a few libraries out there that deal with ZIP files in as3, but beware that this is no easy task for a beginner in ActionScript 3. FZip seems to be the most widely used,

What is the best way to get the minimum or maximum value from an Array of numbers?

让人想犯罪 __ 提交于 2019-11-26 18:41:57
Let's say I have an Array of numbers: [2,3,3,4,2,2,5,6,7,2] What is the best way to find the minimum or maximum value in that Array? Right now, to get the maximum, I am looping through the Array, and resetting a variable to the value if it is greater than the existing value: var myArray:Array /* of Number */ = [2,3,3,4,2,2,5,6,7,2]; var maxValue:Number = 0; for each (var num:Number in myArray) { if (num > maxValue) maxValue = num; } This just doesn't seem like the best performing way to do this (I try to avoid loops whenever possible). The theoretical answers from everyone else are all neat,

Static Actionscript code analysis possibilities

*爱你&永不变心* 提交于 2019-11-26 17:59:15
问题 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? 回答1: 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

How can I get an instance's “memory location” in ActionScript?

ⅰ亾dé卋堺 提交于 2019-11-26 16:05:57
问题 FlexBuilder's debugger will show you the "memory location" (or, I can only assume, something roughly analogous) of any in-scope instance: But I'd like to get this information in code (sort of like Python's id function), so I could very easily trace how objects move through out the system. For example, I might have: trace("Returning", id(foo)); Then somewhere else I could use: trace("Using", id(foo)); To make sure both bits of code are dealing with the same instance. Now, I know that many AS

ActionScript 3.0 + Calculate timespan between two dates?

旧城冷巷雨未停 提交于 2019-11-26 13:56:12
问题 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? 回答1: 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

RegEx to match comma separated numbers with optional decimal part

牧云@^-^@ 提交于 2019-11-26 12:47:53
问题 I\'ve a regex that matches comma separated numbers with an optional two digit decimal part in a given multiline text. /(?<=\\s|^)\\d{1,3}(,\\d{3})*(\\.\\d{2})?(?=\\s|$)/m It matches strings like 1, 12, 12.34, 12,345.67 etc successfully. How can I modify it to match a number with only the decimal part like .23 ? EDIT: Just to clarify - I would like to modify the regex so that it matches 12 , 12.34 and .34 And I am looking for \'stand alone\' valid numbers. i.e., number-strings whose boundaries