tags:

views:

4515

answers:

4

I'm new to Flex SDK and trying to implement a simple project using Doug Mccune's CoverFlow widget. Most of the documentation out there on how to do this assumes that one is using Adobe's FlexBuilder product, which is a $250 Eclipse plug-in that I'd rather avoid buying. The problem I'm having is simply getting Doug's swc file, which is the binary version of his component lib, to be recognized by mxmlc, the Flex SDK project compiler. I keep getting error messages such as

Error: Could not resolve to a component installation

and

Error: Type was not found or was not a compile-time constant: CoverFlow.

I have also tried the type "VideoCoverFlow" as I am pretty sure that these types are defined in Doug's lib. Alas, I am stuck on figuring out where I've gone wrong.

The following is the full text for my mxml project file, called coverflow.mxml.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:local="*"
    height="100%"
    width="100%"
    layout="absolute">

    <local:CoverFlow
        id="CoverFlow"
        horizontalCenter="0"
        verticalCenter="0"
        borderThickness="10"
        borderColor="#FFFFFF"
        width="100%"/>

</mx:Application>

I am trying to compile it with the following command:

c:\flex_sdk_3\bin\mxmlc.exe -compiler.source-path=lib coverflow.mxml

I have also tried moving the CoverFlow_lib.swc file into the same dir as the mxml file instead of using the source-path argument, but that does not seem to make a difference.

I would gladly go RTFM if somebody could be so kind as to point me in the direction of the proper docs. There are related Stack Overflow questions here and here.

Thank you!


Update: I have changed my build command to the following:

mxmlc -library-path+=lib coverflow.mxml

And I also tried the following:

mxmlc -library-path+=CoverFlow_lib.swc coverflow.mxml

With the swc file in the same dir as the mxml file. However, I'm still getting the same errors.

There's also a video here showing the same library that I'm trying to use, but in Flex Builder. Unfortunately, it doesn't show how to use mxmlc.

I've also tried stripping down my mxml to simply,

<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:local="*" >

    <local:VideoCoverFlow />

</mx:Application>
+1  A: 

If it is an swc shouldn't you be using library-path rather than source-path and referencing the swc?

Simon
+3  A: 

Here is a link to the mxmlc command line tool docs from Adobe and a direct link to the command line options reference. I also find mxmlc -help list to be a good place to start.

As another poster recommended, you really want to use library-path to add the path to the directory that contains the swc file. Use the += operator to make sure you don't overwrite the previous values

e.g.)

c:\flex_sdk_3\bin\mxmlc.exe -library-path+=lib coverflow.mxml
James Fassett
A: 

I finally got my project to build. The use of library-path was part of the solution, but I also had to take a closer look at the Doug Mccune library's sources so I could use the correct path information and type names in my mxml.

The winning command line is

mxmlc -library-path+=lib coverflow.mxml

And the working mxml is

<?xml version="1.0" encoding="utf-8"?>

<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:coverflow="com.dougmccune.coverflow.*"
    xmlns:containers="com.dougmccune.containers.*"
    xmlns:local="*" >

    <containers:CoverFlowContainer id="flow" />

</mx:Application

For some reason my container complains if I use id="coverflow". I get an error saying that the id name and the type name aren't allowed to be the same. If anyone can explain that to me, I'd love to understand what's going on there.

Thanks again for the help, Simon and James.

Parappa
I think it is because you have a xmlns named coverflow so you are filling the files symbol table with two symbols with the same name. You do not need the xmlns:coverflow or the xmlns:local
James Fassett
A: 

I have the same problem with this code, cant make it run, in intelij but works woth flex builder 3. Should'nt be a differance should it?

Information:c:\program files\jetbrains\intellij idea\jre\jre/bin/java.exe -Dapplication.home=C:/Dev/Flex Builder 3/sdks/3.3.0 -Xmx384m -Dsun.io.useCanonCaches=false -Duser.language=en -Duser.region=en -classpath C:\Program Files\JetBrains\IntelliJ IDEA/plugins/flex/lib/idea-fcsh-fix.jar;C:/Dev/Flex Builder 3/sdks/3.3.0/lib/fcsh.jar com.intellij.flex.FcshLauncher Information:Adobe Flex Compiler SHell (fcsh) Information:Version 3.3.0 build 4852 Information:Copyright (c) 2004-2007 Adobe Systems, Inc. All rights reserved. Information:mxmlc -load-config=flex_temp_flex_config.xml Information:Loading configuration file C:\intelij workspace\flex\flex_temp_flex_config.xml Information: horizontalScrollPolicy="off"> Information:Compilation completed with 1 error and 0 warnings Information:1 error Information:0 warnings C:\intelij workspace\flex\src\ProteketFlex.mxml Error:Error:line (10)Could not resolve to a component implementation.

<mx:Metadata>
    [ResourceBundle("proteketResources")]
</mx:Metadata>

<mx:Style source="styles/proteket.css"/>

