I have two FLA files, call them MAP.fla and ANI.fla, that I have to merge. One way I tried was to load the ANI.swf in MAP.swf during runtime using the normal way of doing it, using Loader and URLRequest. However, when I try to run it, flash detects errors about methods I have included in ANI.swf.
I do know that the Loader and URLRequest method of doing it works because I tried using it with a different SWF file with simpler content.
P.S. ANI.swf contains methods, instances with classes of their own and timer events. If Loader cannot work on my SWF, is there any other way of carefully doing this without affecing my FLAs?
Below is the error message i am getting. Thanks. :)
TypeError: Error #1010: A term is undefined and has no properties.
at stageRotation/stageRotation::pause()
at stageRotation/::create()
at stageRotation/::initStage()
at stageRotation$iinit()
Loader and URLRequest, are the best ways for doing this work.
your problem may causes by an illegal (unsafe) refering to "stage", from ANI.SWF, or calling ANI.SWF functions from MAP.SWF but in a wrong way.
Can you attach that error message?
Related
Ok so I have game data parser that creates a game out of data file basically, it is using extensively getDefinitionByName which has one problem if the class is not loading somewhere else it throw variable not defined error information=ReferenceError: Error #1065: Variable {MyClass} is not defined. to workaround it I am using a class that holds all the list of components and instantiate it to make these classes available to the compiler.
Ok the question part is there any more efficient way to do that or playing with compiler argument or something ?
Is there something like export in first frame in flash professional as a compiler argument ?
I think what you want is to have a library project with all those "callable" classes, and then reference that library project in your game.
In flash builder, for a library project, you can check which classes are compiled (and so available to getDefinitionByName). (info here)
I am using the OSMF to play HDS videos, the player is hosted in a 'parent' player that removes the OSMF using unloadAndStop() which results with the following error:
Error: Error #2154: The NetStream Object is invalid. This may be due to a failed NetConnection.
at flash.net::NetStream/play2()
at org.osmf.net.rtmpstreaming::RTMPDynamicStreamingNetLoader/reconnectStream()
at Function/<anonymous>()
When removing the OSMF using unload() the error does not occur .
I have made many attempts to resolve this or to try and catch the error but so far with no success, please share if you have any clue on how this might be resolved.
Thanks!
Eran
UnloadAndStop completely clears out everything (ready for Garbage Collector to free up the previously used memory) so now when your Play2() comes in, it finds access to nothing. You can try and separate a part of your code into smaller functions. i.e
Function One for setting up new netStream & netConnection etc
Function Two for playing netstream
Function Three can be for play2() where you have If/Else to check if not_unloaded == true then do play2(); else do Function One from here as a reset
PS: also these two links might help you as I dont (nor need to) know the rest of your code setup. Wether they talk about SWF files or Netstream it all applies the same
http://www.nikesh.me/blog/2010/04/unload-loaded-swf-file-by-unloadandstop-method/
http://www.breaktrycatch.com/problems-with-unloadandstop-a-guide-to-some-undocumented-caveats/
I'm trying to put a sound file into a flash program with the following code.
[Embed(source="../lib/DST-Aircord.mp3")]
static var sndtrck:Class; //used to represent the background music file
static var soundtrack:Sound; //used to handle the soundtrack file
soundtrack = new Sound();
soundtrack.load(sndtrck);
soundtrack.play();
I'm not sure that this is correct but it is throwing the following errors.
Error: Unsupported sampling rate (32000Hz)
Error: Unable to transcode ../lib/DST-Aircode.mp3.
Regarding the first error I checked in iTunes and the sampling rate is 44100Hz which I believe is what Flash needs to run. However FlashDevelop is incorrectly determining the sampling rate? I'm guessing that the second error is caused by the first although I'm not entirely sure what it means. Does anyone know what I might be missing in my attempt to embed sound into this SWF?
EDIT: changing the load function to use the path specified in the embed code yields the same error.
the load function of the Sound class only takes a URL of an external sound file. Im not sure what the class your putting into it is, but it probably throws the errors because a Class itself is not a sound file.
This is a link to the load() function of the Sound class, everything about it is there.
While writing this answer I realized that the question is pretty old. ;)
Anyhow, I ran into the same problem a while back and it could be solved
by this: Unsupported sampling flex/actionscript
Im developing a flash game based on the citrus engine for a uni project.
All of it is done and handed in but im trying to compile the entire project into a release for web.
In flahs builder ive gone file --> export --> release build and compiled the game.
the .swf file opens up fine and initiatze the spirte menu but when clicking the start game button it begins to initiate the game state but then hangs up on a solid colour, in flash debugger im getting these errors
SecurityError: Error #2000: No active security context.
Started
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.citrusengine.utils::ObjectMaker$/FromMovieClip()
at GameState/initialize()
at com.citrusengine.core::CitrusEngine/handleEnterFrame()
SecurityError: Error #2000: No active security context.
Started
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.citrusengine.utils::ObjectMaker$/FromMovieClip()
at GameState/initialize()
at com.citrusengine.core::CitrusEngine/handleEnterFrame()
Any suggestion appreciated
Error #2000 is usually a file not found error. You can get more info from running an IOErrorEvent like so:
myLoader.addEventListener(IOErrorEvent.IO_ERROR, IOError)
function IOError(e:IOErrorEvent):void {
trace(e.text);
}
Likely an issue with pathing to the correct file.
Error #1009 is likely a domino effect of not being able to work on the asset that hasn't been loaded due to the IOError. It could also be an issue if you're loading other SWFs to the stage and those child SWFs attempt to utilize the stage before it's ready, in which case you'd want to only start your scripts until after the addedToStage event has fired. You can set that up like so:
if (this.parent is Stage) {
stageReady();
} else {
addEventListener("addedToStage", stageReady);
}
function stageReady(e:Event = null):void {
// begin your setup code here.
}
The logic here being that if your swf is not encapsulated inside a loader, the parent object should be the stage, otherwise, you can safely add a listener to the loaded swf's timeline that listens for the addedToStage event.
Maybe the following will resolve your problem:
Wrap all the init code to a custom function (lets say: initFunctionOfApplication). Set a delay timer before this init function is called. It's a issue I've had before, and got it fixed with a small delay... Maybe this will fix your problem.
setTimeout(function():void{initFunctionOfApplication();}, 3000);
Keep us posted!
I'm trying to add an event listener to my air application that would prevent the "ActionScript error" window from appearing, so I can handle the error within my application.
I was able to find a little information about this from adobe. I'm just not sure what I should be listening for.
It depends quite a lot on what error is thrown, and why.
Your best bet is to carefully read the ActionScript documentation and add listeners to react to all of the errors that have explicit ErrorEvents (such as IOErrorEvent and SecurityErrorEvent). Those are usually related to network and/or file access, and security issues.
For most other errors, there is the try {} catch() {} finally {} statements. This tutorial might be a good place to start.
And if all else fails, there's UncaughtErrorEvent.
But you should really be using that one as a last resort, not as a magic bullet - the best error handling is a) trying to prevent errors from being thrown in the first place (make sure all variables are properly initialized, test for null, etc.), and b) handling expected runtime errors by catching them explicitly, in order to keep the application running and stable.
You have a couple options. As you know, exception handling is not always possible for certain asynchronous operations.
First off, you need to know what object is responsible for the asynchronous operation that is causing the error. The most sensible approach would be to add the necessary error event handlers to this object.
For instance, a URLLoader performs asynchronous operations; and it's failure can only be handled by adding error event listeners. For example:
var loader: URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
Another 'catch-all' option is to take advanage of the new UncaughtErrorEvent feature of Flash Player 10.1. For this to work, you need to attach the uncaught error handler to the loader of the main application; this will catch everything! For example:
loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, loaderErrorHandler);
private function loaderErrorHandler(e:UncaughtErrorEvent):void {
if(event.error is Error) {
// handle error from embedded SWF
}
// suppress error dialog
e.preventDefault();
}
The last option may not be the best approach as it promotes the swallowing of exceptions instead of addressing and handling the problem properly; nevertheless it can be useful in certain unique circumstances (embedding SWFs).
The window won't appear if you're running the standard version of Flash Player.
It will manifest only as a dialog box on the debugger versions of the
browser plug-ins and stand-alone players, as a message in the output
panel in the authoring player, and as an entry in the log file for
Adobe Flex Builder 3. It will not manifest at all in the release
versions of Flash Player or AIR.
Source : here.