Gzip decompression within Flex

Hello everybody,
I want to decode the Xml data with Gzip encoding from the server. With Google I only find examples of Gzip encoding for the AIR runtime.
Have anybody experience how to use Gzip decompression for server data in Flex?
I would be grateful for any advice.
Thanks a lot, Thomas

ByteArray.uncompress() might help some.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui

Similar Messages

  • SWFloader loads SWF movie within Flex but not when compiled

    When I run my app in Flex, SWFLoader loads the SWF okay as a movie clip but as soon as I Export/Release Build, the new app SWF that is generated won't show the movie clip anymore.  If I take another SWF that is an app (not a movie clip) and give it the movie swf name, my compiled app will show the sub app in a frame.  Why would running something within Flex be any different than running a compiled version?
    Here is some of the code:
    button1 loads the swf.
    button2 loads a sound and when the sound is loaded, the sound is played and the swf is played in onSoundLoaded();
    public  function onSoundLoaded(event:Event):void{
    var localSound:Sound = event.target as Sound;localSound.play();
    var clip:MovieClip = MovieClip(swflodr.content);
    clip.play();
    private  
    function button1Handler(event:Event):void {Alert.show("test 1");swflodr.load(
    "dog.swf");Alert.show(
    "test 2");}
    private  
    function button2Handler(event:Event):void
    var s:Sound = new
    Sound();s.addEventListener(Event.COMPLETE, onSoundLoaded);
    var  
    req:URLRequest = new URLRequest("test.mp3");
    s.load(req);
     private function SwfLodrEventHandler(event:Event):void { 
    var clip:MovieClip = MovieClip(swflodr.content);clip.gotoAndStop(1);
    Alert.show(
    "The event loader is ready");}
    thanks, Mike

    Maybe timing?  The child SWF may not be fully loaded.  Sounds and SWFs are asynchronously loaded.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Different Behaviour within Flex and on Browser

    Hi,
    I am using an XMLsocket in my problem (client and server on
    the same machine).
    As server I have modified slightly the java example from the
    help (server on port 5050).
    When I run my program within Flex (run button), program is
    run, it connects and accepts
    data from the server. When I try to run the program outside
    flex (run the html in the browser),
    then no connection seems to be made to the java program.
    Are any settings of the browser (firefox) configured
    differently when running through Flex?
    server part:
    socket = new ServerSocket(port);
    incoming = socket.accept();
    readerIn = new BufferedReader(new
    InputStreamReader(incoming.getInputStream()));
    // open up standard input
    BufferedReader br = new BufferedReader(new
    InputStreamReader(System.in));
    printOut = new PrintStream(incoming.getOutputStream());
    printOut.println("Enter EXIT to exit.\r\0");
    out("Enter EXIT to exit.\r");
    boolean done = false;
    while (!done)
    //String str = readerIn.readLine();
    String str = br.readLine();
    out("Echo: " + str);
    if(str.trim().equals("EXIT"))
    done = true;
    ====================================
    when run outside flex, surprisingly I can see the:
    "Enter EXIT to exit" on the screen but whenever i type
    something
    it does not appear on the Flex client. This works as it is
    supposed to,
    when executing within Flex...
    thanks

    When you say run from the browser.. is the request served by
    a web server?
    You may be running into crossdomain issues in the 2nd case. I
    would suggest that you print the input stream data from the XML
    Socket to see if its sending a request for crossdomain.xml? If that
    is the case, you should first send the response with the policy
    file back so that subsequent calls succeed.
    Thanks,
    Gaurav Jain
    Flex SDK Team

  • How to render a pdf file within flex

    Hi,
    could any one suggest, how to open a pdf file within flex.
    we have an application built on flex3.
    please suggest.
    regards,
    John

    Hi,
    Is it a Flash or AIR app?
    If it's an AIR app, then use the HTML/web, where you then can navigate to the URL of your PDF.
    If it's an Flash app, then set the wmode to transparent: http://kb2.adobe.com/cps/127/tn_12701.html#main_Using_Window_Mode__wmode__values_
    And then create an iframe in your HTML page, where you load you PDF, set the iframe z-index, so it gets shown on top of the Flash object. Then you kan use the javascript bridge to interact with the iframe.
    Best regards
    Martin

  • DropDownList ItemRenderer within Flex Datagrid Not Refreshing

    I have a datagrid which contains a Spark dropdownlist that needs to  obtain dynamic data.
    The datagrid uses a separate dataProvider.
    When I use a static ArrayCollection within my ItemRenderer, it works (please see listing 1).
    However, when I use Swiz to mediate a 'list complete' event to load  the ArrayCollection, the dropdownlist does not show the new data (please  see listing 2).
    Using the debugger, I inspected the dropdownlist ItemRenderer and  have confirmed the new data is being loaded into the ArrayCollection.
    The new data is not shown in the UI control. I have tried  invalidateProperties() + validateNow() and dispatching events on both  the control and the renderer (this), but nothing seems to make the new  data appear in the control on the datagrid.
    Please help !!!
    Listing 1: Datagrid and static ArrayCollection (this works)
    <mx:DataGrid x="10" y="25" width="98%" id="dgInventory" paddingLeft="25" paddingRight="25" paddingTop="25" paddingBottom="25"
                         editable="true"
                         itemClick="dgInventory_itemClickHandler(event)" dataProvider="{acInventory}"
                         creationComplete="dgInventory_creationCompleteHandler(event)"
                         height="580">
                <mx:columns>
                    <mx:DataGridColumn headerText="Item" dataField="itemName" itemRenderer="components.ItemRendererItem"
                                       rendererIsEditor="true" editorDataField="selection" editable="true"/>
                    <mx:DataGridColumn headerText="Quantity Required" dataField="quantityReq" itemRenderer="components.ItemRendererQuantityRequired"
                                       rendererIsEditor="true" editorDataField="selection" editable="true"/>
                </mx:columns>
    </mx:DataGrid>
    <fx:Script>
        <![CDATA[      
            import mx.collections.ArrayCollection;
            import spark.events.IndexChangeEvent;
            public var selection:int;
            [Bindable]
            protected var acItem:ArrayCollection = new ArrayCollection(
                [   { itemName: "Item1"},
                    { itemName: "Item2"},
                    { itemName: "Item3"},
            protected function dropdownlist1_changeHandler(e:IndexChangeEvent):void
                selection = e.newIndex;
        ]]>
    </fx:Script>
    <s:DropDownList id="ddlItem" prompt="Select Item" dataProvider="{acItem}" labelField="itemName"
                    selectedIndex="{int(dataGridListData.label)}"
                    change="dropdownlist1_changeHandler(event)"
                    width="80%" top="5" bottom="5" left="5" right="5"/>
    Listing 2: Dynamic ArrayCollection (does not work):
    <?xml version="1.0" encoding="utf-8"?>
    <s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                              xmlns:s="library://ns.adobe.com/flex/spark"
                              xmlns:mx="library://ns.adobe.com/flex/mx"
                              focusEnabled="true">
        <fx:Script>
            <![CDATA[      
                import event.ItemEvent;
                import mx.collections.ArrayCollection;
                import mx.events.FlexEvent;
                import spark.events.IndexChangeEvent;
                public var selection:int;
                [Bindable]
                protected var acItem:ArrayCollection = new ArrayCollection();
                protected function dropdownlist1_changeHandler(e:IndexChangeEvent):void
                    selection = e.newIndex;
                protected function ddlItem_creationCompleteHandler(event:FlexEvent):void
                    var eve : ItemEvent = new ItemEvent( ItemEvent.LIST_ITEM_REQUESTED );
                    dispatchEvent( eve );
                [Mediate( event="ItemEvent.LIST_ITEM_COMPLETE", properties="acItem" )]
                public function refreshness( _acItem : ArrayCollection ):void
                    acItem.removeAll();
                    var len:int = _acItem.length;
                    if (len > 0)
                        for (var i:int=0; i < len; i++)
                            var newItem:Object = new Object;
                            newItem["itemName"] = _acItem[i].itemName;
                            acItem.addItem(newItem);
                    this.invalidateProperties();
                    this.validateNow();
                    //dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
            ]]>
        </fx:Script>
        <s:DropDownList id="ddlItem" prompt="Select Item" dataProvider="{acItem}" labelField="itemName"
                        selectedIndex="{int(dataGridListData.label)}"
                        creationComplete="ddlItem_creationCompleteHandler(event)"
                        change="dropdownlist1_changeHandler(event)"
                        width="80%" top="5" bottom="5" left="5" right="5"/>
    </s:MXDataGridItemRenderer>

    After re-reading Peter Ent's ItemRenderer series, this turned out to be quite simple.
    I extended DataGrid to have the ArrayCollection property I needed, then added this to my renderer:
    [Bindable]
                protected var acItem:ArrayCollection = new ArrayCollection();
                override public function set data( value:Object ) : void
                    super.data = value;
                    acItem = (listData.owner as MyDataGrid).itemList; // get the data from the renderer's container (by extending it to add a property, if necessary)

  • GZIP decompression of chunked data?

    I'm trying to decompress a chunked stream of GZIP compressed data, but I don't know how to solve this without major inefficient workarounds.
    The data is coming from a web server, and is sent chunked. This means that before each chunk, the size of the chunk is announced in plain-text, or 0 to terminate.
    Simply wrapping the socket stream with the GZIPInputStream, like in the examples, only works if the stream is entirely GZIP, but this is not the case here.
    I have to repeatedly do a readLine on the input stream to get the length of the chunk, and then I need to send that amount of bytes from the input stream to the GZIP decompressor. I'm stuck here as I don't know a way to 'send' selected bytes to the decompressor. I only know how to create the decompressor by wrapping an existing input stream, and simply by creating said decompressor it consumes bytes from the input stream to verify if it is a GZIP compressed stream.
    The only thing I can come up with is to store the entire compressed data in a huge String, wrap it in a custom-made InputStream subclass that streams bytes from my String, and wrap that in the decompressor. Is this really the only way?
    For example, a webpage like this sends it's data chunked and GZIP-compressed: http://www.anidb.net
    Edited by: 834306 on Feb 6, 2011 11:16 AM
    Edited by: 834306 on Feb 7, 2011 4:54 AM

    Thanks for your responses.
    I indeed thought I had to de-chunk manually. I'm fairly new to all this networking stuff. I've never even heard of a HttpURLConnection.
    What I did before was opening a Socket, sending the manually-constructed request header and then receiving and manually decoding the http header. Something like this (shortened for readability)
    socket = new Socket(url.getHost(), port);
    dataOutputStream = new DataOutputStream(socket.getOutputStream());
    inputStream = new BufferedInputStream(socket.getInputStream());
    String message = "GET " + url.getFile() + " HTTP/1.1" + //
              "\nHost: " + url.getHost() + "" + //
              "\nUser-Agent: Mozilla/1.2 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.13)" + //
              "\nAccept: text/html,application/xml" + //
              "\nAccept-Language: en-us,en;q=0.5" + //
              "\nAccept-Charset: ISO-8859-1" + //
              "\nConnection: close\n\n");
    dataOutputStream.write(message.getBytes());
    <here a lot of code to decode the header and put the field-value pairs in a HashMap>
    <here a lot of code to receive the body of the message, while taking into account the reported content-length and chunking, as well as sending updates to a ProgressListener>I tried HttpURLConnection and indeed it seems a lot easier than the way I did things. However, what I receive from the HttpURLConnection is de-chunked but still GZIP compressed. So it is not completely transparent as I hoped. I wrapped in a decoder and it works.
    Here's what I have now:
    HttpURLConnection connection = null;
    try
         connection = (HttpURLConnection)url.openConnection();
         connection.addRequestProperty("Host", url.getHost());
         connection.addRequestProperty("User-Agent", "Mozilla/1.2 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.13)");
         connection.addRequestProperty("Accept", "text/html,application/xml");
         connection.addRequestProperty("Accept-Language", "en-us,en;q=0.5");
         connection.addRequestProperty("Accept-Charset", "ISO-8859-1");
         connection.addRequestProperty("Connection", "close");
         connection.setUseCaches(false);
         connection.setDoInput(true);
         InputStream inp = connection.getInputStream();
         if (connection.getHeaderField("Content-Encoding").equals("gzip"))
              inp = new GZIPInputStream(inp);
         int i;
         while ((i = inp.read()) != -1)
              logout.write(i);
         connection.disconnect();
    catch (IOException e)
         if (connection != null) connection.disconnect();
    }Thanks a bunch.
    Edited by: 834306 on Feb 7, 2011 5:01 AM

  • Objects Overlay within Flex (foreground/background)

    Hello,
    I am new to flex programming so please forgive me if this
    question is out of place, newbish or just plain stupid.
    Within my flex application, I want to change to a veiw, and
    in that view I want to expand a panel, so that it fills the
    majority of the application size.
    The problem is when I resize this panel in the view, most
    other objects in my application show over it, i.e. the panel itself
    is not at the front of the foreground.
    So my question is, how can I send the form object to the
    front of hte object layers, is this possible at all?
    Thanks in advance,
    Matt.

    Only Canvas (or Application or panel with layout='absolute')
    allow children to overlap.
    The simplest way to control ghis is the order in which the
    children are rendered: the latest goes on top.
    You might also look at the swapChildren() method of some
    containers.
    Tracy

  • Providing application-level help within Flex apps

    What is the general guideline / approach for help (not
    embedded or field-level help but page level or application level
    help like you get when you click Help in most applications) within
    a Flex app? Is it to spawn a new Window that goes to standard
    HTML-based help engines/content or to display the content in a
    dialog within the Flex application itself? Thanks

    Slow down! Found it here:
    http://raghunathraoflexing.blogspot.com/2006/12/flex-i-frame.html

  • Within Flex Debugging with Ruby on Rails?

    Hello guys
    I want to debug within adobe flex builder like we do in normal projects !
    I installed a local ruby on rails server, Now how could i connect/debug dynamically?
    Thanks a lot

    ok

  • Are parallel stages possible within Flex applications?

    Hello,
    I'm interested in exploring Flex, but I don't want to spend
    unnecessary time on it. I'm wondering if it is possible to have
    multiple "layers" (say a foreground, mid-ground, and background)
    within a Flex application. In my particular case, I'd like to have
    some type of animated Flash running in the "background" of the
    application that is always visible. However, when the user
    interacts with this application, is it possible to make visible
    Flex components that exist in the "foreground" or "mid-ground"
    appear "above" it? Or, to say, they come become visible in front of
    the "background layer" when the user clicks a button (i.e. a user
    clicks a button in the flash movie and a Flex form, perhaps for a
    login or something, appears before them in the "foreground").
    As a newbie to Flex I'll appreciate any help.
    -Thanks!

    Sure you could use states to show or hide controls in a view,
    you can use viewstacks to switch between views and you can set
    transparency using the alpha property.

  • Problem in loading swf within Flex 1.5

    Hi all,
    I'm working with a flex project.The logo of that project is a
    spinning wheel created with flash tweens. I ve loaded that swf file
    into Flex using a Loader component. But despite of whatever
    framerate i ve specified, the wheel spins in a constant speed,
    which is a little bit slower than the expected speed of the wheel.
    Is there any option in flex to increase the framerate, or is there
    any other way to do this. Pls.help.

    And this for 1.5:
    "In Flex or Flash, a loaded SWF takes on the FrameRate of the
    parent SWF. In flex you can set the framerate value for the main
    application with "framerate" attribute in the
    <mx:Application> tag."
    Tracy

  • HTML within Flex?

    I need to develop an application that includes web pages from
    many other sources. With native html, you can just use frames, etc.
    Is it possible include a "frame" to other web applications using
    flex?
    Thanks
    Duke

    The answer is Yes if you are developing a Flex 3 application
    to run on AIR, the Adobe Integrated Runtime. AIR includes a full
    HTML renderer. But the answer is No if you are developing a Flex 2
    or Flex 3 application to run on the Flash Player in a browser. The
    Flash Player can only render a very small subset of HTML.
    Unfortunately, including a full HTML renderer in the Flash Player
    would hugely increase its size.

  • Google Maps from within Flex.

    I'm totally new to Flex and have jumped right in at the deep end...
    I'm working on an app for gig lovers.
    Basically you choose your favorite genres of music with check boxes, then put your postcode in and it will tell you the nearest gigs to you and give you details of each one.
    On the right hand side of the app though I would like the app to access google maps somehow and give you a map to the gig.
    Also, it will (probably) need to access google maps in order to assess which gigs are near you.
    Could anyone give me any hints on how to do this?Or just tell me that it can't be done lol.
    Cheers

    Cool.
    Thanks.
    Would it be cheeky if I asked someone to possibly write me a simple walkthrough for building something like this?
    Like I say, I'm very new to the world of Flex

  • JavaScript, Gzip Compression/Decompression, Ajax calls

    Does either the Java Agent or Thin Client execute JavaScript when playing back in eLoad?
    Is there a way to configure it to do so? If I recall neither do, but would like confirmation.
    What about measuring gzip decompression on each page? Will either agent decompress and measure it? or at least execute it?
    What about ajax calls? Would running the Java Agent give us an idea of the performance of the page where lots of ajax calls are being made?

    jimbilly
    1) JavaScript is not executed during a load test by either the Thin Client or the Java Agent, and can not be configured to do so.
    2) I'm not sure if either client will decompress a GZip file, however i don't think it would be very difficult to do so using the JavaAgent and writing the time to a file, i don't see any advantage in doing so as every client machine will have different processing power, so the timings will be very different from the once that you will log.
    3) All the ajax calls will be recorded and played like normal navigation's, just make sure that you have the proxy on during the recording.
    if you need some help doing step 2 please let me know.
    Alex

  • Adobe Air needs HTTP gzip compression

    Hello
    We are developing an Adibe Air application. We use SOAP for
    service calls and we depend entirely upon gzip HTTP compression to
    make the network performance even vaguely acceptable. SOAP is such
    a fat format that it really needs gzip compression to get the
    responses down to a reasonable size to pass over the Internet.
    Adobe Air does not currently support HTTP gzip compression
    and I would like to request that this feature be added ASAP. We
    can't release our application until it can get reasonable network
    performance through HTTP gzip compression.
    Thanks
    Andrew

    Hi blahxxxx,
    Sorry for the slow reply -- I wanted to take some time to try
    this out rather than give an incomplete response.
    It's not built into AIR, but if you're using
    Flex/ActionScript for your application you can use a gzip library
    to decompress a gzipped SOAP response (or any other gzipped
    response from a server -- it doesn't have to be SOAP). Danny
    Patterson gives an example of how to do that here:
    http://blog.dannypatterson.com/?p=133
    I've been prototyping a way to make a subclass of the Flex
    WebService class that has this built in, so if I can get that
    working it would be as easy as using the Flex WebService component.
    I did some tests of this technique, just to see for myself if
    the bandwidth savings is worth the additional processing overhead
    of decompressing the gzip data. (The good news is that the
    decompression part is built into AIR -- just not the specific gzip
    format -- so the most processor-intensive part of the gzip
    decompression happens in native code.)
    Here is what I found:
    I tested this using the
    http://validator.nu/ HTML validator
    web service to validate the HTML source of
    http://www.google.com/. This
    isn't a SOAP web service, but it does deliver an XML response
    that's fairly large, so it's similar to SOAP.
    The size of the payload (the actual HTTP response body) was
    5321 bytes compressed, 45487 bytes uncompressed. I ran ten trials
    of each variant. All of this was done in my home, where I have a
    max 6Mbit DSL connection. In the uncompressed case I measured the
    time starting immediately after sending the HTTP request and ending
    as soon as the response was received. In the compressed case I
    started the time immediately after sending the HTTP request and
    ended it after receiving the response, decompressing it and
    assigning the compressed content to a ByteArray (so the compressed
    case times include decompression, not just download). The average
    times for ten trials were:
    Uncompressed (text) response: 1878.6 ms
    Compressed (gzip) response: 983.1
    Obviously these will vary a lot depending on the payload
    size, the structure of the compressed data, the speed of the
    network, the speed of the computer, etc. But in this particular
    case there's obviously a benefit to using gzipped data.
    I'll probably write up the test I ran, including the source,
    and post it on my blog. I'll post another reply here once I've done
    that.

Maybe you are looking for