How to manage multiple scenes in easeljs? - html

I am impelemting a game in easeljs. I need to add different scenes in different html files. But I dont know how to do it. I mean, when I clicked an object in a file. It must pass different file and load its functuanilities. I searched the problem but the answers always in the same file with adding and removing different containers.

I am not sure what you are trying to do. When you say multiple HTML files, are you referring to content exported by Flash/Toolkit? If so, you will have to do some work to combine the content into one "application". Other than loading HTML files into iframes, there isn't really a straightforward way of loading another HTML file into your application (akin to loading another SWF into a Flash application).
Can you describe more your different scenes, how they are constructed, and what you are trying to accomplish?

Related

Embedding pdf and images in html

I need to embed both pdf-files and images in my html-page, however, due to the fact that my html contains a form and the user has to be able to decide whether he would like to upload a pdf-file or an image, I need a flexible solution regarding how to embed either a pdf-file or an image with the same code.
I read that I could possibly use the <object/> tag, however, I also read that that's not a very "elegant" and possibly slow solution.
I also considered to use <embed/> which, as of right now, is the best solution I could come up with. Unfortunately I couldn't find out about if it's a very conventional solution or not.
I can't seem to find very much resources regarding this topic online, hence why I'm asking here. Are there any other/better ways to embed a pdf- or image-file in an html page?
Edit: I want top display the pdf kind of like a file. Also, I don't want the user to be able to resize the pdf in the viewer
I'm sure this is better suited to a comment, however I'm new and am working on unlocking that feature.
...however,
due to the fact that my html contains a form and the user has to be
able to decide whether he would like to upload a pdf-file or an image...
What are you using for the form (query language & database management)?
(PHP, Django, MySQL, MongoDB, etc)
Are there any other/better ways to embed a
pdf- or image-file in an html page?
I would recommend using embed or iframes. You are correct in thinking that the object tag is not an elegant solution, since you are dealing with images.
Edit: I want top display the pdf kind of like a file. Also, I don't
want the user to be able to resize the pdf in the viewer
Easy to do with iframes. There's a lot of hate when it comes to iframes. As you seem to plan on using it as a tool to display a file within a page, then I believe using an iframe here is just fine.
Check out this link on iframes. (will also tell you how to keep the user from resizing it)

Is there a reason not to embed the main css file into the web page?

I'm trying to optimize the loading time of my webpages, both on the first time and from cache. But I still ask the browser to re-validate all resources to make sure I will never have a weird display or an update problem due to the cache.
So currently the loading of my page always needs two requests: one for the HTML file, one for the CSS file before anything is displayed.
For both of this files, the waiting time is like 150ms while the transfer is like 5ms, which is very low.
So I'm thinking about always embeding my mais css file into the web page.
This isn't the academic way to do, but I think this would multiply the loading speed by 2, making only one request needed to load the page.
Is there a reason why I should not do that ?
you can get the best of both worlds if you set up a build script for your website.. so basically in your local file system you can keep your css files separated, making it more portable and easier to maintain etc.. but at the same time your build script embeds your css and other static files (ie js) into your html page to avoid precisely what you talked about (ie redundant connections to the server)..
Portability, the ability of changing one .css file and change multiple .html files with a reference to that css.
However, if your css is only used in that page, I think is a good reason to include it in the same file.

JSP - How to read file and display Image

I have an JSP page where I want to display an image from a specific folder of my computer. Can any body help me how can I do this ? Another issue is, I want to read a text file from a specific folder by my JSP code, can anybody help me how can I achive this ?
You can use an HTML img tag to display the image. As long as the image is in the same directory as your jsp file, you can just reference it directly.
As far as reading the file goes, it really depends on what exactly you're trying to do here. For a complex web application, (in the interests of keeping your model and view separate) you need to use a lot of different technologies like JSTL and java beans, and maybe even a framework like Spring. If what you're trying to do is simple you can "cheat" and read the file with a scriptlet, just don't expect the code to scale to anything complicated.

Pros and cons of using embedded images instead of dynamic loading

