dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: Getting Variable Value from Embed Code not Working

  1. #1
    Member
    Join Date
    Oct 2007
    Posts
    35

    Getting Variable Value from Embed Code not Working

    Ok so I have an FLV player that is component based, it has the following code in the actions pane for the first frame:

    Code:
    var sourceFLV:String;
    player.source = sourceFLV;
    Then I have the code to embed the video supplied by Publishing the SWF:

    Code:
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>sjpnplayer</title>
    <script language="javascript">AC_FL_RunContent = 0;</script>
    <script src="AC_RunActiveContent.js" language="javascript"></script>
    </head>
    <body bgcolor="#000000">
    <!--url's used in the movie-->
    <!--text used in the movie-->
    <!-- saved from url=(0013)about:internet -->
    <script language="javascript">
    	if (AC_FL_RunContent == 0) {
    		alert("This page requires AC_RunActiveContent.js.");
    	} else {
    		AC_FL_RunContent(
    			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
    			'width', '360',
    			'height', '279',
    			'src', 'sjpnplayer',
    			'quality', 'high',
    			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
    			'align', 'middle',
    			'play', 'false',
    			'loop', 'false',
    			'scale', 'showall',
    			'wmode', 'window',
    			'devicefont', 'false',
    			'id', 'sjpnplayer',
    			'bgcolor', '#000000',
    			'name', 'sjpnplayer',
    			'menu', 'true',
    			'allowFullScreen', 'false',
    			'allowScriptAccess','sameDomain',
    			'movie', 'sjpnplayer',
    			'salign', ''
    			); //end AC code
    	}
    </script>
    <noscript>
    	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="360" height="279" id="sjpnplayer" align="middle">
    	<param name="allowScriptAccess" value="sameDomain" />
    	<param name="allowFullScreen" value="false" />
    	<param name="movie" value="sjpnplayer.swf&sourceFLV=http://www.sjpn.net/VIDEOS/FOOTBALL100607/FB100607.flv" /><param name="play" value="false" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" />	<embed src="sjpnplayer.swf&sourceFLV=http://www.sjpn.net/VIDEOS/FOOTBALL100607/FB100607.flv" play="false" loop="false" quality="high" bgcolor="#000000" width="360" height="279" name="sjpnplayer" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    	</object>
    </noscript>
    </body>
    </html>
    From what I have read adding one of the following SHOULD work:

    Code:
    'FlashVars', 'sourceFLV= url to flv '
    Code:
    <param name="movie" value="sjpnplayer.swf&sourceFLV= url to flv " />
    Neither seems to work, either separately or together. If they should work please let me know and we can change this to figuring out why they don't instead of a better way to do it. If the supplied embed method sucks and there is a better one and you want to lead me through that it would be appreciated. My skill level in Flash is basic, assume I don't know anything and you're almost 100% correct.

    Thanks in Advance,
    Jon

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    The FlashVars method should work, but only if you have javascript disabled. If javascript is enabled, the noscript tag will be ignored. You need to add the flashvars to the other part too.

  3. #3
    Member
    Join Date
    Oct 2007
    Posts
    35
    The actionscript is all right?

    Code:
    <param name="FlashVars" value="sourceFLV= url to flv " />
    Like that?

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    No, like this:

    Code:
    	if (AC_FL_RunContent == 0) {
    		alert("This page requires AC_RunActiveContent.js.");
    	} else {
    		AC_FL_RunContent(
    			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
    			'width', '360',
    			'height', '279',
    			'src', 'sjpnplayer',
    			'quality', 'high',
    			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
    			'align', 'middle',
    			'play', 'false',
    			'loop', 'false',
    			'scale', 'showall',
    			'wmode', 'window',
    			'devicefont', 'false',
    			'id', 'sjpnplayer',
    			'bgcolor', '#000000',
    			'name', 'sjpnplayer',
    			'menu', 'true',
    			'allowFullScreen', 'false',
    			'allowScriptAccess','sameDomain',
    			'movie', 'sjpnplayer',
    			'salign', '',
                            'flashvars', 'sourceFLV=blah.flv'
    			); //end AC code
    	}
    I'm not 100% sure on the actionscript side. I think it should work that way, so long as the referencing code is the root.

  5. #5
    Member
    Join Date
    Oct 2007
    Posts
    35
    Ok, but how do I set it up for people with JS disabled?

  6. #6
    Member
    Join Date
    Oct 2007
    Posts
    35
    It doesn't appear to be working at all, I have JS enabled.

    http://www.sjpn.net/VIDEOS/FOOTBALL1...jpnplayer.html

  7. #7
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You'd leave the noscript in just as before. The only difference was adding the flashvars to the script version too.

    I went to the page, it does appear not to work. But the flashvars are set in the embed tag. Here's a page that details how to get them in the actionscript:
    http://blogs.adobe.com/pdehaan/2006/...actionscr.html

  8. #8
    Member
    Join Date
    Oct 2007
    Posts
    35
    I am afraid that I don't really understand what the page is saying I need to do, could you, if you don't mind, tell me what exactly I need to take from there and put into my actionscript?

  9. #9
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    The loaderinfo and parameters stuff is the important part.
    Code:
    try {
        var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
        sourceFLV = paramObj["sourceFLV"];
    } catch (error:Error) {
        trace("oops: "+error);
    }
    ... //continue with code which uses sourceFLV

  10. #10
    Member
    Join Date
    Oct 2007
    Posts
    35
    Ok so I added what you said, published fine. Doesn't appear to be working though, see the same page as before to see what I mean.

  11. #11
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    At this point it's just debugging. You can use a textfield on the stage like in the example page to show what the parameter values are. That'll verify that the sourceFLV value is getting into the movie correctly. You can also check your server logs to see what actual request (if any) is happening for the flv. Could be the path is incorrect and it's simply not found.

    I'm afraid that without direct access to your movie and/or server it'll be really hard to debug this, so you're pretty much on your own. Unless someone else has a bright idea.

  12. #12
    Member
    Join Date
    Oct 2007
    Posts
    35
    http://www.sjpn.net/VIDEOS/FOOTBALL100607/FB100607.flv

    That's the movie, it's in the same root even, I don't get it. I don't know how to do all this text field stuff, I don't know anything about flash I am just trying to get this player set up so that it will read the movie source from the embed code so I can set up a PHP form to change what movie is displaying so that my successor (whoever takes over the site once I graduate) who may or may not have flash CS3 will be able to just upload the episode and provide the source. If I was going to be around still I'd just keep making a new player for each movie like I have so far but yeah...

  13. #13
    Member
    Join Date
    Oct 2007
    Posts
    35
    Just realized that maybe this is what you want:
    http://www.sjpn.net/VIDEOS/FOOTBALL1...sjpnplayer.fla

  14. #14
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    First, I suggest going through your apache logs, look for requests for the flv. If they're not there, it'll tell you that the swf is not even trying to load it. If they are there, it'll tell you which particular path the swf is requesting, which may or may not be correct.

    All right, here's a really hacky debug technique.
    Code:
    ...//at top of class, where you declare player, etc.
    var tf:TextField = new TextField();
    
    ...//right after putting your flv player on stage
    addChild(tf);
    
    ...//
    tf.autoSize = TextFieldAutoSize.LEFT;
    tf.border = true;
    
    tf.appendText("params:" + "\n");
    try {
        var keyStr:String;
        var valueStr:String;
        var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
        for (keyStr in paramObj) {
            valueStr = String(paramObj[keyStr]);
            tf.appendText("\t" + keyStr + ":\t" + valueStr + "\n");
        }
        sourceFLV = paramObj["sourceFLV"];
    } catch (error:Error) {
        tf.appendText(error);
    }
    I'm afraid that I won't be able to actually use your fla, as I don't have access to cs3 at the moment. I encourage anyone else reading to help out if they can.

  15. #15
    Member
    Join Date
    Oct 2007
    Posts
    35
    Ok so I really hate to ask this but I have done everything I can think of to get this working since 5TonsofFlax, whose help I appreciate greatly, last posted. Anyhow, if someone could download the FLA and get it and the embed code (even if it means embeding it a different way from publishing in Flash CS3 does) working I would appreciate it immensely! I am under a sort-of deadline (lets just say the group is getting itchy and wants their player working) and I need it working. If anyone is wondering I don't actually have access to most of these logs and such Flax was suggesting.

  16. #16
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    One last "duh!" idea: You are setting the player source and doing any other player initialization AFTER getting the sourceFLV value from the params, right?

    Have you been able to determine if any variables at all are getting into the flash from the flashvars?

    Still no cs3 here, but I do have FlashDevelop. [30 minutes later] Which doesn't seem to have the fl.video package. Hooray. Wish I could help.

  17. #17
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    All right, since I can't help with the flv, I can at least help with the flashvars. I have just built and verified that this .as file does work and reads flashvars from this html file.

    Code:
    package
    {
    	import flash.display.Sprite;
    	import flash.text.TextField;
    	import flash.text.TextFieldAutoSize;
    	import flash.display.LoaderInfo;
    	
    	public class Main extends flash.display.Sprite
    	{
    		public var tf:TextField;
    
    		public function Main():void
    		{
    			tf = new TextField();
    			addChild(tf);
    			tf.autoSize = TextFieldAutoSize.LEFT;
    			tf.border = true;
    
    			tf.appendText("params:" + "\n");
    			try {
    				var keyStr:String;
    				var valueStr:String;
    				var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
    				for (keyStr in paramObj) {
    					valueStr = String(paramObj[keyStr]);
    					tf.appendText("\t" + keyStr + ":\t" + valueStr + "\n");
    				}
    			} catch (error:Error) {
    				tf.appendText(error.toString());
    			}			
    		}
    	}
    }
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>Untitled</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    <body>
      <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="360" height="279" id="sjpnplayer" align="middle">
    	<param name="allowScriptAccess" value="sameDomain" />
    	<param name="allowFullScreen" value="false" />
    	<param name="movie" value="flashvarstest.swf" />
    	<param name="flashvars" value="something=somethingelse&apples=oranges" />
    	<param name="play" value="false" />
    	<param name="loop" value="false" />
    	<param name="quality" value="high" />
    	<param name="bgcolor" value="#ffffff" />
    	<embed src="flashvarstest.swf" play="false" loop="false" quality="high" bgcolor="#ffffff" width="360" height="279" 
    	flashvars="something=somethingelse&apples=oranges"
    	name="sjpnplayer" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
      </object>
    </body>
    </html>

  18. #18
    Member
    Join Date
    Oct 2007
    Posts
    35
    Ok... so looking at yours I see a whole ton more code than my actionscript has... like you declare classes and such. I should have thought of that since I know Java... stupid of me.

    Anyhow yeah, this is literally all that is currently in the actionscript pane:

    Code:
    var sourceFLV:String = new String;
    
    try {
        var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
        sourceFLV = paramObj["sourceFLV"];
    } catch (error:Error) {
        trace("oops: "+error);
    }
    
    player.source = sourceFLV;
    I don't suppose THAT could have anything to do with this not working?

  19. #19
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Flash creates a class for that in the background for you. Other than a few tiny little things that shouldn't matter, that looks correct.
    Tiny 1: "new String();", not "new String;"
    Tiny 2: sourceFLV = String(paramObj["sourceFLV"]);

    Both of those are just syntax that shouldn't affect performance if it lets you compile.

    You need to isolate the problem further to figure out what's going wrong. Forget the flashvars for now. Heck, comment out the try/catch. If you replace the source with the value directly, can you get your movie to work?

    player.source="http://www.sjpn.net/VIDEOS/FOOTBALL100607/FB100607.flv"

    Get that working, then figure out how to feed the url in from flashvars.

  20. #20
    Member
    Join Date
    Oct 2007
    Posts
    35
    Yeah I already got that working, someone else checked that with me too, but they weren't really being helpful beyond that, they were getting impatient and they don't have CS3 (still on 8 I think they said) and eventually stopped responding.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center