PDA

View Full Version : Noob question about loading query string to SWF


flagman5
05-02-2007, 12:21 AM
Hi All

I just recently started reading about flash, and I dont really know to find this information. But assuming I got the php/mysql side taken care of, and I got the php to be outputting the var1=data1&var2=data2..

Is it possible to publish a SWF and then give it a query string, like SWF?id=123 so that the 123 can be passed into the php file, so when the flash calls the php, it would loadVariables with php?id=123

I hope my question makes sense. Any instructions to go about doing this would be really helpful!!

Thanks!

Krilnon
05-02-2007, 07:43 AM
See this post: http://www.kirupa.com/forum/showthread.php?p=2110835#post2110835

flagman5
05-09-2007, 10:31 PM
after some tinkering and alot of reading...i wrote this and I am sure its not going to work, lo and behold, i get

1152: A conflict exists with inherited definition flash.display:DisplayObject.name in namespace public.

Which i have no idea what it means....I tried to understand from the adobe compiler error site but still not quiet sure...


function lv(f) {

loadText = new LoadVars();
loadText.load(f);
loadText.onLoad = function() {
name.text = this.poll;
var i;
var temp;
for (i=0; i<3; i++) {
temp = this["file"+i];
if(temp == undefined){
//do nothing
}
else {
results.text += "<img src='"+temp+"'><br/>";
}
}
var options;
var pic_votes;
for (i=0; i<3; i++) {
options = this["temp"+i];
if(options == undefined){
pic_votes = this["vote"+i];
results.text += "<img src='"+this["vote"+i]+"'>"+ this["number"+i] +" votes <br/>";
}
else {
results.text += options +"<br/>"+"<img src='"+this["vote"+i]+"'>"+ this["number"+i] +" votes <br/>";
}

}
results.text += "Total Votes: " + this.total + " votes";

};

}
var id= root.loaderInfo.parameters.id;
var url="http://www.mysite.com/some.php"
url=url+"?id="+id
lv(url);
Can some1 please point me in the right direction??

Krilnon
05-09-2007, 10:35 PM
If 'name' is a TextField, rename it to something else.

flagman5
05-10-2007, 01:20 AM
thanks for the help!

I am back for more hahah.

I got the thing up and running, but because I am feeing the variable here:


var id = root.loaderInfo.parameters.id;
var url="http://www.mysite.com/some.php"
url=url+"?id="+id
lv1(poll_name,url);


so i am doing this in the HTML:


<embed src="widget.swf?id=123" quality="high" bgcolor="#EFF7F6" width="200" height="200" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>


I don't know how to use the debugger....because i need to feed the variable via HTML.

Right now the swf comes up with everything as undefined. and also the text is not rendering as HTML even though i have that <> box selected.

here is the lv1 function

function lv1(loadText, f) {

loadText = new LoadVars();
loadText.load(f);
loadText.onLoad = function() {
poll_name.text = this.poll;

};

}


Please help! Thanks!

flagman5
05-10-2007, 02:12 AM
sorry...some stupid mistake...it works now. I had actionscript 2 not 3..

but i still dont understand why it is not rendering the text as html.

kdittyr
06-20-2007, 04:18 PM
sorry, double posted

#EDIT# I have found the work around for OSX that I didn't know below, you have to take out the noscript tags when publishing straight from Flash CS3 and it works like a charm. #/EDIT#

kdittyr
06-20-2007, 04:24 PM
I believe that it is not rendering as html because you have this:
poll_name.text = this.poll;when it should be:
poll_name.htmlText = this.poll;

I am having problems with query strings in flash cs3 as well... They are working fine in windows, but the same code does not work in OSX. This is killing me.

Here is my as code:var text01:String = this.root.loaderInfo.parameters.line01;
if(text01 == null){
text01 = "undefined";
}

var text02:String = this.root.loaderInfo.parameters.line02;
if(text02 == null){
text02 = "undefined";
}

textBox01.htmlText = text01;
textBox02.htmlText = text02;
and here is the html<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="50" id="flashVar" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="flashVar.swf?line01=hello&line02=working" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="flashVar.swf?line01=hello&line02=working" quality="high" bgcolor="#ffffff" width="550" height="50" name="flashVar" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

Like I said, it works just fine in windows, but not at all on OSX with either Safari or Firefox.