Long story short - passing a variable from a coldfusion document, through the swf (using FlashVars) to a coldfusion document that load the correct images into the swf based upon that variable. I’ve done tons of homework & gotten lots of help but my movie loads w/o reading the coldfusion document that is supposed to load into it.
Here is where my code is messing up… can someone tell me where Im going wrong? Im so upside down on this I’m guessing it’s right in front of my nose.
//forums
var myVariable:LoadVars = new LoadVars();
myVariable.onLoad = function(success:Boolean){
if(success) {
trace(myVariable)
} else {
trace("Error connecting to server.");
}
sender.id=myVariable;
// send the id value to your cfm page using sendAndLoad, and returned xml will be loaded into the xml object x. -could this be where the prob is?
sender.sendAndLoad("gallery.cfm?id=" + myVariable, x, "GET");
}
//from forum ...
[COLOR=magenta][COLOR=black]var x:XML=new XML();
x.ignoreWhite=true;x.onLoad=function(done){
if(done){
trace('xml file is now loaded into '+this);
// now that it is loaded, process it the way you want.
};
//see...[/COLOR]
[/COLOR] var sender:LoadVars=new LoadVars();
}
imageXML.load(x);
_lockroot = true;
My debug says that the variables are undefined. I think this is because I am trying to load x w/o it knowing what is going on. It seems more likely I’d need to load
sender.sendAndLoad("gallery.cfm?id=" + myVariable, x, "GET");
which I thought I was doing… but well obviously not. Im in over my head. I’ve tried paying someone, begging help from experts etc but it seems no one has been able to help me wrap this project up. Anything any of you could do to help would be SO APPRECIATED.
Thanks!:stare:
this is the exact problem im having - ■■■■ its annoying - passing a variable from a coldfusion document, through the swf (using FlashVars) to a coldfusion document that load the correct images into the swf based upon that variable.
using XML sendAndLoad - its so wierd. Im beginning to think its not even possible? Youd think Flash <-> CF <-> XML would work so easily specially since Coldfusion is a Macromedia product
it should be relatively easy. why don’t you post your code?
Coldfusion plays very nicely with flash especially if you use remoting.
If you’re sending a variable to a cold fusion page use the LoadVars object instead of the XML object to send it via sendAndLoad.
If you’re sending a variable and expecting XML in reply, use the LoadVars object in conjunction with an XML object (specified as the return object) like this:
mySender=new LoadVars();
returnedXML= new XML();
returnedXML.ignoreWhite=true;
returnedXML.onLoad=function(success){
//set your xml load handler function here...
}
//assign a var to the loadvars object and give it a value
mySender.variable1=_root.variable1;
//check for _root variable passed in through flashvars...
if(_root.variable1!=undefined){
mySender.sendAndLoad("myCFpage.cfm", returnedXML, "POST");
}else{
//put error handling trace or something to handle not having the variable yet here
};
hope that helps. just remember that this will all be asynchronous so you’ll have to wait until everything is there before you try to work with it!
so you can use a sendAndLoad applied to a Load Vars sender object with an XML as the reciever? Man i hope this works thanks for your help ill try it out tommorow.
Hi Guys
I AM SO SORRY! I had submitted this problem to so many forums looking for help - I missed this one when posting the answer.
YES! Load Vars were the answer! You can specify that loadvar X = #cfm_variable# in both your cfm page and in your actionscript. Then that varibale was passed to the xml document (or in this case a CFM document). I was able to use a CFM document with more varibles loaded off the #cfm_variable# passed through the flash to create the gallery I needed.
If you need a more detailed answer let me know & I’ll try to help.
SO SORRY!!!
Hope you got yours to work!!!
thanks natronp i used the loadVars + XML object, and it works! I also added “POST” to the method - i noticed that i left it out - so your example reminded me…
also that debug thing to test if the flashvars had been passed correctly - that helped me fix it too…
thanks a million!