I am trying to compile some example actionscript code. In Flex (Flash Builder 4.6) I imported a project folder (happens to be the PurePDF examples).
In a few places, I have yellow "?" icons when looking at the source files - though there are no warnings or errors showing up for them yet (I do have other errors I am addressing).
This is an example - when I hover the "?" icon, I see access of undefined property getTime:
end_time = new Date().getTime();
Another one, says undefined property getStackTrace()
catch ( e: Error )
{
trace( e.getStackTrace() );
}
I cleaned up the errors I mentioned, and these yellow "?" marks still appear when viewing the code. There are no warnings or errors in the 'problems' window, but these question marks I describe are still there. Even if I close the file and clean the project and re-open the file.
It seams an issue with Falsh Builder. Anyway to get over it use:
new Date().time
instead of
new Date().getTime()
getTime() is a method of the Date class;
getStackTrace() is a method of the Error class.
Make sure you have imported these two top classes:
import Error
import Date
Related
The Problem
When I was creating a test program using Flash Professional CC, I got the message "Test Movie Launch Failed" while compiling, and when I tried to open it, nothing happened and it didn't open. However, I got no compiler errors whatsoever, it just said "Test Movie Terminated." in the output.
What Might be Going on
I was thinking it might have been an error in my code, but I can't tell since the error message is extremely vague and no runtime errors appear.
So Here's my code (just in case if it's an error of the code)
Info:
Target: Air 3.6 for Desktop
Script: ActionScript 3.0
Objects:
Input Text Box with instance name of "writeT"
Dynamic Text Box with instance name of "readT"
MovieClip with instance name of "Write" (Too lazy to make buttons)
MovieClip with instance name of "Read"
import flash.filesystem.*;
import flash.events.MouseEvent;
Write.addEventListener(MouseEvent.CLICK, writeToFile);
Read.addEventListener(MouseEvent.CLICK, readFile);
var file:File = File.desktopDirectory.resolvePath("stuff.txt");
var fs:FileStream = new FileStream();
function writeToFile(e:MouseEvent):void{
fs.open(file, FileMode.APPEND);
var text:String = writeT.text;
fs.writeUTF(text);
writeT.text = "";
fs.close();
}
function readFile(e:MouseEvent):void{
fs.open(file, FileMode.READ);
var text:String = fs.readUTF();
readT.text = text;
fs.close();
}
EDIT: I commented all of my code and the error still showed up, so ignore the code
I typically see this if I use a library (.swc or .ane) that the desktop debugger cannot use.
If you using any libraries, perhaps uncouple them to see if the error disappears.
Difficult to say what the exact problem could be. From what I read, seems like a version issue. This thread maybe of some help : https://forums.adobe.com/thread/1007928
On a side note, I noticed that you have your instance named as Write and Read. I would typically avoid such names as they might conflict with reserved keywords, and while naming instances, it's best to name them using a camel case convention.
So, I would name them something Iike writeMc and readMc.
Hope this helps.
if you're publishing a mobile app, test on a mobile. you will get that error when using certain mobile-only code in the test environment. ie, test on an appropriate (ios/android) mobile.
I have three classes and a container .swf:
Game - this loads all assets and game mechanics.
Tile - Creates a square and loads image an image via flash Var.
TicTacToe.as - This creates a game instance and is linked via container.swf
In my Game class I have the following code which works fine when I save and compile, and is able to load my images when I update to my .asp page(I am getting the data from a db and passing to flash vars).
var gridUrl:String = "img/" + loaderInfo.parameters.theme + "grid.png";
var gridPos:XMLList = theXML.GRID;
gridLoader.load(new URLRequest(gridUrl));
grid = new MovieClip();
grid.addChild(gridLoader);
When I add this code to the Tile.as to load an image for the square I get a compiler error 1009: Cannot access a property or method of a null object reference. with an error on this line:
var tileBurl:String = "img/" + loaderInfo.parameters.theme + "square.jpg";
Its working in the Game.as class but this same line isn't in my Tile.as and I can't figure out why, even locally when it can't find the variables Game.as simply lists them as "undefined" where as in Tile.as it throws a fit at loaderInfo.parameters, and loaderInfo lists them as "null". Any Help would be appreciated thanks!
It looks that in the time of calling loaderInfo object, this is not yet prepared. Try to delay execution of the code for example by adding empty frame at the begining.
I'm trying to create an application using the NFC (proximity) API on Windows Phone 8. When I copy the example code from the documentation, I get the following compile error...
error CS0103: The name 'Window' does not exist in the current context ...
This error is all over the internet and the common solution seems to be that it only works for native (or C++) code. However the documentation says that it works for managed or native code. How do I get the examples to work in my managed code?
In order to gain access to the active Windows.UI.Core.CoreDispatcher object, you simply need to request Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher.
ORIGINAL EXAMPLE CODE
// Write a message to MessageBlock on the UI thread.
private Windows.UI.Core.CoreDispatcher messageDispatcher =
Window.Current.CoreWindow.Dispatcher;
CORRECTED CODE
// Write a message to MessageBlock on the UI thread.
private Windows.UI.Core.CoreDispatcher dispatcher =
Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
The one small change makes all the examples work! Enjoy.
I am developing a Flash application (Flash Player 11 as target platform) that uses the AS3 Facebook API, which in turn uses as3corelib JSON functionality. Or at least it should do so.
However, in spite of including the latest version (.93) of the as3corelib.swc, I still get the "Error: Access of undefined property JSON". I also tried including the sources directly, to no avail.
Any ideas what I am doing wrong?
As I said, the *.swc is definitely included. As is the source code (all at the correct path).
Edit:
I have a more specific error message:
Error: Can not resolve a multiname reference unambiguously. JSON (from C:\Coding\FlashDevelop\Tools\flexsdk\frameworks\libs\air\airglobal.swc(JSON, Walker)) and com.adobe.serialization.json:JSON (from C:\flash_test\lib\as3corelib.swc)) are available.
I know that JSON is included in AIR, but I do not target AIR, so why does it try include the airglobal.swc?
Your problem is that Flash Player 11 and onwards has native JSON support, so the JSON class you are including is likely colliding with the one from as3corelib. Hence the ambiguity problem.
Try removing as3corelib entirely and see what happens.
Specify the full path to the class. Example, code:
...
var jsonData:Object = JSON.decode(loader.data);
...
will be
...
var jsonData:Object = com.adobe.serialization.json.JSON.decode(loader.data);
...
Trying to implement the new FP 10.1 Global error handler into my projects but no matter what I do any uncaught error will still show up the Exception window (both in debug and release versions of the SWF). All I want to do is to prevent these popups but instead send a message to my logger. Here's my code ...
EDIT: I simplified the code now. Could somebody do me a favor and test the following class and see if it's works for him? Because it's doesn't for me! ...
package
{
import flash.display.Sprite;
import flash.events.UncaughtErrorEvent;
public class GlobalErrorHandlerTest extends Sprite
{
public function GlobalErrorHandlerTest()
{
stage.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtError);
throw new Error();
}
private function onUncaughtError(e:UncaughtErrorEvent):void
{
var message:String;
if (e.error["message"])
{
message = e.error["message"];
}
else if (e.error["text"])
{
message = e.error["text"];
}
else
{
message = e.error["toString"]();
}
trace("Uncaught Error: " + e.text);
}
}
}
I had the same issue as above - I was referencing stage.loadInfo, believing that as that references the stage, it would capture all uncaught errors. However, that doesn't work, you have to actually follow grapefukt's suggestion verbatim: On the actual base display object, place the code
loaderInfo.uncaughtErrorEvents.add...
When you try to place onto stage.loaderInfo or frame.loaderInfo, it has no effect.
In my case, I had to place it in the class that extended the base display object. Very Odd.
The docs say that:
The UncaughtErrorEvents object that dispatches the event is associated with either a LoaderInfo object or a Loader object.
Thus you must listen to the loaderInfo's uncaughtErrorEvents property of your topmost display object:
loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);
UPDATE: I think I may know why you think this isn't working. I made the mistake of testing inside the debugger. When the debugger stopped on the runtime errors I assumed that this proved my uncaughtErrorHandler function was not working. In fact, this was in error. It's just a quirk of the debugger. The debugger will still stop as if it is an unhandled error or exception, but if you press Run again you'll see it DOES execute the error handling code. See my thread Flex 4.0/4.5 global error handling for more info.
Original response:
I am looking for this same info. None of the examples in the API doc nor various blogs on the subject work for me. I've tried just loaderInfo, stage.loaderInfo, systemManager.loaderInfo... It makes no difference. I even tried all of them in a single test case! The addEventListener are being set but the uncaught errors are not firing the uncaughtErrorHandler. Argh. I have wasted far too much time on this! I've reduced it to a very simple program much like above except with all the code in the main mxml file.
How about this: can someone post a Global Error Handling example that DOES work? I'm using Flex SDK 4.1 (I've also tried with 4.5), targeting FP 10.1 (or 10.2 for 4.5), in a mx:Application-based mxml Flex project.
My thread: Flex 4.0/4.5 global error handling
You must set up the listener not to a specific view, but to the main stage object, as it's at the top of the display list (thus picking up any exception of any of its children).