[xray] Minimal connector-only code

Karina Steffens karina at neo-archaic.net
Fri Feb 3 05:57:33 EST 2006


Hi Darren,

Here is a modified XrayConnect class that I tinkered with for use with the
external connector. It's a singleton called by using the getInstance()
method from anywhere in your application. The method needs to be passed a
movie clip reference to load the connector in. 
In the last line: XrayLoader.loadConnector("ConnectorOnly_as2_fp7_OS.swf",
containerClip, showFPS); You need to modify the name of the connector to
whatever it is you're using. 
Hope this is helpful in any way.

Looking at it again, it's probably the wrong place for the connector name,
if that can be changed. It might be better to just give the connector a
generic name ("XrayConnector.swf" perhaps?) and / or maybe pass a new name
to the app via the getInstance() method.
What do you guys think?


---------------------------------------------------------------------
/**
 * Used to initialise the Xray Connector Only Package
 * as a Singleton called by other classes.
 * 
 * @author Chris Allen	chris at cnmpro.com
 * @author John Grden johng at acmewebworks.com
 * @author Karina Steffens karina at neo-archaic.net
 */

import com.blitzagency.xray.util.*;

class com.blitzagency.xray.util.XrayConnect
{

	private static var instance:XrayConnect;
	
	function XrayConnect(containerClip:MovieClip, showFPS:Boolean)
	{
		init(containerClip, showFPS);
	}

	/**
	 * Main entry point into the application.
	 */
	static public function getInstance(containerClip:MovieClip,
showFPS:Boolean):XrayConnect{
	 if (XrayConnect.instance == undefined){
 		  XrayConnect.instance = new XrayConnect(containerClip,
showFPS)
	  }
	  return  XrayConnect.instance;	  
	}

	/**
	 * The method to run when the Connector.adminToolLoadComplete event
is triggered.
	 * Connector.trace, Connector.tt, Connector.tf are setup here to
pass arguments to the admintool
	 */
	public function LoadComplete()
    {
		var ttExists:Boolean = _global.tt ? true : false;
		var tfExists:Boolean = _global.tf ? true : false;
		var icExists:Boolean =
_global.com.blitzagency.xray.Xray.initConnections ? true : false;
		//you can either call AdminTool trace(), tt() and tf() using
_global
		//or by using the Static methods of the Connector class
		//_global.tt("Xray methods available? - ", "\n_global.tt? ",
ttExists, "\n_global.tf?", tfExists);
		//TRACE(Flashout.DEBUG + "ttExists :: " + ttExists);
		if (ttExists && tfExists){
			_global.tt("Xray Connector Loaded")
		}
	}

	private function init(containerClip:MovieClip, showFPS:Boolean):Void
{
		XrayLoader.addEventListener("LoadComplete", this);
    	XrayLoader.loadConnector("ConnectorOnly_as2_fp7_OS.swf",
containerClip, showFPS);
	}
}

----------------------------------------------------------------------------
------------  

> -----Original Message-----
> From: Darren Cook [mailto:darren at dcook.org] 
> Sent: 03 February 2006 01:03
> To: xray at osflash.org
> Subject: [xray] Minimal connector-only code
> 
> Hi,
> A few days ago I posted asking what some lines in the 
> XrayLoadTest.as example are doing. I've repeated them below 
> [1], but I thought I'd rephrase what I'm after and explain my 
> motivation.
> 
> What I'm trying to do is work out the minimum amount of code 
> I need to add to an existing actionscript-only application to 
> be able to use xray with it. The immediate need is to enhance 
> a HelloWorld app in a "linux and osflash" tutorial I'm 
> working on. But I have much more complex apps I want to use xray with.
> 
> So, does anyone have a before/after example of what xray code 
> needs to be added to use the connector only swf? [2] is my 
> code that does not work.
> 
> Darren
> 
> 
> 
> [1]
> I got the XrayLoadTest.as file working!
> But my HelloWorld app still doesn't connect. I guess I'm 
> being too minimal?  Can I ask some questions about XrayLoadTest.as?
> 
> Line 19: import Flashout;
>   Is this required if I'm not using Flashout?
> 
> Line 21: Does my main class have to extend MovieClip in order 
> to use xray? Why?
> 
> Lines 34..38: This looks like it turns root into an instance 
> of XrayLoadTest? Is this just a style thing, or is it 
> required in order to use Xray?
> 
> Line 71: Is it required to set a LoadComplete event listener? 
> Or can Xray still work without?
> 
> 
> [2]:
> import com.blitzagency.xray.util.XrayLoader;
> 
> class HelloWorld{
> /** Holds reference to the single global class that main() 
> creates */ static var app:HelloWorld;
> 
> /** Constructor: does all the work */
> function HelloWorld(){
> var xray_loader:MovieClip=new MovieClip; 
> XrayLoader.loadConnector("ConnectorOnly_as2_fp7_OS_1.4.5.swf",
>  xray_loader);
> 
> _root.createTextField("txt",10,0,0,0,0);
> _root.txt.autoSize='left';
> _root.txt.text="Hello World!";
> 
> _global.tt("Finished initializing HelloWorld"); }
> 
> /** Program entry point: creates one global instance of our 
> class */ static function main(){ app=new HelloWorld(); }
> 
> }
> 
> 
> _______________________________________________
> xray mailing list
> xray at osflash.org
> http://osflash.org/mailman/listinfo/xray_osflash.org
> 
> 




More information about the xray mailing list