Ferry's profile《豺狼的詩篇》BlogLists Tools Help

Blog


    6/7/2007

    another flash editor

    flash develop <- 我覺得非常好用, 比 eclipse + asdt 好像還要 powerful 很多.

    最重要的是,它連 haXe 及 AS3 都照顧到.

    url: http://www.flashdevelop.org/community/
    11/6/2006

    AS3 & Flex 2 API Poster PDF

    Lets see my desktop... xD Yeah!

    Both poster PDF can be downloaded from Flex 2 official site.

    ActionScript 3 Class Diagram

    Flex 2 Framework Diagram
    10/19/2006

    About AS3 Network Media File I/O & Keyboard Events

    Just a little summary of my study in AS3 of these few nights:

    To load certain file types in AS3, you need different ways.

    MP3 - flash.media.Sound
        loaded into a sound object, create an soundchannel object for playback control

    FLV - flash.media.Video
        create video object and call attachCamera for getting stream from camera
        or attachNetStream to stream a FLV

    File Upload to server / Download to PC (not flash) - flash.net.FileReference
        as stated, the actual file will be created at specified location

    Plain text / URL-encoded variables (GET) / binary / XML / text files - flash.net.URLLoader
        need to access the event object that pass into the complete event
        also need to specify URLLoader.dataFormat for getting correct data
        for XML, parse by new XML(event.target.data).
        for name-value pairs variables, new URLVariables(event.target.data)
        then access the variable by URLVariables.<your variable name>
        for plain text, set URLLoader.dataFormat to TEXT and event.target.data is a string.

    SWF / JPG / PNG / GIF - flash.display.Loader
        load into a container display object

    Sometimes you want your AS3 Flash application to be interactive with keyboard.
    You can make any object that is instaniated by subclass of displayObject to listen key press
    events by <object>.addEventListener(KeyboardEvent.KEY_DOWN, <handler function name>)
    (use KeyboardEvent.KEY_UP to detect key release events)

    Inside your handler function, just make a switch case to catch key press/release by
    KeyboardEvent.getKeyCode() / getCharCode()
    for example, if you want to know whether "A" key has pressed,
    switch (String.fromCharCode(event.getCharCode()))
    {
        case A: //do something
    }

    10/11/2006

    ASDoc

    Just notify meyself to take a look on ASDoc.
    http://labs.adobe.com/wiki/index.php/ASDoc
    And about servlet.
    http://www.coreservlets.com/Apache-Tomcat-Tutorial/
    http://www.iti.cs.tu-bs.de/doc/JSDK2.0/doc/servlet_tutorial.html
    http://www.novocode.com/doc/servlet-essentials/chapter3.html
    http://jakarta.apache.org/
    http://tomcat.apache.org/download-55.cgi

    9/4/2006

    Interview with Mike Melanson, lead engineer on the Linux Flash Player team

     
    Comparing with Sun / M$ operating systems that provide only a stable and
    standard APIs for 3rd parties application vendor to develop software that
    can run on those OS, porting a software to open source OS is rather difficult
    because of the choice on several available APIs and the differences among
    different versions of the OS itself. This interview reveals the problems
    encountered in porting Adobe Flash Player 9 to Linux.
    8/7/2006

    AS3 無聊試作型一號與二號


    MSN Space upload 唔到 file,所以冇得放俾大家玩下。 =_=:
    8/4/2006

    Constant random numbers?

    The following random numbers were generated by my .swf file at different time.
    Each row consist of 20 numbers, and I have ran the same .swf file for 30 times.
    Each number was generated by Math.floor(360*Math.random()); which should lies in range 0 to 359.
    Whats wrong with the Math.random()?

    312 265 167 286 113 116 204 74 88 210 296 28 15 297 315 216 298 251 354 313
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    205 96 170 169 277 128 250 71 320 202 287 355 84 212 298 257 45 142 196 71
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    312 265 167 286 113 116 204 74 88 210 296 28 15 297 315 216 298 251 354 313
    312 265 167 286 113 116 204 74 88 210 296 28 15 297 315 216 298 251 354 313
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    205 96 170 169 277 128 250 71 320 202 287 355 84 212 298 257 45 142 196 71
    312 265 167 286 113 116 204 74 88 210 296 28 15 297 315 216 298 251 354 313
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    292 181 262 44 348 101 351 198 55 134 126 223 75 55 81 236 286 246 202 54
    312 265 167 286 113 116 204 74 88 210 296 28 15 297 315 216 298 251 354 313
    8/1/2006

    Adobe... Plz don't fooling around!

    There is a sentence in a promotion email which I had received from Adobe today:
    "Go beyond Ajax by adding richer visual functionality to your web applications."

    It is still acceptable for who are using the FREE Flex SDK to develop RIAs.
    What about the companies who paid thousands of USD to buy Flex 1.5 for just
    ADDING VISUAL FUNCTIONALITY to their web applications?!

    If thats really the fact of why Flex / Flash exist. Ajax has gone far beyond Flex already.
    When we talk about better user experience in using web applications, it usually refers to
    usability, accessibility, etc. We are not simply talking about fancy / eye catching things.
    If your marketing people do not even understand what RIA is, it is totally a shame for Adobe.
    7/30/2006

    AS3 Performance Tips

    Here is the summary from what I have read:
    1. Promotion of Numeric Types:
      a[int(i+1)] is faster then a[i+1]
      - its because i in a[i+1] may infer and promote to type Number (64 bits) even you declare i as int / uint (32 bits).

    2. Manual Common Subexpression Elimination:
      avoid direct use of .length in loops.
      - its because the .length properties of some classes may overrided by other objects and having side effects if use them directly in loop.
      - declare an int to hold the value of .length to ensure its an int throughtout the loop process.
      e.g. var count:int = arr.length;
      for(var i:int = 0; i < count; i++){ ... }

    3. Method Closures:
      avoid the use of anonymous function closures
      - anonymous function closures requires an activation object for outer function, which leads to performance and memory impact.
      e.g.
      using this...

      class A {
      function B { c.addEventListener("click",f); }
      fcuntion f { ... } }

      instead of...

      class A {
      function B {
      var f = function(...){...};
      c.addEventListener("click",f); } }
    For in-depth information of performance issue and complier operation, please read:
    ActionScript 3.0 and AVM2: Performance Tuning - Gary Grossman

    AS3 Garbage Collection

    After viewing the great article of resource management of AS3 by Grant Skinner . I got many inspiration about the underlying operation about resource management (CPU usage, memory allocation) in AS3.

    At a first glance it seems something fresh and hard, but as I'm one of the VERY FEW Flash developer that comes from Software Engineering field and playing with traditional language like C++ / Java for a long period of time, its just something no big deal! (You know, most of the Flash designer or even Flash developer were comes from Art / Music / Language / Translate / Psychology / Philosophy / etc, they may scream and panic when they have to learn how to deal with GC in AS3 lol).

    Enough joking, time to learn:
    - RC = Reference Counting
    - MS = Mark Sweeping
    - GC = Garbage Collection / Garbage Collector
    - DO = Display Object (MovieClip, Sprite, Screen, etc)
    - DO treat like all other object type in AS3 (except primitives)
    - AVM2 GC: 2 approaches goes together -> RC & MS
    - DO no longer DEAD for GC even they were removed from Display List (Stage).
    - Reference count may never down to ZERO due to circular object referencing.
    - Keyword delete or nullifity all active reference of an object don't actually KILL it due to unpredictable timing for memory sweep of GC.
    - Currently not possible to explicitly removeSWF and its content which is dynamically loaded from external sources. They are still waits in memory after you call Loader.unload until GC.
    - Due to the reasons above, even you have (looks like) KILLED an object by traditional approach, they are still reside in your valuable memory (although you have no way to access it again) until GC sweep and wash the memory. (which you never know when.) a.k.a Deferred GC

    So... what?
    Code inside those objects may still running! (although you don't want to).
    There have chances that code will run forever as an object never cleaned up.
    Resources will be released once user closed the application, but what if your program eaten up all resources of user machine just because of memory leak from the flaw of your code? (Imagine your DEAD object's enterFrame event continue to fire once the playhead move and making new instance of itself. Its really scary like an undead legion or bacteria.)

    What should I do?
    - Be very careful in resource management when dealing with AS3.
    - Try to having a habit to write destructor for your class to do object clean-up code and call it when you want to kill your object baby.
    - Remember to unregister event listener which you no longer needed.
    - Remember to unregister all event listener for your object before you delete it / remove it from Display List and null all active reference to it.
    - Try to avoid circular object referencing to increase the GC efficiency by RC approach. (although its not very practical)

    For detailed information please take a look to the great article by Grant Skinner:
    AS3 Resource Management Pt1

    7/29/2006

    AJAX 與 Flash 最後會否共融?

    quote from luar's flash playground: 大半年後,我們應該感謝Ajax

    不知道是當年 Macromedia 的問題還是 Adobe 的問題,
    Flash 這個 RIA 概念的始祖,到頭來現在竟被 AJAX 牽著鼻子走?
    要是 Adobe 到現在還沒有把 Flex SDK 免費的覺悟,
    可能一兩年後 Flash 就會被淘汰...
    至於AJAX,雖然大家同是 RIA 技術,
    即使感謝它為我們帶來免費的Flex SDK,
    對Flash Developer 來說我想總會有條刺吧。