Getting FlashVars from class based AS3 with swfObject

Hi, I'm tryng to get a Flashvar as a string from swfObject using a document class but it is tracing a null - can anybody tell me what I'm doing wrong?

code is below

Thanks a lot, Paul
<div id="flashLoad"></div>
	<script type="text/javascript">
		// <![CDATA[
		var soFlash = new SWFObject("testClass.swf", "myDate", "184", "145", "9", "#FFFFFF");
		soFlash.addVariable("uniqueDate", "2010,4,30,00,00");
		// ]]>



package {

	import flash.display.MovieClip;

	public class testClass extends MovieClip {

		public var getDate:String;

		public function testClass() {

Open in new window

Who is Participating?
Are you using SWF Object version 2?

There is a free AIR app which generates the HTML wrapper for you on the SWF Object Google Code page:

Here is a nice video which describes how to use the AIR app as well as a general introduction to using SWF Object 2:

As for your actual code, try placing the script tag inside of head instead of body and see if it makes a difference. I have attached the new code with some additional changes.

If it still doesn't work, just reply back.

Good luck with your programming,
	<script type="text/javascript">
		var flashVars = {}
		flashVars.uniqueDate = "2010,4,30,00,00";
		swfobject.embedSWF("testClass.swf", "flashLoad", "184", "145", "10.0.0", "", flashVars);
    <div id="flashLoad">
        If you are seeing this message, you don't have Flash installed.
        Too bad...

Open in new window

SideasAuthor Commented:
Thanks IqAndreas   swfObject 2 looks good.

I had to cast it as a string too:

var uniqueDate: String = LoaderInfo(this.root.loaderInfo).parameters.uniqueDate;
                  dateText.text = uniqueDate;

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.