Writing by shivdev on Sunday, 6 of January , 2008 at 9:32 pm
Here are some of the Top 5 Flex Examples for beginners.
Category: Adobe
Writing by shivdev on Sunday, 23 of December , 2007 at 2:53 pm
Sometimes developers require that you need to use a SPECIFIC version of a JDK or a JRE etc. To download any version of Java go to Archive: Java[tm] Technology Products Download.
Category: Java
Writing by shivdev on Saturday, 22 of December , 2007 at 2:09 pm
Here is an example of a Simple Singleton. There are 3 things to remember.
- Create a private static instance of the singleton class.
- The constructor must be private.
- There must be a static method to get the “single” instance of the singleton class.
/* This is NOT Thread Safe - This is a Simple Example of a Singleton*/
public class SimpleSingleton {
private static SimpleSingleton instance = null;
private SimpleSingleton () {
}
public static SimpleSingleton getInstance() {
// lazily create an instance
if (instance == null) {
instance = new SimpleSingleton ();
}
return instance;
}
}
Now here is an example of a Thread Safe Singleton achieved using the synchronized(instance). The reason for checking (instance == null) twice is so that we don’t want all threads to wait when getInstance() is called. Threads must wait only when instance is being created.
public class ThreadSafeSingleton {
private static ThreadSafeSingleton instance = null;
private ThreadSafeSingleton() {
}
public static ThreadSafeSingleton getInstance() {
// Threads will acquire a lock and wait ONLY if instance is NOT NULL
if (instance == null) {
// Only One Thread allowed at a time from this point
synchronized (instance) {
if (instance == null) {
instance = new ThreadSafeSingleton();
}
} // End of Synchronized Block
}
return instance;
}
}
Another Thread Safe Singleton Example
Another way of achieving a Thread Safe Singleton without worrying about synchronization, is by instantiating the Singleton object when the CLASS gets loaded (in the static block). However, the we lose the “lazy initialization” nature of the ThreadSafeSingleton shown above.
public class Singleton {
static {
// This happens when the class is loaded.
instance = new Singleton();
}
private static Singleton instance = null;
private Singleton () {
}
public static Singleton getInstance() {
return instance;
}
}
Category: Interview,Java
Writing by shivdev on Sunday, 11 of November , 2007 at 11:27 pm
Do you get this exception in the states view?
java.lang.ClassCastException
at com.adobe.flexbuilder.mxmlmodel.ComponentInstance.getStates(ComponentInstance.java:162)
at com.adobe.flexbuilder.mxmlmodel.ComponentInstance.getDerivedStates(ComponentInstance.java:193)
at com.adobe.flexbuilder.editors.mxml.views.states.StatesViewContentProvider.hasChildren(StatesViewContentProvider.java:173)
at org.eclipse.jface.viewers.AbstractTreeViewer.isExpandable(AbstractTreeViewer.java:1378)
at org.eclipse.jface.viewers.AbstractTreeViewer.updatePlus(AbstractTreeViewer.java:1845)
at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:536)
at org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractTreeViewer.java:514)
Looks like its FlexBuilder is Case Sensitive and is confused between these tags
<mx:state> … <mx:state>
<mx:State> … </mx:State>
Use <mx:State> … </mx:State> and you should be fine.
Category: Adobe
Writing by shivdev on Sunday, 11 of November , 2007 at 10:15 pm
Are you getting an annoying warning message that says
C:\Program Files\Mozilla Firefox\plugins\NPSWF32.dll
Flex Builder cannot locate the required version of Flash Player. You may need to install Flash Player 9.0 or reinstall Flex Builder. Do you want to try to run your application with the current version?
Solution: (that worked for me)
Copy the file NPSWF32.dll manually from C:\WINDOWS\system32\Macromed\Flash to C:\Program Files\Mozilla Firefox\plugins
This worked for me and got rid of that annoying popup. But I’m not sure, what consequences this will have in the future after further installs/updates of Firefox/Flash etc.
Adobe’s Solution: to this problem can be found at
Flex Builder 2: Installed Adobe Flash Player is Not a Debugger
Another Discussion: (also talks about copying the file manuallY)
new flash player?
Category: Adobe
Writing by shivdev on Friday, 9 of November , 2007 at 10:14 am
Most of you might be familiar with net use which works fine for network drives
net use x: \\SomeHostMachine\SomeShare
For local drives use subst
subst z: c:\SomeFolder\SubFolder
Category: Uncategorized