HubClass is Undefined issue with Class Library - signalr

Hub class is undefined issue when putting the HubClass into Class Library.
I am using a Class Library that contains the HubClass.
when I am accessing the hub class in client side, I am getting the HubClass is undefined issue.
var hub=$.connection.signalHub (here signalHub is undefined)
/signalr/hubs is loading fine without any issues.

Its one of 2 things, either you forgot to set the name of your hub in the attribute on the hub class, or you have a typo. Likely capitalization is incorrect.
Did you mean var hub=$.connection.signalrHub or var hub=$.connection.signalHub

Related

Flex: load parent class into module

My main application contains a ClassA. The main application then loads a module and in that module I would like would to do:
var classA:InterfaceClassA = new ClassA();
It compiles fine but I get this warning:
Warning: YourApplication is a module or application that is directly referenced. This will cause YourApplication and all of its dependencies to be linked in with module.YourModule:Module. Using an interface is the recommended practice to avoid this.
I can't use an interface to generate the new instance, so what is the correct way to do this?
I found an answer in Accessing the parent application from the modules . I created a helper class in the main Application that contains instances of the classes I want to access. In the module I then use:
parentApplication.myModuleHelper.**myClassInstance**.myMethod();
for instance methods and for static class level methods I use:
parentApplication.myModuleHelper.**MyClassInstance**.myMethod()
To get an instance of my class in a module I use this in MyModuleHelper
public function getFullScreenUtil(iFullScreenUtil:IFullScreenUtil , iSystemManager:ISystemManager):FullScreenUtil {
return new FullScreenUtil(iFullScreenUtil , iSystemManager);
}
and this in MyModule:
var _fullScreenUtil:* = parentApplication.moduleHelper.getFullScreenUtil(this , systemManager);
which is all I need for now. I am not sure how I could cast the result of getFullScreenUtil(..) to an actual instance of FullScreenUtil but I expect that it can not be done in modules. Maybe using an interface would provide the solution to that.

ERROR accessing objects that inherit from abstract classes in WF4

Is it possible classes that derive from an abstract base class cannot be used in WF4? I have a library that define several object classes... I'm able to access objects in that library just fine except for objects that inherit from an abstract class.
Each time I reference the abstract class or any other classes in its inheritance chain, I get the following error:
"Compiler error(s) encountered processing expression "cust.DisplayName". 'cust' is not declared. It may be inaccessible due to its protection level."
In this case 'cust' is an instance of a CustomerAccount class which inherits from an AccountEntity (abstract) class which in turn inherits from a BaseEntity (abstract) class...
I can do the following in a C# console application and it works just fine:
CustomerAccount cust = new CustomerAccount();
cust.DisplayName = "John Doh";
Console.WriteLine("Out Put: " + ((iSvrBaseEntity)cust).DisplayName);
Console.WriteLine("Entity Type: " + cust.entityType);
But in the WF4 designer, I'm allowed to instantiate Cust and I'm allowed to assign another object to cust... but when I try to access a property in cust (or assign a value to one of it's properties, the error occurs.
Has anyone encountered this? Is it by design that WF4 doesn't deal with such inheritance? Is there a workaround?...
Thanks!
Types used need to be public but other than that any normal .NET type should work just fine.

Unable to dispatch custom event in flex mobile application

I am trying to get some code working from an example I came across. most of the functionality works but it is failing when it tries to dispatch a custom event. At the moment the code that is trying to dispatch the event is inside a class that handles amf remoting.
the example has this line in it for the dispatch:
Application.application.dispatchEvent(new
RemoteResultEvent(RemoteResultEvent.USER_UPDATE_COMPLETE,"test"));
but that fails as it does not know what application.application is "Multiple markers at this line:
-Access of undefined property application"
I assume that this is because this was not written for a mobile app. I tried changing the dispatcher to EventDispatcher
EventDispatcher(
new RemoteResultEvent(RemoteResultEvent.USER_UPDATE_COMPLETE, "worked"));
but I then get this error:
TypeError: Error #1034: Type Coercion failed: cannot convert events::RemoteResultEvent#18337731 to flash.events.EventDispatcher.
This is the code in the custom event RemoteResultEvent.as :
package events
{
import flash.events.Event;
public class RemoteResultEvent extends Event {
public static var USER_UPDATE_COMPLETE:String = "UserUpdateComplete";
public var message:String;
public function RemoteResultEvent(eventType:String, message:String) {
super(eventType, false, false);
this.message = message;
}
}
}
I am bumbling around in the dark as I am new to flex and this type of development so I could well be doing something really dumb. Any help would be gratefully received.
Thanks
JaChNo
You seem confused about event dispatching in general.
Events can be dispatched in any Flex class that extends, or has a, EventDispatcher. Most Flex Components, including Application extend EventDispatcher. To dispatch the event, you are on the right track just do:
dispatchEvent(new RemoteResultEvent(RemoteResultEvent.USER_UPDATE_COMPLETE,"test"));
That will dispatch the event from your current class. Not that all Flex UI Components, including those made in MXML can be considered a class.
What you are trying to do is dispatch the event on the main level application; which is a horrible encapsulation breach, but doable. You have to cast it as an Application so you do not get a generic object. Like this:
(Application.application as Application).dispatchEvent(new RemoteResultEvent(RemoteResultEvent.USER_UPDATE_COMPLETE,"test"));
This approach is deprecated since Flex 4; and you use the FlexGlobals.topLevelApplication instead:
(FlexGlobals.topLevelapplication as Application).dispatchEvent(new RemoteResultEvent(RemoteResultEvent.USER_UPDATE_COMPLETE,"test"))
You don't say, but you allude to the fact that you are in a Mobile Project. If so, I would not expect the mx Application class to be available unless you explicitly added the SWC w/ MX Components to your class. You'll have to access the Spark Application, which does not have an Application property. That could be why you are getting the error.
Be sure to import the proper application you want to use:
import spark.components.Application
More info on Spark Application class.

Why casting failed when used swf loader

Any class common between flash swf file, loaded in swfloader turns our to throw error
TypeError: Error #1034: Type Coercion failed: cannot convert
media::PlayerContentView#12babac1 to media.PlayerContentView.
My main swf has same class, since its been used by appplication all over, but when swfloader creates object of same name class, it adds 12babac1 to class name. and doesn't work for simple access of array values
public function get Current():media.PlayerContentView
{
return contentItems[VZPlay.CurrentIndex] as PlayerContentView;
}
where as this same code works very fine if Its just the child swf played on it own.
Found it myself, I just saw loadForCompatibility property for swfloader. scribd.com/doc/12990361/Developing-and-loading-subapplications URL may not work, the owner made it private, but setting this property to false make it work all fine. e.g.

access mxml component from external actionscript file

i'm trying to access an mxml component from my external as file. e.g
main.mxml:<br>
<code>[mx:text id="myText" />]</code>
file.as:<br>
<code>var mainM:main = new main();
mainM.text.visible = true;</code>
I get the following error:
[TypeError: Error #1009: Cannot access a property or method of a null object reference]
Any suggestions on how to approach it better.
The ID of your component instance becomes a member of your application and can easy be accessed like so
import mx.core.Application;
mx.core.Application.application.myText.visible = true;
An additional answer is that when you create a new Flex component (new myFlexComponent()), the child UI components are not created until a CREATION_COMPLETE call is invoked, indicating the component is fully created. In the case of application, there is only one, and its automatically created by the framework, and referenced by (Application.application) as stated above.
For example, if your variable was a simple class variable (e.g. myDate:Date), you could access it via the above syntax

Resources