开发者

IntelliJ Idea Java project with Flex, how to embed generated SWF

Sorry for the potentially stupid question, I'm newbie in Java. I have a simple IntelliJ Java project with Flex support. The project contains index.jsp page. And after building of the project, the .swf is placed in the WEB-INF/classes folder.

The directory stucture of the generated artifact i开发者_运维百科s:

index.jsp
Web-inf
  web.xml
  classes
    main.swf

Could you help me please, how to embed main.swf into the index.jsp? If simply - how could I access the file located in the WEB-INF/classes folder?


To supplement Constantiner's comment, regardless of the IDE, you can set up your project to use this convention:

/web
    /flex - Where your Main.swf goes and anything it it needs (i.e. css, jpgs, mp3s, misc assets
    /META-INF - Where your context.xml goes, not accessible to clients
    /WEB-INF
        /classes - The directory where all your pre-compiled java .class files goes
        /flex - Where blazeDS xml config files go
        /lib - Where your java shared libraries go (i.e. jar's
        web.xml - Where you set up your container's listeners and servlet mappings
    index.jsp - Your .jsp will have access to /flex stuff... You could of course promote the contents of /flex to be directly under /web
    index.html - Hello World


To embed a SWF file inside any web page--including one generated from a JSP file--there are a few options:

1) Use the embed HTML tag, something like this:

<embed src="classes/main.swf" quality="high" 
    width="500" height="250" name="Sample" align="middle"
    play="true"
    loop="false"
    quality="high"
    allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
    pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>

Sites like YouTube use this approach to make embedding easy.

2) Use a JavaScript library like SWFObject. The default HTML Templates in the Flex Framework use this. It is, basically, a fancy way to figure out which browser is being displayed and choose the best way to embed the SWF.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