1 Reply Latest reply on May 5, 2008 1:14 PM by weavedog

    passing correct image-file path in flashVar from jsp into embedded Flex application

    weavedog
      I have an application that embeds an image viewer, written in Adobe Flex within a jsp page running in a J2EE application on Tomcat 5.5. The Flex code is a one-line modification of the application displayed at ( http://www.adobe.com/devnet/flex/samples/fig_panzoom/).

      The image viewer is founded and loaded in the output to the screen, but I cannot get the Image Viewer to display the image correctly, even though I succeed when either I run the .swf from the command-line or from an HTML page.



      My webapp is called FRSApp. The directory structure is, under FRSApp:

      myTest.html
      jsp/catalog.jsp
      pan_zoom_files/images/map.jpg


      The JSP code is thus,

      code:



      <%@ taglib prefix="mm" uri="FlexTagLib" %>
      <mm:mxml source="../pan_zoom_files/FIG_PanZoom_for_jsp.mxml" >
      <mm:flashvar name="myVar" value="/FRSApp/pan_zoom_files/images/map.jpg"/>
      </mm:mxml>


      the code within PanZoom.mxml is,

      private var _imageURL:String = Application.application.parameters.myVar;
      ...
      <ns1:ImageViewer
      id="imageViewer"
      imageURL="{ _imageURL }"
      bitmapScaleFactorMax="5"
      bitmapScaleFactorMin=".05"
      width="100%" height="100%"
      x="0" y="0"/>

      ...


      I have tried other paths to the image file, including

      images/map.jpg [required by command-line execution of .swf]

      pan_zoom_files/images/map.jpg [required by HTML page (myTest.html) that embeds the .swf file]




      I have succeeded in loading image viewer embedded in the jsp page when the image path is hard-coded in the mxml file, by means of the following code:

      <div id="swf-id" class="swfcontent"><embed type="application/x-shockwave-flash" src="../pan_zoom_files/FIG_PanZoom_for_jsp.swf" id="swf-id" name="swf-id" bgcolor="#ffffff" quality="high" wmode="opaque" height="480" width="772"></div>
      <script type="text/javascript">
      // <![CDATA[
      var props = new Object();
      props.swf = "../pan_zoom_files/FIG_PanZoom_for_jsp.swf";
      props.id = "swf-id";
      props.w = "772";
      props.h = "480";
      props.ver = "9";
      props.wmode= "opaque";
      var swfo = new SWFObject( props );
      registerSWFObject( swfo, "swf-id" );
      // ]]>
      </script>


      The error is either a "failed to load image" generated by the Image Viewer code, or a Flex system error message, resembling a null-pointer exception:


      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at FIG_PanZoom_for_jsp()
      at _FIG_PanZoom_for_jsp_mx_managers_SystemManager/create()
      at mx.managers::SystemManager/initializeTopLevelWindow()
      at mx.managers::SystemManager/docFrameHandler()



      Any ideas are greatly appreciated!!