Dynamically Load images in ANDROID? OR Load image in ANDROID using a string path.

By | February 11, 2011

With the following code you can load images in your drawable folder dynamically by giving the filename as a String. For that you have to use getResources().getIdentifier which has parameters as the “path”,”drawable” and the “package name”. This returns a unique resource ID which can be used to set the image for a ImageView using… Read More »

Play all songs from your raw directory in ANDROID continuously.

By | February 10, 2011

In ANDROID all resource has a unique resource ID which we get by passing the song name to the function below playSong(). The function getAllResourceIDs() will convert this String which is the name of the song to the unique resource ID which can then be used to play the song. setOnCompletionListener() will be executed when… Read More »

Trim() function in ActionScript(Adobe AIR , FLEX etc)…

By | February 9, 2011

The function for trim in ActionScript is defined inside StringUtil Class. Checkout the following function. public function stringTrim(result:String):String{ result = StringUtil.trim(result); trace(result); return result; } Please post your valuable comments if the post was useful. The function for trim in ActionScript is defined inside StringUtil Class. Checkout the following function. public function stringTrim(result:String):String{ result =… Read More »

CCMenu Animation in Cocos2d iphone

By | February 8, 2011

You cal also animate CCMenu like other sprites to have some effect on your Menu. You can also place spritesheets in each MenuItem. -(void) setUpMenu { CCSprite *Home1 = [CCSprite spriteWithFile:@”Home1.png”]; CCSprite *Home2 = [CCSprite spriteWithFile:@”Home1.png”]; Home2.opacity = 100; CCSprite *Levels1 = [CCSprite spriteWithFile:@”levels2.png”]; CCSprite *Levels2 = [CCSprite spriteWithFile:@”levels2.png”]; Levels2.opacity = 100; CCSprite *Refresh1 =… Read More »

Access a remote database from Adobe AIR or FLEX.

By | February 8, 2011

Access a remote database from Adobe AIR or FLEX. Many often you need to access online database from your application. For doing it in Adobe AIR of FLEX you need HttpService. The following example shows how to access an online database from an AIR Application. Note that you cannot return an array from a remote… Read More »

Crop an Image in Adobe AIR or Flex.

By | February 7, 2011

Below code shows how to crop an image in Adobe AIR. Change the mx:WindowedApplication to mx: Application to run it as a FLEX Application. The code uses copyPixels to extract the desired part from the image file. The important line in the below code crops the image. cropBD.copyPixels(loadBD, new Rectangle(startPoint.x, startPoint.y, squareSize, squareSize),posPoint);

Dynamically change the background of a window in Adobe AIR?

By | February 6, 2011

Change the background of your window with your selected image. Copy and paste the following code to your AIR file and view the result. Note: Please make sure that you have an image in your application source folder. Here the image name is “image.jpg” else you will get URL not found error.

Pass a variable from one window to another in Adobe AIR?

By | February 6, 2011

We often need to access another window variable in the current window. The following example shows how to access a variable from one window in the next window. The logic is to create an object of next window in the current window and assign the value of variable in the current window itself so that… Read More »

Create a polygon in Flash or Adobe AIR using Box2D.

By | February 5, 2011

The below function creates a polygon in the shape of a triangle. Please call the debugdraw function inside your update method to view the results. Make sure you import the Box2D classes into your file. public function init():void { debug_draw(); addEventListener(Event.ENTER_FRAME, update); createTriangle(); } public function createTriangle():void { var fd : b2FixtureDef = new b2FixtureDef();… Read More »

How to Implement Box2D in Adobe AIR?

By | February 4, 2011

Everyone will be fascinated how flash games are built on the web that implements the real world physics. Well for your information there are a lot of physics engines available. One of them is the Box2D. Box2D was written in C++. Then it was converted to flash. So now I am going to show you… Read More »

How to shoot a bullet in the direction of touch in Box2D iphone?

By | January 30, 2011

write the below code in “ccTouchesBegan” function and you are done. Here the ballBody represents the bullet body. You can increase the power variable to increase bullet speed.

How to rotate a body manually in Box2D?

By | January 24, 2011

The below code helps you to rotate a body in Box2D manually. Here the body is named “rotating_body” which is going to rotate and a sprite named “rot_sprite” is it’s userData, please give your own image for it. Make sure that you have it in your resources otherwise your program will crash. Note: call this… Read More »