I am using Adobe Flash Pro CC, AS3 & scaleform.
I create an instance of an object which contains AS Linkage and a use class definition.
Regardless I can visually identify the object is loaded, the constructor class of this object never gets called.
I tried re-creating the object in the scene, renaming, etc... but it still produces the same error.
When running the GfxMediaPlayer, I can see an 1009 error is displayed; a common mistake when the AS Linkage is missing.
Is there any other option for this kind of objects that is restricting how it gets instantiated?
My scene contains several objects that use similar layout and scaleform.clik libraries, but they work as expected an they do get instantiated.
I also have tested this on Flash CS6 with same results, any help appreciated.
I found that the library path for the object was missing. The strange thing, is that same path was used by the rest of the objects that were working fine, no idea how they would be working.
Related
I've been playing around with a button in my storyboard, and had a hard time getting a border around it, until I found a page where it showed how to add a User Defined Runtime Attribute. I was able to make the button look as I wanted, but I wanted to know if there was a way for me to view the list of available attributes for a particular Object.
Clicking the "+" to add a new attribute doesn't provide any kind of auto-complete to show the available ones, and looking through my project code doesn't seem to reveal anything either, not surprisingly. Is there somewhere I can find all of the available attributes for all/any Objects in Xcode? Searches here on SO and in general have not shown any useful results so far.
You can achieve the same thing from code, so just check the properties of UIButton (which is available in the documentation and with autocomplete) and you're good.
You also have to make sure you are checking the properties on an UIButton instance and not the class properties.
User defined runtime attribute is a list of key paths that NIB loading subsystem uses through unarchived process. After initialisation message -setValue:forKeyPath: will be send to your unarchiving object for each key path from this list. So available attributes are not more than set union of all methods with selector sort of -setAttribute: and ivars with "_attribute" or "attribute" name.
All that public attributes you may find at public headers or documentation.
There's also possible to set private attributes, but it's not good practice. For instance, you may find all ivars by breakpoint execution inside any method and look inside "self".
I cant get my head around this. I was looking at the lynda.com ActionScript 3.0 in Flash Professional CS5 Essential Training. I understand all the other stuff, but this guy places a skater on the stage he has this code on the first frame on the main timeline:
import flash.display.MovieClip;
import flash.events.MouseEvent;
var boarder:MovieClip = boarder_mc;
boarder.stop();
boarder.x = 0;
boarder.y = 0;
boarder.addEventListener(MouseEvent.CLICK, clickedBoarder);
function clickedBoarder(evt:MouseEvent):void
{
boarder.gotoAndPlay(2);
}
function restart():void
{
boarder_mc.gotoAndStop(1);
boarder_mc.x = 0;
}
then on the skater he has a Display Object Container (Movie Clip) in it he has a Display Object a bitmap image of a skater and then an animation on the timeline in the skater where at the end the skater falls. On that last frame he has:
stop();
parent.restart();
He explains that this may not work and it doesnt he gets an error:
1061: Call to a possibly undefined method restart through a reference with static type flash.display:DisplayObjectContainer.
He explains that it knows there is a stop() function on the main timeline, and that it knows there is a restart function on the main timeline, but the datatype is different. He also says that the parent is the main timeline.
He says that we need to put Object(parent).restart();
My question is of what datatype and what is the main timeline (Movieclip, DisplayObject, Display Object Container)?
Why would it be a different datatype?
Thanks
The main timeline is a MovieClip, or if you have a DocumentClass, then probably a custom type that at least extends MovieClip.
However when you ask for "parent" of your skater MovieClip, you are really using the parent property that MovieClip inherits from DisplayObject (ActionScript Docs Here). This property returns the parent as type DisplayObjectContainer, regardless of the type that it actually is. Since it is the parent of a DisplayObject, it doesn't matter type it is it has to extend DisplayObjectContainer, so this is how it is returned.
So when you compile your ActionScript, the compiler looks at "parent" and sees it as type DisplayObjectContainer, looks at its definition of DisplayObjectContainer and errors because DisplayObjectContainer doesn't have a function called "restart".
What you said about the "stop" function is not really correct, since you are not calling stop on the main timeline, your are calling stop on the Skater's timeline. If you wanted to call stop on the main timeline you would need to call parent.stop(), and this would give you the same error, since DisplayObjectContainer doesn't have a method called stop.
These are both compiler errors, and are caused because the compiler is following a set of rules, and it can't make assumptions about what might actually happen when your program is running. It just knows that when you call parent.restart() it might receive a DisplayObjectContainer that won't have the method restart on it, and a run-time error will occur.
Now, by casting parent as type object, you are effectively telling that compiler that this thing can have any method or property on it, since Object is a dynamic class. So the compiler will now assume that you as the developer know that the method "restart" will exists on the "Object" that is given to that bit of code, and therefor will not error any more.
Thank you very much for you reply. This is really confusing. I thought that DisplayObjectContainer is a subclass of Display Object and it extends it? I know that Display Object Container is a Display Object and it can contain other Display objects and Display Object Containers. So the way I understand it, the maintimeline is a movieclip and therefore a DisplayObejctContainer, which can contain other Display objects (that you create in you application) and that is why parent returns Display Object Container, but that it is also a abstract class which means that it cannot have methods such as .restart and goToAndPlay() because it cannot actually be instantiated. However if its a MovieClip as you say then it can..... I dont get it.Does it mean that it is an abstract Class?
I'm writing a BlackBerry application which loads XML from a web server and generates objects based on the XML tags. These generated objects all implement the same interface, and are cast to this interface before use.
I've recently implemented menu items in the Messages app which, when selected, launches my app and pushes a screen. This screen is expected to get XML from the server and create objects like normal - and it works, provided it's not called from the menu item.
When called from the menu item, I receive a ClassCastException for only one type of object on the page. Similar objects are cast fine, and this object is cast fine when it's not being instantiated from the menu item class.
Here's where it gets interesting: In the debugger, when Class.forName is run on the XML tag normally, I can highlight the resulting Class object to see
Class my.package.location.ClassName$MyAppName
When I call it from the menu item and get a class cast exception, the Class object appears as
Class my.package.location.ClassName$XMLReflectionTest
I suppose this is why the cast fails, even though both seem to refer to my object.
XMLReflectionTest is not a class or subclass in my project, but Google only returns two search results, neither of which are even somewhat related.
It works fine everywhere else, and even for different classes using the same method! Why would calling Class.forName using the same class string return two "different" classes, based on where it's called from?
I've looked into ClassLoaders, which I could possibly be the issue, but then why would the issue only occur for one class, and not all of them?
I have a runtime error happening in the rtl Streaming in of a form, causing an exception EClassNotFound to be raised, while doing TReader.ReadRootComponent. The particular error message is "Class not found TActionList".
What is odd is:
My main form uses Action list.
For fun, I added ActnList.pas (from the VCL source folder) to my project, to try to fix it.
This happens to me when instantiating a form that I had working until a few minutes ago. The change that I made was in some sub-frame code: I removed all its implementation section code with an ifdef marker, because I am mocking up some frames, for unit testing and prototypes.
I tried adding the action list class to the project, and I tried with and without various compiler and link options, and yet, I still get this exception. Obviously something weird is up. There must be another weird way to get this problem.
In fact, it seems there is something really weird going on. When this error is raised, I get the following call stack:
rtl.Classes.ClassNotFound('TActionList')
rtl.Classes.TReader.FindComponentClass(???)
rtl.Classes.FindExistingComponent
rtl.Classes.TReader.ReadComponent(nil) /// NIL!? WHAT!!!!!
rtl.Classes.TReader.ReadDataInner(???)
rtl.Classes.TReader.ReadData(???)
rtl.Classes.TComponent.ReadState(???)
vcl.Controls.TControl.ReadState(???)
vcl.Controls.TWinControl.ReadState($60B9CF0)
vcl.Forms.TCustomForm.ReadState(???)
rtl.Classes.TReader.ReadRootComponent($606EB90)
rtl.Classes.TStream.ReadComponent($606EB90)
rtl.Classes.InternalReadComponentRes(???,???,$606EB90)
rtl.Classes.InitComponent(TComplexFormContainingFrames)
It seems the nil is intentional, in TReader.ReadDataInner(Instance:TComponent):
while not EndOfList do ReadComponent(nil);
Update: I believe the answer to this question is to understand "serialization contexts" as Mason has mentioned. And, it's time to admit my own Stupidity: I removed the parent of the frame from the project, not realizing it was the parent of the frame. I worked around it being missing by stubbing the type declaration for TMyFrameParent as TMyFrameParent = class(TFrame), and this in turn lead to the condition in question. I am leaving the question here because I think it might be really handy in future to note when this exception occurs in arcane cases, and how to fix it. In particular, Mason has a really interesting bit of information about "serialization contexts" and how they apply to class-name-finding.
It means that the class wasn't found in the current deserialization context. Not all existing classes are registered for all loading. Each form class has RTTI containing references to the components it uses. To get this to work, make sure that your form (or frame, if this is a frame) declares at least one TActionList before the private tag:
TMyForm = class(TForm)
ActionList: TActionList;
OtherComponent: TSomeComponent;
private
//whatever
public
//whatever
end;
Use Classes.RegisterClass to register classes you want to use with the streaming system. Quote from the doc
Form classes and component classes that are referenced in a form declaration (instance variables) are automatically registered. Any other classes used by an application must be explicitly registered by calling RegisterClass if instances are to be saved. Once classes are registered, they can be loaded or saved by the component streaming system.
It seems that this happens when you copy a frame from one project to another project, and that frame inherits from something, and you fake the inheritance, but leave the "inherited" item descriptions in the frame dfm, items like this:
inherited ActionList: TActionList
Left = 520
Top = 576
end
This in turn results in the "current deserialization context" that Mason talked about, not containing the class. One fix is to change Inherited to object in all the above cases.
There is another way to get this error: put 'public' at the top of a form definition class. By default class members are 'published'. I accidentally added 'public' to the top of a form declaration and it produces multiple 'Class not found' exceptions at run-time.
I got a "EClassNotFound" error when I had a TLabel declaration present in my DFM file but there was no declaration for it in the corresponding PAS file. Somehow the form editor screwed up.
The error was not visible until I deleted all labels from my form except that particular "corrupted" one. It was difficult to hunt it down because that label was hidden under a panel.
One easy fix is to cut (ctrl+x) that label (once you find it) from the form and paste it back. This time the form editor will correctly insert a declaration for it in the PAS file.
There is yet another way to get this error: I have put 'private' at the top of a form definition class (because none of the elements were used outside the form).
So same like in previous answer (by Server Overflow): by default class members are 'published' and if you change visibility of a form declaration it produces multiple 'Class not found' exceptions at run-time.
I would like to do coloring in Eclipse without using the presentation reconciler. Therefore, first, I need to figure out how to associate a TextPresentation object with either my editor or document, but I am having difficulty finding out how to link it either of those. Normally, the CreatePresentation in the IPResentationReconciler interface would give the style range to the textpresentation, and from there Eclipse would know what to do with that presentation object. Is there some way to use a TextPresentation object without the use of PresentationReconciler? It would be nice if I could do coloring without the use of reconciler. Thank you.
I finally figured out how to achieve the coloring without the use of Reconcilers.
I discovered that first I needed a way to obtain a reference to my SourceViewer object, as I am extending TextEditor. I also discovered that I could implement the TextListener interface and add my own listener to the SourceViewer object. One must be careful, however, as calling the getSourceViewer() method can result in null if not called at the appropriate spot. Originally, I overwrote the init(...) function in my editor class and made the getSourceViewer() call, but it still resulted in null. After doing a bit of research, I discovered that I could properly obtain a reference to the SourceViewer object by overriding the createPartControl method. I first call super.createPartControl(...) and then make a call to getSourceViewer(). After I obtained that reference, I used that with my listener class I created and was able to do the coloring myself with the setTextColor method the SourceViewer object has. Hope this helps others in the same situation.