<mx:Script>
    <![CDATA[
    import com.*;
    import com.integrate.proteket.flex.datamodels.FileDataModel;
    import com.integrate.proteket.flex.events.NewOrderEvent;
    import com.integrate.proteket.flex.datamodels.Order;
    import com.integrate.proteket.flex.datamodels.CustomerDataModel;
    import com.integrate.proteket.flex.services.CustomerService;
    import com.integrate.proteket.flex.views.orderWizard.OrderWizard;

    import mx.managers.IBrowserManager;

    import com.integrate.proteket.flex.datamodels.PropertiesDataModel;

    import mx.controls.Alert;

    import com.integrate.proteket.flex.datamodels.Constants;

    import mx.rpc.events.FaultEvent;
    import mx.rpc.http.HTTPService;

    import com.integrate.proteket.flex.datamodels.OrderDataModel;

    import mx.rpc.events.ResultEvent;

    import com.integrate.proteket.flex.services.ProductService;

    private var _productService:ProductService;
    private var _customerService:CustomerService;
    private var _propertiesDataModel:PropertiesDataModel;
    private var _propertiesService:HTTPService;
    private var _browserManager:IBrowserManager;
    private var _customerId:int;
    private var _requestLocale:String;
    private var _user:String;
    private var _propPath:String;
    private var _createdByCustomer:String;


    /**
     * Method run when creation of application is complete.
     */
    private function initApplication():void {

        //Reads the flash variables
        getFlashVars();

        if (_customerId > 0 && _propPath != null) {

            //Application properties are loaded at runtime
            _propertiesDataModel = PropertiesDataModel.getInstance();
            _propertiesService = new HTTPService();
            _propertiesService.url = _propPath;
            _propertiesService.addEventListener(ResultEvent.RESULT, handleApplicationProp);
            _propertiesService.addEventListener(FaultEvent.FAULT, handleApplicationPropFault);
            _propertiesService.send();
        }
    }


    /**
     * Responsable for reading flash variables passed in from the URL.
     */
    private function getFlashVars():void {

        //Reads the current flash variables
        _customerId = Application.application.parameters.customerId;
        _requestLocale = Application.application.parameters.requestLocale;
        _user = Application.application.parameters.user;
        _propPath = Application.application.parameters.propPath;
        _createdByCustomer = Application.application.parameters.createdByCustomer;

        //Checks that the customerId can be read
        if (_customerId < 1) {
            Alert.show("Can not read 'customerId' from URL", "Application Error");
            this.removeAllChildren();
        }

        //Sets the correct resource bundle, if local is set by Flash vars
        if (_requestLocale != null) {

            _requestLocale = _requestLocale.toLowerCase();

            if (_requestLocale == "no" || _requestLocale == "nb" || _requestLocale == "nn" ||
                _requestLocale == "nb_no" || _requestLocale == "no_no" || _requestLocale == "nn_no")
                resourceManager.localeChain = [Constants.LOCAL_NB_NO];

            else if (_requestLocale == "sv" || _requestLocale == "se" || _requestLocale == "sv_se")
                resourceManager.localeChain = [Constants.LOCAL_SV_SE];

            else
                resourceManager.localeChain = [Constants.LOCAL_EN_US];
        }
        else
            resourceManager.localeChain = [Constants.LOCAL_EN_US];


        //Sets user data on order object if available
        if (_user != null) {
            OrderDataModel.getInstance().order.createdBy = _user;
            OrderDataModel.getInstance().order.updatedBy = _user;
        }

        //Checks that the propPath can be read
        if (_propPath == null || _propPath == "") {
            Alert.show("Can not read 'propertiesPath' from URL", "Application Error");
        }

        //CreatedByCustomer set on order object
        if (_createdByCustomer != null && _createdByCustomer == "true") {
            OrderDataModel.getInstance().order.createdByCustomer = true;
        }
        else {
            OrderDataModel.getInstance().order.createdByCustomer = false;
        }
    }


    /**
     * Handles the runtime loading of the application properties
     */
    private function handleApplicationProp(event:ResultEvent):void {

        //Setting the application properties
        _propertiesDataModel.applicationProperties = _propertiesService.lastResult.properties.property;

        //Loading the customer related data, based on the customerId given by the URL
        _customerService = new CustomerService();
        _customerService.addEventListener("customerUpdated", handleCustomerResult);
        _customerService.getCustomerData(_customerId);
    }


    /**
     * When customer data is loaded successfully, the products associacted with a
     * customer (employeeDepartmentId) will be loaded.
     */
    private function handleCustomerResult(event:Event):void {

        var employeeDepartmentId:int = CustomerDataModel.getInstance().customer.employeeDepartmentId;

        //Loading the product list
        _productService = new ProductService();
        _productService.getProducts(employeeDepartmentId);
    }


    /**
     * Handles fault if it occurs when fetching the property file
     */
    private function handleApplicationPropFault(event:FaultEvent):void {
        Alert.show("Can not load application properties", "Application Error");
    }


    /**
     * Method which handles when a new order event occurs.
     * This will reset the current order and this view
     */
    private function handleNewOrderEvent(event:NewOrderEvent):void {

        //Creates a new order object and file object
        FileDataModel.getInstance().uploadFiles = new Array;
        OrderDataModel.getInstance().order = new Order;
        OrderDataModel.getInstance().order.createdBy = _user;
        OrderDataModel.getInstance().order.updatedBy = _user;

        //CreatedByCustomer set on order object
        if (_createdByCustomer != null && _createdByCustomer == "true") {
            OrderDataModel.getInstance().order.createdByCustomer = true;
        }
        else {
            OrderDataModel.getInstance().order.createdByCustomer = false;
        }

        //Removes the orderWizard
        orderWizardHolder.removeAllChildren();

        //Creates a new orderWizard and adds it to the application
        var orderWizard:OrderWizard = new OrderWizard();
        orderWizard.addEventListener(NewOrderEvent.NEW_ORDER, handleNewOrderEvent);
        orderWizardHolder.addChild(orderWizard);
    }
    ]]>
</mx:Script>

<!-- Holds the whole application view, and sets up the orderWizard -->
<mx:VBox width="100%" height="100%" id="orderWizardHolder">
    <op:OrderWizard id="orderWizard" newOrder="handleNewOrderEvent(event)"/>
</mx:VBox>

you should probably ask your own question instead of highjacking someone elses
Jason Miesionczek