Ok, figured it out. There's actually a "parent" object you can reference, like so:
var myParent:UIComponent = new UIComponent();
if (parent is UIComponent) {
myParent = parent as UIComponent;
}
This gets me everything I need.
Showing posts with label software. Show all posts
Showing posts with label software. Show all posts
Sunday, July 29, 2007
Flex Pass Message to Parent Component
So I'm passing the time by getting ahead on some stuff for work (possibly dangerous at this point, I know). I have a method in a .mxml that needs to reference its parent component. The way this was accomplished before was by getting a static reference to the main app, then just doing this:
app.component.whateverINeedToDo();
Problem is, now that I'm pulling the parent component out into a module, I can't necessarily rely on a reference to the main app; I need to transfer information some other way. I could use the EventDispatcher system built into Flex. I've already extended this mildly to facilitate interaction between my modules, but it seems like overkill for a simple intra-module method call. Need to think on this.
app.component.whateverINeedToDo();
Problem is, now that I'm pulling the parent component out into a module, I can't necessarily rely on a reference to the main app; I need to transfer information some other way. I could use the EventDispatcher system built into Flex. I've already extended this mildly to facilitate interaction between my modules, but it seems like overkill for a simple intra-module method call. Need to think on this.
Saturday, July 28, 2007
Programs I Could Not Live Without
Whenever I reinstall an operating system, there are several programs I must install before I even think about developing.
Windows:
TextPad - The best lightweight syntax-highlighting editor I've seen for windows. Has all the basics and then some.
Cygwin - The basics of Bash on Windows. Write an honest-to-God bash script on windows. Never mess with a .bat file again.
Flex Builder (if I'm developing in Flex) - Self-explanatory
IntelliJ IDEA (if I'm in Java) - Self-explanatory
Innotek VirtualBox - 90% of the features of VMWare Workstation (and growing), at 0% of the price.
Maven (1 or 2) - Why would I ever want to learn how to use javac?
Python interpreter - Just a huge improvement over the default calculator. Sad, I know.
Linux:
Bluefish - Essentially the Linux equivalent of TextPad. Good for files that are a bit large for VIm.
IntelliJ IDEA
Innotek VirtualBox
Maven (1 or 2)
Windows:
TextPad - The best lightweight syntax-highlighting editor I've seen for windows. Has all the basics and then some.
Cygwin - The basics of Bash on Windows. Write an honest-to-God bash script on windows. Never mess with a .bat file again.
Flex Builder (if I'm developing in Flex) - Self-explanatory
IntelliJ IDEA (if I'm in Java) - Self-explanatory
Innotek VirtualBox - 90% of the features of VMWare Workstation (and growing), at 0% of the price.
Maven (1 or 2) - Why would I ever want to learn how to use javac?
Python interpreter - Just a huge improvement over the default calculator. Sad, I know.
Linux:
Bluefish - Essentially the Linux equivalent of TextPad. Good for files that are a bit large for VIm.
IntelliJ IDEA
Innotek VirtualBox
Maven (1 or 2)
Hello World in Python
Python is a very high-level interpreted scripting language. I have a personal interest in learning it, as it seems to be a great rapid prototyping language. You can quickly and easily write your logic in Python, just to see if it works. If it does rewrite the whole thing (or just resource-intensive chunks) in a compiled language like C++. When I say "quickly and easily," I'm serious. Here's an entire Python Hello World program:
print "Hello World"
As that doesn't tell you much, I'll add some variables and an infinite while loop:
var a,b = "hello", "world"
while true:
print a + b
As you can see, Python has essentially no punctuation requirements (braces, semicolons and the like). It is entirely newline- and whitespace-delimited. Blocks are indicated by indentation. The command is done when you go to the next line. No more debugging a missing curly brace (yeah, yeah, IDE's catch that. Still, it's slick).
The other thing I can see Python being good for (and it's used for this in several schools I know of) is an introduction to programming. It gives you the basics of statements and control structures and loops and even OOP, and it even forces good programming style with the indentations, but it doesn't saddle you with learning all the intricacies of C++ or Java, for example.
print "Hello World"
As that doesn't tell you much, I'll add some variables and an infinite while loop:
var a,b = "hello", "world"
while true:
print a + b
As you can see, Python has essentially no punctuation requirements (braces, semicolons and the like). It is entirely newline- and whitespace-delimited. Blocks are indicated by indentation. The command is done when you go to the next line. No more debugging a missing curly brace (yeah, yeah, IDE's catch that. Still, it's slick).
The other thing I can see Python being good for (and it's used for this in several schools I know of) is an introduction to programming. It gives you the basics of statements and control structures and loops and even OOP, and it even forces good programming style with the indentations, but it doesn't saddle you with learning all the intricacies of C++ or Java, for example.
Flex - Generate a ModuleLoader at Runtime
I spent most of a day running up against a problem in Adobe's Flex 2.0. Flex 2.0.1 introduced the concept of modules. With this, you can stick a <mx:ModuleLoader> component in your .mxml file, then load it with the url to your module .swf file when you need it.
Now, I wanted to allow the user to load arbitrary modules at arbitrary times, and then load those into a ViewStack component. The problem is, no matter what I did, I couldn't seem to get the dynamically loaded module to obey sizing (IE, height="100%"). Here's the solution: You have to put the ModuleLoader in a Canvas, and then add the Canvas to your ViewStack. Also, you must use percentWidth and percentHeight in your <Module> tag (not width and height).
Now, I wanted to allow the user to load arbitrary modules at arbitrary times, and then load those into a ViewStack component. The problem is, no matter what I did, I couldn't seem to get the dynamically loaded module to obey sizing (IE, height="100%"). Here's the solution: You have to put the ModuleLoader in a Canvas, and then add the Canvas to your ViewStack. Also, you must use percentWidth and percentHeight in your <Module> tag (not width and height).
Subscribe to:
Comments (Atom)
