Got Problems with SWFObject

Hello,

i’m using the swfobject add-on to display charts using Fusion Charts. i had followed the examples in earlier discussion about integrating Fusion Charts with vaadin.
The add-on is successfuly installed and i have done the compilation of the widget.
This is my code:


Window win = new Window(“users chart”);
ThemeResource chartResource = new ThemeResource(“swf/FCF_Line.swf”);


SWFComponent swf = new SWFComponent(chartResource, “1600px”, “900px”);
swf.setFlashVar(“dataUrl”, “swf/users.xml”);
swf.setParameter(“movie”, “swf/FCF_Line.swf”);
swf.setParameter(“quality”, “high”);
swf.setParameter(“id”, “Line”);
swf.setParameter(“classid”, “clsid:D27CDB6E-AE6D-11cf-96B8-444553540000”);
swf.setParameter(“codebase”, “http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0”);

[i]
win.addURIHandler(new URIHandler() {

        private static final long serialVersionUID = 1L;

        public DownloadStream handleURI(URL context, String relativeUri) {
            if (relativeUri.startsWith("users.xml")) {
                String myString = "&dataXML=";
                byte currentXMLBytes[] = myString.getBytes();
                ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
                        currentXMLBytes);
                return new DownloadStream(byteArrayInputStream, null, null);
            }
            return null;
        }
    });

[/i]


win.addComponent(swf);
setMainWindow(win);

The problem that’s i got a blank web page and when i click i got the msg about flash component: “About Flash Player …”

i don’t know what causes this problem!!!
Please Help :slight_smile:

Regards,
Jazia

Hi Jazia,

I had a similar issue, the resolution was ensuring that my SWF files were in the correct place. I’m using a ClassResource instead of a ThemeResource, and have the path for example ‘/Charts/SwfName.swf’. In this case the files need to reside in classes/Charts/ in the web app deployment.

Good luck, I am still working out other kinks with the implementation.

Jenica

For future people searching on this topic: one issue I encountered was setting the data url worked on my computer but not others.

Turning on debug mode in fusion charts showed the same URL for both, but the url didn’t begin with a slash so the different browsers were not interpreting it the same.

(to turn on debug mode:
ClassResource chartResource = new ClassResource(“/Charts/somechart.swf”, getApplication());
SWFComponent chart = new SWFComponent(chartResource, “100%”, “100%”);
chart.setFlashVar(“dataUrl”, getApplication().getURL().getPath()+“myUrl”);
chart.setFlashVar(“debugMode”, “1”); <----------------------------LIFESAVER

Ensure that your data url begins with
getApplication().getURL().getPath()+“whateverUrlHere”

You can use a ThemeResource if you put your .swf files under themes/yourTheme/ or you can use a ClassResource if you put your .swf’s on the classpath.

If I run into any other snags I will try to document here, for others (and maybe even for me if I run into these issues again!)

Jenica

Thank you for that LIGHTSAVER!!!

May have found it eventually, but a big help indeed!

C

Sorry… LIFESAVER not LIGHTSAVER :slight_smile: