Monday, February 9, 2009

Flash Prototypes

Flash-bashing seems to be the theme of the day among EDI-ers, so I thought I'd weigh in. Flash...isn't easy to use. There are no quick answers when you're facing a how-do-I-do-this question. Googling occasionally yields results; but more often than not, I the things that I found were either only tangentially related or were using some different version of Flash, so the instructions didn't translate easily. Usually both. The Flash forums that I could find generally consisted of "How do I do something really complicated and specific?" questions and a dearth of simple questions.

The biggest issue is that I haven't been able to find an API anywhere. A list of object methods and properties would have been incredibly helpful when trying to figure out things like "How do I change the color of this button through actionscript?" It seems like the kind of thing that you should be able to do fairly easily, but without knowing exactly what keywords to reference and the format of any parameters, it's nearly impossible. Adobe's LiveDocs has some answers (like this one), but it's very difficult to find the article that you want, and then it still doesn't give you a list of properties - only the syntax for editing them with an example of one or two. Annoying. Incidentally, here is a fairly good API example (although it probably won't mean much to most of you).

Has anyone found a good property list out there?

A few tricks that I figured out that might prove helpful for people:
  • You can define global variables and functions that will persist through different frames.
  • To define a variable, just assign it a value somewhere. (Example: x = 3;). You don't have to give the variable a type, like in other programming languages. I found it useful to declare these variables in the ActionScript area for the first frame. Note that you have to select the same layer when you are trying to find your code again.
  • To refer to these variables later, precede them with" _root." otherwise you might be working with a different version of the variable and frustration and confusion will ensue. (Example: _root.x = 5).
  • I found it useful to create functions to enable/disable certain buttons on my interface which changed frequently. Again, on the ActionScript area for the first frame, you can do something like this: _global.myFunction = Function(Void):Void { ... } where your code goes in between the curly brackets. You can then call the function from anywhere in your program with the line myFunction();
This is probably not the proper way to do things, but it was what I figured out. Anyone else come up with any useful tricks?

1 comment:

  1. That is SO helpful. I literally spent an hour on the Flash help menu trying to figure out how to save stuff between frames. yay!

    ReplyDelete