actionscript-3

flex3 type casting

Does anyone know the real difference between the two ways of type casting in Flex 3? var myObject1:MyObject = variable as MyObject; var myObject2:MyObject = MyObject(variable); I prefer to use the second method because it will throw an Error when type cast fails, whereas the first method will just return null. But are there any other ...

How to Calculate Frequency & Amplitude in Flash AS3 with Flash Player 9

How can I calculate Frequency & Amplitude in As3 with FP9. I got the all raw byte using SoundMixer.computeSpectrum(_testbytes, false, 0); var g:Graphics = this.graphics; g.clear(); g.lineStyle(0, 0x6600CC); g.moveTo(0, PLOT_HEIGHT); var m:Number = 0; for (var i:int = 0; i < 256; i++) { m = (_testbytes.readFloat...

AS3 Object Oriented GUI Design

I'm trying to make a small Flash game that has a GUI, which is basically a menu where players can select certain items, sort of like the Tower Defense games. Would it be a good idea to make the GUI a singleton? Because obviously there can only be 1 instance of the GUI class. Is there a better way? ...

Falling object in Box2D should rotate due to centre of mass?

I'm trying to simulate a falling balloon in Box2DAS3. What is important is that balloon falls the such that the bottom part were you blow it up rotates towards the bottom if it's knock sideways or is dropped at an angle. I've tried offsetting the center of mass of the body and also joining two bodies together with the denser one repre...

PHP Print_r to AS3 Array conversion

I find myself frequently outputting PHP Array data into AS3 applications and I'm always having to do it the hard way - comma delimated, base-64 converted data with custom packers/unpackers on either end. I'd really like an AS3 function that takes the default output of PHP's print_r and converts it to a (potentially nested) AS3 array. Is...

Undefined error I can't figure out

Hey guys...having a math problem. Trying to layout a grid of gray boxes which I want to load thumbnails on top of. I keep getting an error when trying to load the 4th thumbnail. If you remove the 4th person node in the xml it works, but adding the 4th gives me an error? Code is below. Any help is greatly appreciated. package { im...

How to handle HTTPStatus Response 201 with AS3 / Flash / SWFUpload

Hey all. I'm using SWFUpload on a Rails site to allow for MP3 Uploads direct to Sound Cloud. To avoid having to first upload a large file to my server and push to Sound Cloud, I'm hitting their API directly via SWFUpload, passing necessary OAuth token data. Everything works - EXCEPT - Flash can't handle the HTTP response code that Sou...

flex regain lost focus

Hi all, I have a custom component with textbox & a poup button as <mx:HBox> <mx:Text id="source" height="100%" width="40%" data="my text" /> <mx:VBox backgroundAlpha="0" height="100%" borderThickness="0"> <mx:PopUpButton enabled="true" id="editButton" width="40" icon="@Embed('assets/images/Legends/editIcon.png')" ...

Set the dataGridColumn's ItemRenderer dynamically

I have this DataGrid: <mx:DataGrid id="myDataGrid"> <mx:columns> <mx:DataGridColumn dataField="colA" headerText="Column A:" width="40" headerRenderer="path.customComponents.VerticalHeader" itemRenderer="path.customComponents.CustomDataGridItemRenderer" /> </mx:Columns> </mx:DataGrid> Only I don'...

Problem with displaying video when streaming

I'm having a problem when streaming video. Randomly the video isnt shown, the video is playing though as the playhead moves and audio sounds. It's strange though because if I press pause then play the video appears and also if I make it fullscreen it appears. private var videoURL:String = "filename.f4v"; private function setupConnecti...

How do I change the value of an item in a Flex ArrayCollection

I have an ArrayCollection with values predefined. I want to assign a new value to items in the arrayCollection but can not figure out how. Basically I want to do something like this: acGuages.itemUpdated(0).thevalue = 90; (Changing the value from 25 to 90). Thanks. private var arrayGuages:Array=[ {thevalue:"25",height:"115"},...

How to capture current frame from a MovieClip into a BitmapData object?

The movieclip is in a seperate swf file that has been imported into the library. The movieclip itself plays fine (the movieclip is vector based) but when I try and capture the current frame from it into a bitmapdata object nothing seems to happen. I'm wondering if it's some type of security issue? mc is the movieclip bitmap=new BitmapDa...

Memory Problems with ActionScript

I am having trouble with memory allocation during a stress/performance testing of a program. In the test, I tried to do loading/unloading same set of resources again and again. The error I got was "Error, #1000, out of memory". The stack trace was about URLLoader/onComplete and URLStream/readBytes. I checked the memory being used at the ...

Why would my AS2 swf stop loading into AS3 swf with SWFBridge on Mac running safari and mozilla?

I have noticed that my AS2 swf that I load into an AS3 swf with SWFBridge sometimes doesnt load. I have usually loaded the page several times and it works fine then sometimes it does not load. When I quit Safari and restart it it will work again. I havent noticed this happening on a Windows PC but only on Macbook OSX in both Safari and M...

alternative to EVENT.DEACTIVATE

EVENT.DEACTIVATE doesn't work with safari in mac, is there any possible way to do this. (MouseEvent.MOUSE_LEAVE is not the same as detect when user lost the focus of the window) so I ran out of alternatives. ...

How to create multiple processes in Adobe Air program?

How to create multiple processes in Adobe Air program? Docs? Tuts? Algorithms? (for ex I have some design logic and some services client logic i want to run them in separate processes) (Air 2.0 is ok for me) ...

tinting a MC with tweener

Hi I would like to tint a movieclip with the tweener class. This is how I tint the mc without the tween: var c:Color=new Color(); c.setTint(0xff0000, 0.8); clouds.transform.colorTransform=c; it works but I would like to give it a smooth transition that's why I would use tweener. Anyone have an idea? ...

Actionscript 3: Is there a way to detect collisions between a class and a class within a class?

So I'm currently making a platformer game in flash. I want to detect a collision between my player class, and the enemy class. The enemy class is inside of a class called ground. I tried to detect it using hitTestPoint (ground.enemy.hitTestPoint(player.x, player.y, true)), but to no avail. How would I go about doing this? ...

AS3: should private variables have an _

I thought that AS3 now has private abilities added. So why should I still preface private variables with an underscore? private var _privVar:String; ...

AS3 accessing other domains

I have a AS3 swf that scrapes google images for a search query and displays some of the results. It works locally, but when the swf is on a server it can't access google. I've tried Security.allowDomain, but it doesn't work. Any suggestions? ...