Why is it "s" the prefix tag used for HTTPService?

114 views Asked by At

In my Mobile Flex project I declare a HTTPService :

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="" >
    <fx:Style>
        .myClass { color: Red }
    </fx:Style>
    <fx:Declarations>
        <fx:HTTPService id="userRequest" url="http://localhost/tabletteNR/NR.php" useProxy="false" method="POST"> // it causes an error "Impossible to resolve <fx:HTTPService> as a component implementation"
            <fx:request xmlns="">
                <username>a</username>
                <emailaddress>b</emailaddress>
            </fx:request>
        </fx:HTTPService>
    </fx:Declarations>
    ...

When I change the "fx" prefix to "s" then the error disappeared ! So why is "s" the right prefix ? However I looked the package explorer and I did not find the HHTPService inside the spark.swc folder, but I saw it inside the rpc.swc -> mx.rpc.http package. So why is it "s" the right prefix ?

2

There are 2 answers

1
JeffryHouser On BEST ANSWER

The HTTPService class is in the "library://ns.adobe.com/flex/spark" library namespace; and at the top of the view tag you gave that namespace a value of s:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="" >

This is the default, BTW, but you can change it to anything you want. In theory something like this should work:

<s:View xmlns:notfx="http://ns.adobe.com/mxml/2009" 
        xmlns:fx="library://ns.adobe.com/flex/spark" title="" >

<notfx:Style>
    .myClass { color: Red }
</notfx:Style>
<notfx:Declarations>
    <fx:HTTPService id="userRequest" url="http://localhost/tabletteNR/NR.php" useProxy="false" method="POST"> // it causes an error "Impossible to resolve <fx:HTTPService> as a component implementation"
        <fx:request xmlns="">
            <username>a</username>
            <emailaddress>b</emailaddress>
        </fx:request>
    </fx:HTTPService>
</fx:Declarations>

Although it is unusual and seems like a lot of work.

The namespace URLs and the classes inside the namespace are defined in a manifest.xml file which can be created as part of the SWC. Most Flex Developer's I know do not bother to change them.

6
Amit Kumar user3037405 On

To use Spark controls, default prefix is s and to use MX controls, default prefix is mx.

xmlns:s = "library://ns.adobe.com/flex/spark" 
xmlns:mx = "library://ns.adobe.com/flex/mx"