0 Replies Latest reply on Oct 11, 2010 1:50 PM by ekschperte

    Embed movie clip in flex

    ekschperte Level 1

      Hey,

       

      I have converted a avi file to an swf file with "MediaCoder".

      My plan was to simply embed this movie clip into my flex application, which did not work for me. :-(

      How can I embed the swf movie into flex AND play/stop the movie with buttons?

      I tested the following code, but when I click on the stop button I get the error:

      "TypeError: Error #1009: Der Zugriff auf eine Eigenschaft oder eine Methode eines null-Objektverweises ist nicht möglich."

      Obviously there is a problem with that swf file because another swf file is working...

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center" >
          <mx:Panel width="500" height="336">
          <mx:SWFLoader minHeight="300" minWidth="300" id="swfObj" source="@Embed('movie.swf')" creationComplete="init();" height="203" width="462"/>
          <mx:Button click="stop();" label="stop">
          </mx:Button>
          </mx:Panel>
         
          <mx:Script>
              <![CDATA[
                  import flash.display.MovieClip;
                  public var mc:MovieClip = new MovieClip;
                  public function init():void {
                      mc = ( ( swfObj.content as MovieClip ).getChildAt(0) as Loader ).content as MovieClip;
                  }
                 
                  public function stop():void
                  {
                      mc = ( ( swfObj.content as MovieClip ).getChildAt(0) as Loader ).content as MovieClip;
                      mc.gotoAndStop(20);
                  }
              ]]>
          </mx:Script>
      </mx:Application>