You are missing some Flash content that should appear here! Perhaps your browser cannot display it, or maybe it did not initialise correctly.
Passing Data to Swf Loaded by SWFLoader
SWFLoader can be used to load an external flash movie file into the current stage. All that you need to do is to set the source property of SWFLoader. What's more, if you want to passing additional data to the being loaded swf, try passing the data as query strings.
<mx:SWFLoader source="player.swf?movie=video.flv" />
Well, until now it works fine, but how can we pass more data into the swf? You may do as follows.
<mx:SWFLoader source="flvplayer.swf?movie=video.flv&autoplay=true" />
Oops, the compiler throws an error:
The reference to entity "autoplay" must end with the ';' delimiter.
I don't know what this error means, but I will show two ways to avoid the error. First, use member variable and bindings.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
public var source:String = "player.swf?movie=video.flv&autoplay=true";
]]>
</mx:Script>>
<mx:SWFLoader source="{source}"/>
</mx:Application>
The second way, modify source property dynamically in function childrenCreated.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
override protected function childrenCreated():void
{
super.childrenCreated();
player.source = "player.swf?movie=video.flv&autoplay=true";
}
]]>
</mx:Script>
<mx:SWFLoader id="player"/>
</mx:Application>
If the swf is played in browser through a html wrapper, the query strings will work. but if it is played in flash player directly, the query strings will not work. AFS will support query strings in version 1.2.
- asyncria's blog
- Login or register to post comments


Comments
escaping url
In order to get rid of the [The reference to entity "autoplay" must end with the ';' delimiter.] ...
try:
public var source:String = "player.swf?movie=video.flv&autoplay=true";
The error is coming from Flex is parsing your string and thinking you're trying to use the entity &autoplay; . Of course, this isn't the case at all, it (to me) seems more like a Flex parsing "bug". If you escape the special characters, you should be good to go.
Yes, I think you are right,
Yes, I think you are right, the correct MXML tag should be
<mx:SWFLoader source="flvplayer.swf?movie=video.flv&autoplay=true" />