2 Replies Latest reply on Mar 26, 2008 6:43 PM by slaingod

    Flex and a flash movie clip

    smokinjoefission
      Hi All,

      I'm looking for some information on how to take an embedded flash movie clip and control it through Flex. I want to be able to manually move through the movie clip, select frames to display etc.

      Any information pointing me in the right direction would be greatly appreciated.

      Thanks in advance
        • 1. Re: Flex and a flash movie clip
          SujitG Level 2
          Hi,

          Please visit the URL below for information on embedding Flash assets in Flex application.

          http://www.adobe.com/devnet/flash/articles/flex_component_workflow.html

          Hope this helps.
          • 2. Flex and a flash movie clip
            slaingod Level 1
            For Flash SWF's:

            Inside your componet/app def:

            private var movie_clip:MovieClip;
            private var myLoader:SWFLoader = new SWFLoader();

            onInit() {
            myLoader.addEventListener(Event.INIT,loadHandler);
            myLoader.trustContent = true;
            myLoader.load("../assets/my.swf");
            this.addChildAt(myLoader,0);
            }

            private function loadHandler(e:Event):void{
            movie_clip= e.target.content;
            }

            ...

            movie_clip.gotoAndPlay(2);
            movie_clip.some_custom_as3_method();


            For Flex SWF's here is an example:

            import mx.events.FlexEvent;
            import mx.managers.SystemManager;
            import mx.core.Application;

            // * gets rid of type checking so we can leave strict enabled
            [Bindable]public var _appLoaded:*;
            private function onCurrentApplicationComplete(oEvent:Event):void
            {
            _appLoaded = Application(oEvent.target.application);
            }

            private function onCompleteAppLoader(oEvent:Event):void
            {
            var smAppLoaded:SystemManager = SystemManager(oEvent.target.content); //get a ref to the loaded app
            //listen for the application.complete event
            smAppLoaded.addEventListener(FlexEvent.APPLICATION_COMPLETE, onCurrentApplicationComplete);
            }

            // call a custom public method in your application mxml file:
            public function setPlaylist(id:int):void {
            if(_appLoaded) {
            _appLoaded.change_playlist(id);
            }
            }
            ]]>
            </mx:Script>

            <!-- <mx:SWFLoader id="player" x="0" y="0" source=" http://...Player.swf" complete="onCompleteAppLoader(event);" trustContent="true"/>
            --> <mx:SWFLoader id="player" x="0" y="0" source="@Embed('../assets/Player.swf')" complete="onCompleteAppLoader(event);" trustContent="true"/>