SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Guru rockit's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    637
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Passing FlashVars using SwfObject

    Overview
    I'm working with FMS 3, and extending the vod player. the end result is to be able to load a movie through the use of a flashvar, so i can use one copy of the swf file and simply send which movies i want to be played through to the player.

    The AS where i'm attempting to feed in the information is as follows:
    Code Actionscript:
    var movieUrl:String = root.loaderInfo.parameters["filename"];

    And i'm passing the flashvars using swfobject.

    Code JavaScript:
    <script type="text/javascript">
    var flashvars = {};
    flashvars.filename = "rtmp://172.16.10.213/vod/Statlock.flv";
    var params = {};
    var attributes = {};
    swfobject.embedSWF("vodtest.swf", "flashDiv", "660", "700", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
    </script>

    Well, the video never seems to load. my AS file works properly if i assign the value of the movie to the movie variable.

    Code Actionscript:
    var movieUrl:String = "rtmp://172.16.10.213/vod/Statlock.flv";

    Any idea's what may be going wrong here?

  2. #2
    SitePoint Addict
    Join Date
    Jul 2005
    Location
    USA
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    will it work if you try this?

    Code:
    LoaderInfo(this.root.loaderInfo).parameters["filename"];

  3. #3
    SitePoint Guru rockit's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    637
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by an00bis View Post
    will it work if you try this?

    Code:
    LoaderInfo(this.root.loaderInfo).parameters["filename"];
    Didn't work.

    is there a certain way i should be exporting the movie?

    I have 2 files, vodtest.fla & vodtest.as.

    When i test the movie from flash, it doesn't load where it's not accepting a parameter.

    I open the same movie in a web browser and it still does not load, whereas it should be accepting the runtime parameter. Should i be doing something different?

  4. #4
    SitePoint Addict
    Join Date
    Jul 2005
    Location
    USA
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is working for me in ff3/ie7

    flash document class
    Code:
    package {
    	import flash.display.Sprite;
    	import flash.display.LoaderInfo;
    	import flash.text.TextField;
    	import flash.text.TextFieldAutoSize;
    
    	public class Test extends Sprite
    	{
    		public function Test()
    		{
    			var tf:TextField = new TextField();
    			tf.autoSize = TextFieldAutoSize.LEFT;
    			tf.appendText( "filename: " + LoaderInfo(this.root.loaderInfo).parameters["filename"] );
    			addChild(tf);
    		}
    	}
    }
    html
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    	<head>
    		<title></title>
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    		<script type="text/javascript" src="swfobject.js"></script>
    		<script type="text/javascript">
    			var flashvars = {};
    			flashvars.filename = "rtmp://172.16.10.213/vod/Statlock.flv";
    			var params = {};
    			var attributes = {};
    			swfobject.embedSWF("Test.swf", "flashDiv", "550", "400", "9.0.0", false, flashvars, params, attributes);
    		</script>
    	</head>
    	<body>
    		<div id="flashDiv">
    			<a href="http://www.adobe.com/go/getflashplayer">
    				<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    			</a>
    		</div>
    	</body>
    </html>

  5. #5
    SitePoint Guru rockit's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    637
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by an00bis View Post
    this is working for me in ff3/ie7

    flash document class
    Code:
    package {
    	import flash.display.Sprite;
    	import flash.display.LoaderInfo;
    	import flash.text.TextField;
    	import flash.text.TextFieldAutoSize;
    
    	public class Test extends Sprite
    	{
    		public function Test()
    		{
    			var tf:TextField = new TextField();
    			tf.autoSize = TextFieldAutoSize.LEFT;
    			tf.appendText( "filename: " + LoaderInfo(this.root.loaderInfo).parameters["filename"] );
    			addChild(tf);
    		}
    	}
    }
    html
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    	<head>
    		<title></title>
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    		<script type="text/javascript" src="swfobject.js"></script>
    		<script type="text/javascript">
    			var flashvars = {};
    			flashvars.filename = "rtmp://172.16.10.213/vod/Statlock.flv";
    			var params = {};
    			var attributes = {};
    			swfobject.embedSWF("Test.swf", "flashDiv", "550", "400", "9.0.0", false, flashvars, params, attributes);
    		</script>
    	</head>
    	<body>
    		<div id="flashDiv">
    			<a href="http://www.adobe.com/go/getflashplayer">
    				<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    			</a>
    		</div>
    	</body>
    </html>
    i can get that to work either so apparently i'm doing something wrong. my AS3 skills are quite rusty.

    I inserted your sample AS into a new flash document and copied and pasted the snippet in layer 1, and exported. is there anything i'm missing here?

    I've attached a screenshot of my flash cs3 interface.
    Attached Images Attached Images

  6. #6
    SitePoint Addict
    Join Date
    Jul 2005
    Location
    USA
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in as3 you can have a document class which goes in an external file instead of the timeline. remove any code from the timeline and put it in a file called "Test.as". if you open publish settings and click the actionscript button you should see the option to set a document class for the file; enter "Test" and make sure that the .as file you saved before is in the same directory as your .fla

  7. #7
    SitePoint Guru rockit's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    637
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by an00bis View Post
    in as3 you can have a document class which goes in an external file instead of the timeline. remove any code from the timeline and put it in a file called "Test.as". if you open publish settings and click the actionscript button you should see the option to set a document class for the file; enter "Test" and make sure that the .as file you saved before is in the same directory as your .fla
    Wow, no idea what is going on here.

    Here's what i got.
    Complier Errors - 1 reported
    Location test.as, Line 1: 5008: The name of definition 'Test' does not reflect the location of this file. Please change the definition's name inside this file, or rename the file. C:\Documents and Settings\moorert\My Documents\Flash\LMS Video Player\swfobject\test\test.as

    I have test.fla & test.as in the same folder, C:\Documents and Settings\moorert\My Documents\Flash\LMS Video Player\swfobject\test\test.as.

    The Document class in test.fla points to test.as in the document class in the properties window.

    When i published the movie, and opened my webpage the swf file still didn't accept my flashvars.

    Here is the copy of my simple html file
    Code HTML4Strict:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    	<head>
    		<title>Test Flash Vars</title>
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    		<script type="text/javascript" src="swfobject.js"></script>
    		<script type="text/javascript">
    			var flashvars = {};
    			flashvars.filename = "rtmp://172.16.10.213/vod/Statlock.flv";
    			var params = {};
    			var attributes = {};
    			swfobject.embedSWF("Test.swf", "flashDiv", "550", "400", "9.0.0", false, flashvars, params, attributes);
    		</script>
    	</head>
    	<body>
    		<div id="flashDiv">
    			<a href="http://www.adobe.com/go/getflashplayer">
    				<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    			</a>
    		</div>
    	</body>
    </html>

    And here is the contents of test.as
    Code Actionscript:
    package {
    	import flash.display.Sprite;
    	import flash.display.LoaderInfo;
    	import flash.text.TextField;
    	import flash.text.TextFieldAutoSize;
     
    	public class Test extends Sprite
    	{
    		public function Test()
    		{
    			var tf:TextField = new TextField();
    			tf.autoSize = TextFieldAutoSize.LEFT;
    			tf.appendText( "filename: " + LoaderInfo(this.root.loaderInfo).parameters["filename"] );
    			addChild(tf);
    		}
    	}
    }
    Attached Images Attached Images

  8. #8
    SitePoint Addict
    Join Date
    Jul 2005
    Location
    USA
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the document class is case sensitive; should be "Test" and the class file should be "Test.as". attached are the files i was using.
    Attached Files Attached Files

  9. #9
    SitePoint Guru rockit's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    637
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by an00bis View Post
    the document class is case sensitive; should be "Test" and the class file should be "Test.as". attached are the files i was using.
    cool. so yours seems to work, but i'm still not getting any love from flash on mine. I've attached my files (it's 1.3 MB in size so sp wouldn't allow me to upload it). You can see in vodtest.as line 11 where i'm attempting to call the video from the flashvars.

    Code Actionscript:
    var movieUrl:String = LoaderInfo(this.root.loaderInfo).parameters["filename"];

    Again, if i use a direct link to a flv such as
    Code Actionscript:
    var movieUrl:String = "rtmp://172.16.10.213/vod/Statlock.flv";
    the movie will play fine. Maybe you can see something i'm missing here for the loaderinfo not to work.

  10. #10
    SitePoint Addict
    Join Date
    Jul 2005
    Location
    USA
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the LoaderInfo class is as3. FlashVars in an as2 project are set right on the root timeline. so if you change this:
    Code:
    var movieUrl:String = LoaderInfo(this.root.loaderInfo).parameters["filename"];
    to this:
    Code:
    var movieUrl:String = filename;
    it should work.

  11. #11
    SitePoint Guru rockit's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    637
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Quote Originally Posted by an00bis View Post
    the LoaderInfo class is as3. FlashVars in an as2 project are set right on the root timeline. so if you change this:
    Code:
    var movieUrl:String = LoaderInfo(this.root.loaderInfo).parameters["filename"];
    to this:
    Code:
    var movieUrl:String = filename;
    it should work.
    sweet. got it working. thanks for all the help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •