PDA

View Full Version : Accessing flashvars


trident
09-26-2007, 03:05 PM
Just starting to learn flash and actionscript, so please forgive my ignorance. I've also tried searching etc. but I couldn't find any subject that adressed my specific question :)

I'm trying to pass some variables to an actionscript using flashvars. I've written a php script that will generate the HTML needed: <PARAM NAME=FLASHVARS VALUE="year=' . $year . '&month=' . $month . '&day=' . $day;
and also this: FLASHVARS="year=' . $year . '&month=' . $month . '&day=' . $day; inside the embed HTML tag as I understand that you need both for cross browser compability.

Now what I want to do next is to get this info and store it in some variables in actionscript, and I've read various tutorials on how to do it, but I just can't seem to get it to work. This is the actionscript i'm using, which obviously doesn't work? var targetYear = trace(year);
var targetMonth = trace(month);
var targetDay = trace(day);

BTW, i'm using Adobe Flash CS3 set to actionscript 1.0 & 2.0. I think I read somewhere that flashvars only work with Flash MX, but I don't know if that's true, or, indeed, what Flash MX is...

Could anyone explain what I need to do, and help a poor newb out here?
Thanks in advance

mikenaman
10-02-2007, 12:40 PM
Hi there

You just need to remove the word trace from your code. It should read like this...

var targetYear = year
var targetMonth = month
var targetDay = day

Also, flashVars will only send through strings, so make sure if your using the values as numbers, to specify it as a Number(month).

Only use the trace method to write the values to the output window in Flash.

Thanks

Mike