Flash Namespace error 1004: Namespace was not found or is not a compile-time constant - actionscript-3

I have a class: myClass_x.as with contents:
package com.a.b.c
{
public namespace myClass_x = "com.a.b.c:myClass_x";
}
I have a second class: myClass_y with function:
myClass_x function myFunction(param1:int, param2:int, param3:int) : void {...}
I have a third class: myClass_z with function:
override myClass_x function myFunction(param1:int, param2:int, param3:int) : void {...}
When I try to compile, I get error:
1004: Namespace was not found or is not a compile-time constant.
Any ideas what's going wrong?

Are you sure you've imported the namespace at the top of each class?
import com.a.b.c.myClass_x;
You can also get your error if the filename does not exactly match the namespace name.

Above your class block add the line use namespace myClass_x;

Related

[winrt]Unable to initialize the base class of projected type

i'm a newer to cpp/winrt, i use implements_type and base_type to initialize the base class of projected type, but compile error.
namespace Velkhana
{
[default_interface]
unsealed runtimeclass Only{
Only(Object inner);
....
}
}
local class:
class Only2 : public winrt::implements<Only2, Velkhana::Only>
{
Only2() : implements_type(box_value(true)) {
}
};
this compile error: error C2664: 'winrt::implements<Only2,winrt::Velkhana::Only>::implements(const winrt::implements<Only2,winrt::Velkhana::Only> &)': cannot convert argument 1 from 'winrt::Windows::Foundation::IInspectable' to 'const winrt::implements<Only2,winrt::Velkhana::Only> &'
why can't i init base class in this case?
[Image](https://i.stack.imgur.com/oL9GH.png)
https://i.stack.imgur.com/oL9GH.png
I analyzed the source code, but don't find winrt::implements constructor, how local class initializes the grandparent class by implements_type ?
Is there any trick here?

Laravel 5.2 use custom Controller Trait

I want to use my custom Trait stored in app directory into my controller. However I always get this message:
Trait 'app\MessageTrait' not found
My Controller:
namespace app\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use app\Http\Requests;
use app\User;
use app\MessageTrait;
class login extends Controller{
use MessageTrait;
public function index(Request $request){
return back();
}
}
My MessageTrait is contained within MessageTrait.php, located in app directory. Code looks like this:
My Trait:
trait MessageTrait{
public function success(){
return 'success';
}
public function error($message){
return 'error';
}
}
First I thought it may be a Namespace issue - however, User class could be found using same namespacing as my MessageTrait. Any ideas?
I solved this by adding namespace app to the top line of my Trait file. Everything works as expected now!

1120: Access of undefined property flash

In my class, I tried using this line:
trace(flash.utils.getQualifiedClassName(getQualifiedClassName(TempButton)))
However, I get this error:
"1120: Access of undefined property flash."
Can someone help me solve this issue? The code is in an AS file under the class Main that extends as a MovieClip.
You probably have forgotten to import "getQualifiedClassName" class. This code should work:
// remember to import class(es)
import flash.utils.getQualifiedClassName;
public class ... {
// constructor
public function ... () {
// you don't have to use that "flash.utils." before you call the function,
// but you can do that too, if you want
trace(flash.utils.getQualifiedClassName(getQualifiedClassName(TempButton)));
}
}

How to turn a Ceylon class which extends a Java class into the Java class

Suppose you have a Java method in a legacy library you need to use that takes a Class as an argument:
public void takeClass(Class<? extends JavaClass> cls);
Now, suppose you have a Ceylon class which extends JavaClass:
shared class CeylonClass() extends JavaClass() {}
Now, how can I use the method takeClass in Ceylon such that this works?
javaThing.takeClass( `class CeylonClass` );
// or maybe this should work?
javaThing.takeClass( javaClass<CeylonClass>() );
As shown above, I've been trying function javaClass in module ceylon.interop.java without success... if I do javaClass<JavaClass>() then it works, but this is no use for me, of course.
EDIT:
The error I get when using javaClass<CeylonClass>() as shown above:
argument must be assignable to parameter class of takeClass:
Class<CeylonClass> is not assignable to Class<JavaClass>?
Unfortunately, this is a case where you need to drop back to Java to add some glue. You can't, today, write it completely in Ceylon.
Explanation
The problem is that since Ceylon doesn't have use-site covariance, and since the Ceylon typechecker doesn't even understand Java's use-site covariance, the typechecker treats this method:
public void takeClass(Class<? extends JavaClass> cls);
As if it had this more restrictive signature:
public void takeClass(Class<JavaClass> cls);
Furthermore, the typechecker treats all Java classes as if they were invariant types.
Therefore, since javaClass<CeylonClass>() produces a Class<CeylonClass>, it's not considered assignable to the parameter of takeClass(). :-(
Workaround
The workaround is to add the following Java method:
public static <T extends JavaClass> void takeClass2(Class<T> cls) {
takeClass(cls);
}
Now this method can be called like this from Ceylon:
javaThing.takeClass2( javaClass<CeylonClass>() );
HTH
P.S.
While writing this up, I noticed that in fact java.lang.Class is actually a covariant type, and I think that Ceylon should easily be able to notice that too. So I created this issue:
https://github.com/ceylon/ceylon-compiler/issues/1474

1024 overriding a function that is not marked for override

I keep getting this error in a Flash instrument I'm making:
1024 overriding a function that is not marked for override
The error was found in this line:
public function stop():void
The error indicates that you have a method named stop in base class. So in derived class you need to add override in the method declaration.
public override function stop():void
^
You cannot use the function name stop in a class that extends MovieClip.