Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

passing remote object between components

Posted on 2009-02-08
5
Medium Priority
?
172 Views
Last Modified: 2013-11-11
I have a main components where I create a remote object succesfully. I am trying to pass the remote object connection between components, and it's not showing up null.

Here is my main application page with the connection, and the Bindable var on the other component
gateway = "http://" + URLUtil.getServerName(Application.application.loaderInfo.url) + "/amfphp/gateway.php";
				conn = new RemoteObject;
				conn.source = "ChartService";
				conn.destination = "amfphp";
				conn.endpoint = gateway;
				conn.showBusyCursor = true;
                conn.addEventListener("result", onResultRemoteObject);
                conn.addEventListener("fault", onFaultRemoteObject);
 
 
~~~~~~~~~~~~~~~~~~~~~~~~~
//other component var
 
[Bindable] public var conn:Object;
 
override protected function onResultHttpService(e:ResultEvent):void
			{
				var o:Object = conn.eventByDistrict();
//conn is empty, so it can't call the method

Open in new window

0
Comment
Question by:hallikpapa
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Jones911
ID: 23586654
Where are you passing in conn to the 2nd component?
0
 

Author Comment

by:hallikpapa
ID: 23586661
Ah. I thought it did it automatically by just making it bindable.

What's the best way to make a remote object sharable throughout the app?
0
 
LVL 19

Expert Comment

by:Jones911
ID: 23586682
No you need to pass it to the children.

Use a framework:

Cairngorm:  http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm;jsessionid=35C9C31E4451F9A38EB1FD81544EB387
Mate:  http://mate.asfusion.com/
PureMVC:  http://puremvc.org/

Or I guess you could make a static class which is how cairngorm does it if a framework seams to much right now.
0
 

Author Comment

by:hallikpapa
ID: 23586742
Yeah, a framework is way too much for this simple test I am doing.

Would you mind showing a small code example of how this static class would work between the two components?
0
 
LVL 19

Accepted Solution

by:
Jones911 earned 2000 total points
ID: 23586769
Then just import it where you need it.

import com.myApp.className

and use it like

className.conn.sendData();

It might need some mods to work but its a starting point.  I think its pretty bad practice because its effectively a global variable.

Or you could just pass it to the childern objects
package com.myapp
{
	import mx.controls.Alert;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.remoting.RemoteObject;
	
		public static var conn = new RemoteObject;
                                conn.source = "ChartService";
                                conn.destination = "amfphp";
                                conn.endpoint = gateway;
                                conn.showBusyCursor = true;
                                conn.gateway = "http://" + URLUtil.getServerName(Application.application.loaderInfo.url) + "/amfphp/gateway.php";
                conn.addEventListener("result", onResultRemoteObject);
                conn.addEventListener("fault", onFaultRemoteObject);
	}
}

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question