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.
Related
My application currently contains a number of Widgets that are managed by a Widget Manager. When the user clicks on a widget (e.g. a Helper widget), the Widget Manager loads the widget into a separate sibling application domain with the following line of code:
wgtInfo.load(null, null, null, moduleFactory); //wgtInfo = IModuleInfo
However, I am unable to use the widget's variables and functions later on. I attempt to find the Helper widget from the Widget Manager's list of widgets, and I do successfully. But when I try to caste the Helper Widget from type IBaseWidget (the interface all widgets share) to type HelperWidget, I receive the following error:
TypeError: Error #1034: Type Coercion failed.....
This is because the application domain of the class trying to use the Helper widget is different from the application domain of the Helper Widget. I tried to fix this by loading all widgets into the same application domain as the loader:
wgtInfo.load(ApplicationDomain.currentDomain, null, null, moduleFactory);
I now get the following error whenever I attempt to load the Helper widget:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
How can I load my Helper widget into a common application domain that is accessible by the other widgets?
I believe your problem comes from the class not being included in the swf. This is because Flash doesn't compile in classes in a swf if they aren't used to reduce filesize. To prevent this, you only need to create a variable with the helper class you need in that class, like this:
private var helper:HelperWidget;
See if that helps.
I'm gonna repost my 'comment' as a real answer. I'm guessing that the error is not based on the ApplicationDomain but based on which classes you are being compiled into your Module. When Flex compiles the SWF it automatically optimizes unused classes out of the SWF. You can force them back into the SWF in one of two ways:
Use the compiler argument include-libraries to force the Flex compiler to add the class to your SWF.
Add a fake variable in in your application so that the Flex compiler thinks it is used and adds it to the final SWF. Something like this.
private var myFakeObject : HelperWidth;
After trying a number of solutions unsuccessfully (including the other responses on this page), I resorted to another, event-driven, solution.
I ended up dispatching a custom event to notify my other widgets when the Helper widget had completed loading:
(HelperWidget.mxml)
ViewerContainer.addEventListener(AppEvent.WIDGET_OPEN_TAB, widgetOpenTabHandler); //listen for other widgets to open a tab within the Helper Widget
ViewerContainer.dispatchEvent(new AppEvent(AppEvent.WIDGET_READY_OPEN_TAB)); //notify other widgets that loading is complete
My other widgets listen for this event to fire, and upon completion, dispatch another event (AppEvent.WIDGET_OPEN_TAB) to perform a function within the Helper widget.
I am using QJson to serialize a QObject-derived class. I am able to serialize the class itself without any problems, but when it comes to one of its members, I am having a bit of trouble.
The class is named CProject and it contains a property files which is defined as:
QList<CProjectFile> files;
When serializing an instance of CProject, I get a message in the console:
QMetaProperty::read: Unable to handle unregistered datatype 'QList<CProjectFile>' for property 'CProject::files'
I read somewhere that I have to register the datatype, so I added the following after the declaration of CProject:
Q_DECLARE_METATYPE(QList<CProjectFile>)
...and when that did nothing, I added:
qRegisterMetaType< QList<CProjectFile> >();
Nothing is working. What am I doing wrong?
I don't know how QJson works but perhaps it requires stream operators. Try as below after declaration of CProjectFile class
class CProjectFile
{
...
};
Q_DECLARE_METATYPE(CProjectFile)
qRegisterMetaType<CProjectFile>("CProjectFile");//Do this if you need signal/slots
qRegisterMetaTypeStreamOperators<QList<CProjectFile> >("CProjectFileList");
See also QT Doc for stream operators
I am getting these weird runtime errors. I am using Flex 3.5 SDK with flash player set to 10.0.00.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.flash::UIMovieClip/removeFocusEventListeners()[E:\dev\flex\sdk\frameworks\projects\flash-integration\src\mx\flash\UIMovieClip.as:2368]
at mx.flash::UIMovieClip/focusOutHandler()[E:\dev\flex\sdk\frameworks\projects\flash-integration\src\mx\flash\UIMovieClip.as:2411]
I get this errors when I click on any other control in a popup. I am using buttons, textarea,textinput,and a list. I dont know how to fix this ... It would be great if someone pull me out this problem?
Without the code it's gonna be hard to pinpoint. This error could occur if you are trying to 1) access the property of an object that hasn't been created by the time the focus out handler is called, or 2) access the property of an object that ins't referenced in the focus out handler.
Make sure any non-local variables in the focus out handler reference an object that has been created somewhere in your application before the call to the focus out handler. Also, make sure a reference to each object gets passed into the focus out handler by declaring those variables globally, or passing the object to the function as a parameter.
Post the code if you can.
Seems you have to remove focus from your UIMovieClips before removing them from the stage:
http://forums.adobe.com/thread/658335?tstart=-1
Or just target flash player 10 where this bug is fixed.
Add this code to the top of any function that may remove a UImovieClip from the display list:
if (stage)
{
stage.focus = null;
}
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
I want to extend the FileReference class of Flex to contain a custom property. I want to do this because AS3 doesn't let me pass arguments to functions through event listeners, which makes me feel sad, so I need this property to exist on the event target, so I can access it.
I also want to be able to cast extant FileReference objects to this class without any fuss. I have:
var fr:SmxFR = e.target as SmxFR
and I want that to work; right now it just returns null.
A blank, newly instantiated SmxFR object has the extended property in place, but all of its inherited properties and objects return Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.
This is the class I am using, SmxFR.as:
package
{
import flash.net.FileReference;
public class SmxFR extends FileReference
{
public var housenum:String = "";
public function SmxFR()
{
super();
}
}
}
Kept it as straightforward as I could, really. Can someone please help me figure this out? Thanks.
Edit:
Per request, this is the instantiation which results in the aforementioned error in all inherited objects:
var fr:SmxFR = new SmxFR();
I get living handle property from that, and all other (that is, inherited) properties throw Error #2037.
So, maybe what I want to do is going to require overriding FileReferenceList? If the original objects must be instantiated to SxmFR, that's what I'll have to do, since I'm using FRL to allow the user to select multiple files at once. Are you guys sure there is no way to fast from a FileReference to my class?
You can totally pass objects via event listeners, it's just done in a specific way. I'd learn to do it correctly, rather than trying to extend a core library which could cause you problems later if you make a small mistake.
My solution: instead of extending FileReference, extend Event and add your properties to that.
var myEvent:MyExtendedEvent = new MyExtendedEvent();
myEvent.myCustomProperty = myValue;
dispatchEvent(myEvent);
Then in your handler you just write:
function myEventHandler(e:MyExtendedEvent):void {
trace(e.myCustomProperty);
}
Much more painless to go down this road! The added benefit is that if any other Flash Developer anywhere ever looks at your code they're not going to get hit in the face with a non-standard customized FileReference. :)
When e.target is instantiate as FileReference you can't cast it to SmxFR because it's not in the line of inheritance. In the other way you can a SmxFR Object to FileRefernce.
Extending FileReferenceList is not going to be helpful. FileReferenceList.browse() method creates an array of FileReference object when user selects multiple files - that happens internally (may be in its private methods) and you cannot change that behavior and force it to create SxmFR objects instead. Use custom events as Myk suggested.
This article talks about Sound objects, but may be that's applicable to FileReference objects too. May be you cannot reuse them. Post the code where you use the SmxFr class and get the said error.