2 Replies Latest reply on Aug 27, 2010 1:49 PM by kostyamy

    Playing Flash animation in FLEX

    mateusz34444

      Hi,

      I've created five animation in Adobe Flash and now I want to use it in my FLEX app. I want to use two buttons, start/stop and PAUSE, for every animation. I've tried to use FlashComponentPlaceholder but I don't know how to control my animations. I've allready tried to find any help in google, but I can't find anything. How to use my animations in FLEX app properly and how to control them by buttons? Is there posibillity to change animation speed in FLEX? How to disable animations autostart when app loads?

       

      Thanks for any help ;]

        • 1. Re: Playing Flash animation in FLEX
          kostyamy

          why don't you just create very simple movie player, something like that:

           

           

           

           

           

          <mx:Metadata>

          [

           

          Event(name="complete",type="mx.events.VideoEvent")]

          </mx:Metadata>

           

           

          <mx:Script>

          <![CDATA[

           

          import mx.controls.VideoDisplay;

           

          import mx.events.MetadataEvent;

           

          import mx.events.VideoEvent;

          [Bindable]

           

          public

          public

           

          var video : String;

           

           

          public function play():void

          {

          videoDisplay.play();

          }

           

           

          public function stop():void

          {

           

          if (videoDisplay.playing)

          videoDisplay.stop();

          }

           

           

          public function get playing():Boolean

          {

           

          return videoDisplay.playing;

          }

           

          private function playPauseButtonClicked(evt:MouseEvent):void {

           

          if (videoDisplay.playing) {

             videoDisplay.pause();

          }

          else {

            videoDisplay.play();

          }

          }

           

           

          private function stopButtonClicked(evt:MouseEvent):void {

          videoDisplay.stop();

          }

           

           

          private function stopBubbling(event:Event):void

          {

           

          if (event.eventPhase == EventPhase.BUBBLING_PHASE)

          event.stopPropagation();

          }

           

          private

           

           

          function playheadUpdate(evt:VideoEvent):void {

           

          }

          </mx:Script>

           

           

          <mx:Canvas width="100%" height="100%">

           

          <mx:VideoDisplay id="videoDisplay" source="{video}" playheadUpdate="playheadUpdate(event)" width="100%" height="100%"

          complete="videoCompleted(event);" bufferTime="

           

          1"/>

           

          <mx:HBox id="controls" styleName="videoControlSkin" alpha="0.0" click="stopBubbling(event)" visible="false">

               <mx:Button id="playPauseButton" styleName="videoPausePlayButton" toggle="true" selected="{videoDisplay.playing}"

               click="playPauseButtonClicked(event)"

           

          />

              <mx:Button id="stopButton" styleName="videoStopButton" click="stopButtonClicked(event)" />

          </mx:HBox>

           

           

           

          </mx:Canvas>

           

           

          Stick it somewhere on your canvas and here you go.

          • 2. Re: Playing Flash animation in FLEX
            kostyamy Level 1

            you know i think i gave wrong answer, i mean it works just fine for let's f4v files but to play swf you can do somethign similar:

             

             

            <mx:Image

             

            id="movie" complete="onMovieLoadComplete(event)"/>

             

             

            <mx:Script>

            protected

             

             

            var player:MovieClip = null;

            ...

            private function openMovie(url:String):void

                this

             

             

            .movie.source = url;

            }

             

            private

             

            function onMovieLoadComplete(event:Event):void {

            ...

                player = movie.content as MovieClip;

                if (player)

                {

                     // adjust 'movie' layout here if you need based on the actual movie dimentions

                     player.play();

                }

            }

             

             

            </mx:Script>