Using Runtime Configured Services in Flex

Now that I have

  1. Passed FlashVars to Flex using php
  2. Dynamically configured Flex runtime services from FlashVars

The flex application can now request the actual service using the channel setting defined in the initialization function in step 2 above.

Here is the code snippet from step 2, where the amfChannelSet variable has been defined. amfChannelSet can then be used in a RemoteObject service call.

private static var _amfChannel:AMFChannel = null;
			
[Bindable]
public var amfChannelSet:ChannelSet = null;


//create an amf channel dynamically here
_amfChannel = new AMFChannel(SiteConfigModel.CHANNELID,SiteConfigModel.amfEndPoint);
amfChannelSet = new ChannelSet();
amfChannelSet.addChannel(_amfChannel);

Example of using this bindable variable in an actual service call

<mx:RemoteObject
        id="roCourseListing"
        destination="my-amfphp"
        channelSet="{amfChannelSet}"
        source="CourseListingsService"
        fault="Alert.show( event.fault.faultString, 'Error' )"
        showBusyCursor="true"
        >
       <mx:method name="getInstructorListing" 
        	result="handleInstructorListingResult(event)" 
        	fault="handleOnFault(event.fault.message)"/>
        
   </mx:RemoteObject> 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: