|
-
getURL POST & GET won't work
I've put the same variable name with the same content all over the flash movie, even inside the on(release).
Then I go:
on (release) {
var picho:String = "hola";
getURL("http://myurl/index.php", "GET");
}
Before that I used "_blank" in between, but I took it away as I read was causing problems to someone. Same thing:
The php script doesn't get anything, the address bar doesn't show any variables and I ran out of searching options for the solution.
This is a Flash 8 movie loaded into CS3.
Thanks for any suggestion.
-
AKA [ Paul Bainbridge]
Can you tell us what your trying to do?
-
Yes, I'm just trying to POST OR GET the flash movie variables over the internet and to get to process them at the other end with the page index.php hosted at http://myurl
According to flash help, this will do it:
The following ActionScript uses POST to send variables in the HTTP header. Make sure you test your documents in a browser window, because otherwise your variables are sent using GET:
var firstName:String = "Gus";
var lastName:String = "Richardson";
var age:Number = 92;
getURL("http://www.adobe.com", "_blank", "POST");
But it doesn't to me, either using GET or POST.
-
Quick reply doesn't work? I just lost my reply. Ok, let's go again:
I'm just trying to GET or POST some flash movie variables over the internet and to get to process them at the other end by the file index.php hosted at http://myurl.
According to flash help, this will do it:
The following ActionScript uses POST to send variables in the HTTP header. Make sure you test your documents in a browser window, because otherwise your variables are sent using GET:
var firstName:String = "Gus";
var lastName:String = "Richardson";
var age:Number = 92;
getURL("http://www.adobe.com", "_blank", "POST");
But it doesn't to me. The url is correctly opened but variables are safely kept inside the swf, no indication they'll be released whatsoever to the outside world.
-
FK'n_dog
if you are trying to send the variable picho, use -
var picho:String = "hola";
getURL("http://myurl/index.php?picho="+picho);
test in browser as appended vars fail silently in authoring environment
-
ok, my posts might be delayed somewhere, I assume they are on their way while I reply to a_modified_dog.
Thanks, but, if I want to post them hidden in the http header... what should I do?
-
what the...! The posts are not queued are they?... ok, I'll go again with my reply to webdreamer:
Quick reply doesn't work? I just lost my reply. Ok, let's go again:
I'm just trying to GET or POST some flash movie variables over the internet and to get to process them at the other end by the file index.php hosted at http://myurl.
According to flash help, this will do it:
The following ActionScript uses POST to send variables in the HTTP header. Make sure you test your documents in a browser window, because otherwise your variables are sent using GET:
var firstName:String = "Gus";
var lastName:String = "Richardson";
var age:Number = 92;
getURL("http://www.adobe.com", "_blank", "POST");
But it doesn't to me. The url is correctly opened but variables are safely kept inside the swf, no indication they'll be released whatsoever to the outside world.
-
Ok, third try the post has got there. Sorry if my previous two appear after. Will look as I'm spamming.
-
FK'n_dog
PHP Code:
getURL("http://myurl/index.php?picho="+picho, "POST");
// or
lv = new LoadVars();
lv.picho = "hola";
lv.sendAndload("http://myurl/index.php", lv, "POST");
lv.onLoad = function(){
trace(unescape(this)); // catch returned values or errors from php
};
-
Ok, I'll try that, modified_dog, but if that works I'll get very annoyed with flash help writers, because what they say is different.
-
Create a new movie clip like...
var movClip:MovieClip = _root.createEmptyMovieClip("mov", _root.getNextHighestDepth());
movClip.picho = "hola";
movClip.getURL("address", "POST");
-
toltec7, I'm not very skilled at flash, so I've added your code into the on(release) method of the main movie, like this:
on (release) {
var movClip:MovieClip = _root.createEmptyMovieClip("mov", _root.getNextHighestDepth());
movClip.picho = "hola";
movClip.getURL("http://myurl/index.php", "GET");
}
But it doesn't even navigate to the url (let alone sending the variables )
Regarding a_modified_dog's example, even I define the variable picho RIGHT BEFORE the getURL statement, the content seems to be plain blank:
on (release) {
var picho:String = "hola";
getURL("http://megaclor.110mb.com/index.php?url="+picho, "GET");
}
I'm using GET to have at least the chance of seeing the variable going on the address bar.
Is adobe flash kind of criptic, or is just me?
-
AKA [ Paul Bainbridge]
Hey i got know replies to say this thread was still active!
Anyways...
Dont know how you guys have got lost here.
this is all you need.
code:
on (release) {
getURL("http://megaclor.110mb.com/index.php?someVar=hello", "_blank");
}
or if you want to use some populated var
code:
on (release) {
var picho = "hello"
getURL("http://megaclor.110mb.com/index.php?someVar="+picho, "_blank");
}
//More than one var
on (release) {
var picho1 = "hello"
var picho2 = "you"
getURL("http://megaclor.110mb.com/index.php?someVar1="+picho1+"&someVar2="+picho2, "_blank");
}
Hope that clears things up for you.
-
Ok, your code does work, webdreamer, which leaves me with the enigma of why if they define it everywhere as ":String" wont work as expected. After all, a type declaration after the name is perfectly logic as I understand it. But hey...!
Now, what if I want to send, not picho, but something like root.loaderInfo.url?
This doesn't work:
on (release) {
var picho = root.loaderInfo.url;
getURL("http://myurl/index.php?url="+picho, "GET");
}
Neither this does:
on (release) {
getURL("http://myurl/index.php?url="+root.loaderInfo.url, "GET");
}
Isn't root.loaderInfo.url the right way to obtain the url being navigated by the browser window that contains the swf being played.
I'm just trying my swf to say to my server: "Hey, I'm *this* swf and I've been clicked while playing myself to a user who was browsing *this* url".
Last edited by marexposed; 05-06-2008 at 08:56 AM.
-
 Originally Posted by marexposed
