<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; fault</title>
	<atom:link href="http://blog.flexexamples.com/tag/fault/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Calling a simple web service from Flex using the WebService class</title>
		<link>http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/</link>
		<comments>http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 06:40:24 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[WebService]]></category>
		<category><![CDATA[fault]]></category>
		<category><![CDATA[operation]]></category>
		<category><![CDATA[result]]></category>
		<category><![CDATA[send()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/</guid>
		<description><![CDATA[<p>The following example shows how you can call a ColdFusion Web Service from Flex using the &#60;mx:WebService /&#62; tag.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/WebService_operation_send_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.utils.ObjectUtil; private var startTime:int; private var [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can call a ColdFusion Web Service from Flex using the &lt;mx:WebService /&gt; tag.</p>
<p>Full code after the jump.</p>
<p><span id="more-540"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/WebService_operation_send_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.events.FaultEvent;
            import mx.utils.ObjectUtil;

            private var startTime:int;
            private var endTime:int;

            private function button_click():void {
                webService.getMonths.send();
                startTime = getTimer();
                lbl.text = "";
            }

            private function getMonths_result(evt:ResultEvent):void {
                textArea.text = ObjectUtil.toString(evt.result);
                calcTime();
            }

            private function getMonths_fault(evt:FaultEvent):void {
                Alert.show(evt.type);
                calcTime();
            }

            private function calcTime():void {
                endTime = getTimer();
                lbl.text = "total time: " + (endTime - startTime) + "ms";
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:WebService id="webService"
            wsdl="http://www.flash-mx.com/ws/months.cfc?wsdl"&gt;
        &lt;mx:operation name="getMonths"
                resultFormat="object"
                result="getMonths_result(event);"
                fault="getMonths_fault(event);" /&gt;
    &lt;/mx:WebService&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="button"
                label="get months from web service"
                click="button_click();" /&gt;
        &lt;mx:Spacer width="100%" /&gt;
        &lt;mx:Label id="lbl" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:TextArea id="textArea"
            editable="false"
            width="100%"
            height="100%" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/WebService_operation_send_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/WebService_operation_send_test/bin/main.html" width="100%" height="300"></iframe></p>
<p>If you&#8217;re using ColdFusion, the months web service is as follows:</p>
<p class="download">months.cfc</p>
<pre class="code">
&lt;cfcomponent output="false"&gt;

    &lt;cffunction name="getMonths" access="remote" returntype="array" output="false"&gt;
        &lt;cfset var monthNames = ListToArray("January,February,March,April,May,June,July,August,September,October,November,December") /&gt;
        &lt;cfreturn monthNames /&gt;
    &lt;/cffunction&gt;

&lt;/cfcomponent&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Calling a simple web service from Flex using the WebService class on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/',contentID: 'post-540',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'fault,operation,result,send()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Dynamically loading XML files using the HTTPService tag</title>
		<link>http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/</link>
		<comments>http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 06:59:35 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[HTTPService]]></category>
		<category><![CDATA[TileList]]></category>
		<category><![CDATA[XMLListCollection]]></category>
		<category><![CDATA[fault]]></category>
		<category><![CDATA[send()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/</guid>
		<description><![CDATA[<p>In previous examples, <a href="http://blog.flexexamples.com/2008/03/08/creating-a-simple-image-gallery-with-the-flex-tilelist-control/">&#8220;Creating a simple image gallery with the Flex TileList control&#8221;</a> and <a href="http://blog.flexexamples.com/2008/02/15/creating-a-simple-image-gallery-with-the-flex-horizontallist-control/">&#8220;Creating a simple image gallery with the Flex HorizontalList control&#8221;</a>, we saw how you could create a simple image gallery using the TileList and HorizontalList controls.</p> <p>The following example shows how you can load XML files using the HTTPService [...]]]></description>
			<content:encoded><![CDATA[<p>In previous examples, <a href="http://blog.flexexamples.com/2008/03/08/creating-a-simple-image-gallery-with-the-flex-tilelist-control/">&#8220;Creating a simple image gallery with the Flex TileList control&#8221;</a> and <a href="http://blog.flexexamples.com/2008/02/15/creating-a-simple-image-gallery-with-the-flex-horizontallist-control/">&#8220;Creating a simple image gallery with the Flex HorizontalList control&#8221;</a>, we saw how you could create a simple image gallery using the TileList and HorizontalList controls.</p>
<p>The following example shows how you can load XML files using the HTTPService tag so that you can dynamically load different galleries.</p>
<p>Full code after the jump.</p>
<p><span id="more-577"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/HTTPService_send_test_2/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.rpc.events.ResultEvent;
            import mx.rpc.events.FaultEvent;
            import mx.controls.Alert;

            private var alert:Alert;

            private function loadGallery(src:String):void {
                httpService.url = src;
                httpService.send();
            }

            private function httpService_fault(evt:FaultEvent):void {
                var title:String = evt.type + " (" + evt.fault.faultCode + ")";
                var text:String = evt.fault.faultString;
                alert = Alert.show(text, title);
                xmlListColl.removeAll();
            }

            private function httpService_result(evt:ResultEvent):void {
                var xmlList:XMLList = XML(evt.result).images.image;
                xmlListColl = new XMLListCollection(xmlList);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XMLListCollection id="xmlListColl" /&gt;

    &lt;mx:HTTPService id="httpService"
            resultFormat="e4x"
            fault="httpService_fault(event);"
            result="httpService_result(event)" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="gallery 1"
                click="loadGallery('gallery1.xml');" /&gt;
        &lt;mx:Button label="gallery 2"
                click="loadGallery('gallery2.xml');" /&gt;

        &lt;mx:Button label="gallery 404"
                click="loadGallery('gallery404.xml');" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:TileList id="tileList"
            dataProvider="{xmlListColl}"
            itemRenderer="TileListItemRenderer"
            columnCount="3"
            columnWidth="150"
            rowCount="2"
            rowHeight="100" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="download">TileListItemRenderer.mxml</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/ --&gt;
&lt;mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"&gt;

    &lt;mx:Image source="{data.@src}"
            horizontalCenter="0"
            verticalCenter="0" /&gt;

    &lt;mx:Label text="{data.@lbl}"
            fontWeight="bold"
            horizontalCenter="0"
            bottom="0" /&gt;

&lt;/mx:Canvas&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/HTTPService_send_test_2/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/HTTPService_send_test_2/bin/main.html" width="100%" height="350"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Dynamically loading XML files using the HTTPService tag on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/',contentID: 'post-577',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'fault,send()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/03/29/dynamically-loading-xml-files-using-the-httpservice-tag/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

