This is my class in essence
import mx.controls.Image;
public class ImageFrameView extends Image
{
//Model. Contains x, y, z and z. Url for the png/jpg or swf-file
private var m_imageFrame:ImageFrame;
public function ImageFrameView(imageFrame:ImageFrame)
{
super();
m_imageFrame = imageFrame;
initFrameView();
}
private function initFrameView():void
{
maintainAspectRatio = false;
width = m_imageFrame.width;
height = m_imageFrame.height;
x = m_imageFrame.x;
y = m_imageFrame.y;
rotation = m_imageFrame.rotation;
source = m_imageFrame.url; //Url points to a handler on the same server which serves images and/or swf-files.
}
}
And it's used like this in a class SpreadView which extends UIComponent
var imageFrameView:ImageFrameView = new ImageFrameView(contentFrame as ImageFrame);
addChild(imageFrameView);
Png and Jpeg works fine. And swf-files which I export from Indesign CS4 or Indesign CS5 works fine aswell. But recently,older swf-files which have been exported using the same method and parameters (in Indesign CS4) and which used to work, have suddenly refused to load and I get the following error, when UpdateDisplayList is called for the ImageFrameView:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.adobe.indesign::IDSWFFile/readConfigurationData()
at com.adobe.indesign::IDSWFFile()
What happens is that the loaded swf-file throws an exception when it tries to read its own configuration.
All swf-files that I've created past and present still work. All swf-files that clients have created created past and present - doesn't work even tough they worked in the past. As far as I know the swf-files is created using the same method and parameters.
Can there be some sudden change in Adobe Flash that I'm not aware of? Me and my client is using Flash 10.1 or higher. Where does the error orgin from?
It seems like it is page transistions and/or page curl was the culprit. I don't know why but when I ticked off the options for page transistions the error vanished when the pdf is loaded. As such features is meaningless in my app I will make sure that such options is disallowed when the clients exports swf-files from indesign.
Related
I've found several articles relating to variable FlexVersion and error 1065, but nothing seems to help.
EDIT:I've attempted to implement SEVERAL guides on embedding images into flashDevelop with the same result. Everything works correctly until I try to add the embedded image, then I get the above error.
Has no one here seen this error?
My Class (which I've stripped down to nothing in order to pinpoint the issue):
package {
import flash.display.Sprite;
import flash.display.Bitmap;
public class JMouse extends Sprite {
[Embed(source = "../lib/jacobsLadder.png")]
private var Picture:Class;
//private var pic:Bitmap = new Picture(); // THIS LINE
public function JMouse() {
init();
}
private function init():void {
}
}
throws the error when the line "THIS LINE" is not commented out. I've tried adding "as Bitmap" to the end of this line without luck.
I am calling this class from my document class:
jMouse = new JMouse();
the file, jacobsLadder.png, is in my lib folder, and I used FlashDevelop to "Generate Embed Code."
I am using FlashDevelop 5.0.1.3 for .NET 3.5
Any Ideas?
EDIT: I also tried this (and similar variations), as per the suggestion:
"The type of code you can run at variable declaration scope is limited. Creating an instance of Picture requires decoding and so will fail at that point. Instead create your instance of Picture within an instance methods or the constructor."
[Embed(source = "../lib/jacobsLadder.png")]
public static var Picture:Class;
public function JMouse() {
var pic:Bitmap = new Picture();
init();
}
But I get the same error.
The type of code you can run at variable declaration scope is limited. Creating an instance of Picture requires decoding and so will fail at that point. Instead create your instance of Picture within an instance methods or the constructor.
ANSWER: Load the bitmapdata with a loader.
Although the OP (me) was asking how to embed the file, the mysterious problem of "Error #1065: Variable FlexVersion is not defined" issue is apparently an insurmountable one, and I hope that anyone else who may come across this problem may find solace in the following (courtesy of John Mark Isaac Madison et al):
How do you load a bitmap file into a BitmapData object?
While not the an answer, per se, it at least allows the OP to continue on in his work as an alternative to lighting his house on fire.
My main application swf file is being loaded by a simple loader swf application that is useful to break cache. In both applications I would like to have access to a singleton. I will provide you with an example to reproduce the bug. So here's our singleton:
package {
public class SingletonTest {
public static const instance:SingletonTest = new SingletonTest();
public function SingletonTest() { /* Nothing here. */ }
public function test():void {
trace("SingletonTest!");
}
}
}
In constructors of both loader and main classes I call:
SingletonTest.instance.test();
That is made in order to be sure that my singleton class code will be included in both applications. I won't provide you with loader code but it's very simple. It creates Loader instance, it creates LoaderContext supplying it with both current ApplicationDomain and SecurityDomain, etc...
But when I launch my loader application I get following error:
Main Thread (Suspended: TypeError: Error #1034: Type Coercion failed:
cannot convert SingletonTest#47a3091 to SingletonTest.)
SingletonTest$cinit
I get this error right after main application was loaded with loader. Event.COMPLETE is not dispatched yet so no handlers involved. I spent a lot of time trying to find something about application or security domains but it seems like it's not the issue because what I found next is really strange. If instead:
public static const instance:SingletonTest = new SingletonTest();
I will write:
private static var _instance:SingletonTest;
public static function get instance():SingletonTest {
if (_instance == null) _instance = new SingletonTest();
return _instance;
}
Then there will be no such error and everything will be fine. Obviously flash player is performing some unexpected behavior here. There's very few information on this issue out there. Most of people get this error because of missing loader context but as I said before here it's not the case. Some discussions on this are even left without any answers which is strange to me because I find this to be quite a common problem to be encountered when using small applcation loader.
Spent almost 12 hours trying to solve the problem. At last found the solution. In order to avoid runtime error which I provided above you need to compile your singleton class into swc-library. That's it.
In my case that singleton was providing global access to logging and only option was to switch from singleton pattern to static class. But I didn't want it very much because I really like this one-line singleton instantiation: "public static cosnt instance:MyClass = new MyClass();".
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've had a similar issue to this, but the means that I solved the last one are not working here.
I have a custom class that consists of 12 separate .as modules. They're declared in the document class as follows:
import trailcrest.v1.s3.averta;
import trailcrest.v1.s3.chronos;
import trailcrest.v1.s3.eripio;
import trailcrest.v1.s3.fabrilla;
import trailcrest.v1.s3.gradua;
import trailcrest.v1.s3.lingua;
import trailcrest.v1.s3.navigare;
import trailcrest.v1.s3.pedem;
import trailcrest.v1.s3.praeferre;
import trailcrest.v1.s3.scriba;
import trailcrest.v1.s3.securos;
import trailcrest.v1.s3.sonus;
public static var Averta:averta = new averta();
public static var Chronos:chronos = new chronos();
public static var Eripio:eripio = new eripio();
public static var Fabrilla:fabrilla = new fabrilla();
public static var Gradua:gradua = new gradua();
public static var Lingua:lingua = new lingua();
public static var Navigare:navigare = new navigare();
public static var Pedem:pedem = new pedem();
public static var Praeferre:praeferre = new praeferre();
public static var Scriba:scriba = new scriba();
public static var Securos:securos = new securos();
public static var Sonus:sonus = new sonus();
This is a new version of the code. I am able to successfully refer to all of these classes and the public variables and functions inside in the "osr.as" document class. I can also SEE one module from another (i.e. Sonus can see Scriba using "osr.Scriba."
Where I'm having trouble is that, while the various modules used to be able to access all of each other's public functions and variables perfectly, after I added some new modules and variables and removed some old ones, Flash Professional is still literally USING the old version. Inside of any module, the code hints are showing all of the old public functions and variables, and none of the new ones.
I am guessing that this has something to do with some sort of temporary file that I can't get to. I absolutely need this working this week!
My .fla is "Tester.fla," and the document class is "osr.as." They're both in the same directory. Also in the same directory is the folder structure "/trailcrest/v1/s3/" which contains all of the Trailcrest modules.
Help??
EDIT: Whenever I try to reference one Trailcrest class from another Trailcrest class (i.e. osr.Sonus.foo), I get...
TypeError: Error #1009: Cannot access a property or method of a null
object reference.
I have confirmed beyond a shadow of a doubt all references.
This is the age old problem of what ultimately boils down to is the Verify Error. It happens when you embed "Class A" in one or more applications, modules, swfs, etc. Ultimately every output swf that uses "Class A" must be recompiled when "Class A" is changed. Otherwise you end up with a situation where 1 module has the newer implementation but others don't. This problem is compounded by the fact that the application domain is defined as a "first in wins" when it encounters a Class of the same name / package - meaning if the old one is referenced first, the newer one loaded later gets ignored.
The more permanent solution is to use class promotion to an RSL that ultimately allows the RSL to control the actual "Class A" reference in which it also implements an "IClassAImpl" interface that all modules use. This allows the compiler to cross link the reference with a signature it knows about without actually embedding the actual class itself.
Well, I finally figured it out. Here's the skinny on what was happening:
#1: Flash was apparently pulling an old version of the Trailcrest modules. To remedy this, I backed up everything and then removed all old instances of Trailcrest from my entire computer. Then, I put only the new modules back. That fixed the problem with Code Hints showing the old modules and variables.
#2: I had been experiencing Error #1009 whenever one Trailcrest class tried to access any component of another Trailcrest class, even though the references were all correct.
The cause was that I was calling functions on the various modules directly from the document class osr.as, outside of a function. This, of course, executes on the program start.
However, all the code within one Trailcrest class that called another Trailcrest class (i.e. osr.Sonus.foo) would not be able to access "foo" because osr.as for some reason or another hadn't finished initializing the classes before it ran the code that called them. This occurred, even though the problem code was well below the code that initialized the classes (see my question).
To fix this, I simply had to wrap the problem code into a public static function in the document class, and then call it from the Timeline. That ensured that all the classes were initialized before they tried referencing each other.
Needless to say, everything is running like a well-oiled machine now. How weird.
I'd welcome any explanation as to WHY this fixed the problem.
I have a .swf file that uses the following code:
private function onClick(e:MouseEvent):void {
var popUpClass:Class = getDefinitionByName(e.currentTarget.popUp) as Class;
popUpContent = new popUpClass();
}
However when I load that swf into another "container" swf I am getting a Reference Error #1065. I have been reading several posts on stack overflow (for example, this one and this one) but I am still confused as to what to do.
For example, do I change the code in my "loaded swf" to reference it's own application domain (not the domain of the container swf?) and if so, how do I do this exactly?
OR do I load the swf file and assign it it's own application domain in the code of the container? (not the code for the loaded swf?)
Also, my "e.currentTarget.popUp" just has a short name "PopUpWhateverName" should I be giving it a full package name like "com.MyLoadedSwf.Assets.PopUpWhateverName"?
Yes , full package name : getDefinitionByName("com.MyLoadedSwf.Assets.PopUpWhateverName")
but You can also try :
var popUpClass:Class = e.currentTarget.popUp.constructor;
popUpContent = new popUpClass();