Getting variables from a query string on a swf.
Hi People. I'm hoping someone might be able to help me here.
Here's my scenario:
I have a swf file on my page that loads an flv video.
At current, its working fine, but the actionscript within flash is not dynamic, therefore the video is always the same.
Here's what I'm trying to achieve:
I want to be able to attach a query at the end of my swf eg. myflashfile.swf?id=1.
I can do that dynamically in php, and i can generate the correct id when needed, thats not a problem. What is the problem is how I actually retrieve this variable in flash and how i set up a variable in flash, so that it will always display the correct video depending on its id.
If anyone can help, I would be extremely appreciative. I've been working with flash for quite a bit of time, however I've only really used it for animation, only getting into AS, and dynamic AS now.
Many thanks in advance,
you can simply use _root.id to refer to the variable.
BTW: using flashvars in the embedding
<embed src="myflashfile.swf" flashvars="id=1" ...>
might be better than
<embed src="myflashfile.swf?id=1" ....>
because it allows the movie to load from cache
thanks a lot for that. thank you very much.
I am trying to do what you're describing (and I've seen done before) however I'm a n00b, and getting lost at the very beginning.
Here is what I'm trying to do:
Have a unique page ID for content item on a dynamic php blog site (more like a video content site like youTube (ex. http://www.site.com/videos/video.php?id=xxxx) with my own flash encoded swf player.
-- I don't know how to acheive this EXACTLY, especially since I've already begun creating my site using joomla 1.0.x... but anyway... the "?id=xxxx" I assume would be the ID field number for a specific content item (youTube vid entry/"page") in mysql db named sitedb_joomla...
each content item (video page) should have a number of specific variables (db fields) such as Description, Video Title, Created by...
I want all of these content specific fields to be called into the swf I've created (the player) to be displayed when called up (..../videos.php?id=xxxx)
Here is what I've done:
I've created a flash video player (videoplayer.swf) with actionscripting for the buttons to control the dynamically loaded .flv file.
I am storing my .flv files (video content) on my server at "www.site.com/flv/videocategory/file.flv"
I am able to load an XML object in actionscript and call up a specific .flv file from the XML markup using onLoad function.
I am able to write simple videos.php file to connect to mysql db and output valid XML markup. (not sure whether to iterate through all of my id records for the XML file (php) i want to feed into the XML object in the flash player (swf), or (HOW TO?) call up a specific XML markup for one specific ID record. (video item record id=xxxx for example).
Here's where I get really confused:
1. How do I create a single content page with the variable url ending "?id=xxxx" -- (is joomla already doing that for me??)
2. How do a embed my swf player in my content item page = and call into the player the XML markup (i assume created by a separate php writtten file) for the specfic id record of item id=xxxx
I hope my rambling makes sense. Any help would be greatly appreciated...
probably all you need to do is change
thanks that did the trick. i was able to load the xml object (in this case a php file) by either typing in the url:
embedding my swf file using FlashVars="id=[mychoice]"
however..... its been about 48 hours, i've made a few changes to my swf, but have gone OVER and OVER it and can't find what would be causing my malfunction now:
now when i type in the url with the appended query string:
I am NOT getting my flash file, all of my variables are coming in UNDEFINED.
I am getting the correct flash presentation when I use FlashVars however (_root.id) is being read by flash...
I'm assuming that flash is not accepting my variable anymore (no clue as to why) when it comes from the query string on the .swf?id URL
COULD it be that I have since added another LoadVars obj within my actionscript and therefore the _root.id caller is not loading the id variable into the _root anymore???
any more help would be awesome... thanks in advance
would you mind to show an actual url for testing?
Click Here to Expand Forum to Full Width