actionscript-3

AS3/PureMVC Best Practices? Best code examples of well architected projects?

I am a AS3 novice learning PureMVC and want to write code following best practices so that any other AS3 developer can pick up my code and easily understand what I did, I am tempted to do stuff as I would in JavaScript or Asp.Net/C#, but I have a feeling that might not be the best approach. Thoughts? Links? ...

Flex HTTPService does not include Content-Length header ?

I am trying to get a Flex application to communicate with a custom python webserver I have developed. I am noticing that I cannot read the postdata received because Flex does not seem to include the Content-Length in the HTTP headers. (My webserver work when posted to from plain HTML) Is this a known problem? any ideas how to set the ...

Regexp matching of list of quotes strings - unquoted

in Javascript, the following: var test = '"the quick" "brown fox" "jumps over" "the lazy dog"'; var result = test.match(/".*?"/g); alert(result); yields "the quick","brown fox","jumps over","the lazy dog" I want each matched element to be unquoted: the quick,brown fox,jumps over,the lazy dog what regexp will do this? ...

How can addChild choose the wrong insertion index?

So, In a Flex app I add a new GUI component by creating it and calling parent.addChild(). However in some cases, this causes an error in the bowels of Flex. Turns out, addChild actually does: return addChildAt(child, numChildren); In the cases where it breaks, somehow the numChildren is off by one. Leading to this error: RangeErro...

Passing a function to another function in Actionscript 3

I have a function that passes an array to another function as an argument, there will be multiple data types in this array but I want to know how to pass a function or a reference to a function so the other function can call it at any time. ex. function A: add(new Array("hello", some function)); function B: public function b(args:A...

StackTrace in Flash / ActionScript 3.0

I want to see the stack trace in any function of my code, so i made somthing like this to call it and print the stack trace: public function PrintStackTrace() { try { throw new Error('StackTrace'); } catch (e:Error) { trace(e.getStackTrace()); } } I like to know if there are other way to do this. In some pl...

Best way to determine whether a XML attribute exists in Flex

I have a XML response from an HTTPService call with the e4x result format. <?xml version="1.0" encoding="utf-8"?> <Validation Error="Invalid Username/Password Combination" /> I have tried: private function callback(event:ResultEvent):void { if(event.result..@Error) { // error attr present } else { // ...

Multi-line label in RadioButton component (AS3)

I'm making a small quiz-application in Flash (and ActionScript 3). Decided to use the RadioButton-component for radiobuttons, but I'm having some problems getting the word-wrapping to work. The code for creating the button can be found below. _button = new RadioButton(); _button.setStyle("textFormat", _format); _button.label = _config....

What the heck does loader.load((newSource is URLRequest)? newSource:new URLRequest(newSource)); do?

I ran across the following code in Ely Greenfield's SuperImage from his Book component - I understand loader.load() but what does the rest of do? loader.load((newSource is URLRequest)? newSource:new URLRequest(newSource)); It looks like some kind of crazy inline if statement but still, I'm a little preplexed. And if it is an if state...

In ActionScript (NaN==parseFloat(input.text)) warns that it will always be false. Why?

Despite the rather clear documentation which says that parseFloat() can return NaN as a value, when I write a block like: if ( NaN == parseFloat(input.text) ) { errorMessage.text = "Please enter a number." } I am warned that the comparison will always be false. And testing shows the warning to be correct. Where is the corrected doc...

In my ActionScript3 class, can I have a property with a getter and setter?

In my ActionScript3 class, can I have a property with a getter and setter? ...

How can I disable copy / paste in Flex Text controls?

Long story short, I need to put some text in my Flex application and I don't want users to be able to copy. I was going to use a label, but apparently labels do not support text wrapping. Can I make it so that users cannot select text in a Flex Text control? Thanks. ...

Flash rendering: optimisation tips and tricks

I'm about to push out a website soon and so I've gotten in the last stages. Time to optimize the baby! The website performs pretty good overall, with an average framerate of 32fps. But at some heavy animation parts it likes to drop a couple of frames to about 22fps. Which is not that horrible. But I'm tweaking it as much as possible to k...

How do I visually "break out" of a Container in Flex?

Here's my problem - I have some code like this: <mx:Canvas width="300" height="300"> <mx:Button x="800" /> </mx:Canvas> So the problem is that the Button inside the canvas has an x property way in excess of the Canvas's width - since it's a child of the Canvas, the Canvas masks it and creates some scrollbars for me to scroll over...

Find top 3 closest targets in Actionscript 3

I have an array of characters that are Points and I want to take any character and be able to loop through that array and find the top 3 closest (using Point.distance) neighbors. Could anyone give me an idea of how to do this? ...

When should an oldschool flash developer use flex?

What are the key differences between Flash and Flex? I have over five years experience with flash and feel very comfortable developing with it and ActionScript3. I find myself more and more curious about Flex and want to know when it is best to use flash or flex. Also, is everything that can be done with MXML, able to be done with AS3...

Runtime CSS fails silently when Flex application is loaded by a non-Flex application

I have compiled a CSS swf file which includes embedded skins for my Flex application. In our download product, this CSS works fine. On the web, a non-Flex container is loading the Flex application, and the CSS fails silently. When the application is debugged, the following runtime error can be seen in the trace output, but is not rais...

In Flash, how would I run an e4x statement when that statement is stored in a String?

So I have something like this: var xmlStatement:String = "xmlObject.node[3].@thisValue"; What mystery function do I have to use so that I can execute xmlStatement and get thisValue from that xmlObject? Like.... var attribute:String = mysteryFunction(xmlStatement); P.S. I know eval() works for actionscript2, I need the as3 solution....

Scrollable regions in ActionScript 3 Visualization

What is the best way to create several scrollable regions in an ActionScript 3 visualization that extends flash.display.Sprite and makes use of hierarchy of of low level DisplayObjects (Sprite'a, Shape's, TextField)? I have tried to use three mx.containers.Canvas objects added as children of the main Sprite and have also tried converti...

Flex graphic assets: SWF or SWC?

Which is a better format to store graphic assets for a Flex application, SWF or SWC? Are there any real differences, and if so what are they? ...