Glen
Glen

Reputation: 695

Spark Label Unamiguious Issue

In the code below i can't work out why i am getting this error: Can not resolve a multiname reference unambiguously. spark.components:Label it worked before and now i just get the error message.

<?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" width="800" height="523" maxWidth="800" maxHeight="523" initialize="httpService.send()" showStatusBar="false" backgroundColor="white" backgroundAlpha="1">
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.controls.Label;
            import mx.rpc.events.ResultEvent;

            public var returnData:ArrayCollection;

            protected function httpService_handler(event:ResultEvent):void{
                returnData = event.result.people.person;

                for( var i:int = 0; i < 5; i++){

                    var lbl:Label = new Label();
                    lbl.text = "News Item " + i;
                    //newsHGroup.addElement(lbl);
                }
            }
        ]]>
    </fx:Script>
    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        @namespace mx "library://ns.adobe.com/flex/mx";


    </fx:Style> 
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
        <s:HTTPService id="httpService" url="http://pipingautos.com/~nibbrco/glen-dev-folder/air/school-catch-up/test.php" result="httpService_handler(event)" />
    </fx:Declarations>

    <s:BorderContainer borderVisible="false" mouseDown="nativeWindow.startMove();" skinClass="MainStyle" width="800" height="523" id="container">
        <s:Group id="newsSlider" left="435" top="120" height="100" width="340">
            <s:Rect width="100%" height="100%" id="backRect">
                <s:fill><s:SolidColor color="0xc7d1e5" alpha="0.5" /></s:fill>
            </s:Rect>
            <s:HGroup>
                <s:Label text="testing" />
            </s:HGroup>
        </s:Group>

    </s:BorderContainer>
</s:WindowedApplication>

Upvotes: 2

Views: 179

Answers (1)

RIAstar
RIAstar

Reputation: 11912

You're mixing up spark.components.Label with mx.controls.Label. The Label in your AS code is an mx one (see the import statement), but the Label in your mxml code is the Spark version (see the 's' namespace).
They are actually kind of - the same - component; the former is the Flex 4 equivalent of the latter, which is a Flex 3 component.
Since you seem to be building a Flex 4 app, just stick with the Spark version. Just replace that mx 'import' statement with the spark classpath:

import spark.components.Label

Upvotes: 4

Related Questions