actionscript-3

How to deal with Number precision in Actionscript?

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? ...

RTMP Stream Bitrate alternatives

Which bit rates would you assign as normal and high based on a HD-H.264 RTMP stream considering exclusively broadband connections (using a progressive stream fallback for slower connections) ? EDIT : Lacking of answers I realize my question is just far too vague. The "answer" was not meant to be a solution in itself - which is just not...

Flex: Databinding watch

Given this MXML component: <mx:TextBox id="test" text="{test2.text.length &gt; 5}" /> How can I get an event dispatched whenever the value of test2.text.length > 5 changes? I've tried ChangeWatcher, BindUtils and PropertyChangeEvent, but no luck :( Thanks; [EDIT] Copying my comments from further down: Well... I'm actually using...

creating optimized swf from a swc

I've created a swc library. Opening this swc, I can extract the library.swf. Placing library.swf on my server and using it as an RSL, everything works fine. If I run optimizer against the library.swf, the resultant library-optimized.swf does not work as an RSL. I get Flex Error #1001: Digest mismatch with RSL ... Redeploy the match...

filling in (...rest) parameters with an array?

Some as3 functions handle overloading by allowing for an arbitrary number of parameters using the convention: public function doSomething( ... rest ):void; I am in a situation where I need to pass all the values of an array (of arbitrary length) into this type of function... I am not sure how to do this. Suggestions? Here is a hack...

Flex - Dispatch custom Event on receipt of standard Event

I am processing a FileReferenceList.fileList[] of multiple files a user selects in the following code.. for (i=0;i < event.currentTarget.fileList.length; i ++){ fileByteData = new ByteArray(); fileByteData = (event.currentTarget.fileList[i].data as ByteArray); loader = new Loader(); loader.contentLoaderInfo.addEventList...

Fastest way to delete one entry from the middle of Array()

What is the fastest way to delete one specific entry from the middle of Array() Array is large one having Strings. I dont want just to set Array[5] = null, but instead array size should be reduced by one and array[5] should have content of array[6] etc. ...

best way make default param = a variable?

I have a variable, and a function for brevity lets consider it looks like this: private function applyDiscount (value:Number):Number { return value*_discount; //_discount defined somewhere else } OK thats all fine and dandy but say I want to be able to call that function and be able to pass my own discount, but still use the _discount...

How to list all classes contained within an SWF

Is there a way to get a list of all classes contained within then currently running SWF? You could use describeType on the root and then traverse down the list to find all Classes of instances referenced within your app, but this method does not work for classes that have been included, but not referenced (local references, for example)....

Change label of a NativeMenuItem

I'm experimenting with Adobe AIR and Google Maps API in Flex Builder. The question is, i'm making a NativeMenu, and was wondering, how can I change the label of the "Fullscreen" item to "Exit fullscreen" when the stage is in fullscreen? If you see any thing in the code that could/should be written better, please let me know ;) Here is ...

How can I fix this Implicit Coercion error in Flash?

I'm playing with a Physics Engine for AS3 and the code below is basically the hello world example. However, I made a slight change by declaring the property "ball" as a WheelParticle at the beginning of the class definition. (forgive my terminology if it's wrong). Before, it was declared inside the constructor as var ball:WheelParticle...

Creating a new attribute in an XML node using E4X in AS3

Is there any way to do it? ...

AS3:Best practice for getting image from Loader()

When loading images using Loader, what's the preferred way to add the image to the display list? Grabbing the data in an Event.COMPLETE handler like new Bitmap( Bitmap(LoaderInfo(e.target).content).bitmapData ) , or adding the Loader instance itself? ...

AS3: Extending Loader, how to draw border on its content

I'm extending Loader(), is it possible to draw a border around the content without resorting to some hacks? I understand Loader can't have any additional children, otherwise I would just create a shape to the contents size and add it. But is there a way to coerce or cast the content object in order to use the drawing API on it? ...

How do I stop a datagrid's first-row itemRenderer from instantiating/adding/initializing/etc twice?

In a Flex DataGrid's first row, the itemRenderer will initialize twice. Tracing the results reveals that the flex framework is possibly creating two instances of the first row's itemRenderer. In a more complex application, where the itemRenderer contains a data-bound ColorPicker, we're seeing an infinite loop occur because of this prob...

How to manipulate user files without uploading to the server first?

Is it possible with AS3 to prompt a file select screen to the user, get the selected file data and use it directly in the movie without the need to upload this file to the server first and then get it back? I want something like FileReference to enable the user to selected many image files then I want to display/manipulate these images d...

How to subscribe for an javascript event form Flex 3 action script code?

Hello, everyone. We have that Flex app talking to the server. We need some kind of *FlexEvent.ON_BROWSER_WINDOW_CLOSE* event but, unfortunately Flex does not provide such. So I've got the advice to catch a javascript "onbeforeunload" event and call the flash client thru the ExternalInterface-registred method. Is there any way to subsc...

Set the icon of a Flex button with a Sprite in runtime

I want to set the icon of a button in flex. The default syntax is as follows. myButton.setStyle("icon", iconClass); and iconClass is normally an embedded object. But what I want to do is, use a standard Sprite or a MovieClip (which I find during runtime) as the icon. Is this possible? Has anyone done this? Thanks! ...

Read variable from another function

How can I access an variable from another function? I have a function that sets and variable: private function create () { var str:String = "hello"; } private function take() { var message:String = str; } ...

FlashDevelop cannot see the MXML Component File I made

Following a Video tutorial on Flex, but I am inside the FlashDevelop IDE as opposed to Flex Builder. Now, in the video they create a custom MXML Component which is simply a derived Horizontal Box. The markup of the video tutorial to mine is the same and I have the MXML file in the same folder as the Main.MXML. I get the following ...