Posts tagged tips

งึนๆ งงๆ เวลาใช้ Flash Builder 4 หรอ? Help content ช่วยได้!

สำหรับหน้าใสๆ ใหม่ๆ ที่สนใจโหลด Adobe Flash Builder 4 มาลองเล่น หรือแม้แต่หน้าเก่าๆ (อย่างผมก็คนหนึ่งแหละ) บางทีอาจจะรู้สึกมึนๆ งงๆ ใช้ไปสักพัก อยากจะหาอะไรมาทาถู ทาถู ยาหม่องตราน้องเกิ้ล ก็สรรพคุณหลากหลาย ต้องมานั่งจับผิดจับถูกกันเอง ผมก็มี tips เล็กๆ น้อยๆ มาฝากกันครับ ไว้แก้มึน

นั่นก็คือ Adobe เขาก็เตรียมพร้อมเหมือนกับพวก .NET และ Java แหละครับ โดยแทนที่จะปล่อยให้นักพัฒนาไปค้นหาตามน้องเกิ้ล เขาก็ทำการ release เอกสารอ้างอิงโดยละเอียด พร้อมตัวอย่างและวิธีใช้ Flash Builder และการทำงานกับ Flex SDK มาให้ในตัว Flash Builder 4 เลย  วิธีการเข้าไปอ่านมีดังนี้ครับ ง่ายกว่าที่คิดซะอีก

ตามมาด้านในเลยครับ More >

What lie beneath “useWeakReference”


I just read the most surprise secret of addEventListener workflow, wrote by Ted. He explained the process if we have use the default value of ‘useWeakReference’ ( fault by default ). The garbage collector will not remove its in almost situation. This result can be raise more unexpected performance for our application.

In the other hand, if we set this argument with ‘true’ value, the garbage collector will found its, then remove it as fast as it’s possible (this will not break common rule of object-oriented programming language)

You can read more about Ted’s exposing here.

ความจริงที่น่าตกใจก็คือ เมื่อใดก็ตามที่พวกเรา ได้ทำการ addEventListener แล้วไม่ได้ set ค่าอะไรให้กับ argument ที่ชื่อ useWeakReference (ซึ่งค่า default ของมันคือ false) นั่นหมายความว่า instance ของ object ที่เรานำมา subscribe หรือในอีกทางหนึ่ง เรียกว่า การนำ functionของ instance นั้นมา เป็น listener นั่นเอง ดังตัวอย่างด้านล่าง

   1:  this.addEventListener( Event.EventName, foo.fooFunction );

อย่างนี้ล่ะครับที่จะมีการ garbage collect ใดๆ ทั้งสิ้น แต่ถ้าหากเราเปลี่ยนเป็น

   1:  this.addEventListener( Event.EventName, foo.fooFunction , true );


อย่างนี้ล่ะครับนาย garbage collector จะเฝ้ามอง reference ของ foo จากมุมมืด มีโอกาสเมื่อไหร่จัดการทันที