spark textInput in Flex 4.12.1 and 4.13 issue - apache-flex

When a spark textInput is used with displayAsPassword=true in Apache Flex 4.12.1 and 4.13 throws "ReferenceError: Error #1065: Variable flashx.textLayout.factory:TextLineFactoryBase::_pass0Lines is not defined."
Works well if either spark textInput is replaced with mx textInput or Flex 4.12 and earlier.
Thanks

Related

QML Connection and IDE - new syntax: Implicitly defined onFoo properties in Connections are deprecated

In the new version of QML 1.5.0, it is recommended to use the new syntax for connection e.g.
MouseArea {
Connections {
function onClicked (mouse) {foo (mouse)}
}
Using the "Qt Design Studio 1.5.0" or "Qt Creator 4.12.1" IDE
I get this warning.
With the old syntax, connections are visible in the Form Editor -> Connection View window and nothing is displayed there after the change
for a new one.
Form Editor -> Connection with old syntax.
Being in a UI file e.g. main.ui.qml
Old syntax:
I receive a message:
Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo (<arguments>) {...}
After correcting for the new syntax, the message is: Function are not supported on a Qt Quick UI Form. (M22). and now is no possibility to edit the window using Form Editor.
I also can't make a connection to property e.g.
property bool mouseEnable: false
Connections {
target: parent
function onMouseEnableChanged(parent)
}
This is probably intended to be a signal handler but no signal of the target matches the name.
It is possible to stay with the old syntax without displaying a warning
or maybe someone knows how to use the new syntax without the above IDE errors?

QML QtQuick `control` property of corresponding Style object is sometimes null

I have some QML code using QtQuick.Controls 1.4 from Qt 5.6.1. I have some wrappers around various controls, such as ComboBox; these make use of Style objects. For instance, MyComboBox is a ComboBox with a custom ComboBoxStyle.
Every so often, when certain components are loaded, the control property in the Style object is null:
In MyComboBox.qml:
...
style: ComboBoxStyle {
...
label: Label {
text: control.currentText
...
The resulting error output is:
qrc:/MyComboBox.qml:72: TypeError: Cannot read property 'currentText' of null
Restarting the application typically fixes the error.
I have no idea how this could happen or why the error appears non-deterministic. What can I do to investigate?
This appears to have been fixed in release 5.6.1-1; since upgrading, we have not observed this error. Presumably we were simply observing one of the less-critical symptoms of QTBUG-53761.
Credit to jpnurmi for recognizing the similarity of the symptoms I described to the behavior of the bug, and for notifying me that a release with a fix was available (which, sadly, is not evident on the Qt 5.6 release-series page).

Component.onCompleted complains about "Non-existent attached object"

I have a QML file Foo.qml:
import NDDView 1.0
NDDView {
source: "nddcontent/Foo.uip"
Component.onCompleted: console.log("Yay!")
}
The NDDView component inherits from QQuickFramebufferObject. When I compile and use this component in my project, I get the error:
qrc:/Foo.qml:5 Non-existent attached object
Why am I getting this error?
How can I instead run 'setup' code on my component?
In case it matters, my real component looks more like this:
NDDView {
property var paths: ([])
property int items: 20
property string prefix: "foo"
Component.onCompleted: {
for (var i=items;i--;) paths.push(prefix+i);
}
}
I am trying to procedurally populate an array when the component is instantiated. If there's a better/alternate way to perform this task without Component.onCompleted, I'm happy to use it instead.
The Component QML Type type is registered by the QtQml module, and for backwards compatibility and convenience reasons, also by the QtQuick module. In order to make the type available, you must import either of these modules. Therefore, when writing QML apps with Qt 5, most .qml files begin with either:
import QtQuick 2.0 // or later
or
import QtQml 2.0 // or later
The latest available version depends on which Qt version you are using, and how old Qt versions you want to support. Importing the latest version, which is documented in the beginning of each QML type, is necessary if you use properties or methods introduced in the latest version.

Flex Mobile Why persistNavigatorState="true" and stage.setAspectRatio(StageAspectRatio.PORTRAIT) don't mix?

Why can't I use persistNavigatorState="true" and stage.setAspectRatio(StageAspectRatio.PORTRAIT) together in initializing program.
<s:View ...creationComplete="init()">
protected function init():void {
stage.setAspectRatio(StageAspectRatio.PORTRAIT);
}
[SWF] Main.swf - 3,394,828 bytes after decompression
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at views::Try01/init()[C:\Users\James\Adobe Flash Builder 4.5\myProgram\src\views\Try01.mxml:19]
at views::Try01/___Try01_View1_creationComplete()[C:\Users\James\Adobe Flash Builder 4.5\myProgram\src\views\Try01.mxml:4]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:13128]
at mx.core::UIComponent/set initialized()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:1818]
at mx.managers::LayoutManager/validateClient()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1090]
at mx.core::UIComponent/validateNow()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:8067]
at spark.components::ViewNavigator/commitNavigatorAction()[E:\dev\4.5.1\frameworks\projects\mobilecomponents\src\spark\components\ViewNavigator.as:1878]
at spark.components::ViewNavigator/commitProperties()[E:\dev\4.5.1\frameworks\projects\mobilecomponents\src\spark\components\ViewNavigator.as:1236]
at mx.core::UIComponent/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:8209]
at mx.managers::LayoutManager/validateProperties()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:597]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:783]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1180]
Whenever I enable persistNavigatorState, my program won't run. Is there a way to use both together? Thanks
[Line 4] creationComplete="init()"
protected function init():void {
[Line 19] stage.setAspectRatio(StageAspectRatio.PORTRAIT);
}
Perhaps the creationComplete event fires before the stage is accessable. Using persistNavigatorState changes the startup behavior of your application a bit by first fetching your navigator's state info from the persistence cache. This line in the Flex docs is quite telling: when the application restarts, only the state of the current ViewNavigator is restored. Also, the stage in flex is not accessable until an object is added to the displayList. So if you call setAspectRatio when the stage is empty, you will get a null obj reference.
Instead of using stage.setAspectRatio(StageAspectRatio.PORTRAIT) on creationComplete, you can try setting including <aspectRatio>portrait</aspectRatio> in your app.xml.
Or, you could listen for the addedToStage event in your view, and call stage.setAspectRatio(StageAspectRatio.PORTRAIT) in the event handler. That way you know for sure that the stage is available.
References:
Adobe Enable Persistence in Mobile App
Flexponential - orientation and deviceOrientation in Flex Mobile apps
Anselm Bradford - After CreationComplete A Flex Component’s Stage Property Is… What? Null?

