image ads

Monday, October 18, 2010

stupid XML in Flash Lite Digital Home

For Flash Lite Digital Home's developers, working with XML really is a nightmares;

If you are not aware of it, it will make your application stop functioning, part of your data will lost;
If you are not aware of it, it will make your device crash and the memory leak issue will appeal without your notice.

Normally developer will think that delete the XML object created or set that XML object to null then the Garbage Collector will auto collect it;

Unfortunately, it work another way round.
As we know, the Garbage Collector in Flash Lite was using reference count method.
This mean if a variable the reference count not equal to zero, the Garbage Collector will not collect it.

For this XML case, somehow a global variable in Adobe XML class, "idMap" hold a reference of the XML object itself. This make the reference count never become zero, so the Garbage Collector will not auto collect it.

This will make the memory leak issue happen in your device at the end!
This will make your application running slow, when you try to exit your application, it will take more long time as usual. Sometime will reach 5minutes!!!

So must remember delete the variable "idMap" before delete the XML object.

Here is some sample code:

1. For global XML variable
import mx.utils.Delegate;
class test{
private var xml:XML = null;

private function loadXML():Void
{
this.xml = new XML();
this.xml.ignoreWhite = true;
this.xml.onLoad = Delegate.create(this, this.XMLonLoad)
this.xml.load(url);
}

private function XMLonLoad(success:Boolean):Void
{
trace(this.xml);
//work with xml data
delete this.xml.idMap;
delete this.xml;
this.xml = null;
}

}


2. Local XML variable
import mx.utils.Delegate;
class test
{
private function loadXML():Void
{
var xml = new XML();
xml.ignoreWhite = true;
xml.onLoad = Delegate.create(this, function(success:Boolean):Void
{
trace(this.xml);
//work with xml data

delete xml.idMap;
xml = null;
});
xml.load(url);
}
}

Sunday, October 17, 2010

不知不觉

Flash Lite Digital Home,
真的对它又爱又恨。。。
它,令我有时不知要笑还是要哭;
它,有太多令人预想不到的限制;
但,不知不觉,
大约一年半以前,
突然要应付它;
到现在,
已经对了它,年半有余。。。
从一无所知,到今天,
也还不能说完完全全掌握它;
但,至少它让我学会了不少东西。

Thursday, July 15, 2010

新版本的4次龟兔赛跑(转贴,很有意义)

我们曾经讲过,龟兔赛跑的故事,你说龟兔赛跑有什么讲头啊,我在幼儿园就听老师说过了,我说你知道什么呢,龟兔赛跑是说兔子骄傲,半路睡觉了,所以乌龟跑第一了,我说这不是太简单了。
  北京大学光华管理学院可不是这么讲的,龟兔赛跑同学首先提出问题,难道只赛这一次吗?不对,还得接着赛呢,第一次兔子输了,兔子不服,要求赛第二次,第二次龟兔赛跑,兔子吸取经验,不睡觉了,一口气跑到终点,所以第二次龟兔赛跑是兔子赢了。
  乌龟输了,乌龟不服气咱们要求再赛第三次那就赛吧,乌龟说前两次都是你指定路线跑的,现在得由我指定路线跑,兔子想反正我跑得比你快吧,好,指定路线跑了,结果兔子又跑到前面,快到终点了,一条河把路挡住了,兔子过不去了,乌龟慢慢爬到了,乌龟游过了河。
  第三次龟兔赛跑是乌龟赢了,于是两人就想了赛第四次,咱们老赛干吗,竞争,咱们合作吧,咱们优势互补吧,于是优势互补,优势互补陆地上兔子驮着乌龟跑,过河的时候乌龟驮着兔子游,两个人同时达到终点,双赢的结果。
  第一次赛跑的启示:所以这个例子告诉我们,四次龟兔赛跑对我们的发展战略来讲是四个重要的启示,第一个重要的启示是,第一次赛跑的重要启示是,当你处在劣势的时候不要气馁不要松懈,要坚持到底等待对手犯错误,你看如果第一次龟兔赛一跑了,兔子跑在前面了乌龟一看,得,我这下怎么也赢不了了,我弃权了好,你弃权了它睡觉还是它赢,因为它醒过来它跑到终点。结果乌龟坚持不懈等待对手犯错误,果然兔子犯错误了,半路睡觉了,所以他赢了,第一次赛跑这个启示。
  第二次赛跑的启示:要善于把潜在的优势变成现实的优势,兔子它能跑是潜在的优势,第一次它睡觉,它不跑它没有转化,第二次它一口气跑到终点,潜在优势转化为现实优势了,所以第二次是兔子赢了,对我们每个人来说对我们每个地区来说,不要去津津乐道你的潜在优势何在,重在转化,重在转化。
  第三次龟兔赛跑的启示:当你发现原来的策略不管用了,要及时调整策略,改变策略。第二次赛跑完以后乌龟懂得一个道理,只要沿着原来这条路线跑,哪怕跑一万次都是兔子赢,我永远没有胜的可能,只要它不睡觉都是它赢啊,那怎么办呢,及时调整策略换条路线跑,一条河把路挡住了,你的优势发挥不出来了,所以第三次赛跑它是及时调整策略的结果。
  第四次赛跑的启示:是合作、优势互补、双赢都是建立在相互信任的基础上的,相互信任,你看,如果不相互信任行吗?好,陆地上兔子驮着乌龟跑,兔子耍坏,拐弯的时候,一扭身把乌龟摔个重伤怎么办,过河的时候乌龟往下一沉把兔子淹死了怎么办,所以必须在相互信任的基础上。我小孙女在幼儿园里看的有个书叫新龟兔赛跑,我一看这个新龟兔赛跑,来看看是怎么回事,我一看这种书不能让小孩看的,它讲这个新龟兔赛跑怎么跑呢,就是比赛之前,乌龟要他弟弟埋伏在那个终点,等那个兔子快跑到了,他弟弟出来了,乌龟长的样子都差不多,他也不认得哪个是哥哥哪个是弟弟,就说哎呀,你都先到了我输了,这种是不对的,这是教小孩偷*耍滑啊。咱们是要以诚信为本。诚信为本这样子才行。

Friday, January 8, 2010

Thursday, January 7, 2010

Popbox CNET review....

Popbox launch at CES Unveiled on Jan. 5th





Related Link:
http://www.engadget.com/2010/01/05/syabas-popbox-hands-on

http://www.engadget.com/2010/01/04/popbox-is-popcorn-hour-evolved-with-1080p-streaming-and-netflix

http://www.gizmodo.com.au/2010/01/syabas-popbox-media-streamer-looks-great/