2

I ported some parts of the code from OL 3.3 to OL 5.0 recently. I thought that everything will work but when i try to run it using the ant script i have I am getting this error.

 [echo] C:\Program Files\OpenLaszlo Server 5.0.x\Server\lps-5.0.x/WEB-INF/lps/server/bin/lzc.bat
 [exec] Compiling: C:\Workspace\application\client\src\TestClient.lzx to TestClient.swf10.swf
 [exec] compiler output is Loading configuration file C:\Program Files\OpenLaszlo Server 5.0.x\Server\lps-5.0.x\WEB-INF\frameworks\flex-config.xml
 [exec] C:\Documents and Settings\310773\Local Settings\Temp\lzswf9\Workspace\application\client\src\build\TestClient\app.swf (289808 bytes)

So, I took the folder and i compiled it directly in Laszlo. It's not showing any error but when the swf is about to load the main page I am getting this error. Any idea why?

TypeError: Error #1007: Instantiation attempted on a non-constructor.
    at $lzc$class__mvz/$mvx()
    at LzNode/__LZresolveReferences()
    at LzNode/__LZcallInit()
    at LzCanvas/__LZcallInit()
    at LzCanvas/__LZinstantiationDone()
    at LzInstantiatorService/makeSomeViews()
    at LzInstantiatorService/checkQ()
    at Function/http://adobe.com/AS3/2006/builtin::call()
    at LzEvent/sendEvent()
    at LzIdleKernel$/__update()
karthick
  • 11,998
  • 6
  • 56
  • 88
  • You should choose better titles for your question. Just saying that you are upgrading from OpenLaszlo 3.3 to 5.0, and you ran into an error doesn't make your question interesting. If you list the error message in the title of your question, it will be much easier for other developers to get their own problems solved. Therefore I edited the question title, as you can see. – raju-bitter Aug 24 '12 at 09:33
  • @r.bitter:Ok..I'll follow that.. – karthick Aug 24 '12 at 10:18

3 Answers3

2

That's the error message you get when you try to instantiate a class which is not defined. Here is an example:

<canvas>

  <class name="myclass">
    <handler name="oninit">
      // Instantiate a class which is not defined
      var x = new lz.missingclass();
    </handler>
  </class>

  <myclass />

</canvas>

Check for missing <includes> of classes which are being instantiated through scripts. You can always check the list of Adoboe Flash Run-Time Errors as well, sometimes there is useful information contained here.

Edit: Solution to problem added
This commment pointed to the problem:

I found that this line is causing the problem. <attribute name="dp" value="$once{new lz.Datapointer()}" />. Any idea why?

If you check the OpenLaszlo reference for 5.0, you will see that the class names (on the left side in the class browser) use different case; some classes use camel case (lz.Browser, lz.DataElement), others use all lowercase (lz.view, lz.datapointer). In your case, you should have used lz.datapointer instead of lz.Datapointer.

Therefore this code will compile and run without any problems:

<canvas>

  <class name="my_class" extends="node">
      <attribute name="dp" value="$once{new lz.datapointer()}" />
  </class>

  <my_class oninit="Debug.inspect(this.dp)" />

</canvas>

A good way to test for the correct name of a class is to use the JavaScript in console in DHTML runtime, where you have auto-completion for lz.??? classnames:

Auto-completion for LZX class names in the browser JavaScript console

Debugging SWF #1007 errors in OpenLaszlo
If you run into a #1007 error in the SWF runtime, I would compile the application for DHTML with the debugger disabled and the JavaScript error console open. Try this:

  1. Change the line of with the $once{} constraint to

    <attribute name="dp" value="$once{new lz.Datapointer()}" />

  2. Compile the app in Chrome using DHTML runtime and debug=false. You should see the following error in the JavaScript console:

Error for undefined class in JavaScript console

  1. Click on the right side on error-1007.lzx:3, and you'll see the generated JavaScript code with the line causing the error

JavaScript error in code generated by the OpenLaszlo compiler

This line fails:

this.setAttribute("dp",new (lz.Datapointer)())

and you can even reproduce the error by typing new (lz.Datapointer) into the console.

