Reputation: 213
I'm working on a very simple flash but having problem compiling to the swf file. The detailed error info are roughly translated as follows:
*AssetManager.as
Line 47 : DisplayObject variable cannot be "undefined"
Line 51 : DisplayObject variable cannot be "undefined"
Line 101 : DisplayObject variable cannot be "undefined"
*SWFaddress.as
Line 10 : void method has been used where Boolean value was required
Line 60 : displace problem(I suspect it means some files has been moved to elsewhere) ,clearInterval method is no longer supported,it has been moved to flash.utils pack
Line 243 : setInterval method is no longer supported, it has been moved to flash.utils. please consider Timer class
Please refer to the screen-shots and the code line in question has been highlighted.
Upvotes: 0
Views: 174
Reputation: 10339
If .getChildByName()
couldn't get you the DisplayObject
it will return null. Try changing undefined to null. (Line 47, 51, 101 in AssetManager.as)
Instead of using setInterval and clearInterval from flash.utils.*
, use flash.utils.Timer
.
For example:
var myTimer:Timer = new Timer(1000); // 1 second
myTimer.addEventListener(TimerEvent.TIMER, runMany);
myTimer.start();
function runMany(event:TimerEvent):void {
trace("runMany() called @ " + getTimer() + " ms");
}
And use .stop()
on the timer object instead of clearInterval. More about the Timer class: flash.utils.Timer.
In the case of ExternalInterface.available
I guess the problem is because you have the _availability
variable defined static.
P.S. Referring to screen shots of your code is not very nice way how to do it.. Better paste the code in next time.
Upvotes: 2
Reputation:
Although I've never attempted anything like this, and thus can't really say, I'm going to guess that the odd errors you're getting in SWFAddress are caused by your excessive use of statics. You're defining a static variable as you're casting it in a static namespace based on another static variable. The compiler is probably saying that void is being returned because one static is being defined before the other, and the default value to an undefined static is most likely void, not null. This is hard to say for sure as it would require looking at the tamarin C++ source code but I'm gonna call it anyway. Excessive use of statics, as in the case of your code, is indicative of a lack of understanding of class and object structures. The only time you should be defining statics is when you want to define types of an object or something of this nature. For example the MouseEvent class has statics to define which type of mouse events can be created: MouseEvent.MOUSE_DOWN etc. Try changing up your classes so they are instantiated correctly, using object-level methods and variables instead of static ones. Or, if you want to just get your project done here, try defining static variables that are based on other static variables inside of functions that you manually call instead of in the static/class namespace.
*Update* It's hard to put it all into one answer but basically the way that statics work is, they are the very first thing to be created by the virtual machine and they are permanent. They are not a dynamic or disposable object, the type of objects the virtual machine was really built to use. A static is defined before anything else so, in the case of the odd error where you're getting a void instead of boolean, is because as the compiler or virtual machine moves down the list of "to-do's" it bubbles things like this to the top and does them first. However, it's probably trying to define your _availability static variable before the ExternalInterface.available static variable has been fully defined. I hope this adds a bit of clarification to the original answer.
Upvotes: 1