toltec7, I'm not very skilled at flash, so I've added your code into the on(release) method of the main movie, like this:
on (release) {
var movClip:MovieClip = _root.createEmptyMovieClip("mov", _root.getNextHighestDepth());
movClip.picho = "hola";
movClip.getURL("http://myurl/index.php", "GET");
}
But it doesn't even navigate to the url (let alone sending the variables  )
you should do that code in timeline I guess...
so name you button (instance name)
and do this on _root or some other timeline...
button.onRelease = function () {
var movClip:MovieClip = _root.createEmptyMovieClip("mov", _root.getNextHighestDepth());
movClip.picho = "hola";
movClip.getURL("http://myurl/index.php", "POST");
}
that really should work if you wanna send with POST.
you can send with GET by adding a query string like the other guy explained...
-
AKA [ Paul Bainbridge]
 Originally Posted by marexposed
Ok, your code does work, webdreamer, which leaves me with the enigma of why if they define it everywhere as ":String" wont work as expected. After all, a type declaration after the name is perfectly logic as I understand it. But hey...!
Now, what if I want to send, not picho, but something like root.loaderInfo.url?
This doesn't work:
on (release) {
var picho = root.loaderInfo.url;
getURL("http://myurl/index.php?url="+picho, "GET");
}
Neither this does:
on (release) {
getURL("http://myurl/index.php?url="+root.loaderInfo.url, "GET");
}
Isn't root.loaderInfo.url the right way to obtain the url being navigated by the browser window that contains the swf being played.
I'm just trying my swf to say to my server: "Hey, I'm *this* swf and I've been clicked while playing myself to a user who was browsing *this* url".
it should be _root.blah...
not root.blah...
-
FK'n_dog
i personally favour the LoadVars method as getURL is somewhat outdated 
here is a link to see a working file (php included)
http://www.jackleaman.co.uk/temp/vars.html
-
AKA [ Paul Bainbridge]
 Originally Posted by a_modified_dog
I think it's depends on what he's looking to do with the vars. I mean what if he wants to populate a html based form fields with data passed in the url?
Thats the only reason i can see my self using the suggested method.
in the other hand if he's doing something like a contact form the sendAndLoad() would be the better method even though some template sites out there seem to do the suggest method.
-
I wish I say "it did work", but it didn't unfortunately.
I tried both examples as I did before, this time adding the underscore as prefix. As usual I "export movie", I upload to the server, I reload the page that contains the swf, I click on it and I get a popup browser window navigating to the address stated in getURL, but I only get an empty string next to the "url=" in the browser's address bar.
Neither _root.loaderInfo.url or root.loaderInfo.url seems to provide a value. At least not as I'm using them.
Any (more) ideas?
-
Ok a_modified_dog, I'll try your code now.
Wait! Is your code informing where the swf is hosted or where is being played? Because if it's the former, that's not what I'm looking for. I need to know the address of the web-page where the swf is being played.
Anyway, I still will try the loadvars method.
Last edited by marexposed; 05-06-2008 at 09:46 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|