raju-bitter
  • 8,906
  • 4
  • 42
  • 53
  • Your point does make sense.But why the compiler isn't throwing the error – karthick Aug 24 '12 at 10:21
  • 1
    Because of the dynamic nature of ActionScript. The compiler cannot know if 'lz' refers to a variable, package. And even if a constructor lz.missingclass() is not known at compile time, you might just add the reference at runtime. If you have just the class name - not lz.missingclass(), but just missingclass() - the compiler will catch the error. – raju-bitter Aug 24 '12 at 10:57
  • I have included everywhere as a folder that is and whatever classes present in that folder have classes included like . This shoudn't cause any problems right? – karthick Aug 24 '12 at 15:25
  • 1
    Check the generated ActionScript code of method causing the problem. If you run the application without debug enable, what is the exact exception message the Flash Player Content Debugger is showing? –  Aug 24 '12 at 16:24
  • @bork999: Where is the location of generated ActionScript code? – karthick Aug 25 '12 at 09:32
  • @bork999: I found that this line is causing the problem.. Any idea why? – karthick Aug 25 '12 at 10:21
2

Just as a point of info: The case of class names was "regularized" in 4.0 so that the case of a class that implements a tag is the same as that tag. See Mapping Class and Tag Names.

PTWithy
  • 168
  • 2
  • 5
0

Here is an example of the problem and a workaround:

1) PROBLEM:

Here is the code of a short OpenLaszlo application demonstrating the problem:

<canvas width="1000" height="584">

  <view name="myContainer" width="500" height="500">

    <handler name="oninit">
      var objCB = new lz.combobox(this);
    </handler>

  </view>


</canvas>

In this example there is no <combobox> tag in the application so the compiler does not think it needs to include the OpenLaszlo <combobox> class code in the application. Hence, when we try to instantiate a combobox with the line "var objCB = new lz.combobox(this);" the compiler throws the following error:

ERROR @test1007error.lzx≈5: TypeError: Error #1007: Instantiation attempted on a non-constructor.

2) WORKAROUND:

The solution for the problem is to add an include in your application for <combobox>:

<canvas width="1000" height="584">

  <include href="lz/combobox.lzx" />

  <view name="myContainer" width="500" height="500">

    <handler name="oninit">
      var objCB = new lz.combobox(this);
    </handler>

  </view>


</canvas>

This time the error is not thrown and we see the combobox appear at the top left of the application when we run it.

Kmeixner
  • 1,664
  • 4
  • 22
  • 32
  • 2
    You don't have to use a relative path when including the lz components. When the href attribute starts with **lz**, the OpenLaszlo compiler will automatically look in the $LPS_HOME/WEB-INF/lps/components/ folder for the included LZX files. Here is the corresponding documentation: http://www.openlaszlo.org/lps4.9/docs/developers/custom-components.html#d0e92698 – raju-bitter Aug 24 '12 at 16:38
  • Raju, what should the include be changed to? I tried just and the compiler throws an error: usr/local/lps-4.9.0/Server/lps-4.9.0/develtest/test/test1007error.lzx: file not found: combobox.lzx – Kmeixner Aug 24 '12 at 17:47
  • Nevermind, I figured out that it is . Thanks Raju. – Kmeixner Aug 24 '12 at 17:49
  • Yes, that's correct. It's in the developers docs as well, if you follow the link in my last comment. – raju-bitter Aug 24 '12 at 22:09
  • @Kmeixner: Should i use the include for a node too? Suppose i have a file control.lzx in a library and i am using the node's id to perform some operation in the file test.lzx like gControl.show() – karthick Aug 25 '12 at 09:04
  • @Kmeixner: How are you getting the file name? ERROR @test1007error.lzx≈5: I am not getting the file name at all. – karthick Aug 25 '12 at 09:38
  • @Kmeixner: Thanks to bork999 i was able to get the action script code.I found that this is the problem . Any idea why this is causing a problem? – karthick Aug 25 '12 at 10:18
  • 1
    @kathrick Re: "Should i use the include for a node too?" I don't think you would ever have to do this for the tag since it is the very base OpenLaszlo object that all openlaszlo objects are extended from. – Kmeixner Aug 27 '12 at 16:13
  • 1
    @karthick: Re: "How are you getting the file name?" This is tricky in Flash 9+ platforms, they do not tell you the actual variable name, they just give you the error and the line number the method the problem occurs is in. If you compile with backtrace mode on in debug mode it will give you the exact line, but you will still have to see which variable is on the line to figure out what the name of the variable causing the problem. This is a limitation of the Flash 9+ debugger from Adobe. – Kmeixner Aug 27 '12 at 16:16