PDA

View Full Version : LocalConnection, ID of Connection?


Helge
01-30-2008, 07:43 PM
Hi,

I am starting writing my own swf with actionscript 2. I got no Flash (?) and can not open any fla files or what ever they are named.

I want to create a localconnection from my thumbs.swf to the running pano.swf with several panos. Clicking on an mc should load pano1 or pano2 or pano3 from pano.swf. OK?

I am able to make a local connection i.e with SPi-V:

var myLC = new LocalConnection();
myLC.send('spv.engine','spv.API', 'setView(\"'+this.LinkString+'\")');
myLC.close();


This sample connects to the connection named 'spv.engine'.

My problem: I did not understand, what is the name of the connection within FPP.

Please help!

thank you,

Helge

zleifr
01-30-2008, 07:56 PM
in global, you set the ID of the connection with localconnectionID="connectionID_here". The combobox controller supplied by Denis uses a localconnection ID of lc_test, for what it's worth.

Zephyr

Helge
01-30-2008, 08:37 PM
Thanks Zephyr for your quick reply.

Meanwhile I found the tutorial from Jason Villmer, but this did not helped me.

Here is the xml I use with pano.swf:


<?xml version="1.0" encoding="iso-8859-1"?>
<panorama>
<!-- parameters section -->
<parameters>
layer_1 = plugins\hotspots.swf
layer_2 = plugins\cylconverter.swf
panoType=cylinder
panoName=pano1
</parameters>
<hotspots>
<global localconnectionID="mycon">

<spot id="map" url="ThumbGallery.swf" static="1" alignX="00" alignY="-0.48" depth="10" salign="LM"/>

</global></hotspots>
<cylconverter />
</panorama>


I named the LocalconnectionID as you mentioned and I am trying to open via this name in my actionscript.

In the ThumbGallery.swf are the thumbs created with as2.
And here the code of my mc that should load the pano named 'pano1'


mc.onRelease = function () {
var myLC = new LocalConnection();
myLC.send("mycon", "execute", "loadPano(?panoName=pano1,,none)");
myLC.close();
}


Nothing happens when I am clicking on the mc.

Any sugestions?

tia,
Helge

zleifr
01-31-2008, 02:31 PM
what is the localconnection id in ThumbGallery.swf?

Zephyr

Helge
01-31-2008, 02:52 PM
what is the localconnection id in ThumbGallery.swf?

Zephyr

I don't know if understand.

I create the localconnection with
var myLC = new LocalConnection();
myLC.send("mycon", "execute", "loadPano(?panoName=pano1,,none)");
myLC.close();


I am only sending requests to the pano.swf. The local connection for the destination ist named 'mycon' as you can see in the myLC.send command.

I read, that this is enough for local connections if I only want to send. I dont want to make a bidirectional connection.

OK?

Helge

Helge
02-01-2008, 12:41 PM
Anyone who can help me?

The sample from Jason Villmer is not working on my PC, because I am not able to write AS3 code, only AS2. I have no possibility to open/edit fla

rgds,
Helge

zenofonte
02-01-2008, 05:52 PM
I'm quite newbie...

..but just today I tried to invok a method in an application (AS3) by an .swf hotspot developed in AS2.
I used localConnection re-using the controller.fla code. In this way it's possible to handle the local_connection_id problem.

In fact you used localconnectionID="mycon"... but I understood that you have to you use the setSlot method (invoked by FPP) to manage the localConnection name when you use: myLC.send("mycon", "execute", "loadPano(?panoName=pano1,,none)");

so instead of "mycon" you have to call the localConnection set by FPP as controller.fla does.
Actual it should be myLC.send(masterSlot, "execute", "loadPano(?panoName=pano1,,none)");" ... masterSlot instance is defined in setSlot function.

so try to re-use that code modifying the part that call send() method of localConnetcion.

Maybe is not so clear, due to my approximate knowledge.... but try in this way :D

Helge
02-02-2008, 03:49 PM
@zenofonte:

Thanks for your tips, but I am not not able to make working AS2 code.
If i am copying the setSlot function code from Jason Villmer
function setSlot(slot) {
masterSlot = controllerName+"_master_"+slot;
slaveSlot = controllerName+"_slave_"+slot+"_"+Math.random();
_lc.close();
_lc.connect(slaveSlot);
trace("set slave: "+slaveSlot);
startWatch();
};

to my AS2 script (into the main function of the main class) my compiler want accept the function above.

Below is the code (reduced to the minimum, I snipped out the XML reading part...)