FlexUnit: Spark component test issue (UIImpersonator)

FlexUnit 4.1
FlashBuilder 4.5.1
BACKGROUND
I'm trying to test a custom Flex 4 skinnable component, using the FlexUnit UIImpersonator class. If I run my tests from a FlashBuilder Spark only project everything works fine. If I try to test from a project with the mx component set on the classpath I get a "getElementIndex not available in non Flex 4 projects" error.
QUESTION
Can I unit test spark components in FlexUnits visual test environment while still having the mx component set on the classpath?
RESEARCH
UIImpersonator delegates it's method calls to a "testEnvironment".
The implementation used for this "testEnvironment" is decided by the VisualTestEnvironmentBuilder class and the FlexEnvironmentBuilder class. If the FlexEnvironmentBuilder class can find the "mx.core.Container" on the classpath it returns a MX environment, else a Spark environment. Only the spark environment has valid implementations for Flex 4 relevant method calls on the UIImpersonator – like the addElement method.
I have the same problem, and didn't found any solution. I suggest to file a bug, but since FlexUnit is in the process of being adopted by Apache Flex, I don't think it would be resolved anytime soon.
As a workaround. Just use UIImpersonator.addChild() and add a reference to mx.core.Container in your TestRunner. This ensures that a MX container is used as testEnvironment and you won't receive a 'getElementIndex...' error.
import mx.core.Container
public function runTests():void {
// reference to mx container
var containerRef:Container = new Container();
// Run your testsuite as usual. eg:
var core:FlexUnitCore = new FlexUnitCore();
core.run(MyTestSuite);
}

Resources