BTA Flexing

My passion RIAs…………..Shardul Singh Bartwal

Play and Stop Swf in Flex

Posted by Shardul Singh Bartwal on September 21, 2009

Play and Stop Swf in Flex
Many of times I have seen people to looking for requirement when they want to stop and play the swf out side the swf. This becomes more important when you  want  to  play or stop the swf’s which are not created by you.Below is the code  for  the  same  requirement.  In  this  demo  Application ,  I   am  using a Loader for playing the swf. Hope it will be helpful for you if you require.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" 
layout="absolute" creationComplete="OnCreationComplete()">
		import mx.core.UIComponent;
		private var loader:Loader; 
		private function OnCreationComplete():void
			var url : String ="assets/MyanimatedSwf.swf";
			loader = new Loader();
			var request:URLRequest = new URLRequest(url);
			loaderHolder.rawChildren.addChild(loader as DisplayObject);

		private function onStop():void
		var mc : MovieClip = loader.content as MovieClip;
		private function onPlay():void
		var mc : MovieClip = loader.content as MovieClip;;
<mx:VBox width="100%" height="100%" horizontalAlign="center"
		<mx:Canvas id="loaderHolder" width="500" height="500"/>
		<mx:Button label="Stop" click="onStop()"/>
		<mx:Button label="Play" click="onPlay()"/>

Enjoy Flexing………….


4 Responses to “Play and Stop Swf in Flex”

  1. Zee said


    • shardulbartwal said

      I just checked it it is working fine.
      Please note that it will not work if your swf will be the AVM1 based swf. So pls try with the
      swf which AVM2 based. I hope you are clear with the AVM. If you have any doubt then pls creat
      a new swf with action script 3 it will work fine.

      with Regards,
      Shardul Singh Bartwal

  2. Incredible! This blog looks just like my old
    one! It’s on a completely different subject but it has pretty much the same page layout and design. Superb choice of colors!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: