[xray] Minimal connector-only code

Karina Steffens karina at neo-archaic.net
Thu Mar 16 17:37:40 EST 2006


Well, I guess the main thing is that because this class is a singleton,
you're ensuring that Xray is only loaded once, and can add this code to
assorted classes without worrying about initiating multiple instances of
Xray. 
 
For example, the project I was working on when I wrote this script had a
bunch of different movies loaded into the main movie, and both the main and
sub movies were using my MVC framework classes. What I did was just plonk
the getInstance() call into the base View class and never had to worry about
creating multiple instances.
 
It's also a nice bare-bones example of how to use the external connector,
traces out that the connector is loaded and can be extended if needed.
 
Karina
 
PS: Sorry a bit late with replying, had a major power cut here yesterday...
 
  _____  

From: John Grden [mailto:neoriley at gmail.com] 
Sent: 14 March 2006 13:10
To: xray at osflash.org
Subject: Re: [xray] Minimal connector-only code



Ok, i finally sat down and tested the singleton (thank you Karina!)

It works just fine, like you say, with 2 lines of code:

import com.blitzagency.xray.util.XrayConnect;
var xRay = XrayConnect.getInstance(_level0, true); 

But my question would be, why use it instead of XrayLoader?  The only
savings typing-wise is 1 argument, but you've now got extra kb added to your
file:

import com.blitzagency.xray.util.XrayLoader;
XrayLoader.loadConnector ("xray.swf", _level0, true);

Maybe there's another benefit I'm missing - what do you guys think?  I don't
mind adding it to the package as an option at all, but just want to make
sure there's a good reason for it being there. 

John


On 3/14/06, xray at osflash.org <xray at osflash.org> wrote: 

> So what should become Daren's example :

Below is the code that works for me. I'm not sure there has been a new 
release since so you have to make and put XrayConnect.as in the
com.blitzagency.xray.util directory. In case you don't have it I've
attached it.

Darren

//------------------------------------------------------------------- 
import com.blitzagency.xray.util.XrayConnect;

class HelloWorld{
/** Holds reference to the single global class that main() creates */
static var app:HelloWorld;

/** Constructor: does all the work */ 
function HelloWorld(){
_root.createTextField("txt",10,0,0,0,0);
_root.txt.autoSize='left';
_root.txt.text="Hello World!\n";

_global.tt("Finished initializing HelloWorld"); 
}

/** Program entry point: creates one global instance of our class */
static function main(){
XrayConnect.getInstance(_level0,true);    //true means show
                                        //frames per second 
app=new HelloWorld();
}

}


_______________________________________________
xray mailing list
xray at osflash.org
http://osflash.org/mailman/listinfo/xray_osflash.org








-- 
John Grden - Blitz 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/xray_osflash.org/attachments/20060316/ad0a6245/attachment.htm


More information about the xray mailing list