Flashcanvas an answer for non-html5 browsers?

Discussion and feedback on Construct 2

Post » Sun Jan 29, 2012 10:34 am

http://flashcanvas.net/example/benchmark

Would it, in theory, be possible to use this as opposed to the canvas, and perhaps remove sound support to allow non-html5 compliant browsers the ability to use games?
B
14
S
3
G
1
Posts: 25
Reputation: 1,289

Post » Sun Jan 29, 2012 11:57 am

It's easy to do it now.
You just have to edit the index.html file ;).
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Sun Jan 29, 2012 7:22 pm

[QUOTE=jessejoh]... Would it, in theory, be possible to use this as opposed to the canvas ... ?[/QUOTE]Not just in theory, but in practice! Simply download flashcanvas.js and flashcanvas.swf, and then add to your index.html:
[CODE]
<!--[if lt IE 9]>
<script type="text/javascript"
        src="<your dir>/flashcanvas.js">
</script>
<![endif]-->
[/CODE]
No other change needed!Velojet2012-01-29 19:32:00
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Sun Jan 29, 2012 7:26 pm

Are you telling me that we no longer require html5 enabled browser?
B
14
S
3
G
1
Posts: 25
Reputation: 1,289

Post » Sun Jan 29, 2012 7:28 pm

So it would seem! (At least as far as < IE9 are concerned.)

There's a good account of how it works here.Velojet2012-01-29 19:35:56
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Sun Jan 29, 2012 8:07 pm

This looks interesting - will check it out and see if it works. Can't make any guarantees though, excanvas was another alternative for example but turned out to be far too slow to be useful.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri May 18, 2012 11:09 am

So, I got flashcanvas pro from flashcanvas.net working!

You can view it on my server here:
http://linkit.faceyspacey.com/

Ok here's what I did:

1) dropped the flashcanvas /bin folder with all their goodies in the document root

2) i added the js that turns it on when needed by adding this at the top of the <head>:


<!--[if lt IE 9]><script type="text/javascript" src="bin/flashcanvas.js"></script><![endif]-->


3) i created javascript indexOf() function for arrays and put it before the Construct 2 runtime js:


<script type="text/javascript">
if (!Array.prototype.indexOf) {   Array.prototype.indexOf = function(elt /*, from*/)   {     var len = this.length >>> 0;      var from = Number(arguments[1]) || 0;     from = (from < 0)          ? Math.ceil(from)          : Math.floor(from);     if (from < 0)       from += len;      for (; from < len; from++)     {       if (from in this &&           this[from] === elt)        return from;     }     return -1;   }; }
</script>


4) I loaded all the runtime js and index.html js generated by Construct 2 at the appropriate time (i just did it for now how the flashcanvas.net examples do it), which is like this:


<body onload="setup()">


5) then i created 2 setup() functions. one for IE 8 and below, and one for everything else. Here's how I toggle between the two:


<!--[if IE]><script type="text/javascript" src="setup-ie.js"></script><![endif]-->
<![if !IE]><script type="text/javascript" src="setup.js"></script><![endif]-->


6) so here's what setup-ie.js looks like. And I'll summarize what I did first. Basically it writes to the dom a different c2runtime.js file called c2runtime-ie.js. And in that js file all I did was change the addEventListener methods to attachEvent, which is supported in IE7 and IE8. And i did the same thing in setup-ie.js file, which contains the js Construct 2 puts in the index.html file. So here is setup-ie.js:


function setup() {
$('head').prepend("<script src='c2runtime-ie.js'>\x3C/script>");


jQuery(window).resize(function() {
               if (window.c2resizestretchmode === 1)
               {
                    window.c2resizestretchmode = 2;          // put back when breaking back out of fullscreen
                    var canvas = document.getElementById("c2canvas");
                    window.c2oldcanvaswidth = canvas.width;
                    window.c2oldcanvasheight = canvas.height;
                    window.c2eventtime = Date.now();
                    var w = jQuery(window).width();
                    var h = jQuery(window).height();
                    cr_sizeCanvas(w, h);
               }
               else if (window.c2resizestretchmode === 2)
               {
                    // Size event fires twice on FF + Chrome, ignore second trigger
                    if (Date.now() > window.c2eventtime + 50)
                    {
                         window.c2resizestretchmode = 0;
                         cr_sizeCanvas(window.c2oldcanvaswidth, window.c2oldcanvasheight);
                    }
               }
          });
     
          // Start the Construct 2 project running on window load.
          jQuery(document).ready(function ()
          {
               // Create new runtime using the c2canvas
               cr.createRuntime("c2canvas");
          });
          
          // Pause and resume on page becoming visible/invisible
          function onVisibilityChanged() {
               if (document.hidden || document.mozHidden || document.webkitHidden || document.msHidden)
                    cr_setSuspended(true);
               else
                    cr_setSuspended(false);
          };
          
          document.attachEvent("visibilitychange", onVisibilityChanged, false);
          document.attachEvent("mozvisibilitychange", onVisibilityChanged, false);
          document.attachEvent("webkitvisibilitychange", onVisibilityChanged, false);
          document.attachEvent("msvisibilitychange", onVisibilityChanged, false);
}




------

So that leaves getting sound to work. I just started using Construct 2, with the sole aim being to get this to work in IE7 and IE8 using flash canvas. I looked through its Audio object real quick, and it seems completely custom, rather than based on SoundManager2, which seems to be the best cross-platform audio option.

C2 TEAM CAN WE REPLACE YOUR AUDIO FRAMEWORK WITH SOMETHING MORE CROSS PLATFORM AND MAKE IE7/IE8 SUPPORT ONE OF YOUR KEY SELLING POINTS? It seems to be a no brainer at this point. Maybe there are other bugs, depending on what you want to do with C2 that has made them stay away from IE7/IE8, but if their pretty fancy Space Blasters game works in IE7/IE8, many games your developers will want to make will work in those browsers.

What can we do to get sound working in IE7/IE8. What do you recommend?

B
4
Posts: 49
Reputation: 854

Post » Fri May 18, 2012 6:33 pm

I don't see why support in IE7/IE8 is so important.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sat May 19, 2012 10:23 am

@sqiddster : for those using C2 to create webapps, and not only games, IE7 support can be useful (since a lot of companies still use it).
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Sat May 19, 2012 10:55 am

So, does this mean we'll be able to submit to Newgrounds? (NG will most likely eventually accept HTML5, but there seems to be some resistance to it right now, so I don't see it happening in the near future.)
B
15
S
2
G
3
Posts: 45
Reputation: 2,638

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests