[Laszlo-dev] Is there a way to make this work in both swf8 and swf9 ?

Donald Anderson dda at ddanderson.com
Mon Oct 6 06:18:08 PDT 2008


Okay it's
   http://www.openlaszlo.org/jira/browse/LPP-7127

Subject says it is JS1 problem, but it looks from the end of the  
description that
there is also a problem in SWF8?
Bottom line is both code fragments should work in all runtimes.

On Oct 6, 2008, at 5:50 AM, P T Withington wrote:

> Don, you should probably create a bug for the JS1 back-end to fix  
> this.  Right now, when a class is translated to JS1, the initial  
> values for slots are passed as arguments to the class constructor,  
> and hence evaluated in a context before the class is defined.   
> Instead the initial values should be moved into the same context  
> that top-level statements in the class body are evaluated in (which  
> is what the work-around that André describes is doing by hand).
>
> On 2008-10-05, at 18:27EDT, André Bargull wrote:
>
>> This pattern is used for the service classes: first declaration,  
>> then the definition. Works there for swf8 and swf9.
>>
>> <script when="immediate" ><![CDATA[
>>  public class LzQName {
>>    static var XSD_STRING;
>>    LzQName.XSD_STRING = new LzQName("string",  
>> LzNamespace.URI_DEFAULT_SCHEMA_XSD);
>>    function LzQName(type:String, uri:String) {
>>    }
>>  }
>> ]]></script>
>>
>>> >/
>>> />/
>>> />/ It should work in both runtimes to just leave out the name of  
>>> the class,
>>> />/ since static vars are 'in scope' of the class body.
>>> />/
>>> /
>>> OK that works for that case, but there's another case that's  
>>> causing an
>>> error in swf8, which is when the thing tries to instantiate an  
>>> instance of
>>> itself as a static var initializer, e.g.,
>>>
>>> public class LzQName {
>>> static var XSD_STRING =
>>>   new LzQName("string", LzNamespace.URI_DEFAULT_SCHEMA_XSD);
>>>
>>>
>>> <a title="#75">ERROR @rpc/library/qname.js#130: call to undefined  
>>> function
>>> 'LzQName'</a>
>>>
>>
>
>


--

Don Anderson
Java/C/C++, Berkeley DB, systems consultant

voice: 617-547-7881
email: dda at ddanderson.com
www: http://www.ddanderson.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-dev/attachments/20081006/1a691c9c/attachment.html


More information about the Laszlo-dev mailing list