2
votes

I have one OpenLaszlo/AS3 App (olapp.lzx) and one Flex App (flexapp.swc). I want to include flexapp.swc in olapp.lzx as follows:

olapp.lzx (AS3):
===============
...
var flexapp:Sprite = new FlexApp();
flexapp.doSomething();
...

The flexapp.swc is compiled from this mxml:

flexapp.mxml:
============
<?xml version="1.0"?>
<!-- intro/FlexApp.mxml -->
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">
    <mx:ComboBox>
        <mx:dataProvider>
            <s:ArrayList>
                <fx:String>AK</fx:String>
                <fx:String>AL</fx:String>
                <!-- Add all other states. -->
            </s:ArrayList>
        </mx:dataProvider>
    </mx:ComboBox>
</mx:Application>

When I compile flexapp.mxml to swf, it runs nicely, but instantiation from AS3 fails (TypeError: Error #2007). I researched that mxml->as3 integration is not the usual way to go, but for this particular case I need to. I have to admit that I'm not yet too familiar with Flex, only OpenLaszlo. What should be changed in flexapp.mxml? Thanks!

1
A SWC is an ActionScript library; not a runnable App.... I've never heard of anyone trying to add an Application tag into a SWC; but I suppose it should be technically possibly. I suspect--but am not sure--that the MXMLC compiler does some magic when creating a SWF based on the Application tag that allows the app to actually run. Such steps may not exist when creating a SWC. If I were you I'd look into create a SWF from your Flex code and then loading it at runtime from your OpenLaszlo app. - JeffryHouser
I could not manage to include swf files in OpenLaszlo for some reason, but will try on another occasion. But I was able to include a swc created from a pure .as code, which does nothing else than extending Sprite and draws some circles in it. When I inherit from UIComponent instead of Sprite, it does not show any graphics anymore, although there is also no error message anymore. Could it be that Flex components in general can not be finalized without mxml and thus not included in OpenLaszlo? - Horst P
OpenLaszlo deploys to many platforms, the Flash Player just being one of them, correct? You should be able to load a SWF at runtime in the Flash Player using a loader object livedocs.adobe.com/flex/3/html/… . I have no idea how that fits into OpenLaszlo, though. The reason your Flex SWC isn't working is most likely because the Flex Framework is not being initialized [I believe I addressed that in my original comment] - JeffryHouser
Ok, I tried the way you suggest by loading a runnable .swf. I used the Example from the Documentation link, and it worked nicely. But not for those .swf files I have compiled out of mxml. Maybe I've compiled them wrongly, since I don't have an IDE. I'll check that. - Horst P
I've now got access to an improved OpenLaszlo installation with newest Flex inside. Using this I was able to load a big SWF MXML/Flex App into an OL window. This even worked for both, Flash 10 and 11. I don't know why it didn't work with 4.9.0. Unfortunately, the OL window seems to block certain mouse drag events from the App, although 90% of all other mouse actions work. When I use a simple view instead of window, all mouse actions are deactivated. But I will investigate this issue next. So after all, your hint for Loader and SWF helped me. Thank you! - Horst P

1 Answers

0
votes

OpenLaszlo does not officially support importing a Flash SWF application into it. The only exception are movies encoded to the SWF format.

(If your application is in Flash 9 (SWF9) or greater then the SWF movies need to be encoded in AVM2 format, for Flash 8 or lower, the AVM1 codec).

If you attempt to load a SWF that is anything other than a simple SWF movie into an OpenLaszlo <view> then the result will be unpredicatble.