Wanted to use Log4j without configuration file.
So here is the clean code.
//Java
FileAppender fa = new FileAppender(new SimpleLayout(),filename,true);
fa.activateOptions();
Logger logger = Logger.getLogger(filename);
logger.addAppender(fa);
logger.info(data);
logger.removeAllAppenders();
Vishwajit Girdhari : a Pune based .NET consultant and blogger. Building Rich Internet Application to cross the mile with a smile....... Designer[30%]/Developer[70%]'s Blog.
Friday, September 29, 2006
Thursday, September 28, 2006
SWFLoader : Dynamically load / unload my 'sub applications' in Flex 2.0
Dynamically load / unload my 'sub applications' in Flex 2.0 (compiled swf) but user feel should be as if only one mxml has been loaded.
One problem in flex...
You have 3 .mxmls that get compiled into .swf ( Say A , B , C . )
step1 You have to load B inside A
step2 In B there is a button on click you have to unload B from A and load C
step3 Also in C there is a button on click you have to unload C from A and load B
---
My approach
for Step1 : cool!
I am loading B in A using SWFLoader.
for step2 : stuck!
I am not able get hold of the instance A from which i can change source property of swfLoader (instance) to "C.swf"
for step : whatever works for step 2 :-(
--
Solution ;)
Two days after making this post I figured out a simple way to achieve this.
Code below demonstrates the my approach.
Thanks,
Vishwajit Girdhari
Flexblog : http://flexiness.blogspot.com
One problem in flex...
You have 3 .mxmls that get compiled into .swf ( Say A , B , C . )
step1 You have to load B inside A
step2 In B there is a button on click you have to unload B from A and load C
step3 Also in C there is a button on click you have to unload C from A and load B
---
My approach
for Step1 : cool!
I am loading B in A using SWFLoader.
for step2 : stuck!
I am not able get hold of the instance A from which i can change source property of swfLoader (instance) to "C.swf"
for step : whatever works for step 2 :-(
--
Solution ;)
Two days after making this post I figured out a simple way to achieve this.
Code below demonstrates the my approach.
Thanks,
Vishwajit Girdhari
Flexblog : http://flexiness.blogspot.com
Main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml "
layout="absolute"
creationComplete="init(event)" >
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.events.Event;
private function init(e:Event):void
{
//doing nothing
}
public function loadSWF (filename : String) : void
{
swfLoader.source=filename;
}
]]>
</mx:Script>
<mx:SWFLoader id="swfLoader" source="one.swf"
></mx:SWFLoader>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.
layout="absolute"
creationComplete=
<mx:Script>
<![CDATA[
import mx.controls.
import flash.events.
private function init(e:Event)
{
//doing nothing
}
public function loadSWF (filename : String) : void
{
swfLoader.source=
}
]]>
</mx:Script>
<mx:SWFLoader id="swfLoader" source="one.
></mx:SWFLoader>
</mx:Application>
one.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml "
layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
public function handleOne ( event : Event ) :void {
mx.core.Application.application.loadSWF("two.swf");
}
]]>
</mx:Script>
<mx:Button id="btnOne" label="Button One" click="{handleOne(event)}"
y="200"></mx:Button>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.
layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.
public function handleOne ( event : Event ) :void {
mx.core.Application
}
]]>
</mx:Script>
<mx:Button id="btnOne" label="Button One" click="{handleOne(
y="200"></mx:Button>
</mx:Application>
two.mxml
<?xml
version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml "
layout="absolute">
<mx:Script>
<![CDATA[
import flash.profiler.showRedrawRegions;
import mx.controls.Alert;
public function handleTwo ( event : Event ) :void {
mx.core.Application.application.loadSWF("one.swf");
}
]]>
</mx:Script><mx:Button id="btnTwo" label="Button Two"
click="handleTwo(event)" x="300"></mx:Button>
</mx:Application>
version="1.0" encoding="utf-
<mx:Application xmlns:mx="
layout="absolute">
<mx:Script>
<![CDATA[
import flash.profiler.
import mx.controls.
public function handleTwo ( event : Event ) :void {
mx.core.Application
}
]]>
</mx:Script><mx:Button id="btnTwo" label="Button Two"
click="handleTwo(
</mx:Application>
Friday, September 08, 2006
Printing a hash map in flex
A small piece of AS code that saves a lot of my debug time and frustrations...
Mostly use while understanding the remote object structure.
//code:
//Alerting the hashmap contents
var str = "";
for(var k:String in hashMap)
{
str += k + ":" + hashMap[k] + "\n";
}
Alert.show("Printing hash map : \n" + str);
Mostly use while understanding the remote object structure.
//code:
//Alerting the hashmap contents
var str = "";
for(var k:String in hashMap)
{
str += k + ":" + hashMap[k] + "\n";
}
Alert.show("Printing hash map : \n" + str);
Subscribe to:
Posts (Atom)