View Full Version : Some questions
Metal3d
08-28-2008, 12:41 AM
Hi,
I'm using openlaszlo 4.1.1 and I'm trying 4.2beta. First, congratulations for this great framework and thanks !
I'm creating a chatroom with webcam and i encountered some troubles. Please, help me to understand:
1 - rtmpconnection works only in SERVER mode. If i try to deploy SOLO, rtmpconnection won't work. Is it normal? Is there solution ?
2 - Creating classes is easy, but access to elements inside the class is not trivial. Let me show you an example:
<class name="mytest" extends="view">
<view name="firstview">
</view>
<view name="secondview">
<view><!-- unamed view -->
<text name="foo"></text><!-- so this text isn't easy to get in code-->
<button name="test">Test
<handler name="onclick">
//access to firstview need lot of 'parent'
var fv = parent.parent.parent.firstview
</handler>
</button>
</view>
</view>
</class>
If I decide to move button on firstview, I have to change de handler code...
And tell me how to get "test" text element... Please, note that I cannot use "id" because this class will appears several times.
And "this" points to the current element, not the class... it's really ambiguous for developpers who come from other languages
3 - Libraries are really usefull but I wander why every classes I create are declared in "lz" namespace.
For example, if I create a class named "bar" into library, creating new "bar" in ecmascript is done like this: "var b = new ls.bar"
That's all for now :)
Regards,
Patrice, France
rcyeager
08-28-2008, 11:13 AM
I'm using openlaszlo 4.1.1 and I'm trying 4.2beta. First, congratulations for this great framework and thanks !
Suggest using 4.0.12 for any serious work. 4.1.x has some serious Jira's...none of my projects work well with 4.1.x yet. The SWF runtime compiles apps that are almost twice as large and twice as slow vs. 4.0.12.
1 - rtmpconnection works only in SERVER mode. If i try to deploy SOLO, rtmpconnection won't work. Is it normal? Is there solution ?
I looked at the rtmpconnection.lzx implementation briefly and didn't spot any obvious requirements for proxied mode. Suggest adding some debug trace output in this file, to see if you can track down where the problem may be when it does the connect.
2 - Creating classes is easy, but access to elements inside the class is not trivial.
This is a common frustration with complicated view hierarchies. In your code above, I would use classroot.firstview myself. There isn't much you can do when views need to be moved around, unfortunately. Over time, as you gain experience you'll learn how to write your code to minimize the impact...but again, not much can be really done with complex view hierarchies.
And tell me how to get "test" text element... Please, note that I cannot use "id" because this class will appears several times.
From external to the class, it would be classInstanceName.secondview.pickaname.test.text. Note that you have to pick a name for the unnamed subview of secondview!
And "this" points to the current element, not the class... it's really ambiguous for developpers who come from other languages
OL LZX is an instance-based language, which makes for fast prototyping. Tags are instances of classes, so the "this" within a tagged instance of an uninstantiated class makes perfect sense, once you get used to it.
3 - Libraries are really usefull but I wander why every classes I create are declared in "lz" namespace.
For example, if I create a class named "bar" into library, creating new "bar" in ecmascript is done like this: "var b = new ls.bar"
IMO, the OL developers really sucked it hard when they added this change into 4.1.x, just to support swf9. Dumping user-defined classes into the lz namespace makes zero sense from an application developer's point of view. They might as well bit the bullet and added user-defined namespaces, which still aren't available. Doesn't help that a lot of the documentation doesn't include the lz namespace in the samples, confusing new adopters like yourself even more.
If you like being on the bleeding edge of technology and like keeping lots of bandages handy when things go wrong, then you'll like OL.
Robert Yeager
http://www.qrowd.com
http://www.cooqy.com
Metal3d
08-28-2008, 02:15 PM
At first, thanks to anwer me :) and excuse my english
Suggest using 4.0.12 for any serious work. 4.1.x has some serious Jira's...none of my projects work well with 4.1.x yet. The SWF runtime compiles apps that are almost twice as large and twice as slow vs. 4.0.12.
Ok, i will try.
I looked at the rtmpconnection.lzx implementation briefly and didn't spot any obvious requirements for proxied mode. Suggest adding some debug trace output in this file, to see if you can track down where the problem may be when it does the connect.
So maybe the 4.1.X and 4.2 version is the problem. I will try with 4.0 version because debug messages didn't gave me solution.
This is a common frustration with complicated view hierarchies. In your code above, I would use classroot.firstview myself. There isn't much you can do when views need to be moved around, unfortunately. Over time, as you gain experience you'll learn how to write your code to minimize the impact...but again, not much can be really done with complex view hierarchies.
It's a pitty, but I can live with this :)
From external to the class, it would be classInstanceName.secondview.pickaname.test.text. Note that you have to pick a name for the unnamed subview of secondview!
That's what I used to do... it was an example.
OL LZX is an instance-based language, which makes for fast prototyping. Tags are instances of classes, so the "this" within a tagged instance of an uninstantiated class makes perfect sense, once you get used to it.
Yes, I don't blame the method, I did only need some precision
IMO, the OL developers really sucked it hard when they added this change into 4.1.x, just to support swf9. Dumping user-defined classes into the lz namespace makes zero sense from an application developer's point of view. They might as well bit the bullet and added user-defined namespaces, which still aren't available. Doesn't help that a lot of the documentation doesn't include the lz namespace in the samples, confusing new adopters like yourself even more.
Yes, I understood this by testing to create libraries. I wanted to create some namespaces and/or library names... but it never worked...
If you like being on the bleeding edge of technology and like keeping lots of bandages handy when things go wrong, then you'll like OL.
Yes, rock'n'roll !!! I love to try new technologies. I already tested OL months ago but without "project" to code. Now, I have a flash project to do (for myself) and I tried Flex.
OL have better methods and writting concepts excepting some "names" very badly choosen.
For example, an edittext view value is getted by "element.text" and not "element.value". Or movable attribute for windows is "allowdrag"... and not "moveable" or "dragable" as "resizable"...
I also had to extend rtmpconnection to pass several arguments to the connect method...
But really, OL permitts to create great flash application under Linux without to pay licences, etc... Really, I love !
Metal3d
08-28-2008, 02:57 PM
I tried with OL 4.0.13 and have the same issue with rtpmconnection... but I found why.
In fact, I tried on a local directory (file:///home/patachou/....). So I retried on apache directory and everything goes right :)
Retried with OL 4.2beta and it worked as well.
I perfer to use OL 4.2 because redefine method on extended class generate warnings on OL 4.0.X.
About size and speed, OL 4.2 generated a SWF bigger by 5% (and not twice for me). Speed is approximativally the same (better stream cam on 4.2 version... normal ?)
So now, I know that I will never use Flex anymore :p
Thanks again
rcyeager
08-28-2008, 05:56 PM
Good news!
My apps have about 50,000 lines of code. If you aren't creating anything that sophisticated, then you probably won't notice the bloat or performance loss in 4.1 vs 4.0.12. If your app only has a few hundred lines of code, then the compiled app size is just measuring the size of the LFC runtime, which didn't change too much.
Good luck,
Robert Yeager
http://www.qrowd.com
http://www.cooqy.com
Metal3d
08-29-2008, 01:17 PM
Ok, I have other questions, but i will open a new thread.
Thanks
Metal3d
09-01-2008, 03:44 PM
In fact, I found the way to have "this" class:
This is "classroot"
Found while I was modifying windowpanel styles :)
Thanks
caclark
09-01-2008, 04:45 PM
Let me add my 2 cents worth to some of RC's comments:
The SWF runtime compiles apps that are almost twice as large and twice as slow vs. 4.0.12.
There must be some proportional measure to it. I don't have an app as big as RC's, but I did see a 30% increase in the size that I'm not too fond of...
This is a common frustration with complicated view hierarchies. In your code above, I would use classroot.firstview myself. There isn't much you can do when views need to be moved around, unfortunately. Over time, as you gain experience you'll learn how to write your code to minimize the impact...but again, not much can be really done with complex view hierarchies.
I have used classroot.searchSubviews( "name", "<whatever name I'm looking for>" ) to locate a child view. I haven't performance benchmarked it to see how expensive it is. Has anyone else? I'd be interested in the results.
IMO, the OL developers really sucked it hard when they added this change into 4.1.x, just to support swf9. Dumping user-defined classes into the lz namespace makes zero sense from an application developer's point of view. They might as well bit the bullet and added user-defined namespaces, which still aren't available. Doesn't help that a lot of the documentation doesn't include the lz namespace in the samples, confusing new adopters like yourself even more.
Yeah. I might not have put it that harshly, but they sure didn't do what I'd have liked. I think they should have implemented developer-defined namespaces. I'm not a Flash VM expert by any means, but I'd sure like to know the reason they didn't. Perhaps they can add a namespace attribute to class definitions in the future with a default of "lz" to keep from breaking the current scheme. This would allow developers to move their code to their own namespace.
Maybe Henry or Tucker or one of the other gurus behind OL can shed some light on it.
senshi
09-02-2008, 03:42 PM
I have used classroot.searchSubviews( "name", "<whatever name I'm looking for>" ) to locate a child view.
"LzView#searchSubviews(..)" performs a simple BFS, so the more subviews and sub-subviews you create, the worse performance will get.
Yeah. I might not have put it that harshly, but they sure didn't do what I'd have liked.
That change was not motivated for the swf9-support, in fact for swf9, (as3-)namespaces are not even used (yet).
Generally it is treated as bad practice to place any objects in the global-namespace (be it _root or window). So modern RIA-frameworks create their own (pseudo-)namespaces (like "dojo.*", "YAHOO.*" etc.). Additionally, certain classes, for instance "lz.window" in the DHTML-runtime, couldn't be simply registered as "window" in the global namespace. So users were confused why they could write "new button()", but not "new window()".
I think they should have implemented developer-defined namespaces.
Behind the scenes, all code is first compiled as JS2 and then later to the specific runtime-code (swf8-9, dhtml). And we also try to stay as compliant as possible to the current ES4 specs, which are still unstable and have recently dropped namespaces (https://mail.mozilla.org/pipermail/es-discuss/2008-August/006837.html). So it's still open when and in which way namespaces will be supported in OpenLaszlo.
From Laszlo-Dev:
http://www.openlaszlo.org/pipermail/laszlo-dev/2008-July/016094.html
http://www.openlaszlo.org/pipermail/laszlo-dev/2008-July/016104.html
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.