Question

Years ago I created a tiny, simple SWF just to play MP3 files on various browsers. I exposed interfaces and called them from JavaScript. It was all small and straightforward; you can see the entire Guise.as source code.

I compiled the main class using mtasc, which allows you to specify a main function for initialization code:

/**Main entry point.*/
static function main(mc)
{

This was working just fine until I wanted to add WAV support. Flash doesn't natively support WAV, so I tried to add in a library. But the library required Flash 10 and wouldn't compile on mtasc, so I downloaded Flex 4.6 and tried to use mxmlc. Boy, was my pain only beginning.

My compiled SWF no longer works---even for MP3 files. I don't know where to start finding the problem, but I know I have lots of unanswered questions---maybe one of them is my problem:

  • If I understand correctly, mxmlc doesn't have the concept of a "main entry point", but Flash will simply create an instance of the "main class"', whatever that is. But how do I specify the main class? If I reference my class with mxmlc on the command line, will that class automatically become the main class, or is it absolutely required that my class be in the root (i.e. in no) package? Does it have to have a special name?
  • After I successfully designate a main class, can I simply move my entry point code into the constructor of my main class?
  • In my original class, I added a global function to convert an object to an array using Array.from=function(object:Object). This gave me an error while I was in strict mode---apparently because it doesn't like me to add static methods to the Array class object. Will this still work in non-strict mode? What's the problem? If I convert it to a normal method on my class, will it work?
  • As I'm accustomed to doing in "real" JavaScript, I added a Function.prototype.bind=function() function so that, when I have callbacks, this will be set correctly. Will this still work? Can I add methods to the prototype of Function?
  • Do I even need to bind the context anymore? If I call something like positionTimeoutID=setTimeout(fireSoundPosition.bind(this), 1000), without bind(this), will Flash pass the correct this to my callback method?
  • The Flex compiler complained that several API methods had changed, so maybe modifying my calls changed something and I don't understand the new API. Is there any way to debug this SWF? Write to the browser console? A beep? Anything? Without buying some big IDE from Adobe or something?

Any feedback would be appreciated. I'm sure there's just one or two little adjustments that's throwing the whole thing off, but maybe with a little help from the community I won't have to spend several days reading entire books and buying new SDKs just to recompile my SWF with a couple of new calls... Thanks.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top