I was just wondering what are the pros and cons of using embedded images instead of dynamic loading? Because when making games on pure AS3 (without Flash IDE), its a pain to manually embed all the assets needed... That makes your code sloppy, besides you don't have control to automatically change the hud, for example, by only changing the external file.
But I heard that some sites only let you upload a single swf, so you can't have external images. Also I heard that some are worried about users downloading their art... But as far as I know, and please correct if I'm wrong, they can also download them if they hack the swf with a decompiler. Having it external, you can encrypt the image, and unencrypt it on the code, so if they try to download they will only get encrypted code.
So... What do you think about embedding images? Please share all your thoughts to me.
I believe dynamic loading of images is a better approach. I agree with you about the game problem you stated, but when you are talking of flash/as3 as a whole, games are just one of the things among the many, you do. Also there are a few which also accept multiple files & maybe more will allow later. As of now hosting sites are just being on the safe side by not allowing multiple files & formats. So if you really have additional files you could just host them elsewhere & call them from your main swf.
I however cant agree about the point of making the code sloppy by managing images dynamically. When you do it through an IDE the IDE is writing the code for you, but as you might realize letting an IDE decide what to write doesn't always make the best. Manually handling things let's you understand all entry & exit points of an app. Moreover, would you want to open a flash IDE every time you wish to add an image, make an update, etc.
I usually like to use IDE cause of the awesome tools it provides to make things more efficient & prefer letting the code do all management/control stuff.And yes, if you have many small images (as in online flash games), embedding is better approach.
As far as the security is concerned even externally loaded files can be accessed if the encryption algorithm you use, can be found by decompiling the swf. So your best bet in case of security is usually using a third party software to encrypt the swf, which let's say increases your chance to prevent theft of your material. So if you really encrypt the swf using a 3rd party tool, both the ways would be acceptable.
I believe both approaches are valid, it mainly depends on your assets.
As you know embedding assets, will increase the size of your swf, I would only consider doing this for icon type images where size is hardly an issue.
For bigger images, I would definitely go for dynamic loading which I also find more flexible.
If I have lots of small icons, I'm embedding them. Imagine that number of requests in runtime, any of which may timeout. Pain of embedding, where? A single Embed tag in source or CSS for an asset. "Constant" assets must be embedded, "variable" ones - loaded.
Edit: OK, I got it. Pain of embedding lots of assets. Here is one idea come to my mind... Even if you loading something dynamically, you need some list with all filenames? You may take list of files and generate class full of public static const members with [Embed] attributes, that's fairly trivial. Then you use that class in project and voila, all is in the place. Maybe this helps.

How can I make a Table of Contents frame in XSL?

I have an XML file that I am creating an XSL stylesheet for.
What I would like is to have two frames and do two passes on the data, the first would create a Table of Contents in the left frame, and the second would have the body of data in the right.
I can do the two passes, the problem is putting them in separate frames. The frame HTML element takes in a source; I can't put my source directly in there.
I can think of a few ways to get around this, none of which I'm thrilled with, so I wanted to see if anyone had found a way to do this.
As said before, you need 3 files for this.
In XSLT 2.0 you can generate multiple output files from one xsl stylesheet using the xsl:result-document instruction.
In XSLT 1.0 you don't have that function, but depending on the processor it might be possible. For example for Xalan see http://xml.apache.org/xalan-j/extensions_xsltc.html#redirect_ext
If you want to use frames you need three separate files.
The frame file. This is just a strict HTML file
A file for your table of contents
A file for your content
The first one is as specified just an HTML file. The second two are XSL files that will eventually turn into HTML. A good tutorial on frames is here at W3Schools.
EDIT: The more I think about this, the more I dislike the solution. It requires the XSL parser to be run twice for each time the initial page is served
Have you thought about using CSS or tables to do your layout? There are some really good open source CSS templates flying about here on the interwebs.
This was relatively stable data that would be generated by a script, so what I ended up doing was creating separate stylesheets for the TOC and the main window, then using those to generate html files for each of them after I generate the html.
Then my main page was just a static html page that referenced these generated html files.
There's probably a better way to do it, but this is an internal reference, so this is enough to get me going.