all groups > flash data integration > april 2006 >
You're in the

flash data integration

group:

Passing a variable to asp


Re: Passing a variable to asp Motion Maker
4/17/2006 10:50:27 PM
flash data integration:

var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
trace (" result_lv.onLoad - success:" + success);
if (success) {
trace( result_lv.writing)
trace (" result_lv.onLoad - result_lv.writing:" +
result_lv.writing);

} else {
trace("was not able to connect to server") }
};
var send_lv:LoadVars = new LoadVars();
//Add the Post variables to send_lv here.
send_lv.namefirst = name_ti.text;
send_lv.sendAndLoad("http://81.97.3.2/cart1/cactushop5_1/employee2.asp",
result_lv, "POST");

-- Lon Hosfordwww.lonhosford.comMay many happy bits flow your way!
[quoted text, click to view]

I cannot work out how to get the variable namefirst from flash to the asp I
use :

loadVariablesNum("http://81.97.3.2/cart1/cactushop5_1/employee2.asp", 0,
"POST");

The variable namefirst is in a dynamic textbox

The asp is as follows:



<%@Language="VBScript"%>

<%
Dim cn
Dim cmd
Dim rs
Dim cont

Set cn = Server.CreateObject("ADODB.Connection")

cn.ConnectionString = "driver={MySQL ODBC 3.51
Driver};server=myurl;uid=root;pwd=XXXX;database=test;OPTION=3"

cn.Open



Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.CommandType = 1
namefirst1 = namefirst
'Response.Write "NameFirst"
cmd.CommandText = "Insert into Sample (namefirst, namelast, position)
values('"&namefirst1&"','yourtime','email')"

Set rs = cmd.Execute

Response.Write "writing=Ok"
cn.Close
%>

This inserts a new record but the field namefirst remains blank.


Cheers

SteveW

Passing a variable to asp SteveW
4/18/2006 12:46:44 AM

I cannot work out how to get the variable namefirst from flash to the asp I
use :

loadVariablesNum("http://81.97.3.2/cart1/cactushop5_1/employee2.asp", 0,
"POST");

The variable namefirst is in a dynamic textbox

The asp is as follows:



<%@Language="VBScript"%>

<%
Dim cn
Dim cmd
Dim rs
Dim cont

Set cn = Server.CreateObject("ADODB.Connection")

cn.ConnectionString = "driver={MySQL ODBC 3.51
Driver};server=myurl;uid=root;pwd=XXXX;database=test;OPTION=3"

cn.Open



Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.CommandType = 1
namefirst1 = namefirst
'Response.Write "NameFirst"
cmd.CommandText = "Insert into Sample (namefirst, namelast, position)
values('"&namefirst1&"','yourtime','email')"

Set rs = cmd.Execute

Response.Write "writing=Ok"
cn.Close
%>

This inserts a new record but the field namefirst remains blank.


Cheers

SteveW

Re: Passing a variable to asp SteveW
4/18/2006 3:27:46 PM
Cheers for the help so far. I have come from a delphi database background so
be gentle with me......

I have put the code on a button release on another layer. But nothing
happens, the trace does not show anything.
The only error I got was the movie has to be flash 5 so I set the output
options to flash 5.
I have a basic understanding (added comments) but I not sure where name_ti
comes into the equation.


[quoted text, click to view]
// this section sends a sucsess or failure of result_lv.onLoad (not
sure what onLoad does).

[quoted text, click to view]


[quoted text, click to view]

Re: Passing a variable to asp Motion Maker
4/18/2006 3:51:54 PM
[quoted text, click to view]
According to the documentation LoadVars works for the Flash 6 player and AS
1.0.

[quoted text, click to view]

This is the instance name of a TextInput V2 UI Component available in Flash
MX 2004 authoring. But you could use a TextField instead.

You can drag a TextInput component on stage and in the properties give it an
instance name such as name_ti or whatever you want that is a valid name. Or
you could use a TextField in tools, set the type to Input and also give it
an instance name such as name_txt.

The example I posted is adapted from the on-line help which are great
templates:
http://livedocs.macromedia.com/flash/8/main/00002336.html

