[Laszlo-dev] [Platform-team] lz.colors question

J Crowley jcrowley at laszlosystems.com
Fri Nov 14 13:20:21 PST 2008


Thanks.  There also seems to be a bug in that DHTML doesn't display 
colors that are displayed in SWF8.  I'll file that one as well...

P T Withington wrote:
> That sounds like at least 2 bugs.
>
> 1) I'm not sure the compiler should be giving an error if you write an 
> expression as the initial (immediate) value for a color.  The compiler 
> should just let that expression be passed through and evaluated at 
> load time.  It is an optimization for the compiler to try to evaluate 
> constant colors at compile time, so it should not give an error if it 
> cannot.
>
> 2) The constraint/swf9 issue is a bug in constraints.  If you try to 
> constrain to an object property and the object is not an LzEventable 
> (i.e., cannot participate in our event system) then the constraint 
> should not be trying to 'listen' for events from that object.  _Maybe_ 
> you should be getting a warning, but I don't think you need to.  If 
> you thought you could update lz.colors and have constraints update, 
> you would have to say lz.colors.setAttribute('iceblue', ...) and that 
> _would_ give you an error, so you would know right then that something 
> was rotten.
>
> Please file both bugs with your test cases.
>
> On 2008-11-14, at 14:46EST, J Crowley wrote:
>
>> Here's something else... I changed the example to:
>>
>> <class name="box1" width="100" height="100" 
>> bgcolor="${lz.colors['gold4']}" />
>>
>> <class name="box2" width="100" height="100" 
>> bgcolor="${lz.colors.iceblue1}" />
>>
>> Which works fine in SWF8, but doesn't show the colors for the boxes 
>> in DHTML (If I remove the constraints from the first one, I get a 
>> compiler error, and if I remove them from the second, it shows black 
>> and gives an "Invalid value for bgcolor" message in the Debugger) and 
>> gives this error in SWF9:
>>
>> TypeError: Error #1034: Type Coercion failed: cannot convert 
>> LzInheritedHash at 716ccd1 to LzEventable.
>>   at LzNode/applyConstraintMethod()[C:\Documents and 
>> Settings\laszlo\Local Settings\Temp\lzswf9\lzgen2652\LzNode.as:1048]
>>   at LzNode/applyConstraintExpr()[C:\Documents and 
>> Settings\laszlo\Local Settings\Temp\lzswf9\lzgen2652\LzNode.as:1083]
>>   at LzNode/__LZresolveReferences()[C:\Documents and 
>> Settings\laszlo\Local Settings\Temp\lzswf9\lzgen2652\LzNode.as:943]
>>   at LzNode/__LZcallInit()[C:\Documents and Settings\laszlo\Local 
>> Settings\Temp\lzswf9\lzgen2652\LzNode.as:424]
>>   at LzCanvas/__LZcallInit()[C:\Documents and Settings\laszlo\Local 
>> Settings\Temp\lzswf9\lzgen2652\LzCanvas.as:443]
>>   at LzCanvas/__LZinstantiationDone()[C:\Documents and 
>> Settings\laszlo\Local Settings\Temp\lzswf9\lzgen2652\LzCanvas.as:390]
>>   at LzInstantiatorService/makeSomeViews()[C:\Documents and 
>> Settings\laszlo\Local 
>> Settings\Temp\lzswf9\lzgen2652\LzInstantiatorService.as:193]
>>   at LzInstantiatorService/checkQ()[C:\Documents and 
>> Settings\laszlo\Local 
>> Settings\Temp\lzswf9\lzgen2652\LzInstantiatorService.as:130]
>>   at Function/http://adobe.com/AS3/2006/builtin::call()
>>   at LzEvent/sendEvent()[C:\Documents and Settings\laszlo\Local 
>> Settings\Temp\lzswf9\lzgen2652\LzEvent.as:92]
>>   at LzIdleService/__idleupdate()[C:\Documents and 
>> Settings\laszlo\Local 
>> Settings\Temp\lzswf9\lzgen2652\LzIdleService.as:53]
>>   at LzIdleKernel$/__update()[C:\Documents and Settings\laszlo\Local 
>> Settings\Temp\lzswf9\lzgen2652\LzIdleKernel.as:27]
>>
>>
>> P T Withington wrote:
>>> But he should also be able to say:
>>>
>>>  bgcolor="iceblue"
>>>
>>> and/or
>>>
>>>  bgcolor="${this.acceptValue('iceblue', 'color')}"
>>>
>>> Which might be more instructive.  In the first case, you are 
>>> specifying a constant color, and since bgcolor is an attribute with 
>>> a type of `color` the token `iceblue` is acceptable as a value (not 
>>> tested).  In the second case, you are using a constraint, and (at 
>>> least as of now), constraints are simply expressions that _directly_ 
>>> set the value of an attribute -- they _do_not_ pass through the data 
>>> interface, which converts string representations into values 
>>> according to type.  (I think this is desirable.)  So, in the second 
>>> case, I am calling the (currently unpublished) `acceptValue` method, 
>>> which takes a string representation of a value and parses it 
>>> according to the specified type.
>>>
>>> There should be a better way.  Perhaps I should be able to say:
>>>
>>>  bgcolor="$accept{'iceblue'}"
>>>
>>> (meaning use acceptValue and the attribute's declared type to parse 
>>> the value of the expression)?  We've already got $path and $style, 
>>> why not $accept (unless someone can come up with a better name).  I 
>>> think this would allow me to say something like:
>>>
>>>  <inputtext id="color" />
>>>  <view bgcolor="$accept{color.text}" />
>>>
>>> would that be useful?
>>>
>>>
>>> On 2008-11-13, at 21:16EST, Max Carlson wrote:
>>>
>>>> You should be able to just set it to bgcolor="lz.colors.iceblue4" - 
>>>> constraints shouldn't be required.  Also note that colors aren't in 
>>>> global[] anymore - use lz.colors[''] instead.
>>>>
>>>> J Crowley wrote:
>>>>> So, I'm working on fixing one of the color dguide examples.  The 
>>>>> description on the doc page (docs/developers/color.html) reads:
>>>>> -----
>>>>> To specify any color but the 16 which are usable by name, use 
>>>>> 0xFFFFFF hex codes. Alternatively, the non-standard colors named 
>>>>> in |lps/components/base/colors.lzx| were added to OpenLaszlo's 
>>>>> global namespace. Those colors can also be employed by name, but 
>>>>> note the ${constraint} syntax around the bgcolor specification. 
>>>>> There are two ways to make the constraint: 
>>>>> |bgcolor="${global['iceblue1']}"| is the same as 
>>>>> |bgcolor="${iceblue1}"|.
>>>>> -----
>>>>> The example this describes is:
>>>>> -----
>>>>> <canvas debug="true">
>>>>> <simplelayout axis="x" spacing="10"/>
>>>>> <class name="box1" width="100" height="100" 
>>>>> bgcolor="${global['gold4']}" />
>>>>> <class name="box2" width="100" height="100" bgcolor="${iceblue1}" />
>>>>> <box1 id="sun">
>>>>>  <text text="Sun"/>
>>>>> </box1>
>>>>> <box2 id="mystic">
>>>>>  <text fgcolor="0xFFFFFF" text="Mystic"/>
>>>>> </box2>
>>>>> </canvas>
>>>>> -----
>>>>> Thing is, the only way to get the example to work is to change 
>>>>> bgcolor="${iceblue1}" to bgcolor="${lz.colors.iceblue1}", and 
>>>>> trying to use the global['gold4'] syntax doesn't actually work.  
>>>>> So my question is:  Is the description in the documentation 
>>>>> wrong?  Because doing it the way the description states results in 
>>>>> a Debugger error.  (Keep in mind I'm using the docs on 
>>>>> openlaszlo.org, since I can't build locally, so if the description 
>>>>> has already been changed, let me know and I won't file the bug, 
>>>>> but I do need to fix the example.  What I need to know then is, 
>>>>> what is the new way of doing this?)
>>>>> Thanks!
>>>>> Josh
>>>>
>>>> -- 
>>>> Regards,
>>>> Max Carlson
>>>> OpenLaszlo.org
>>>
>>>
>>
>>
>
>




More information about the Laszlo-dev mailing list