ArticleDirectory
- Openlaszlo dhtml css 3 demo-to flash or not to flash, is no question!
Openlaszlo dhtml css 3 demo-to flash or not to flash, is no question!
By Raju bitter on August 25,200 9
Since the openlaszlo DHTML runtime has been released, I 've been wondering if there' ll ever be the time for me to say: "I can imagine that flash won't be a necessity for always Ally very appealing RIAs!" That time has come, thanks to the incredible work on great open source projects like the Firefox browser or WebKit.
Judge for yourself, here are two versions (DHTML/JavaScript and swf9) of a demo application, that was plain red by Zachary Johnson's great css3 text-shadow demo. this is the openlaszlo DHTML/JavaScript version of the demo, and as always with the advanced CSS features, you need a modern browser for it to work (I 've successfully tested with Firefox 3.5 +, Safari 4.x or WebKit nighly build, Google Chrome and opera 10 ):
Please upgrade your browser
And in case you wonder, what the swf9 version of this application looks like, here it is. even after so many years of working with openlaszlo it's still surprising to see how well the platform renders applications must SS runtimes.
I believe this demo underlines what I 've said in my previous blog, that openlaszlo can be one of the key keys ys to drive adoption of standards like HTML 5 and css3 extensions in the RIA space, providing a backup version of an application in flash for Internet Explorer 6/7 and older browsers. and who wocould choose flash, if you can get exact the same visual results with open standards!
Update: Some people have requested the source code for this example. this is the main LZX file, and here is a link to the ZIP file containing the graphic resources as well. I ran tested with openlaszlo 4.5.1 and trunk.
View plaincopy to clipboardprint?
-
-
-
- <? XML version = "1.0" encoding = "UTF-8"?>
-
- <! -- * Gpl_copyright_begin ************************************* **********
-
- * Copyright 2009 Raju bitter
- * Use is subject to license terms.
-
- * This program is free software: You can redistribute it and/or modify
-
- * It under the terms of the GNU General Public License as published
-
- * The Free Software Foundation, either version 3 of the license, or
-
- * Any later version.
-
- *
-
- * This program is distributed in the hope that it will be useful,
-
- * But without any warranty; without even the implied warranty
-
- * Merchantability or fitness for a special purpose. See
-
- * GNU General Public License for more details.
-
- *
- * You shoshould have written ed a copy of the GNU General Public License
-
- * Along with this program. If not, see
-
- * Gpl_copyrightincluend ************************************** **************** -->
-
- <Canvas width = "600" Height = "400" bgcolor = "# ffffff" proxied = "true">
-
-
-
- <! -- Resources -->
-
- <Resource Name = "spotlightres" src = "spotlight.png"/>
-
- <Resource Name = "openlaszlores" src = "OpenLaszlo-Header.png"/>
-
-
-
- <! -- Reposition boxes depending on mouse X-pos -->
- <Handler name = "onmousemove" reference = "LZ. globalmouse"> <! [CDATA [
-
- VaR posx = canvas. getmouse ('x ');
-
- VaR posy = canvas. getmouse ('y ');
-
- If (posx> 0 & amp; posy> 0 & amp; posx <canvas. width & amp; posy <canvas. height ){
-
- Spotlight. setattribute ("X", (posX-spotlight.width/2 ));
-
- Spotlight. setattribute ("Y", (posY-spotlight.height/2 ));
-
- // Calculate Angel and distance
-
- VaR xx = posx-canvas. width/2;
-
- VaR YY = (posy-canvas. Height/2 );
- VaR distance = math. SQRT (math. Pow (XX, 2) + math. Pow (YY, 2 ));
-
- VaR angle = math. atan (yy/xx)/(math. PI/180 );
-
- If (XX <0 ){
-
- Angle + = 180
-
- }
-
- If (XX> = 0 & amp; YY <0 ){
-
- Angle + = 360
-
- }
-
- Thetext. setattribute ("distance", distance/2 );
-
- Thetext. setattribute ("angle", angle + 180 );
-
- }
- ]>
-
- </Handler>
-
-
-
- <Class name = "demotext" extends = "text">
-
- <! -- As3 import statements -->
-
- <Switch>
-
- <When property = "$ as3">
-
- <Passthrough>
-
- Import flash. Filters. dropshadowfilter;
-
- </Passthrough>
-
- </When>
- </Switch>
-
-
-
- <! -- Shadow distance -->
-
- <Attribute name = "distance" value = "12"/>
-
- <! -- Shadow angle -->
-
- <Attribute name = "angle" value = "0"/>
-
- <! -- Blur X -->
-
- <Attribute name = "blurx" value = "5"/>
-
- <! -- Blur y -->
-
- <Attribute name = "blury" value = "5"/>
-
-
- <! -- Xoffset for CSS Dropbox -->
-
- <Attribute name = "_ xoffset" value = "0"/>
-
- <! -- Yoffset for CSS Dropbox -->
-
- <Attribute name = "_ yoffset" value = "0"/>
-
-
-
- <! -- Reference to the Flash dropshadowfilter object -->
-
- <Attribute name = "shadowfilter" value = "null"/>
-
-
-
- <Handler name = "oninit">
-
- This. addboxshadow ()
- </Handler>
-
-
-
- <Method name = "addboxshadow">
-
- If ($ DHTML ){
-
- // LZ. Text clipping active, which wocould cut off the shadow in DHTML
-
- // Workaround for http://jira.openlaszlo.org/jira/browse/LPP-8415
-
- This. getmcref (). style. Overflow = "visible ";
-
- This. getmcref (). firstchild. style. Overflow = "visible ";
-
- This. getmcref (). firstchild. style. Clip = "";
-
- This.css calculateoffset ();
-
- VaR cssstring = "#333" + _ xoffset + "PX" + _ yoffset + "PX" + blurx + "PX ";
- Debug. Write (cssstring );
-
- This. getmcref (). style. textshadow = cssstring;
-
- } Else {
-
- /* Dropshadowfilter constructor values:
-
- * [Distance: Number]
-
- * [Angle: Number]
-
- * [Color: Number]
-
- * [ALPHA: Number]
-
- * [Blurx: Number]
- * [Blury: Number]
-
- * [Strength: Number]
-
- * [Quality: Number]
-
- * [Inner: Boolean]
-
- * [Knockout: Boolean]
-
- * [Hideobject: Boolean])
-
- */
-
- This. shadowfilter = new flash. Filters. dropshadowfilter (this. distance, this. angle,
- 0x333333, 0.95, this. blurx, this. blury, 1, 2, false );
-
- // Have to remove mask on Sprite for swf8 Runtime
-
- // Workaround for http://jira.openlaszlo.org/jira/browse/LPP-8426
-
- If ($ as2 ){
-
- This. Sprite. removemask ();
-
- }
-
- Updateswffilter ();
-
- }
-
- </Method>
-
-
-
- <Handler name = "onangle">
- If ($ as2 | $ as3 ){
-
- This. shadowfilter. angle = This. angle;
-
- This. shadowfilter. Distance = This. distance;
-
- This. shadowfilter. blurx = This. blurx;
-
- This. shadowfilter. blury = This. blurx;
-
- Updateswffilter ();
-
- } Else if ($ DHTML ){
-
- This.css calculateoffset ();
-
- VaR cssstring = "#333" + _ xoffset + "PX" + _ yoffset + "PX" + blurx + "PX ";
-
- This. getmcref (). style. textshadow = cssstring;
-
- }
- </Handler>
-
-
-
- <Method name = "updateswffilter">
-
- This. Sprite. getmcref (). Filters = [This. shadowfilter];
-
- </Method>
-
-
-
- <Method name = "csscalculateoffset">
-
- // Css3 doesn't use angle, but x/y offset. So we need
-
- // Translate from angle and distance to x and y offset for css3.
-
- // Math. Cos and math. Cos are based on radians, not degrees
-
- VaR radians = This. Angle * Math. PI/180;
-
- This. _ xoffset = math. Round (math. Cos (radians) * This. Distance );
- This. _ yoffset = math. Round (math. Sin (radians) * This. Distance );
-
- </Method>
-
-
-
- </Class>
-
-
-
- <Demotext align = "center" Y = "$ {canvas. Height/2-this.height}" id = "thetext" clip = "false"
-
- Fontsize = "70" fontstyle = "bold" fgcolor = "# 2c657a" opacity = "1.0"> openlaszlo </demotext>
-
-
-
- <View id = "wall" resource = "openlaszlores" Y = "$ {canvas. Height-180}"/>
-
-
-
- <View id = "spotlight" x = "$ once {canvas. width/2-this.width/2} "Y =" $ once {canvas. height/2-this.height/2} "resource =" spotlightres "/>
-
- </Canvas>
<? XML version = "1.0" encoding = "UTF-8"?> <! -- * Gpl_copyright_begin ************************************* * ********* Copyright 2009 Raju bitter * use is subject to license terms. * This program is free software: You can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the license, or * any later version. ** this program is distributed I N the hope that it will be useful, * but without any warranty; without even the implied warranty of * merchantability or fitness for a participant purpose. see the * GNU General Public License for more details. ** you shoshould have written ed a copy of the GNU General Public License * along with this program. if not, see
and if you built some other cool demos with css3 or HTML5 support, please ping me!