;

PDA

Click to See Complete Forum and Search --> : getUrl and passing variables.


OwenAus
11-05-2002, 07:42 AM
I wonder if someone would give me a clue here .. none of these pass any variables through.

Not collecting the variables from the frame (which is what I thought happened):
var a=1;
getUrl("page.asp","_blank","GET");

nor appending to url in traditional way, with or without GET:
getUrl("page.asp?a=1","_blank","GET");
or
getUrl("page.asp?a=1","_blank");

The pages load OK, but the name/value pairs disappear.

So I guess I need educating. Anyone willing to give me a clue. :)

Bob Hartzell
11-05-2002, 07:58 AM
I am not very familiar with this myself but there are a number of examples in the PostToServer folder.

I believe that target refers to movie clip or main movie (_root no quotes) not frame target.

Hilary or Johnie will know the answer.

OwenAus
11-05-2002, 09:01 AM
Hi Bob,

Thanks for that. (I keep forgetting about the examples folder).

Had a quick look and the 2nd example above seems to be correct (fits with what the eg suggests) so it must be something I am doing (or not doing) I guess.

necromanthus
11-05-2002, 04:06 PM
OWEN,
Try to use
loadVariables("yourpage.asp","GET"); (to receive) and
loadVariables("yourpage.asp","POST"); (to send)
instead of "getURL".
Also,don't forget that your dynamic page (ASP in this case) must be able to "format" as text array the output data:
var1=OWEN&var2=AUS&...&varn=END
cheers

OwenAus
11-05-2002, 07:52 PM
Hi Necromanthus,

Thanks. I'll give it a whirl. If this runs true to form it will be some silly oversight by me. lol. :p

johnie
11-05-2002, 09:14 PM
Passing it to another page using GetURl by apending the URL depends on a lot on the page recieving the Variable. The page has to be specifically formated for it and on a Web Server... If its not on a Web Server or if the catching page is not set up right it fails.

bridelh
11-05-2002, 10:10 PM
Originally posted by necromanthus
loadVariables("yourpage.asp","GET"); (to receive) and
loadVariables("yourpage.asp","POST"); (to send)


The above is not totally correct:

"GET" and "POST" will both send and receive variables, but GET will append them to the URL (max 255 characters) and post will place them in the header (no physical length restrictions)

One other point to remember:
Because KM does not support loadVariablesNum(), you need to specify the target as a string like such..

loadVariables("menu.txt","_level0");

and not like this:

loadVariables("menu.txt",0);

Although the previous one will appear to work, it is not. The action will fail and automatically put the variables on level0.

Also, the default is "POST" if not specified.

Be aware that ALL variables on the timeline that loadVariables is initiated from will be sent to the server - which is why you should try and use loadVariables from within a movieclip so you can restrict the variables that are sent.

Hilary

--

OwenAus
11-05-2002, 10:52 PM
WooT! A bit more to this than at first meets the eye. :)

Thanks. And with this conquered, only sound remains to be explored - until the all-singing all-dancing release of KoolMoves MX. :D

necromanthus
11-05-2002, 10:54 PM
for Hilary...
PREPELIX works just perfect for a long time ago with:
loadVariables("getscore.php","GET"); and
loadVariables("sendscore.php","POST");
And Hilary,pay attention:
both lines are sending REQUESTS to the dynamic page !
NO need to specify the target !
the target is the movie who send this request (the ROOT or a child-movie).
:mrpimp:

bridelh
11-06-2002, 01:57 AM
And Hilary,pay attention:
both lines are sending REQUESTS to the dynamic page !
NO need to specify the target !
the target is the movie who send this request (the ROOT or a child-movie).

I know this Necro, but I just wanted to make it clear for anyone else that GET and POST will do both but in different ways.

I also know that you don't need the Target, but I wanted to let people know that if you do use a target you need to specify it as a string....thats all ..... Just trying to clarify things for everyones benefit.

Hilary

--

necromanthus
11-06-2002, 06:05 PM
Hilary is talking from AS dictionary (uncompleted & buggy document,btw).
However,he's right.
But I'm talking from "real life".
To see that I'm right,just do the following:
1) Use KM v3.5 (or v3.6) and make a 1 keyframe movie (no tweens).
2) Inside this movie,make a child-movie called "names".
3) Inside the "names" movie insert 2 dynamic texts called "name1" and "name2".
4) Create a text file called "players.txt" with this line:
name1=OWEN&name2=AUS&name3=HILARY
(the text file must be in the same directory with the SWF file)
5) For the "names" movie add this script:
onClipEvent(load){
this.loadVariables("players.txt","GET");
stop();
}
6) Run the movie and see the "amazing" result !

question: where is the TARGET inside the "loadVariables" command ?
ha ha ha
:mrpimp:

bridelh
11-06-2002, 06:53 PM
There are two specific loadVariables functions.
One is a global FUNCTION:
loadVariables ("url",level/"target"[,variables])


The other is a movieClip METHOD:
mc.loadVariables("url", variables);

You are using the MovieClip Method which does not require a target because the target is the mc.

The global function requires a target....


Hilary

--

necromanthus
11-06-2002, 07:15 PM
I know that.
But why don't you said so from beginning ?
OwenAus was searching for this solution (the best,btw).
p.s.
Also don't forget that is working for the ROOT too !
Hilary,
I try here to put a peon at work (chopping a tree).
Huge amount of script and hundreds of graphic keyframes.
So...best regards and "see" you soon !
Remus
:p

OwenAus
11-06-2002, 07:25 PM
hehe. You guys are real gurus. :)

My intention is to pass some variables from a movie swf contained in page A to a script page B. I was intending to use GET (asp collects using request.querystring).

I can use a workaround with JS, eg javascript: popwin(args); with the popwin function that loads the window in the javascript of the containing page. Inelegant perhaps, but a solution.

I think I will do it that way whilst I try to work out what everything you have written actually means - I think (actually I know) I lost the plot somewhere. :p

I thought getUrl called a new page/document and loadvariables collected data for a movie from a datasource, eg a file?

necromanthus
11-06-2002, 07:43 PM
Dear OWEN,
loadVariables can receive/send variables from/to a dynamic page (CGI,PHP,ASP,etc)
Use _root.loadVariables("pagename.asp","POST"); to send some variables to your page.
p.s.
What's new about your girl ?
ha ha ha

johnie
11-07-2002, 05:02 PM
Actually the Javscript for this isn't generated in the SWF... Its actually on the web page. Unless you have helper frames it is a very bad Kludge to pass a new values directly from Flash Via Javascript directly from the SWF-Trust me on that one- I experimented months with it back before KM 2.7X.

The best way is to set up a Javscript on the recieving pages that looks for the appended values and then re-writes the HTML to Display Flash with regular HTML Value passing.

This is the code to do this http://www.polar-lights.com/fla/url.html

Using the method you simply use Get URL- As that is all you are doing is appending the Variables to the URL.

I've already posted an example of this BTW...

My Card example generates a URL with the appended values and Emails it to the Sender then when the Sender Clicks on the URL it passes the values back into the SWF using this method.

The Example Again... http://jsnider.0catch.com/card.html

OwenAus
11-07-2002, 07:50 PM
Hi guys,

Thanks, this thread has been really informative!

Both of my brain cells are now buzzing around excitedly. Hopefully they will settle down soon and start to digest all the information.

:)