[Laszlo-dev] why can't I access the "capabilities" static var on LzSprite in swf9??

P T Withington ptwithy at gmail.com
Tue Apr 8 09:02:07 PDT 2008


Static vars are lexically scoped. They are available to methods in the  
class. I'm not sure the scoping works in our JS1 backend though. So it  
is safer to reference it directly from the class. If you need to get  
to one from an instance you would say instance.constructor.static.

On Apr 8, 2008, at 11:25, "Henry Minsky" <hminsky at laszlosystems.com>  
wrote:

> That works. I wonder why accessing it via "this.sprite.capabilities"
> is giving a runtime error. Maybe I don't understand
> something about how JS2 static vars are accessed?
>
> On Tue, Apr 8, 2008 at 11:16 AM, Philip Romanik
> <promanik at laszlosystems.com> wrote:
>> do you get the error if you don't try accessing it through this, ie:
>>
>> if (LzSprite.capabilities.readcanvassizefromsprite == true)
>>
>>
>>>
>>>
>>>
>>> I'm trying to merge the sw9 and main versions of LaszloCanvas, and  
>>> I have
>> some modifications in to try and compile in swf9. I'm getting  
>> things to
>> compile but get this error at runtime when the app starts up:
>>>
>>> [Fault] exception, information=ReferenceError: Error #1069: Property
>> capabilities not found on LzSprite and there is no default value.
>>> Fault, LzCanvas() at LzCanvas.as:29
>>> 29    if (this.sprite.capabilities.readcanvassizefromsprite ==  
>>> true) {
>>> (fdb)
>>>
>>>
>>> The code in question is here in LzCanvas:
>>>
>>>   this.sprite = new LzSprite(this, true);
>>>   if (this.sprite.capabilities.readcanvassizefromsprite == true) {
>>>
>>>
>>> And LzSprite has "capabilities" declared as a static var, as  
>>> follows:
>>>
>>> public class LzSprite extends Sprite {
>>>
>>>     public static var capabilities:* = {
>>>     rotation: true
>>>     // Avoid scaling canvas to percentage values - SWF already  
>>> scales the
>> viewport size, so take window size literally to avoid scaling twice
>>>     ,scalecanvastopercentage: false
>>>     // the canvas already knows its size
>>>     ,readcanvassizefromsprite: false
>>>     ,opacity: true
>>>     ,colortransform: true
>>>     ,audio: true
>>>     ,accessibility: true
>>>     ,htmlinputtext: true
>>>     ,advancedfonts: true
>>>     }
>>> }
>>>
>>>
>>> So why would the runtime be complaining that it cannot find the  
>>> property?
>> Shouldn't it be available at runtime to the LzSprite instance due  
>> to being a
>> static class var?
>>>
>>>
>>> --
>>> Henry Minsky
>>> Software Architect
>>> <mailto:hminsky at laszlosystems.com>hminsky at laszlosystems.com
>>>
>>
>>
>
>
>
> -- 
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com


More information about the Laszlo-dev mailing list