Can You Still Pass Vars Through A Query String?
I'm trying to pass variables in through a query string appended to my url like so,
http://www.mydomain.com?myVar1=value1&myVar2=value2
From what i've read am i correct in thinking that i should be able to access these properties through 'this.loaderinfo.parameters'?
I don't seem to be able to get this to work for some reason? I'm able to get it tworking when passing in Flashvars through my html and then accessing them through the loaderinfo.parameters object, but not through a query string? Anyone got any ideas? Should this be possible?
Also i was wondering it there's any foreseeable issue passing in values both through Flashvars and a query string or should the loaderinfo.parameters object be populated with all the values?
cheers.
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 08-11-2008, 04:23 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Pass Variable Via Query String
i'll try to explain this the best I can.
I have a flash header that I need included in a shopping cart site that will have nav and the header descriptions for each site page. It has 2 navigations, top and side. Side nav only controls the flash itself to display stuff that won't be in the rest of the site, like an about us section. The top nav controls what page the shopping cart goes to AND the flash header display. For example, when I click on my top nav button 'systems' I need it to go the 'systems page' and change the flash header to display info about the systems. Now when the 'system' button is clicked the page changes to the 'systems' page but since its a header the flash just pops up on the new page reloaded to its original state. So how would I fix this? could flash pass a variable via the query string to determine what frame it should be on when going to a new page?
[F8] Dynamic Query String & Pass Variables To And Fro Php
Hi!
I have a webpage that needs to load a variable from query string and then the swf sends this variable to php to search it in databse and return respective entries.
My trouble is the page where the swf is placed in an HTML page whose URL is something like this : http://www.mysite.com/variableName=dynamicValue
Actually this is a link thats sent in an email. When clicked it loads this page. Here http://www.mysite.com/variableName= is static, but dynamicValue is a 15 letter randomly generated code.
I wanted to know is it possible to pass this dynamic value of the variable into my swf. If so, how to do that.
My second query is I wanted to send this variable from flash to a php file which will search it in a database and return related entries to flash. Now, I've done this seperately, that is, send variables to php by post method and get variables from php by get method. But I dont know how to do these two operations in one single call.
I am using Flash 8, though i'm exporting the movie to flash 6 player compatible and actionscript 2. Any help is welcome. Please let me have the feedback.
thanks
ashwin.
Pass Variables Into Flash Via Query String
I used to do this all the time to pass in simple values to Flash but with Flash 8 it doesn't seem to be working properly. I've stripped it down to it's most basic and it still doesn't seem to be working. I've got a test page here:
http://icglink.com/flashtest/
The top set uses the standard object/embed method, the left one passing in a 0, the right passing in a 1. Both use the variable named previousvisitor.
The bottom set use the same variable and value structure, but with the swfobject javascript call instead of the object/embed method.
I've got a case statement on the 5th frame that tests the incoming variable and directs the playhead to one frame label or another. The idea is that if someone has come to the site for the first time, they'll get to see a video. If not, they'll get a still frame with a "play video" button.
I'm also including a link to the FLA (version 8 remember).
http://icglink.com/flashtest/cookieTEST.fla
So does anyone have ANY idea why this isn't working correctly? I really need to get this working and it should be dead simple.
Query String Vs Flash Vars?
Hi -
Im building an mp3 player to load and play various single mp3 files for a website. i want to control each instance of the player with variables in the param name and embed sections of the html code... (ie.. load a unique title, mp3 url into each instance of the movie on a given page)
im new to this side of flash... ive googled for info and found a few things but not enough to implement what im trying to do.... would be cool if some one could sort me out on this cheers-
John
Query String Vs Flash Vars?
Hi -
Im building an mp3 player to load and play various single mp3 files for a website. i want to control each instance of the player with variables in the param name and embed sections of the html code... (ie.. load a unique title, mp3 url into each instance of the movie on a given page)
im new to this side of flash... ive googled for info and found a few things but not enough to implement what im trying to do.... would be cool if some one could sort me out on this cheers-
John
AS3 - How Can I Pass Vars Without Using URL String?
Hello,
I have one AS3 swf (loader.swf) that needs to load a second AS3 file (main.swf).
loader.swf has some variables that I would like to pass to main.swf.
I don't want to append the variables in the URL string, because then main.swf won't be cached properly.
In AS2 I could use FlashVars, which passes the variables without adding them to the URL string.
How can I do this in AS3?
Load Vars From.asp Based On A Query String
In a certain part of my movie I want to load variables from an asp file based on a query string. I find out that loadVariablesNum("myAsp.asp?id=1") doesn't work.
How do I do it?
myAsp.asp generates specific results based on an ID...
Thanks!
Class ► ASP Format Query String Vars
I recently had a flash project that required me to get query string variables and found it cumbersome, however i found a query string class here on the forums originally created by MichaelxxOA. http://www.actionscript.org/forums/s...31&postcount=2
I reqrote it and structured it to act like Request.QueryString() familiar to those that have worked with asp and aspx.
I also added some functionality to datatype the variables as well. For example, and numeric variable value will become a number once it is pulled in and a true or false will be converted to Boolean.
Anyway, I figured I would share...................
ActionScript Code:
//External Interface Class
import flash.external.ExternalInterface;
class Request
{
//STATIC PROPERTIES
//----------------------------------------------
//Switch to Load Vars if they haven't already been loaded
private static var hasLoaded:Boolean = false;
//Define Javascript Function
private static var getURLFunction:String = "function get_url(){return window.location.toString();}";
//Array to store values once they have been loaded.
private static var values:Array = new Array();
//CONSTRUCTOR
//----------------------------------------------
public function Request(){}
//PUBLIC STATIC METHODS
//----------------------------------------------
//--Query String
public static function QueryString(varName:String)
{
//Pull Valuse From Query String if you havent already.
if(!hasLoaded)
{
hasLoaded = true;
getValueArray();
}
return values[varName];
}
//--Get Values From Query String
private static function getValueArray():Void
{
trace("]> Loading Variables from Query String.");
var o:Array = new Array();
//Call Javascript Function
o = ExternalInterface.call(getURLFunction).split("?")[1].split("&");
for(var i:Number = 0; i < o.length; i ++)
{
var tempName:String = o[i].split("=")[0];
var tempValue:String = o[i].split("=")[1];
trace(" - " + tempName + " = " + tempValue);
if(!isNaN(Number(tempValue)))
{
//Datatype value as a Number
values[tempName] = Number(tempValue);
}else if(tempValue.toLowerCase() == "true" || tempValue.toLowerCase() == "false"){
//DataType value as a Boolean
values[tempName] = Boolean(tempValue);
}else{
values[tempName] = tempValue;
}
}
}
}
You would use it like this....
ActionScript Code:
var varFromString = Request.QueryString("varName");
Pass Frame Variable Via Query String Bettween 2 Swf In 2 Different Html Files
Hello, I have an swf movie embedded in an HTML. One of the links calls to another HTML with a different SWF embedded. I need to link back to the original HTML/SWF but to a certain frame within that SWF using HTTP query. I understand that I can do this with Javascript and by parsing the HTTP query. Can anyone direct me to a tutorial or give me some help?
Thank you
maknenoiz
Error 2101: The String Passed To UrlVariables.decode() Must Be Url-encoded Query String
I am trying to make a flash contact form which will submit the firstname, lastname, email and comments to an asp.net page.
I am have having the following error:
Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs
I am using the following action script code as pasted below. This action script is communicating with an asp.net file to send the email out. In the end it responds back with response=passed or failed.
I have already spent around 3 hours figuring it out.. and looking through the internet for resolution but no luck. Any help will be appreciated.
stop();
submit_btn.addEventListener(MouseEvent.CLICK, submit);
function submit(e:MouseEvent):void
{
var variables:URLVariables = new URLVariables();
variables.firstname = firstname_txt.text;
variables.lastname = lastname_txt.text;
variables.email = email_txt.text;
variables.comments2 = comments_txt.text;
var req:URLRequest = new URLRequest(”emailacount.aspx”);
req.method = URLRequestMethod.POST;
req.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, sent);
loader.addEventListener(IOErrorEvent.IO_ERROR, error);
loader.load(req);
status_txt.text = “Sending…”;
}
function sent(e:Event):void
{
status_txt.text = “Your email has been sent.”;
firstname_txt.text = “”;
lastname_txt.text = “”;
email_txt.text = “”;
comments_txt.text = “”;
}
function error(e:IOErrorEvent):void
{
status_txt.text = “There was an error. Please try again later.”;
}
and the following asp.net code:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Net.Mail" %>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Try
Dim fromEmailAddress = "paul@lancierinc.com"
Dim toEmailAddress = "rizwandar@gmail.com"
Dim firstName = Request.QueryString("firstname_txt")
Dim lastName = Request.QueryString("lastname_txt")
Dim comments = Request.QueryString("comments_txt")
Dim userEmail = Request.QueryString("email_txt")
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress(fromEmailAddress)
mail.To.Add(toEmailAddress)
'set the content
mail.Subject = "Email from" & firstName & " " & lastName
mail.IsBodyHtml = True
Dim strBody As String = "<b>Email from</b>" & " " & firstName & " " & lastName & "<br><b>Email Address:</b> " & userEmail & "<br><b>Comments:</b> " & comments
mail.Body = strBody
'send the message
Dim smtp As New SmtpClient("mail.lancierinc.com")
smtp.Send(mail)
Dim urltoencodestring2 = "response=passed&err=0"
'Response.Write(urltoencodestring2)
Catch smtpEx As SmtpException
'A problem occurred when sending the email message
'ClientScript.RegisterStartupScript(Me.GetType(), "OhCrap", String.Format("alert('There was a problem in sending the email: {0}');", smtpEx.Message.Replace("'", "'")), True)
Response.Write(smtpEx.Message)
Dim urltoencodestring = "response=failed&err=1"
'Response.Write(urltoencodestring)
Catch generalEx As Exception
'Some other problem occurred
'ClientScript.RegisterStartupScript(Me.GetType(), "OhCrap", String.Format("alert('There was a general problem: {0}');", generalEx.Message.Replace("'", "'")), True)
Dim urltoencodestring3 = "response=failed&err=1"
'Response.Write(urltoencodestring3)
End Try
End Sub
</script>
String Passed To URLVariables.decode() Must Be A URL-encoded Query String...
I really don't understand why this won't work? I've made a test which sends some POST data to a script on my page which works fine. But why does not this work?
Code:
var mapsize = _cmap.fieldx.toString(16) + _cmap.fieldy.toString(16);
var names = "Zomis_AI6";
var description = "descr";
var result = "gameresult";
var upldata: String = "mapsize="+mapsize+"&names="+names+"&description="+description+"&result="+result;
trace(upldata);
var variables:URLVariables = new URLVariables(upldata);
var request2:URLRequest = new URLRequest();
request2.url = "http://www.zomis.net/record.php";
request2.method = URLRequestMethod.POST;
request2.data = variables;
var loader2:URLLoader = new URLLoader();
loader2.dataFormat = URLLoaderDataFormat.VARIABLES;
loader2.addEventListener(Event.COMPLETE, uploadcomplete);
try {
loader2.load(request2);
trace("Loaded");
}
catch (error:Error) {
trace("Unable to load URL");
}
Tracing gets:
Code:
mapsize=1010&names=Zomis_AI6&description=descr&result=gameresult
Loaded
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables$iinit()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()
Pass A String, Return Object With Name String
I feel like this should be pretty easy, but I 'm not quite sure how to do this...
I've got a string that is the name of a movieclip which is on the stage. I'd like to write a function which I can pass that string and have it return the object which has the instance name of that string.
Any hints?
Thanks.
John
AMFPHP - Can't Pass Variable Into SQL Query
Hey guys,
Yeah, I know there's a Flash Remoting forum, but the last post there is months old and gathering dust. So here goes...
Just getting to grips with AMFPHP but I've run into an annoying problem tat I can't seem to work out.
OK, this works, no problem:
PHP Code:
/**
*queries Moodle FlashMod DB table only if logged on as user
*@returns recordset (array) of Word Search activity records
*/
public function get_wordsearch_records()
{
return mysql_query('SELECT * FROM `mdl_flashmod_results` WHERE `swfname` = 'Word Search' ');
}
But this just returns false:
PHP Code:
/**
*queries Moodle FlashMod DB table only if logged on as user
*@returns recordset (array) of input activity records
*/
public function get_wordsearch_records($activity_type)
{
return mysql_query('SELECT * FROM `mdl_flashmod_results` WHERE `swfname` = $activity_type ');
}
I've also tried all sorts of other combinations of quotes, re-setting the variable in the PHP file, etc. but I always get false unless I hard code the SQL query.
Any help?
Pass Variable To Swf To Query Database
I am trying to create a page that lets a user preview mp3’s. The mp3s file locations are stored in a database and there is an <cfoutput query > that takes say the mp3 file ids and places it in the swf file. The swf file trys to call the database and loads the file.
I am having major difficulty as I am not an actionscript programmer.
Attach Code
HTML PAGE:
<cfoutput query =”myQueryName”>
<object …>
<param name="movie" value="mp3player.swf?fileID=#myQueryName.fileIDnumber#" />
…othercode.
</object>
</cfoutput>
ActionScriptPage:
var musicPlays:Boolean = false;
var theSound:String = LoadVars(URL.s);
var loopTune:Sound = new Sound();
loopTune.onLoad = function(success:Boolean) {
if (success) {
loopTune.start(0, 999);
musicPlays = true;
_root.musicPlayer.gotoAndStop("playing");
}
};
loopTune.loadSound("s", false);
musicPlayer.playStop.onPress = function ():Void {
if (musicPlays) {
this._parent.gotoAndStop("stopped");
loopTune.stop();
musicPlays = false;
} else {
this._parent.gotoAndStop("playing");
loopTune.start(0, 999);
musicPlays = true;
}
};
URL Query Vars Class
VERIFIED WORKING ON FIREFOX 1.8+, SAFARI 2.0+ & MSIE 6+
This may also work on older versions, however I have not verified them.
The Fix
- Any swf that uses ExternalInterface must be embedded into the code dynamically using javascript (i.e. SWFObject / http://blog.deconcept.com/swfobject) in order to be compatible with all three browsers.
- You are able to pass inline functions using Externalinterface.call, however in order to work the must be generic in order to work in Safari:
---- WORKS: ExternalInterface.call("function(){return true;}");
---- DOES NOT WORK: ExternalInterface.call("function getVariable(){return true;}");
Test URL
http://www.frozenflame.net/queryTest.htm?test=howdy
Below is the code to my request class based on MichaelxxOA's urlQuery class (http://www.actionscript.org/forums/s....php3?t=119839).
* Only calls ExternalInterface to execute the javascript once.
* Uses a single Static call for variable request // Request.QueryString("varName");
* Datatypes numbers, booleans and strings.
Request.as
ActionScript Code:
//External Interface Classimport flash.external.ExternalInterface;class com.Javascript.Request{ //STATIC PROPERTIES //---------------------------------------------- //Switch to Load Vars if they haven't already been loaded private static var hasLoaded:Boolean = false; //Define Javascript Function private static var getTheURL:String = "function(){return window.location.href.toString();}"; //Array to store values once they have been loaded. private static var values:Array = new Array(); //CONSTRUCTOR //---------------------------------------------- public function Request(){} //PUBLIC STATIC METHODS //---------------------------------------------- //--Query String public static function QueryString(varName:String) { //Pull Valuse From Query String if you havent already. if(!hasLoaded) { hasLoaded = true; getValueArray(); } return values[varName]; } //--Get Values From Query String private static function getValueArray():Void { trace("]> Loading Variables from Query String."); trace(" (" + getTheURL + ")"); trace("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="); var o:Array = new Array(); //Call Javascript Function //ExternalInterface.call("document.write",["<script>" + "
" + "<!--" + "
" + "function getTheURL()" + "
" + "{" + "
" + "return window.location.href.toString();" + "
" + "}" + "
" + "-->" + "
" + "</script>"]); o = ExternalInterface.call(getTheURL).split("?")[1].split("&"); for(var i:Number = 0; i < o.length; i ++) { var tempName:String = o[i].split("=")[0]; var tempValue:String = o[i].split("=")[1]; trace(" - " + tempName + " = " + tempValue); if(!isNaN(Number(tempValue))) { //Datatype value as a Number values[tempName] = Number(tempValue); }else if(tempValue.toLowerCase() == "true" || tempValue.toLowerCase() == "false"){ //DataType value as a Boolean values[tempName] = Boolean(tempValue); }else{ values[tempName] = tempValue; } } trace("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="); } }
Implementation:
ActionScript Code:
var pageID:String = Request.QueryString("pageID");
Hope this helps!
Original Thread: http://www.actionscript.org/forums/s...light=URLQuery
Only Pass Certain Vars
hi
I use getURL to call a .php script to which I pass on variables via POST. But I have really a lot of them in _root and I wonder if there is a way to only pass on some of the variables I choose.
Can I set variables "private"?
Any Suggestions are appreciated.
greets
andreas
How To Pass Vars
ok i added the flash meidaplayback component to play mp3's. it will load mp3 dynamicaly from the query strings like player.swf?path=test.mp3 so please can anyone teme how do i do this i name the instance "player" and added the action script to it :
on (load) {
_root.player.contentPath = path
}
Some thing Wrong? Please help me
Pass Vars To PHP
hey is it possible to pass a variable through to PHP and onto an email???
kinda like
Code:
var name_var = "myname";
var location_var = "where im at";
send_button.onRelease = function()
{
var formData:LoadVars = new LoadVars();
var formData.name = name_var;
var formData.location = location_var;
formData.sendAndLoad("http://www.mysite.com/contact_process.php",_blank,"POST");
formData.onLoad = function()
{
if(formData.message_sent == "ok")
{
gotoAndStop(2);
}
else
{
gotoAndStop(3);
}
}
}
PHP Code:
<?php// Send the message$mailfrom="<$_POST[email]>";$email=blah@mysite.com;$subject="order form ";Location:$_POST[location]<br><br>[name]$headers = "MIME-Version: 1.0
";$headers .= "Content-type: text/html; charset=iso-8859-1
";$headers .= "From: ". $mailfrom."
";mail($email,$subject,$data,$headers);echo "message_sent=ok";?>
I just threw this together from others.
I guess i might as well test it.
Quote:
$data
Where is this php variable set or is it global to all the data passed??
Can't Pass String To Nc.connect(string)
hey guys. fairly new to flash, but I've managed to throw together a player with info and tutorials from here and other places. I've got everything just how I want it save for one problem. I've got an XML file that I get the URL for my server from and also get the names of videos to populate a list. Here's the problem:
I can get the URL into a string in my program (it traces fine). However, when i try to pass that string in my nc.connect(string) it doesn't work. Everything loads fine, but when you click a video, it can't connect to it. If I manually enter the URL into the connect field like this: nc.connect("rtmp://url") it works fine.
So am I missing something? Why can it take the URL manually entered and not from a string?
Pass Vars From JavaScript
Does anyone know how to pass variables from JavaScript to flash without using fsCommand?
Or if anyone knows how to pass variables from JavaScript to ASP that would help me too!
Pass Vars With NavigateToURL()
I want to use navigateToURL() to go to a page but I also want to pass that page some POST vars, is this possible?
Thanks!
Pass PHP Vars To Flash
Hello all, Well I have been working on this for a while, I googled the hell out of it, and I cant seem to find what I am looking for. Can anyone help.
I have a PHP file that runs alone fine, When I ECHO them they display fine in the browser, but I cant seem to pass these to Flash. What I would like to do is pass each of these to there own Txt Box. I guess I just dont know how to convert what I ECHO to a var in flash so I can then put it in a dyn text box. Heres the PHP Code. Thanks. (and yes I have only attached the echo end of the code, I didnt include where PHP pulls the date from the DB - Figured it wasnt needed).
Attach Code
echo $jesey_22 = $jersey;
echo "<Br>";
echo $name_22 = $name;
echo "<Br>";
echo $team_22 = $team;
echo "<Br>";
echo $plates_22 = $plates1 + $plates2 + $plates3 + $plates4 + $plates5 + $plates6 + $plates7 + $plates8 + $plates9 + $plates10 + $plates11 + $plates12;
echo "<Br>";
echo $singles_22 = $S1 + $S2 + $S3 + $S4 + $S5 + $S6 + $S7 + $S8 + $S9 + $S10 + $S11 + $S12;
echo "<Br>";
echo $doubles_22 = $D1 + $D2 + $D3 + $D4 + $D5 + $D6 + $D7 + $D8 + $D9 + $D10 + $D11 + $D12;
echo "<Br>";
echo $triples_22 = $T1 + $T2 + $T3 + $T4 + $T5 + $T6 + $T7 + $T8 + $T9 + $T10 + $T11 + $T12;
echo "<Br>";
echo $homeRuns_22 = $HR1 + $HR2 + $HR3 + $HR4 + $HR5 + $HR6 + $HR7 + $HR8 + $HR9 + $HR10 + $HR11 + $HR12;
echo "<Br>";
echo $hits_22 = $hits1 + $hits2 + $hits3 + $hits4 + $hits5 + $hits6 + $hits7 + $hits8 + $hits9 + $hits10 + $hits11 + $hits12;
echo "<Br>";
echo $walks_22 = $BB1 + $BB2 + $BB3 + $BB4 + $BB5 + $BB6 + $BB7 + $BB8 + $BB9 + $BB10 + $BB11 + $BB12;
echo "<Br>";
echo $SF_22 = $SF1 + $SF2 + $SF3 + $SF4 + $SF5 + $SF6 + $SF7 + $SF8 + $SF9 + $SF10 + $SF11 + $SF12;
echo "<Br>";
echo $ER_22 = $ER1 + $ER2 + $ER3 + $ER4 + $ER5 + $ER6 + $ER7 + $ER8 + $ER9 + $ER10 + $ER11 + $ER12;
echo "<Br>";
echo $RBI_22 = $RBI1 + $RBI2 + $RBI3 + $RBI4 + $RBI5 + $RBI6 + $RBI7 + $RBI8 + $RBI9 + $RBI10 + $RBI11 + $RBI12;
echo "<Br>";
echo $runs_22 = $runs1 + $runs2 + $runs3 + $runs4 + $runs5 + $runs6 + $runs7 + $runs8 + $runs9 + $runs10 + $runs11 + $runs12;
echo "<Br>";
echo $AVG_22 = $AVG1 + $AVG2 + $AVG3 + $AVG4 + $AVG5 + $AVG6 + $AVG7 + $AVG8 + $AVG9 + $AVG10 + $AVG11 + $AVG12;
echo "<Br>";
echo $OBP_22 = $OBP1 + $OBP2 + $OBP3 + $OBP4 + $OBP5 + $OBP6 + $OBP7 + $OBP8 + $OBP9 + $OBP10 + $OBP11 + $OBP12;
echo "<Br>";
echo $atBats_22 = $atBats1 + $atBats2 + $atBats3 + $atBats4 + $atBats5 + $atBats6 + $atBats7 + $atBats8 + $atBats9 + $atBats10 + $atBats11 + $atBats12;
Class > Query Vars To Flash - ASP Style
I recently had a flash project that required me to get query string variables and found it cumbersome, however i found a query string class here on the forums originally created by MichaelxxOA over at actionscript.org. http://www.actionscript.org/forums/s...31&postcount=2
I reqrote it and structured it to act like Request.QueryString() familiar to those that have worked with asp and aspx.
I also added some functionality to datatype the variables as well. For example, and numeric variable value will become a number once it is pulled in and a true or false will be converted to Boolean.
Anyway, I figured I would share...................
ActionScript Code:
//External Interface Classimport flash.external.ExternalInterface;class Request{ //STATIC PROPERTIES //---------------------------------------------- //Switch to Load Vars if they haven't already been loaded private static var hasLoaded:Boolean = false; //Define Javascript Function private static var getURLFunction:String = "function get_url(){return window.location.toString();}"; //Array to store values once they have been loaded. private static var values:Array = new Array(); //CONSTRUCTOR //---------------------------------------------- public function Request(){} //PUBLIC STATIC METHODS //---------------------------------------------- //--Query String public static function QueryString(varName:String) { //Pull Valuse From Query String if you havent already. if(!hasLoaded) { hasLoaded = true; getValueArray(); } return values[varName]; } //--Get Values From Query String private static function getValueArray():Void { trace("]> Loading Variables from Query String."); var o:Array = new Array(); //Call Javascript Function o = ExternalInterface.call(getURLFunction).split("?")[1].split("&"); for(var i:Number = 0; i < o.length; i ++) { var tempName:String = o[i].split("=")[0]; var tempValue:String = o[i].split("=")[1]; trace(" - " + tempName + " = " + tempValue); if(!isNaN(Number(tempValue))) { //Datatype value as a Number values[tempName] = Number(tempValue); }else if(tempValue.toLowerCase() == "true" || tempValue.toLowerCase() == "false"){ //DataType value as a Boolean values[tempName] = Boolean(tempValue); }else{ values[tempName] = tempValue; } } } }
This is how you would use it
ActionScript Code:
var qsVar = Request.QueryString("varName");
Use Form To Query MySQL DB, Then Pass Data To Flash File?
Say I have a form (form.html) that asks for a login name and password.
It then queries a mysql db via php (login.php) and if there's a match, then the user is taken to a page (welcome.php) with an embedded flash file (hello.swf) in which it says Hello [username].
If I could get just that far, it would be great. I'm getting confused on a number of things but most notably what kind of text box I'd use in the flash file (dynamic or input) and what method to use pass the variable. I mean if I were doing this as a regular php page (Hello [username]) then I know how to print the name in the new page but I'm clueless when flash comes into play
How To Pass Vars From Movie To Mc_parameters?
as in topic:
i have my button with effects made on text. I know how to pass the args to flash movie from html. but how to pass them from movie to mc parameters?
OR
how to evaluate variables in component, movie parameters?
Pass Multi Vars In Geturl ?
can somebody please tell me how to pass multiple vars in a get url string
for example
on(release){
getURL("/page.php?mode=1&u="+_root.u, "_self");
}
works but
on(release){
getURL("/page.php?mode=1&u="+_root.u"&sid="+_root.sid, "_self");
}
doesnt, it gives me errors when im trying to publish
all i need to do is add +_root.u and +_root.sid to the query string
the data is bought in via the embed tag by the way
PLEASE Help Me Pass Vars From One Flash Movie To Another
I'd like to pass a variable from one flash movie to another.
can i do that without using and side scripting language?
i think flash can output a text file somehow, but i don't know how and i'm not sure about that.
if some scripting is necessary please give me an example. this is pretty urgent
thanks
Way To Pass Browser Vars To Flash W/o Javascript ?
generating a php page, i'd like to pass username and password to flash movie (which then talks to php) the javascript that i got off of macromedia's technotes, doesn't well.. work. not in all browsers on all platforms that flah 6 supports anyway. here's what it suggests for non ie browsers, doesn't work in mozilla:
Code:
<script language="javascript">
window.movieName.document.SetVariable("username","<? echo $username; ?>");
window.movieName.document.SetVariable("password","<? echo $password; ?>");
isn't there some neat way to pass username and password (NOT VIA GET) to flash player? some kinda PARAM's or something... if not, does anybody know a good place with an >in depth< reference to passing js vars to flash? that will work in mozilla and stuff on macs.
dross
Pass Vars From HTML To Flash NOT WORKING
Hi there!
Hi have an HTML file (actually is a php file) similar do the following code (I have to mess out some code or it won't show in the post. No opening tags):
Code:
//START CODE
OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="780" HEIGHT="440" id="index2.swf" ALIGN="">
PARAM NAME="FlashVars" value="area=<?=$area?>">
PARAM NAME="movie" VALUE="index2.swf?area=<?=$area?>"> <PARAM NAME=loop VALUE=false> <PARAM NAME=menu VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>
EMBED src="index2.swf?area=<?=$area?>" FlashVars="area=<?=$area?>" loop=false menu=false quality=high bgcolor=#FFFFFF WIDTH="780" HEIGHT="440" NAME="index2.swf" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT>
//END CODE
Note all the area=<?=area?> tags. This is where I have tried to pass the var area to index2.swf. All code came from books or posts from this and other actionscript foruns.
Following is the code inside the fla file to the index2.swf. The code that should "process" the var area is in the first frame.
Code:
//STARTING CODE TO ANALYSE AREA VAR
switch (area) {
case "1" :
_root.ilustra.gotoAndPlay ("galinha");
_root.gotoAndPlay("menu1");
area = "";
break;
case "4" :
_root.ilustra.gotoAndPlay ("galinha");
_root.gotoAndPlay("menu4");
area = "";
break;
case "2" :
_root.ilustra.gotoAndPlay ("galinha");
_root.gotoAndPlay("menu2");
area = "";
break;
case "7" :
_root.ilustra.gotoAndPlay ("galinha");
_root.gotoAndStop("menu7");
area = "";
break;
case "3" :
_root.ilustra.gotoAndPlay ("galinha");
_root.gotoAndPlay("menu3");
area = "";
break;
case "5" :
_root.ilustra.gotoAndPlay ("galinha");
_root.gotoAndPlay("menu5");
area = "";
break;
default:
loadMovieNum("destaque.swf", 1);
_root.ilustra.gotoAndPlay ("ilus");
_root.gotoAndStop("inicio");
area = "";
break;
}
//END CODE TO ANALYSE AREA VAR
When I run the swf all goes well, every button works, every MC works, etc... When I try to jump to a certain frame uusing the var area. It does not work at all.
I need urgent help on this one! Any ideas?
Pass One Movies _root Vars To Its Parent ?
what is the syntax for saying "this swf's _root level" does: _top.varname or _parent.varname do this? when i do _root.varname then the vars get jacked when i try to load the movie into another one because the other movie thinks it's _root is _root ??
New 'Secured' Server = Vars Wont Pass?
My company recently upgraded our web server to a 'secured' server with a SSL certificate, and I found that our old AS3 Flash / PHP email form wont pass variables.
The attached code is the basics of the var URL passing.
Is there a reason it no longer works? Maybe a security issue? :confused:
Attach Code
var req:URLRequest = new URLRequest("mailer.php");
var vars:URLVariables = new URLVariables();
var loader:URLLoader = new URLLoader();
vars.name = name_box.text;
req.method = URLRequestMethod.POST;
req.data = vars;
AS2 - Pass Embedded Vars And Create An Array
I am using swfobject to pass some image urls to flash, theses can vary from one to several images. Eg:
Code:
var so = new SWFObject("gallery.swf", "gallery", "800", "600", "1", "#000000");
so.addVariable("image0","image1.jpg");
so.addVariable("image1","image2.jpg");
so.addVariable("image1","image3.jpg");
How can I have flash read them and create an array of objects from them, I have tried but just can't get my head around it
Code:
var s = 0;
_global.imageArray = new Array();
while (newimage != undefined) {
newimage = "_root.image"+[s];
if(newimage != undefined){
imageData = new Object;
imageData.path = newimage;
s++
}
}
Flash Fails To Parse PHP Vars When Retrieved By MySQL Query.
FACTS
1. I'm using PHP to query a mySQL database.
2. I'm using the LoadVars class to retrieve those variables from PHP into Flash.
3. I'm using Flash 8, PHP 5, and MySQL 5.
PROBLEM:
Flash will not parse the PHP page if I include a MySQL
query on that page. The variables are passed, but Flash
doesn't read them.
For example, this code below works fine on its own:
Code:
$tagline = " some word";
echo ("&tagline=$tagline");
But when I add the mySQL query, Flash fails to
pickup the variables even though they show up as URL
encoded in the source of the output html page.
Code:
db_connect();
$sql = 'SELECT
tagline
FROM
some_table
ORDER BY RAND() LIMIT 1';
if( ($result = mysql_query($sql)) === FALSE )
{
echo mysql_error();
} else
while ($row = mysql_fetch_assoc($result))
extract($row);
echo ("&tagline=$tagline");
This is the actionscript I'm using:
Code:
tagData = new LoadVars();
tagData.onLoad = function(write){
text = this.tagline;
}
tagData.load("variables.php");
Can anyone think of a workaround for this?
Query String
in the src parameter in my html file I've got
http://www.myDomain.com/myMovie.swf?var=val
What is the best way to extract the values in this query string...I do have a method, but it is longer than i think it needs to be...any ideas?
Query String
How to read Query String for example:
test.swf?test=1&id=23&line=23,
how to read the values of test, id and line inside the flash move in script?
Query String
I want to pass variables into a flash movie using a query string... How can I do it?
i.e myPage.htm?id=4
I want to be able to get the id variable from the query string into flash
String Query
how can i change the font color using string query?
so other people can use the file with their own text and font color.
sample:
myflash.swf?text=Hello World!&fontcolor=0xFF0000
i also want to load a pic using string query,
sample
myflash.swf?text=Hello World!&fontcolor=0xFF0000&image=mypic
thanks, hope you can help me.
How To Get The Query String?
Can somebody tell me how to get the query string? this._url always returns the value at compile time, which of course is my local file:///....myMovie.swf. I'd love to get everything after the question mark, e.g.
mydomain.com?test=test
Any ideas?
<edit>I know that you have to try this from a webserver, in which case it does the same thing, except http://... rather than file:///...</edit>
<edit>Is the only way to do this via javascript?</edit>
URL Query String
How can I get the document URL and query into a variable in actionscript?
I tired using the method below, but this does not work in IE.
http://actionscript.org/forums/showthread.php3?p=561688
Here is an example you can try in both Firefox and IE.
http://hombrefeo.com/fla/?foo1=bar1&foo2=bar2
AS2:: String Query
I have a string that looks something like this:
TestString - "1,0,0,0,0,0,1,0"
I need to create some sort of loop (I think) to search though the string and look to see if it contains any 1's.
How was I go about this?
Any help would be great thanks.
Query String ?
a client is asking me for this:
is this possible?
We would like to present our visitor with a different scene within the
movie depending on the location. For example:
http://www.xxx.com/links.asp?cat=52&Dest=Malta
Would load a scene with a backround picture of Malta
http://www.xxx.com/links.asp?cat=44&Dest=Greece
Would load a scene with a backround picture of Greece
The image file is located in the root and is called greece.jpg
If no picture is found then a default picture is displayed.
In/Out Query String
I am working on parsing a query string from an html doc to flash. It comes into flash but won't come back out to the link I have. I don't know if what I'm trying to do is possible or if I need to use another method. I can't server side .
Thank you
here are the files : http://www.joshspoon.com/js_queryString.rar
Query String With %D8
Dear everybody
I have changed from Flash 5 to Flash MX. In Flash 5 it was possible to call a flash movie with a query string containing the danish letters , and , which all have numbers beyond 127.
The same query strings write nonsense in my flash movie text fields.
I have also tried to use FlashVars as documented on
http://www.macromedia.com/flash/ts/...s/flashvars.htm
but it gives the same error.
Have I forgotten something? How can I transfer letters like %D8 to the flash 6 player?
Torben
Pulling From A Query String
alright I've fidgured some things out and this is what I am currently doing.
I am attempting to load variables placed into the query sting (url) into a dynamic text field with the same variable name. Currently it is effecting the variable but it is not putting the values into the text field
Here is my code:
loadVariablesNum ("void", 0, "POST");
to = "0";
from = "0";
I have attempted sending the variables using "GET" as well as "Don't send" with the same results
the page is
http://www.familyties.com/dogDaystes...=josh&from=bob
If you remove the "to" and "from" on the query string the default value of "0" appears in each variable
What am I doing wrong?
Sending Query String To ASP
I've tried to send a query string to an ASP page using loadVariablesNum as belows:
loadVariablesNum ("http://www.domain.com/test.asp?type=1", 0, "GET");
But, I can only see that Request("type") from ASP return null value. What's is the problem?
Thank you for your help.
Sending Query String
Hi all!!
I am using Flash 5.. doing a CD presentation in flash projector or exe..
on click of a link I want to send a query string:
pagename.html?Firstname=Joe
but when it opens the page I am not getting "?Firstname=Joe" in the addressbar of the browser..
pls help..
Load Swf Into Swf (specifying In Query String)
Hi I have the following problem (I am not too experiences with flash AS, but trying to learn).
Basically I have the following model:
player.swf (interface that looks like winamp for instance)
song01.swf (swf with imported mp3)
What ends up happening is song01.swf is loaded into player swf. The way it works right now is I have to hardcode the name of the song to load into each player.swf. But what I'd like to do is to specity which song I want to add in a query string and player.swf will pick it up. For instance:
www.mysite.dom/player.php?song=song01.swf
then player.swf in player.php will pick up the variable song01.swf and laod it into itself.
Can anyone give a quick hint? Thanks much guys.
And lastly, I am doing it all in Flash 5.
Vladislav Kulchitski
GetURL With Query String And Asp
kay. i've got a variable in my asp page keeping track of user preferences. i'm making a link graphic in flash 5 that needs to grab this variable, and redirect to another page within the site... so, in plain jane asp, the link goes:
response.write "<a href=""description.asp?" & strQSMin & "&pid=90210"">"
easy enough, but when i try the matching string in actionscript:
on (release) {
getURL ("description.asp" & strQSMin & "&pid=90210", "", "GET");
}
it's a no go...
i've tried a dozen variations here, none of which have resolved anything.
any hints as to what's up here?
cheers
staceass
|