Showing posts with label Code Snippet. Show all posts
Showing posts with label Code Snippet. Show all posts

Wednesday, May 30, 2012

How to format Date object in a custom way or using locale

When you want to format your Date object in Actionscript instead of building string on your own (using getDay() and other functions provided by Date object) you can use Date Formatters. Unfortunately there are

Friday, May 25, 2012

Adobe AIR mobile app - how to get screen orientation?

In my recent project I had to get current screen orientation in my mobile app. How can you do this in Flex? I believe there are many ways to achieve that but here is my solution.

Friday, September 9, 2011

GraphUtil - class for setting brightness and grayscale in Image

Recently in one of my projects I needed to change brightness in image that was in Spark Image control. It got me some time to find the best solution to do that. Finally I made my own class - GraphUtil. This class use ColorMatrixFilter to do all the magic. This is

Monday, August 29, 2011

Swiz URLMapping

Swiz Framework, since the 1.0 version, has a great feature that allows you to create your own metadata processor. I didn't create any of my own yet but I found a great one created by Ryan Campbell - check his site here LINK. Generally speaking it

Friday, July 22, 2011

Separate class for assets

In projects with many assets it is very handy to embed them in one (or few, but in the same package) class, so you can instantiate them everywhere in the project. The benefit of this is quite obvious - after making any change in your assets you just have to change one class, you don't have to search through the code to find place that is needed to be changed. Assume that

Wednesday, June 1, 2011

Wrapper class for RemoteObject

In my projects I use AMF connections very often. In my of my previous posts I showed you PHP class and some Actionscript code that connects to it (LINK). This code is fine when you have very simple application, but in bigger projects it's very handy to write a wrapper class for handling AMF connections. Let's start with

Saturday, May 7, 2011

How to watch Bindable vars in Actionscript code

Bindable vars can be watched by the MXML components - but what if we want to see in Actionscript code if bindable var is changed? Is there any way to do that? Of course there is! The class we need is mx.binding.utils.ChangeWatcher. Unfortunately this class has many downsides and generally works worse than binding in MXML, but nevertheless it's still quite useful. As usual let's start with the

Monday, April 4, 2011

Quick way to invoke pop up window

In my last post (LINK) I showed you how to invoke a pop up window from your app. I did this by creating an instance of PopUpWindow class in my main app and then center it on current DisplayObject. I want to show you simpler and more robust way to achieve that.

Tuesday, March 29, 2011

Communication with pop up window (callback & custom event)

Pop up windows are very handy components, especially for showing some important information to user. But this is only communication in one way, what if we want to get data back from user? We can put some controls to retrieve input from user in pop up window (TextArea for instance), but how this data could be transferred to main application?

Tuesday, January 18, 2011

How to start with AMFPHP

AMFPHP is great piece of code made for connect Flash applications with its server side (coded in PHP in this matter) by using AMF protocol. It's way better in terms of efficiency and packet size than standard GET/POST calls.

Thursday, December 23, 2010

Object Pooling in Flixel

When I started to write my first game called Infinite Shooter I didn't realise that when you destroy an object in Flixel engine (using kill() function) it doesn't really disappear - it just "hang in the nowhere", still existing in allocated memory. Because of that after a few minutes of gameplay, when many planes arrived on and left the screen, I had a huge memory leak. Solution for that is making an object pool, where you can reuse killed objects and make a new ones from them. How can you achieve that in Flixel engine?