views:

2301

answers:

3

I have a Flex application, which loads a SWF from CS3. The loaded SWF contains a text input called "myText". I can see this in the SWFLoader.content with no problems, but I don't know what type I should be treating it as in my Flex App. I thought the flex docs covered this but I can only find how to interact with another Flex SWF.

The Flex debugger tells me it is of type fl.controls.TextInput, which makes sense. But FlexBuilder doesn't seem to know this class. While Flash and Flex both use AS3, Flex has a whole new library of GUI classes. I thought it also had all the Flash classes, but I can't get it to know of ANY fl.*** packages.

A: 

Flex and Flash SWFs are essentially the same, just built using different tools. I'm not sure if they share the same component libraries, but based on the package names I'm guessing they at least mostly do.

If it's a normal Text Input then I would guess it's an instance of mx.controls.TextInput.

Herms
+2  A: 

The fl.* hierarchy of classes is Flash CS3-only. It's the Flash Components 3 library (I believe it's called, I might be wrong). However, you don't need the class to work with the object. As long as you can get a reference to it in your code, which you seem to have, you can assign the reference to an untyped variable and work with it anyway:

var textInput : * = getTheTextInput(); // insert your own method here

textInput.text = "Lorem ipsum dolor sit amet";

textInput.setSelection(4, 15);

There is no need to know the type of an object in order to interact with it. Of course you lose type checking at compile time, but that's really not much of an issue, you just have to be extra careful.

If you really, really want to reference the object as its real type, the class in question is located in

Adobe Flash CS3/Configuration/Component Source/ActionScript 3.0/User Interface/fl/controls/TextInput.as

...if you have Flash CS3 installed, because it only ships with that application.

Theo
A: 

Keep in mind that if you do as Theo said and reference it with the correct type it will compile that class in both swfs, even if you're not using it in the first one. Unfortunately the fl.* classes don't implement any interfaces so you can't type them to the interface instead of the implementation. If you could, only the interface would get compiled, which is much smaller than the implementation. For this one it won't be a big deal, it's probably going to add only a couple kb, but in the long run it adds up. Just a heads up ;)

Antti