In my code below, I am trying to use the variable id pulled from
flashvars and use it in the URL of the HTTPService. creationComplete
calls the initVars() function which sets the variable ID equal to the
parameter id from flashvars. 

My variable ID is not accessible within HTTPService, but within
serviceResult() it is getting the value of ID and printing to the
Canvas TextArea with id="contentText".

I unsuccessfully tried using mxresult as well within the HTTPService.

Any thoughts on what I can do to solve this?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
        creationComplete="service.send();initVars();"
        layout="absolute"
        backgroundGradientColors="[0xffffff,0xffffff]"
        width="100%" height="300"
        
        >
        
        <mx:Script>
                <![CDATA[
                        import mx.rpc.events.FaultEvent;
                        import mx.rpc.events.ResultEvent;

                        [Bindable]
                        public var ID:String;   
                        
                        private function initVars():void {
                                ID = Application.application.parameters.id;
                        }

                        private function serviceResult(event:Event):void {
                                
                                contentText.htmlText = ID + 
service.lastResult.content;
                        }
        
                        private function serviceFault(event:Event):void {
                                trace('broken service');        
                        }
                ]]>

        </mx:Script> 

        <mx:HTTPService url="{'http://www.mydomain.com/script.php' + ID}"
id="service" result="serviceResult(event)" fault="serviceFault(event)"
method="GET" contentType="application/xml" useProxy="false">
        </mx:HTTPService>
        <mx:Canvas...>
                <mx:TextArea ... id="contentText"/>
        </mx:Canvas>
</mx:Application>

Reply via email to