Alert Button with Image in Adobe AIR/FLEX…

By | March 8, 2011

We usually see only alerts with text only, but in Adobe AIR and FLEX we can have alerts with our images in it. That’s really cool right. Take a look at this simple example. It places an image in the alert. Make sure that you have the image named “alert_image.png” in your “src” folder or otherwise give the… Read More »

admin

How to Disable Right Click on HTML page using jQuery ?

By | March 8, 2011

Hi, In some special cases you may need to disable the Right Click option on HTML page you are using. An easy way to do it using jQuery is follows. Use the following code in the HTML page where you want to disable Right Click. $(document).ready(function(){ $(document).bind(“contextmenu”,function(e){ return false; }); }); 🙂

admin

SQL Function For Rounding Decimal Numbers – Syntax

By | March 7, 2011

If you want to round a decimal number using SQL, use the ROUND() function of SQL. Syntax: SELECT ROUND(column_name,decimals) FROM table_name eg: SELECT itemName, ROUND(Price,2) as Price FROM Purchase It will select itemName and Price from the table ‘Purchase’ and will Round the Price with 2 decimal places. 🙂

admin

How to play music in cocos2D or Box2D, iPhone?

By | March 7, 2011

This simple code plays a music…….. [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@”my_music.mp3″]; For stopping the music use this……. [[SimpleAudioEngine sharedEngine]stopBackgroundMusic]; To pause the music use this line of code….. [[SimpleAudioEngine sharedEngine] pauseBackgroundMusic];

admin

How to make gear joint in Box2D, iPhone?

By | March 7, 2011

Gear joints are one of the real specialities of Box2D. By creating gear joints between two bodies you can actually simulate a real world gear. For creating a gear joint you need two bodies connected by a revolute or prismatic joint. The below code creates two bodies in the shape of a circle which is actually attached to… Read More »

admin

Swing JPanel with background image

By | March 7, 2011

This code add an image to Jpanel. JPanel panel1 = new JPanel(); JFrame recursion_frame = new JFrame(); BackgroundPanel stack_image1 = new BackgroundPanel(“Recursion.jpg”); panel1.setLayout(null); panel1.setLayout(new BorderLayout()); panel1.setBackground(Color.lightGray); panel1.setVisible(true); recursion_frame.setContentPane(panel1); ///adding to panel… recursion_frame.getContentPane().add(stack_image1); //adding image to panel…

admin

Position swing window in center of the screen

By | March 7, 2011

In some case we need to position the window in the center of the screen . The same effect can be achieved by hard coding the center points .But in that case the window position change when the screen resolution changes This code will position the window in center irrespective of different screen resolutions public JFrame stack_frame =… Read More »

admin

Stop window resizing in Swing

By | March 7, 2011

This is very useful because in some case we want to stop the window from resizing. The resizing can spoil our entire window design public JFrame stack_frame = new JFrame(); stack_frame.setResizable(false);

admin

MessageDialog window in Java Swing

By | March 7, 2011

This is a simple message window which popup after an event . You can put this code inside an clicklistener JOptionPane.showMessageDialog(content_frame.getContentPane() , ” Message String “, JOptionPane.INFORMATION_MESSAGE);

admin

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! It will work… Read More »

admin

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. NSString *path= [[NSBundle… Read More »

admin

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 often have the… Read More »

admin

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 collision. if((contact.fixtureA ==… Read More »

admin

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]; 🙂

admin

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 it? 🙂

admin

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 your valuable comments…..

admin

Load a webpage in Titanium iPhone or ANDROID

By | March 4, 2011

This is a simple code in Titanium which opens the browser in your phone with the specified URL. var URL = “http://www.google.com”; Titanium.Platform.openURL(URL); Please leave your comments on this post.

admin

How to turnOff suggestions in editText in ANDROID?

By | March 4, 2011

Sometimes we may not need suggestions to appear in the textbox in our application in ANDROID. This simple codes turns off this suggestion …. Put this code inside your editText tag in the layout xml file. if the above code is not working try this… Please leave your valuable comments………..

admin

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() { public void actionPerformed(ActionEvent… Read More »

admin

Unscheduling All Selector Functions in Cocos2D iPhone

By | March 3, 2011

There may arise certain situations there you are using a number of @selector functions and want to stop all those selectors. In cocos2D there is an easy way to stop/unschedule all the selectors with a single line of code! Use this line of code where ever you want to unshedule all the selectors being activated. [self unscheduleAllSelectors]; 🙂

admin

Play an MP3 in Adobe AIR/FLEX

By | March 3, 2011

Often in out applications we need to play sounds , so this code explains how to play, stop and resume an mp3 sound in Adobe AIR/FLEX. What you have to do is to copy the following code and place it inside your “mx:Script” tag. After that place three buttons for play, pause and stop and connect it to… Read More »

admin

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 my_webview = Titanium.UI.createWebView({… Read More »

admin

Load a webpage in Adobe AIR

By | March 2, 2011

This example shows how to load a webpage inside Adobe AIR, For this first you have to place an HTML control in your design for loading the html content. Create an page “index.html” inside the application directory of your current project and add some Html content to it. After that copy the following code to your source file.… Read More »

admin