May 21, 2012, 11:35:16 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Prowlie Welcome back! The site migration is complete and normal service resumed.
Advanced search
Pages: [1]   Go Down
Print
Author Topic: Using _Post Data in ActionScript  (Read 1000 times)
0 Members and 2 Guests are viewing this topic.
BigAmp
Fledgling
*
Offline Offline

Gender: Male
Posts: 1



WWW
« on: January 21, 2009, 08:55:29 AM »

Hey All,

Hope someone can help me with this. I have some data sent between web pages via the POST method and I need to know how to read this data in ActionScript.

Example of what I am trying to do. If the POST value of "profile" is equal to my name 'BigAmp' then goToAndPlay .....

Thanks for help!

BA
Logged
Vector
Resident Actionscript Guru
Assistant Admin
Heroic
****
Offline Offline

Gender: Male
Posts: 3803


~ Programmer | National Laser Tag Player | Bent ~


WWW
« Reply #1 on: January 22, 2009, 05:24:40 PM »

Judging from what you've written, I'm guessing that you have a form on one page, and a flash file on your next page.
Unfortunately there isn't a way to directly access information regarding the current webpage that your flash document is being displayed on. However, with a couple of inbetweeners you can do it.

Firstly, you need to use GET instead of POST. Javascript can access GET variables as they are part of the URL, but POST variables are not accessible, as they are sent to the server, but not sent back to whoever is viewing the page.

What you will need to do is grab these get variables using javascript, and then use javascript to load the swf file into your webpage.

Code:
// This is javascript to grab GET variables
// Thanks to http://keithnorm.com/2008/12/30/parse-query-string-into-associative-array-with-javascript/

function parseQuery() {
var queryAsAssoc = new Array();
var queryString = unescape(top.location.search.substring(1));
var keyValues = queryString.split(/\&/);
for (var i in keyValues) {
var key = keyValues[i].split(/\=/);
queryAsAssoc[keyValues[0]] = keyValues[1];
}
return queryAsAssoc;
}

// Usage: variables = praseQuery();
//             alert( variables[ 'profile' ] );    // will show 'BigAmp' in a message box

So you chuck something that uses that in your <body onload="......."> tag. You use those variables to construct your flash code.

So before javascript tinkers, it will look something like
Code:
<object width="550" height="400">
    <param name="movie" value="somefilename.swf" />
    <embed src="somefilename.swf" width="550" height="400" />
    </embed>
</object>

after javascript tinkers, it should look like
Code:
<object width="550" height="400">
    <param name="movie" value="somefilename.swf" />
    <param name="profile" value="BigAmp" />
    <embed src="somefilename.swf" width="550" height="400" profile="BigAmp" />
    </embed>
</object>

Notice that you have to add the information twice - one to handle internet explorer, and the other to handle every other browser on the planet.

If you need more help just yell. Cheers Smiley
Logged

~Vector
Brackenwood
   

 Logged
Pages: [1]   Go Up
Print
Jump to:  

Theme by Pieter, based on Black Rain by Crip Powered by SMF 1.1.16 | SMF © 2011, Simple Machines XHTML | CSS

Page created in 0.053 seconds with 24 queries.