What is Objective C Keyword id ?

By | March 6, 2011

Hi, Objective C uses a special keyword ‘id’. Let’s see what it is. Objective C -id- is actually a ‘pointer to an object’. That is ‘id’ can hold a pointer to any objective c object. It doesn’t matter the object’s class. eg: NSString *myString = @”Coderz Heaven!”; id newString; NSString *tempString; newString=myString; tempString=newString; That’s it!… Read More »

Read a plist from your resources folder in Iphone Objective C

By | March 6, 2011

Plist or property list are usually used for storing data in iPhone. They are normal XML files, you can open it in a texteditor to view it’s data. This sample code shows how to read data from the plist. Reading a plist will return an array.You can print out the array to view the results.… Read More »

Remove unwanted memory from iPhone….

By | March 5, 2011

Hi all …… You know iPhone doesnot have garbage collection like ANDROID. So it becomes the responsibility of the developer or programmer to release the resources and remove the unwanted textures from your memory. If you don’t remove the unused textures and other variables from your memory your application will exit after a while. You… Read More »

Collision Detection In Box2D – Using With Cocos2D

By | March 5, 2011

For an interactive game building using Box2D, collision detection of Box2D bodies is necessary. There is an easy way to implement collision detection in Box2D. For checking whether two bodies have collided with each other in Box2D while using it with cocos2D, then use the following lines of code where ever you want to check… Read More »

Removing Unused Textures in Cocos2D

By | March 5, 2011

Sometimes unused textures may cause you memory leak! So you need to remove the unused textures. For removing unused textures, use the following line of code, where ever you want to remove unused textures. [[TextureMgr sharedTextureMgr] removeUnusedTextures]; 🙂

Removing Forces From Your World in Box2D Cocos2D

By | March 5, 2011

Hi, In certain situations you may need to remove all the forces you have applied on different bodies in your box2D world. Then what to do? Removing all the forces from the bodies in the box2D world is simple. Just use the single line of code. yourWorld->ClearForces(); Here yourWorld is your Box2D world. Simple, isn’t… Read More »

File Operations in Adobe AIR/FLEX

By | March 5, 2011

The following example shows how to deal with a simple text file in Adobe AIR/FLEX. This example illustratesd how to write a string to a text file and save it in the desktop. However you can use the “application directory” but make sure that you have necessary write permission to access the directory. Please leave… Read More »

Creating a JMenubar in java swing

By | March 4, 2011

Creating a JMenubar is simple. JMenuBar menubar = new JMenuBar(); JMenu menu1 = new JMenu(“File”); JMenu menu2= new JMenu(“Help”); file = new JMenuItem(“Exit to menu”); edit = new JMenuItem(“Exit”); JMenuItem about = new JMenuItem(“About us”); f.setJMenuBar(menubar); menu1.add(file); menu1.add(edit); menu2.add(about); menubar.add(menu1); menubar.add(menu2); file.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //Action…… } }); edit.addActionListener(new ActionListener() {… Read More »

How to load a PDF in Titanium?

By | March 3, 2011

Loading a PDF file in Titanium may be sometimes our requirement for an application. For loading a PDF we need to have a webview inside a scrollview so that it is scrollable also. Take a look at this simple example. /** creating a window **/ var window = Titanium.UI.createWindow{}; /** creating a webview **/ var… Read More »

Dynamically Load CSS in Adobe AIR/FLEX / Load css in Adobe AIR/FLEX using Class.

By | March 2, 2011

This example shows how to dynamically load css in Adobe AIR / FLEX. Here in this example Panel id the tag name for the panel control. Drag a panel control to your design then copy the code to your source file. “myTabs” is the class for the CSS. Panel { borderColor: #CBE0FF; border-style:solid; borderThickness: 1;… Read More »

Client Side Form Validation – using JavaScript

By | March 1, 2011

Hi, JavaScript is mainly used for client side scripting. In client side scripting one of the thing which we are usually in need is Validation of Forms. We want to know the user , who is interacting with the form have already given the necessary details before submitting or saving etc. Here is a simple… Read More »

Using ButtonBar in Adobe AIR/FLEX, A simple Example

By | March 1, 2011

Hello………. A button Bar is a convenient way to place your buttons in an application. It saves a lots of space in your application interface. Take a look at the following example which shows how to use the ButtonBar. An itemClickEvent is attached to each button in the ButtonBar. You can place as many buttons… Read More »

How to load a URL in Objective C or Cocoa in iPhone?/ Open Safari in Objective C

By | March 1, 2011

This code snippet helps you to open a webpage in Safari. Code uses openURL to load the webpage in the web browser. Write this function as an action to a button……… – ( IBAction ) loadWebPageInSafari : ( id ) sender { NSURL *my_URL = [NSURL URLWithString:[Your_URL stringValue]]; if ( [ [NSWorkspace sharedWorkspace] openURL :… Read More »

Using Arrays in JavaScript – Basics

By | February 28, 2011

Hi… We all know, Arrays are nothing but variables which can hold all your variable values with a single name. Let’s see some basic operations of Arrays in JavaScript. To Create a New Array. Use the following code. var myArray = new Array(); This code of line created a new Array object called myArray. Adding… Read More »

How to get a selected Item from a spinner in ANDROID?

By | February 28, 2011

We have come across this issue many times during programming to get a selected item in your combobox. ANDROID has built in functions to get the selected item from a spinner. Take a look at the snippet. Here my_spinner id the spinner variable and using getSelectedItem() which will return an object and by using toString()… Read More »

How to add more than One HTML Document in a single Browser ?

By | February 28, 2011

Hi… There may arise certain situations where you need to include more than one HTML document in the same browser. But how? It’s simple. It’s by using FRAMES of HTML. FRAMES can be included inside FRAMESET. Let’s see an example. <frameset cols="200,400"> <frame src="http://www.coderzheaven.com" /> <frame src="http://www.google.com" /> </frameset> This will create two column frames… Read More »

ProgressBar in ANDROID…..

By | February 28, 2011

Progress bars are our basic needs when we want to show something for a long time or some progress takes a long time and we want to show it’s progress. Keeping that in mind ANDROID also has built in progress views. There are basically two types of progress views in ANDROID. ProgressDialog.STYLE_SPINNER and ProgressDialog.STYLE_HORIZONTAL Take… Read More »

Toggle between Full Screen and normal Screen in Adobe AIR or FLEX.

By | February 27, 2011

Hi all……… We often need to toggle between fullscreen and normal screen in our application. The following code snippet helps you to toggle between these two screens in Adobe AIR or Flex. Here I am using StageDisplayState class to do both which has “stage.displayState = StageDisplayState.FULL_SCREEN” and ” stage.displayState = StageDisplayState.NORMAL” constants to do this.… Read More »