<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How to Retrieve FlashVars Data in ActionScript 3.0</title>
	<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30</link>
	<description>Luck is the residue of good design.</description>
	<pubDate>Wed, 19 Nov 2008 04:18:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Jasmin Auger</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-234814</link>
		<pubDate>Thu, 31 Jul 2008 17:27:07 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-234814</guid>
					<description>Hi David, sorry to bring an old post back to life, but I just wanted to tell you that the only way I have been able to pass an external variable to my SWF was to put them after the name of the swf in the js variable, and in the param and the embed tags. I've been searching over the internet for about 2 hours now and it seems it's the only thing that works for me. I have a rather complex project, but I don't understand why it doesn't work using the FlashVars method... When using FlashVars, the variables are simply not passed and I get a &quot;url parameter must be non-null&quot; error.

Here are the 3 var I had to change:

In the AC_FL_RunContent script:

'movie', 'gallery?menuName=xml/MenuAng.xml&amp;#38;pictureName=xml/Pictures.xml',

In the param tag:



and in the embed tag:

src=&quot;gallery.swf?menuName=xml/MenuAng.xml&amp;#38;pictureName=xml/Pictures.xml&quot;

Hope this might help other people!</description>
		<content:encoded><![CDATA[<p>Hi David, sorry to bring an old post back to life, but I just wanted to tell you that the only way I have been able to pass an external variable to my SWF was to put them after the name of the swf in the js variable, and in the param and the embed tags. I&#8217;ve been searching over the internet for about 2 hours now and it seems it&#8217;s the only thing that works for me. I have a rather complex project, but I don&#8217;t understand why it doesn&#8217;t work using the FlashVars method&#8230; When using FlashVars, the variables are simply not passed and I get a &#8220;url parameter must be non-null&#8221; error.</p>
<p>Here are the 3 var I had to change:</p>
<p>In the AC_FL_RunContent script:</p>
<p>&#8216;movie&#8217;, &#8216;gallery?menuName=xml/MenuAng.xml&amp;pictureName=xml/Pictures.xml&#8217;,</p>
<p>In the param tag:</p>
<p>and in the embed tag:</p>
<p>src=&#8221;gallery.swf?menuName=xml/MenuAng.xml&amp;pictureName=xml/Pictures.xml&#8221;</p>
<p>Hope this might help other people!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-136071</link>
		<pubDate>Mon, 18 Feb 2008 19:23:58 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-136071</guid>
					<description>J,

Haha, you're welcome!  Glad I could help.  :)</description>
		<content:encoded><![CDATA[<p>J,</p>
<p>Haha, you&#8217;re welcome!  Glad I could help.  <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: J</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-136064</link>
		<pubDate>Mon, 18 Feb 2008 19:09:27 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-136064</guid>
					<description>THANK YOU THANK YOU THANK YOU THANK YOU!!!!!!!!!!!!!!!!!!!!!!!</description>
		<content:encoded><![CDATA[<p>THANK YOU THANK YOU THANK YOU THANK YOU!!!!!!!!!!!!!!!!!!!!!!!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126622</link>
		<pubDate>Thu, 31 Jan 2008 14:54:44 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126622</guid>
					<description>Adam,

Assuming you have a movie clip with the instance name &lt;code&gt;box&lt;/code&gt;, the following would adjust the width and height of that movie clip to half the width and height of the Stage:

&lt;pre&gt;&lt;code&gt;stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

stage.addEventListener(
  Event.RESIZE,
  resizeHandler
);

function resizeHandler(evt:Event):void {
  box.width = stage.stageWidth / 2;
  box.height = stage.stageHeight / 2;
}&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Adam,</p>
<p>Assuming you have a movie clip with the instance name <code>box</code>, the following would adjust the width and height of that movie clip to half the width and height of the Stage:</p>
<pre><code>stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

stage.addEventListener(
  Event.RESIZE,
  resizeHandler
);

function resizeHandler(evt:Event):void {
  box.width = stage.stageWidth / 2;
  box.height = stage.stageHeight / 2;
}</code></pre>
]]></content:encoded>
				</item>
	<item>
		<title>by: Adam Petrie</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126617</link>
		<pubDate>Thu, 31 Jan 2008 14:34:55 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126617</guid>
					<description>I think you are exactly correct in you explanation for the changes.

The example was incredibly simple, but if you altered the values in the tags and set the width of a MovieClip to be equal to Stage.width, then when you opened the page in the browser, the MovieClip was resized appropriately.

In fact that is exactly what I'd like to accomplish with AS3 because I have already written a function that resizes my UI on a FullScreenEvent so in essence all the code required is already there, I just need to figure out how (or where) to get the correct values from.

I am going to begin playing with the AS3 equivalents right now.  If you'd like a copy of that (incredibly rudimentary) example, feel free to e-mail me and I will send it over.

Thanks for the input though, I've been racking my brain for a week now and as of yet, no one else on the net has been able to provide any input at all.</description>
		<content:encoded><![CDATA[<p>I think you are exactly correct in you explanation for the changes.</p>
<p>The example was incredibly simple, but if you altered the values in the tags and set the width of a MovieClip to be equal to Stage.width, then when you opened the page in the browser, the MovieClip was resized appropriately.</p>
<p>In fact that is exactly what I&#8217;d like to accomplish with AS3 because I have already written a function that resizes my UI on a FullScreenEvent so in essence all the code required is already there, I just need to figure out how (or where) to get the correct values from.</p>
<p>I am going to begin playing with the AS3 equivalents right now.  If you&#8217;d like a copy of that (incredibly rudimentary) example, feel free to e-mail me and I will send it over.</p>
<p>Thanks for the input though, I&#8217;ve been racking my brain for a week now and as of yet, no one else on the net has been able to provide any input at all.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126610</link>
		<pubDate>Thu, 31 Jan 2008 13:59:47 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126610</guid>
					<description>Adam,

Definitely, let me know about the example you put together with your co-worker!  :)  I'm curious to see what you found.  My hunch is that you're referencing the read-only &lt;code&gt;Stage.width&lt;/code&gt; and &lt;code&gt;Stage.height&lt;/code&gt; properties, which indeed return the width and height values of the Stage at the current moment.  If you used pixel values in the width and height attributes of your &lt;code&gt;&amp;#60;object&amp;#62;&lt;/code&gt; and &lt;code&gt;&amp;#60;embed&amp;#62;&lt;/code&gt; tags, then those &lt;code&gt;Stage&lt;/code&gt; properties will reflect the values of those attributes.  On the other hand, it's just as possible to use percentage values, which will allow the SWF to resize at runtime in response to the user resizing the browser.  In that sort of scenario, those &lt;code&gt;Stage&lt;/code&gt; properties (and their AS3 equivalents) will give you different numbers, depending on the current size of the SWF.  In that way, you can tell the size of the Stage (i.e., the SWF), but it may or may not match the numbers specified in the HTML.

Check out the &lt;code&gt;Stage&lt;/code&gt; class in either version of ActionScript to see about using the &lt;code&gt;onResize&lt;/code&gt; event.  That will allow you to adjust the SWF's width and height as you please &amp;#8212; with pixels or percents &amp;#8212; and then respond to those values at runtime.</description>
		<content:encoded><![CDATA[<p>Adam,</p>
<p>Definitely, let me know about the example you put together with your co-worker!  <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I&#8217;m curious to see what you found.  My hunch is that you&#8217;re referencing the read-only <code>Stage.width</code> and <code>Stage.height</code> properties, which indeed return the width and height values of the Stage at the current moment.  If you used pixel values in the width and height attributes of your <code>&lt;object&gt;</code> and <code>&lt;embed&gt;</code> tags, then those <code>Stage</code> properties will reflect the values of those attributes.  On the other hand, it&#8217;s just as possible to use percentage values, which will allow the SWF to resize at runtime in response to the user resizing the browser.  In that sort of scenario, those <code>Stage</code> properties (and their AS3 equivalents) will give you different numbers, depending on the current size of the SWF.  In that way, you can tell the size of the Stage (i.e., the SWF), but it may or may not match the numbers specified in the HTML.</p>
<p>Check out the <code>Stage</code> class in either version of ActionScript to see about using the <code>onResize</code> event.  That will allow you to adjust the SWF&#8217;s width and height as you please &mdash; with pixels or percents &mdash; and then respond to those values at runtime.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Adam Petrie</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126348</link>
		<pubDate>Thu, 31 Jan 2008 04:04:31 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126348</guid>
					<description>You're right, what Im asking is only similar in fashion to your original post, but you write intelligently so I thought I'd ask.

Specifically, yes I do want to know if I can read the width and height attributes and until this afternoon, I'd agree with you that It was not possible to read them in any version of AS.  Contrary to that a co-worker and I came up with an incredibly simple example that shows the swf being aware of those values in AS 2.0.  Of course Im home now and the example is at work.

Regardless, what I'm after is a way to resize my swf before runtime.  I've created a widget that will be part of an online library where clients can customize and embed their widgets for their own use.  I'd like to allow them to create a widget of any size.

Do you know of any routes that will make this possible?</description>
		<content:encoded><![CDATA[<p>You&#8217;re right, what Im asking is only similar in fashion to your original post, but you write intelligently so I thought I&#8217;d ask.</p>
<p>Specifically, yes I do want to know if I can read the width and height attributes and until this afternoon, I&#8217;d agree with you that It was not possible to read them in any version of AS.  Contrary to that a co-worker and I came up with an incredibly simple example that shows the swf being aware of those values in AS 2.0.  Of course Im home now and the example is at work.</p>
<p>Regardless, what I&#8217;m after is a way to resize my swf before runtime.  I&#8217;ve created a widget that will be part of an online library where clients can customize and embed their widgets for their own use.  I&#8217;d like to allow them to create a widget of any size.</p>
<p>Do you know of any routes that will make this possible?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126339</link>
		<pubDate>Thu, 31 Jan 2008 03:37:08 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126339</guid>
					<description>Adam,

FlashVars data (or query string data) enters the SWF via name/value pairs fed separately from the actual embed code.  I &lt;em&gt;think&lt;/em&gt; you're asking if it's possible to read the height and width attributes of the &lt;code&gt;&amp;#60;object&amp;#62;&lt;/code&gt; and &lt;code&gt;&amp;#60;embed&amp;#62;&lt;/code&gt; tags, right?  If so, that isn't possible in any version of ActionScript &amp;#8212; again, unless you pass it in as a FlashVars variable.

AS2's &lt;code&gt;Stage.width&lt;/code&gt; and &lt;code&gt;Stage.height&lt;/code&gt; properties are now &lt;code&gt;stage.stageWidth&lt;/code&gt; and &lt;code&gt;stage.stageHeight&lt;/code&gt; in AS3.  You can reference any &lt;code&gt;DisplayObject&lt;/code&gt; instance, including the main timeline, to get your &lt;code&gt;stage&lt;/code&gt; reference, and from there, check the properties mentioned.  Does that help?</description>
		<content:encoded><![CDATA[<p>Adam,</p>
<p>FlashVars data (or query string data) enters the SWF via name/value pairs fed separately from the actual embed code.  I <em>think</em> you&#8217;re asking if it&#8217;s possible to read the height and width attributes of the <code>&lt;object&gt;</code> and <code>&lt;embed&gt;</code> tags, right?  If so, that isn&#8217;t possible in any version of ActionScript &mdash; again, unless you pass it in as a FlashVars variable.</p>
<p>AS2&#8217;s <code>Stage.width</code> and <code>Stage.height</code> properties are now <code>stage.stageWidth</code> and <code>stage.stageHeight</code> in AS3.  You can reference any <code>DisplayObject</code> instance, including the main timeline, to get your <code>stage</code> reference, and from there, check the properties mentioned.  Does that help?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Adam Petrie</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126330</link>
		<pubDate>Thu, 31 Jan 2008 03:09:31 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-126330</guid>
					<description>Is there any way to read in the value of the width and height parameters in the embed code?

In AS 2.0 you could set the values in the embed code and then use Stage.height and Stage.width to read them in....  this has changed in AS 3.0 and I have tried desperately to find a solution.

Know of anything?  Cheers.</description>
		<content:encoded><![CDATA[<p>Is there any way to read in the value of the width and height parameters in the embed code?</p>
<p>In AS 2.0 you could set the values in the embed code and then use Stage.height and Stage.width to read them in&#8230;.  this has changed in AS 3.0 and I have tried desperately to find a solution.</p>
<p>Know of anything?  Cheers.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-96099</link>
		<pubDate>Fri, 02 Nov 2007 01:48:07 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30#comment-96099</guid>
					<description>Nicole,

In ActionScript 3.0, the &lt;code&gt;Sound&lt;/code&gt; class doesn't feature a &lt;code&gt;stop()&lt;/code&gt; method like it does in AS2.  To stop sound in AS3, you have to instantiate a &lt;code&gt;SoundChannel&lt;/code&gt; instance and associate your &lt;code&gt;Sound&lt;/code&gt; instance with that.  Like this:

&lt;pre&gt;&lt;code&gt;var s:Sound = new Sound();
var chan:SoundChannel;
iconButton.addEventListener(
 MouseEvent.MOUSE_UP,
 function(evt:MouseEvent):void {
  s.load(new URLRequest(root.loaderInfo.parameters.audio));
  chan = s.play();
 }
);
stopButton.addEventListener(
 MouseEvent.MOUSE_UP,
 function(evt:MouseEvent):void {
  chan.stop();
 }
);&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Nicole,</p>
<p>In ActionScript 3.0, the <code>Sound</code> class doesn&#8217;t feature a <code>stop()</code> method like it does in AS2.  To stop sound in AS3, you have to instantiate a <code>SoundChannel</code> instance and associate your <code>Sound</code> instance with that.  Like this:</p>
<pre><code>var s:Sound = new Sound();
var chan:SoundChannel;
iconButton.addEventListener(
 MouseEvent.MOUSE_UP,
 function(evt:MouseEvent):void {
  s.load(new URLRequest(root.loaderInfo.parameters.audio));
  chan = s.play();
 }
);
stopButton.addEventListener(
 MouseEvent.MOUSE_UP,
 function(evt:MouseEvent):void {
  chan.stop();
 }
);</code></pre>
]]></content:encoded>
				</item>
</channel>
</rss>