Perhaps you need to move to Flash 6 player in publish settings.

Also the loadVariablesNum you posted at the start of the thread is the Flash
5 and earlier days and I have little experience with them. LoadVars is the
AS OO way to go.

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
Cheers for the help so far. I have come from a delphi database background so
be gentle with me......

I have put the code on a button release on another layer. But nothing
happens, the trace does not show anything.
The only error I got was the movie has to be flash 5 so I set the output
options to flash 5.
I have a basic understanding (added comments) but I not sure where name_ti
comes into the equation.


Re: Passing a variable to asp Motion Maker
4/19/2006 4:40:12 PM
On the ASP side I use

Request("VarFromFlash")

Request("namefirst1")

cmd.CommandText = "Insert into Sample (namefirst, namelast, position)
values('" & Request("namefirst1") &"','yourtime','email')"

I use a regular HTML form to test the server script. This makes it easier
for me to debug the server script as the error message show up readily.

Once that is working, then Flash is really a plug-in (once you got the code
template down).

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
I have a simpler app as per the example as follows:

var submitListener:Object = new Object();
submitListener.click = function(evt:Object) {
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
result_ta.text = result_lv.welcomeMessage;
} else {
result_ta.text = "Error connecting to server.";
}
};
var send_lv:LoadVars = new LoadVars();
send_lv.name = name_ti.text;
send_lv.sendAndLoad("http://81.97.3.2/cart1/cactushop5_1/employee2.asp",
result_lv, "POST");
};
submit_button.addEventListener("click", submitListener);


Employee2.asp as follows:

<%@Language="VBScript"%>

<%
Dim cn
Dim cmd
Dim rs
Dim cont

Set cn = Server.CreateObject("ADODB.Connection")

cn.ConnectionString = "driver={MySQL ODBC 3.51
Driver};server=81.97.3.2;uid=XXX;pwd=XXXXX;database=test;OPTION=3"

cn.Open



Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.CommandType = 1
namefirst1 = result_ta
'Response.Write "NameFirst"
cmd.CommandText = "Insert into Sample (namefirst, namelast, position)
values('"&namefirst1&"','yourtime','email')"

Set rs = cmd.Execute

Response.Write "writing=Ok"
cn.Close
%>

When I run the app I get a new record with
namelast as yourtime
Position as email
namefirst as 'blank'
I am therefore not reading 'namefirst1= result_ta' or the variable is not
being passed from within flash.

Any ideas??

Re: Passing a variable to asp SteveW
4/19/2006 5:52:08 PM
The code is not calling employee2.asp. What am I missing here?


[quoted text, click to view]

Re: Passing a variable to asp SteveW
4/19/2006 6:33:46 PM
I have a simpler app as per the example as follows:

var submitListener:Object = new Object();
submitListener.click = function(evt:Object) {
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
result_ta.text = result_lv.welcomeMessage;
} else {
result_ta.text = "Error connecting to server.";
}
};
var send_lv:LoadVars = new LoadVars();
send_lv.name = name_ti.text;
send_lv.sendAndLoad("http://81.97.3.2/cart1/cactushop5_1/employee2.asp",
result_lv, "POST");
};
submit_button.addEventListener("click", submitListener);


Employee2.asp as follows:

<%@Language="VBScript"%>

<%
Dim cn
Dim cmd
Dim rs
Dim cont

Set cn = Server.CreateObject("ADODB.Connection")

cn.ConnectionString = "driver={MySQL ODBC 3.51
Driver};server=81.97.3.2;uid=XXX;pwd=XXXXX;database=test;OPTION=3"

cn.Open



Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.CommandType = 1
namefirst1 = result_ta
'Response.Write "NameFirst"
cmd.CommandText = "Insert into Sample (namefirst, namelast, position)
values('"&namefirst1&"','yourtime','email')"

Set rs = cmd.Execute

Response.Write "writing=Ok"
cn.Close
%>

When I run the app I get a new record with
namelast as yourtime
Position as email
namefirst as 'blank'
I am therefore not reading 'namefirst1= result_ta' or the variable is not
being passed from within flash.

Any ideas??



AddThis Social Bookmark Button