Justin Mclean created FLEX-35262:
------------------------------------
Summary: [FlexJS] Uncaught exception
Key: FLEX-35262
URL: https://issues.apache.org/jira/browse/FLEX-35262
Project: Apache Flex
Issue Type: Bug
Components: FlexJS
Reporter: Justin Mclean
This code:
{code}
<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:js="library://ns.apache.org/flexjs/basic"
xmlns:comp="components.*">
<js:valuesImpl>
<js:SimpleCSSValuesImpl/>
</js:valuesImpl>
<js:initialView>
<js:View id="base" percentWidth="100" percentHeight="100">
<comp:Box no="3" colour="red" />
</js:View>
</js:initialView>
</js:Application>
{code}
And this component:
{code}
<?xml version="1.0"?>
<js:Container xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:js="library://ns.apache.org/flexjs/basic">
<js:beads>
<js:ContainerDataBinding />
</js:beads>
<fx:Script><![CDATA[
protected var _colour:String;
[Bindable]
public var no:int;
[Bindable]
public function set colour(colour:String):void {
bigBox.style = "background-color:" + colour + ";text-align:center;";
}
[Bindable]
public function get colour():String {
return _colour;
}
]]></fx:Script>
<js:Container id="bigBox" height="32" width="32"
style="background-color:#E3E3E3;text-align:center;">
<js:Label text="{no}"
style="line-height:32px;font-size:150%:font-weight:bold" />
</js:Container>
</js:Container>
{code}
Gives an exception when run.
{code}
Box.js:88 Uncaught TypeError: Cannot set property 'style' of undefined
at components.Box.__bindingWrappedSetter__colour (Box.js:88)
at components.Box.bindable__set__colour (Box.js:124)
at components.Box.set__colour (Box.js:135)
at
Function.org.apache.flex.utils.MXMLDataInterpreter.initializeStrandBasedObject
(MXMLDataInterpreter.js:158)
at Function.org.apache.flex.utils.MXMLDataInterpreter.generateMXMLArray
(MXMLDataInterpreter.js:95)
at Function.org.apache.flex.utils.MXMLDataInterpreter.generateMXMLInstances
(MXMLDataInterpreter.js:218)
at org.apache.flex.core.View.org.apache.flex.core.ContainerBase.addedToParent
(ContainerBase.js:149)
at Main.org.apache.flex.core.Application.addElement (Application.js:116)
at Main.org.apache.flex.core.Application.initialize (Application.js:55)
at Main.org.apache.flex.core.Application.start (Application.js:212)
components.Box.__bindingWrappedSetter__colour @ Box.js:88
components.Box.bindable__set__colour @ Box.js:124
components.Box.set__colour @ Box.js:135
org.apache.flex.utils.MXMLDataInterpreter.initializeStrandBasedObject @
MXMLDataInterpreter.js:158
org.apache.flex.utils.MXMLDataInterpreter.generateMXMLArray @
MXMLDataInterpreter.js:95
org.apache.flex.utils.MXMLDataInterpreter.generateMXMLInstances @
MXMLDataInterpreter.js:218
org.apache.flex.core.ContainerBase.addedToParent @ ContainerBase.js:149
org.apache.flex.core.Application.addElement @ Application.js:116
org.apache.flex.core.Application.initialize @ Application.js:55
org.apache.flex.core.Application.start @ Application.js:212
(anonymous) @ index.html:108
{code}
Looks the setter is being called before bigBox exists. I can see that
this.numElements is 0 inside the colour method.
Alex suggested that a try/catch should be added to the generated code.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)