PDA

View Full Version : localConection not sending variables?



ben_is_sparky
October 11th, 2005, 12:27 PM
I've got a bunch of movieclips which are thumbnails. When you click them, they open a popup with that picture up big and a little description of it.

I've got these two pieces of code:
Sender


onClipEvent(load){
thisName = this._name
thisPictureNumberArray = thisName.split("Container")
thisPictureNumber = thisPictureNumberArray[1]
//Popup Window Variables
winURL = "popup_2.html";
winName = "Andrew Scott Photography";
winWidth = 830;
winHeight = 770;
winToolbar = 0;
winLocation = 0;
winDirectories = 0;
winStatus = 0;
winMenuBar = 0;
winScrollbars = 1;
winResizable = 0;
//If clicked...
this.onRelease = function(){
thisPictureTitle = _parent.titlesArray[thisPictureNumber]
thisPictureDescription = _parent.descriptionsArray[thisPictureNumber]
thisPicturePath = _parent.pathsArray[thisPictureNumber]
//Send the Picture Info to the Popup
//Open Popup
getURL ("javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open('" + winURL + "','" + winName + "','" + "width=" + winWidth + ",height=" + winHeight + ",toolbar=" + winToolbar + ",location=" + winLocation + ",directories=" + winDirectories + ",status=" + winStatus + ",menubar=" + winMenuBar + ",scrollbars=" + winScrollbars + ",resizable=" + winResizable + ",top='+((screen.height/2)-(" + h/2 + "))+',left='+((screen.width/2)-(" + w/2 + "))+'" + "')}else{myWin.focus();};void(0);");

//Check when the popup is opened.
sendPicturreInfo = new LocalConnection();
sendPicturreInfo.connectionOK = function(){
sendPicturreInfo.send("pictureInfo", "getinfo", "Picture 1", "This is the first test picture.", "pictures/tort1.jpg");
}
sendPicturreInfo.connect("connectionTest");
}
}


Reciever


popConnector = new LocalConnection();
popConnector.getInfo = function(title,description,path){
//Load the picture
loadMovie(path,pictureBox);
//Put in the Title and description
textBox.html = true
textBox.htmlText = ""
textBox.htmlText = "<font size='14' color='#117733'><b>"+title+"</b></font><br><font size='14' color='#000000'>"+description+"</font>"
}
popConnector.connect("pictureInfo");
popConnector.send("connectionTest", "connectionOK");


It's working fine, but when I change the values in the first part ( sendPicturreInfo.send("pictureInfo", "getinfo", "Picture 1", "This is the first test picture.", "pictures/tort1.jpg");) to be the variables thisPictureTitle, thisPictureDescription and thisPicturePath, it just shows up blank in the popup window. When I just use text strings "Picture 1" then it works fine.

Any ideas why?

Edit: and if I trace the variables trace(thispictureTitle); it works fine too, so they're being got fine.

rudester
October 11th, 2005, 02:10 PM
Seems like i have the same problem. My connections work ok locally. Once I have them in a server they fail. Any pointers?

rudester
October 11th, 2005, 02:15 PM
Note: I also have the same scenario with the pop-ups

ben_is_sparky
October 12th, 2005, 01:47 AM
It's weird, because in all the tutorials, they use variables fine. :diss:

Is it some problem with my code, or a problem similar to rudester's somehow?

ben_is_sparky
October 12th, 2005, 12:17 PM
Ok, I'm having another problem with the popup now... Something to do with my javaScript maybe?

Edit: This is only in IE, FF shows the popup fine (apart from what i was saying above) I think I read somewhere about FF automatically fixing small errors in your code, is that true, and is it the problem here?

Edit2: Here's my JS, which I think is the problem, because the message only comes up when I click the button to open the popup.


//Open Popup
getURL ("javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open('" + winURL + "','" + winName + "','" + "width=" + winWidth + ",height=" + winHeight + ",toolbar=" + winToolbar + ",location=" + winLocation + ",directories=" + winDirectories + ",status=" + winStatus + ",menubar=" + winMenuBar + ",scrollbars=" + winScrollbars + ",resizable=" + winResizable + ",top='+((screen.height/2)-(" + h/2 + "))+',left='+((screen.width/2)-(" + w/2 + "))+'" + "')}else{myWin.focus();};void(0);");

ben_is_sparky
October 13th, 2005, 11:59 AM
*bump*

Any ideas on either of these?

Edit: After a bit of fiddling, I find that If I comment out these two bits, I don't get the error, but of course, it doesn't work.



//Open Popup
//getURL ("javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open('" + winURL + "','" + winName + "','" + "width=" + winWidth + ",height=" + winHeight + ",toolbar=" + winToolbar + ",location=" + winLocation + ",directories=" + winDirectories + ",status=" + winStatus + ",menubar=" + winMenuBar + ",scrollbars=" + winScrollbars + ",resizable=" + winResizable + ",top='+((screen.height/2)-(" + h/2 + "))+',left='+((screen.width/2)-(" + w/2 + "))+'" + "')}else{myWin.focus();};void(0);");

//Check when the popup is opened.
sendPicturreInfo = new LocalConnection();
//sendPicturreInfo.connectionOK = function(){
//sendPicturreInfo.send("pictureInfo", "getinfo", "Title", "description", "pictures/picture1.html");
//}
sendPicturreInfo.connect("connectionTest");