AS3 Wapper Class

Roman Klis
2008-03-03
2013-05-28
  • Roman Klis
    Roman Klis
    2008-03-03

    Hi there !

    First off all I want to congratulate you on this great project. Personally I think It has great potential - even to take out Adobe Flex Data Charts. Have you seen them? In my opinion they are very similar to these form you project, but it is a different story.

    Going straight to the point -  I managed to write very simple "wapper class" for open-flash-charts for as3.

    It consists of one main file in root folder of src (ChartExample.mxml), and one in component (OpenFlashChart.mxml) in package org.openflashchart. In this component you should edit render function in order to get chart you want.
    So how does it work? Pretty simple, in component openflashchart.mxml, in function render() user defines how to chart will look like by defining URLVariables. Data are to the component by public fields "datas", and corresponding to values labels are kept in "labels". Please keep in mind that if you want to have different type of data / more data series displayed on the chart you should implement it on your own hand - it should be quite simple. I have also included ripped help from php wapper file in the openflashchart.mxml extanded by some unchecked examples - I hope they will be helpful.

    Keep in mind that in as3 there are some problems with refresing content of SWFLoader object ( it is used to store open-flash-chart.swf), so on each render whole object is dropped and loaded again. I know that it is not a proper approach but it works. Also there are some problems with resizing component (not exactly 100% width/height).

    I believe it is possible to add animations to those charts by calculating positions of data series frame by frame. Example : Lets say we want to have a series of data ([1,4],[2,2],[3,7], where [x,y]) floating into correct position from bottom of the panel. We can do it by "rendering" lets say 100 times frame by frame, so into open-flash-charts we would pass :

    render iteration........... positions
    1                                   [1,0.04];[2,0.02];[3,0.07]
    2                                   [1,0.08];[2,0.04];[3,0.14]
    3                                   [1,0.12];[2,0.08];[3,0.21]
    4                                   ....
    ...
    100                              [1,4],[2,2],[3,7]

    This would be a linear animation, but if it is possible to create this kind of animation, why not other?

    Best regards
    Roman Klis

    PS. I include source code on the rapidshare :

    http://rapidshare.com/files/96664736/ChartExample.rar.html

     
    • monk.e.boy
      monk.e.boy
      2008-03-03

      So open-flash-chart.swf is embeded inside your wrapper object?

      This is not allowed because of the GPL (I am going to move to the LGPL to overcome this 'bug' :-) )

      But this is an interesting project. I am currently moving all the code from as2 to flex+as3 would this help any?

      monk.e.boy

       
    • Roman Klis
      Roman Klis
      2008-03-03

            So open-flash-chart.swf is embeded inside your wrapper object?
            This is not allowed because of the GPL (I am going to move to the LGPL to overcome this 'bug' :-) )
            But this is an interesting project. I am currently moving all the code from as2 to flex+as3 would this help any?
            monk.e.boy

      Nope, open-flash-chart is not embeded inside my wapper class (not 100% sure, maybe SWFLoader embeedes this object). My "wapper class" uses it same way as php server side but thanks to as3 I can use it on a client side from my AS3 class. Same mechanism is used by JS on a web site to generate a chart, but in that case user have to dl once again whole open-flash-chart object with passed to it new data. I only pass it form client application - this is only difference.

      I think this would help both there are some prones of using flash 8 - it is much faster (especially in graphic) then flash9 (at least I read so on the Internet - correct me if Im wronge).

      Roman Klis

       
    • monk.e.boy
      monk.e.boy
      2008-03-06

      Apparently the next version of flash will use your graphics card to display all the layers - so it should be very quick.

      If you are using a flash movie to download the chart and display it rather like the HTML page does it then this is fine. I am not going to sue you or anything - it is a simple bug in the license I initially chose (before I understood them :-)

      So the next version will be more permissive so you can use the charts in all sorts of ways :-)

      cheers dude!!

      monk.e.boy