Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Flash be used to pull data from an ASP recordset? 2

Status
Not open for further replies.

gchaves

Programmer
Oct 27, 2003
105
US
Hello!

Can anyone recommend a good web site/tutorial that illustrates how to use Flash to access data within an ASP recordset (if it can even be done)? I have googled the subject and have come up short and could really use some assistance.

Thanks,
GC
 
Flash is client side, ASP is server side. You can pass variables/parameters to your Flash object, so you can write them out with ASP and insert the appropriate values that way.

Code:
<PARAM NAME=FlashVars VALUE="var1=<%= aspvar1 %>">


Lee
 
It is really not to complicated to have an embedded flash movie communicate with ASP.

Code:
//ActionScript v1
onLoad() {
	//place a request to an asp script
	//relative to the swf path
	this.loadVariables("myasppage.asp",'POST');
}
onFrame(2) {
	//'listen' for a response
	if (done!="1") {
		//loop to frame 1 until we get the
		//last variable
		prevFrameAndPlay();
	} else {
		//we got it, so now trace the value
		//to the flash debug panel
		trace(myAspVariable);
	}
}
onFrame(3) {
	//stop playing the movie when you're done
	stop();
}

myasppage.asp
Code:
<%@LANGUAGE="VBSCRIPT"%>
<%
response.write("&myAspVariable=Hello World")
response.write("&done=1")
%>

To really make this useful you would need a Dynamic Text Box in the flash movie, and assign it the variable myAspVariable.

Here is an article on Flash+ASP. It's an oldie but a goodie.

Might also want to check out SwishMax (not swish2) as it is only $99 US and can compile to swf8 and projectorMX. Has a 30-day fully functional trial download. The IDE is incredibly easy and there is a great forum that supports it at Swish-DB. SwishMax supports AS1 and some AS2.

-a6m1n0

Curiosity only kills cats.
 
OK...Thanks for the replies! Here is what I am up against. I am working with a Flash 2.0 programmer who doesn't really know ASP. If you haven't guessed by now, I am an ASP programmer who knows nothing about Flash. We have been tasked with creating a site in Flash that needs to pull data from a database in order to generate drop down menus based on a selection made in another drop down menu. In other words, if a user selects "computers" from a drop-down menu created in Flash containing selections "planes", "trains", "computers", "automobiles", then we need to send a request from Flash to an ASP page which queries a database and looks for all selections in a table that are associate with the selection "computers". Then we need to send the resulting recordset back from ASP to Flash and have it add entries into a second drop-down menu such as "Dell", "HP", "iMac", "Compaq", "IBM", etc. We have been researching how to do this using a function called LoadVars, although neither one of us has ever had a need to use this. Can this be done using LoadVars? If so, any help to help us get started would be greatly appreciated!

Thanks,
GC
 
Sure, you can use LoadVars Object to get the data from an ASP page. See Here
One thing though...most examples you find will use PHP as the backend -- get used to seeing these. It's not much different than ASP and 95% of examples involving getting data to Flash is in PHP.

-a6m1n0

Curiosity only kills cats.
 
OK...I'm getting stuck.

I have an ASP page that queries my database and builds a recordset. I have it running within the confines of a loop statement (in table format) in order to display it in an ASP page. How would I be able to send the resulting recordset (and all of its data) to a Flash .swf file so that it is displayed within the flash movie?

I have been trying to use the loadVars object to no avail.

Any help would be greatly appreciated!

thanks,
GC
 
As a quick append to my last post, I only have it running within a loop to make sure that I am pulling the data from the database. I don't need to display the data within the ASP page, just need to be able to send the resulting recordset to Flash for it to display within the movie.

thanks,
GC
 
Without some code to look at I am unsure what your exact problem would be. But some tips...

If you are using Flash8 then you must declare all objects/variables. Syntax is also case sensitive. loadvars will work in swf7 or less, but only loadVars works in swf8.

swf has a limited understanding of html, and this does not include html tables. So if you are trying to send html source with table tags the movie will not load the data.

One last thing...there is a 'weirdness' when using response.write to communicate with a swf. Say you have this loop...
Code:
dim x,y,str
y=3
for x=1 to y
   str="&x"&x&"="&x
next
response.write(str)

This obviously builds this string: &x1=1&x2=2&x3=3

For some reason, and I do not know why, this will *not* work with a swf. This though does work:

Code:
dim x,y
y=3
for x=1 to y
   response.write("&x"&x&"="&x)
next

Based on the description of your problem you gave last, this is about the best I can do towards helping you with a solution.

-a6m1n0

Curiosity only kills cats.
 
a6m1n0,

Thank you for your reply! We have come up with Flash/ASP code that allows us to make a selection from a drop down menu in Flash, display the selection in a text box in Flash and when a button is pushed on the Flash page, it sends the data to ASP, writes it into a variable which we can query for and then displays the results in our ASP page. Now, instead of displaying the results within ASP, we want to send the results back to Flash to display. Here is my ASP code:

Code:
<%

If Request.Form("sCoinChosen")<>"" Then
	'Response.Write "I am getting here!!!"
	Dim coinType
	coinType=Request.Form("sCoinChosen")
	coinType=cStr(coinType)

'--------------------------------------------------------------------												
						'create recordset object
						Dim sqlCoinType		
						Dim objRSCoinType		
						Set objRSCoinType = Server.CreateObject("ADODB.Recordset")

						sqlCoinType = "SELECT * FROM coins WHERE coin_name = '" & coinType & "';"
		
						'open the recordset
						objRSCoinType.Open sqlCoinType, objConn, 2, 3
				
						objRSCoinType.MoveFirst
	
							Response.Write "&sCoinChosen=" & objRSCoinType("coin_desc") & ""
							
						objRSCoinType.Close
						Set objRSCoinType = Nothing
							
'--------------------------------------------------------------						
 
 End If
 
%>

Do I have my results formatted correctly to send back to Flash? (We are using Flash Version 8)

As always, any help is most certainly appreciated!

Thanks,
GC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top