0 Replies Latest reply on Oct 13, 2009 1:07 PM by rul987

    Embedding a SWF with actionscript

    rul987

      I tried to embed a swf into a flex 3 file. Usually it does not need to be passed as a bit stream but it has to be when the swf is using actionscript.

      http://www.flshow.net/index.php

      I got the component from the site mentioned above and it is called Carousel 2.0.

       

      I tried embedding this into a page. Here is the code

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

       

      <mx:Script>
          <![CDATA[

       

       

              import flash.events.*;
              import mx.core.*;
              import mx.managers.*;
              import mx.controls.*;

       

      [

       


        Embed("Carousel.swf",mimeType="application/octet-stream")]
          [Bindable]
        private var carousel:Class;
        private var myLoader:Loader = new Loader();

       


          ]]>
      </mx:Script>

       

          <mx:Canvas x="10" y="10" width="780" height="580">
         
          <mx:Image id="Carousel" source="{carousel}" width="964" height="397" x="10" y="10"/>
          </mx:Canvas>

         
      </mx:Application>

       

      The code compiles fine but had runtime errors.

       

      TypeError: Error #1034: Type Coercion failed: cannot convert carseff_flash_carousel@ad7a5e1 to flash.display.DisplayObject.
          at mx.controls::SWFLoader/loadContent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\co ntrols\SWFLoader.as:1260]
          at mx.controls::SWFLoader/load()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\controls\ SWFLoader.as:1211]
          at mx.controls::SWFLoader/commitProperties()[E:\dev\3.0.x\frameworks\projects\framework\src\ mx\controls\SWFLoader.as:1015]
          at mx.core::UIComponent/validateProperties()[E:\dev\3.0.x\frameworks\projects\framework\src\ mx\core\UIComponent.as:5670]
          at mx.managers::LayoutManager/validateProperties()[E:\dev\3.0.x\frameworks\projects\framewor k\src\mx\managers\LayoutManager.as:519]
          at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:639]
          at Function/http://adobe.com/AS3/2006/builtin::apply()
          at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\sr c\mx\core\UIComponent.as:8460]
          at mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src \mx\core\UIComponent.as:8403]

       

      Does anyone have any suggestions to make this work. Maybe there is a bug or the code is bad( I did see a bug on something like this when I used google). Thanks for reading my post.