class clsMain {

public static function main() {

var controllerName:String = "mycon";

function setSlot(slot) {
masterSlot = controllerName+"_master_"+slot;
/* dont need this, do I??
slaveSlot = controllerName+"_slave_"+slot+"_"+Math.random();
_lc.close();
_lc.connect(slaveSlot);
trace("set slave: "+slaveSlot);
startWatch();
*/
};

Stage.scaleMode = "noscale";
Stage.align = "LT";

//Here I am creating my thumbnails defined by an xmlfile. the code for reading an setting
//needed var is snipped, because its not needed showing my problem
var thumbContainer:MovieClip = _root.createEmptyMovieClip("container", 0);
for (i = 0; i < ThumbList.length; i++) {
var mc:MovieClip = _root.container.createEmptyMovieClip("mc_thumb" + i, i);
var pic:MovieClip = mc.createEmptyMovieClip("pic", 0);
pic.loadMovie("mythumb.jpg");

//HERE COMES THE LOCALCONNECTION.SEND
mc.onRelease = function () {
var myLC = new LocalConnection();
myLC.send("mycon", "execute", "loadPano(panoName=eingang)");
myLC.close();
}
}
}


Please help, what am I doing wrong?

Helge

zenofonte
02-02-2008, 10:50 PM
Hi Helge

I'm knowing that I'm not able to help you "teoretically deep"... but I'm a newbie to AS3 to (I didnt learn AS2 before too).

I don't understand why and where you're going wrong. [.. what's the error? what's going wrong?].

This is the way as I re-used the code of controller.fla

on(release)
{
//I need to use LocalConnection on button release
// Use the same name in spots.xml: <global controller="lcSpot">
// Better use different controller names for different panorama applications
var controllerName = "lcSpot";

// Master slot name:
var masterSlot:String;
// Slave slot name:
var slaveSlot:String;

// Begin of connection code (better use it as is).
var dumpSlot = controllerName+"_dump_"+random(1000000);
var _lc = new LocalConnection();
_lc.allowDomain = function () {
return true; // allow all connections
}
_lc.connect(dumpSlot);
_lc.onStatus = function(info) {
if (info.level == "error") {
trace("No master connection detected.");
_lc.close();
delete _lc;
}
};
_lc.setSlot = function(slot) {
masterSlot = controllerName+"_master_"+slot;
slaveSlot = controllerName+"_slave_"+slot+"_"+random(1000000);
_lc.close();
_lc.connect(slaveSlot);
trace("set slave: "+slaveSlot);
_lc.send(masterSlot, "execute", "statica"); // THIS IS THE CODE THAT I NEED TO SEND TO MY ROOT APPLICATION

//startWatch(); // I don't need to use the watcher, no new pano's has to be loaded
};
_lc.send(controllerName+"_master_0", "getSlot", dumpSlot);
// end of connecion code

var panoName:String; // current pano name
var panoBusy:Boolean; // true if panorama is loading or a transition effect is in process
var iid:Number; // interval id

// start watching parameters "panoName" and "panoBusy":
function startWatch () {
iid = setInterval(this, "sendQuery", 500);
}
// send query:
function sendQuery () {
// 3rd argument is array of askable parameters, 4th and 5th are connection name to callback
_lc.send(masterSlot, "getParams", ["pano.panoName","pano2.panoName"], slaveSlot, "callback");
}
// listener function:
_lc.callback = function(values) {
/* // store panoName
panoName = values[1] != null ? values[1] : values[0];
// if the second panorama is not null, set busy flag:
panoBusy = values[1] != null;
if (panoName != _cb.getSelectedItem().data) {
var n = _cb.length;
for (var i=0; i<n; i++) {
if (_cb.getItemAt(i).data==panoName) {
_cb.setSelectedIndex(i);
}
}
}*/
};

// remove focus manager, let the panorama has the focus
focusManager.enabled = false;
focusManager = null;

}

As you see by your own it's not an elegant re-use. Actual many code it's not needed... but it doesn't affect the behaviour, so I didn't examine the surplus.

Usually I like to clear my code. This time I need that just works. And it does.

Hope that this helps you, whatever way.

Helge
02-03-2008, 05:39 PM
@zenoforte: you rock:-) don't know what I am doing but you last post helped me. I put your code inside my mc.onRelease = function () . Skipped some codelines and functions (I think, there is a problem with nested functions in as2?)

Now I can go on writing the plugin. Thanks again,

Helge

zenofonte
02-03-2008, 08:27 PM
Great.

I've learned so much reading this forum. I'm happy if sometimes I can help or inspire someone of the crew.... :cool: