1 Reply Latest reply on Oct 29, 2010 10:19 AM by Flex harUI

    How can I use Spark and Mx Components in a NativeWindow?

    misthalas2

      Hi,

       

      First of all, please, excuse my english... I'll try to express in the best way I can...

       

      I'm working in a AIR application, with Flash, Flex Builder y Action Script 3. I'm creating a new interface, and the main class extends from NativeWindow. The design and look&feel of my application is much different so I plan to create my own components, but I want to use some Spark or mx components and make some skinning or styling.

       

      When I've tried add some components in the stage of my main class (NativeWindow), the component doesn't appear or a compilation error if a try differents ad bizarre things. After reading and searching a lot. I think that Spark or MX component need a Spark or MX container. I've done some tests and if I add a WindowedApplication, I can use Spark/MX components, but I have two differents "windows": my own window and the Spark window.

       

      What am I searching? I solution to add Spark/MX components under my NativeWindow and integrate with the rest of my components.

       

      My main MXML file is:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
              xmlns:s="library://ns.adobe.com/flex/spark"
              xmlns:mx="library://ns.adobe.com/flex/mx"
              xmlns:b="*"
              xmlns:a="com.copmadrid.arioco.window.*"  windowActivate="this.close()">
      <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
        <a:MainWindow id="ariocoWindow">
        </a:MainWindow>
      </fx:Declarations>
      </s:WindowedApplication>

       

      In Declarations, I create my own window. If I add Spark/MX components in this file, they're added in another Flex-like window. I have two windows. For this reason I put this.close() to close the Flex Window. It's a trick for the moment.

       

      Inside <a:MainWindow>, I can't add anything becouse Flex Builder 4 said that I can't add component in declaration - trying to add a component inside the NativeWindow. If I add Spark/MX components in the ActionScript class of MainWindow, even if I add a Spark WindowedApplication, they aren't appear.

       

      I have to ways, and I'll be very thankful if someone could help me:

       

      1. How can add in the MXML file Spark/MX components under the MainWindow after the delcaration block. I've searched but I haven't found a way to do it.

       

      2. Inside de ActionScript class file of MainWindow, add Spark/MX components but I supposse that I have to make an instance of a class that I can add to the stage of MainClase (extends from  NativeWindow) and will be visible there and a valid container for Spark/MX components. I have no idea about which class could be a bridge between NativeWindow and a valid Spark/MX coontainer.

       

      Thanks in advance! Greetings from Spain!!!