PDA

View Full Version : Passing Variables To Flash 5 - Quick and Simple


Boethius
01-15-2003, 10:03 AM
Hi!

I am using ColdFusion 5 for development, MySQL as the database, and the .swf has to be Flash 5.

Now, I have read about making a file that contains "&foo=bar", and to me that is pretty clear, however, the solution isn't as slick as I want it to be.

Browsing the threads I came across http://www.actionscripts.org/forums/showthread.php3?s=&threadid=903 that would be a more elegant way of solving the problem. That is passing the variables through the flash source. However, I have tried this numerous times and I can't figure out if I should use loadVariablesNum or not and if so what URL I should pass. The method is of course obvious since its GET.

Example :
<embed src="foobar.swf<cfif isDefined('url.bar')>?foo=#url.bar#</cfif>" ... />

The question is how do I access them in flash?

jimburton
01-15-2003, 02:38 PM
variables passed in this way are available on the main timeline with no further ado - IMO though this is the least elegant way of doing it, definitely less manageable once you start passing more and more data and only available once when the movie loads.

tg
01-15-2003, 03:36 PM
wrap your statement in <cfoutput> tags:

<cfoutput>?foo=#url.bar#</cfoutput>

Boethius
01-16-2003, 08:55 AM
Thanks for the replys!

No I already have cfoutputs, they are just outside...

Is there another way of doing this? For example POSTING into flash?

thanks :)

jimburton
01-16-2003, 09:24 AM
more like flash requesting these variables by calling a seperate template, one whose only output is name=value pairs...you load those variables into flash using loadvars - very simple to do, there's a tute in the tutorials section which is good......

Boethius
01-16-2003, 10:34 AM
yes, i am aware of that :) its looks like a good idea, but your saying there is no way to POST variables into flash?

the latter might pose a security risk, however, its better than doing it in the URL because that is even worse :)

so you're saying if I would make a template with only those variables as ASCII ouput then flash would be able to read them, I wonder if this is possible to do in an application framework?

BTW I have flash 5, or alteast the .swf needs to be, so I don't know if I can use loadVars funtion? If i was using MX then this wouldn't be a problem because I would do everything over an XML stream :)

jimburton
01-16-2003, 10:47 AM
I forgot you were using f5 - loadvars is mx so the options are plain loadvariables or xml/xmlsocket - the xmlsocket methods are the closest you will get to posting data to the movie without it having been requested......they are the ones peole tend to use to build chat apps and the like

I'm not sure what you mean re application framework - the movie using any of these methods works as a client side application, sending off http requests to scripts back at the cf ranch, loading the results silently and displaying/acting on the results...the actual script you call can be any URI, so it doesn't matter if you're in something like a fusebox application where you have to call it like index.cfm?fuseaction=admin.login&etc etc