Export SWC from Flash and Access Child from Flex - apache-flex

I'm creating an actionscript project in Flex Builder. I succeed to export from Flash a SWC file, and to use it succesfully in Flex. I have a good programming background and Flex looks very simple for me, but I have difficult times in flash.
I'm trying to achieve something that might be very simple(not for me of course):
I create a simple shape in Flash, convert it to symbol. Then I create a TextField. The I select both the elements and convert them to another symbol, and Export it as a movieclip in swc.
In flex I want to change the value from the textfield. How should I do? I'm trying to do:
var t:ExportedMC = new ExportedMC();
t....(what should I write here)
As I mentioned when I open flash I feel like an elephant in a porcelain store. I have 2 questions here:
- how to assign a name to the textfield in flash? I'm using CS4.
- how to access it as a child in flex?

When you create the symbol in Flash and export it to actionscript (in symbol properties dialog), you created a class that is accessible in Flex (after including the resultant swc in flex project library path). Any controls/shapes/symbols within that class will be contained within and created along with the containing class.
If you have any objects/smybols in that class that you would like to access/modify/whatever, you need to give them an instance name (you can do it without this step, but it's more complicated). In Flash, you edit (doubleclick) the class object in the library, then select a particular sub-object/symbol/control in the class object and give it a name by entering something under in object properties tab. That name will be included in the exported class as an property that you can access as any other class property (width,height,x,y,...).
For example, if you have a ExportedMC symbol that includes a TextField control which you gave instance name ('txtFieldName', for example), you would access it in Flex like so:
var t:ExportedMC = new ExportedMC();
t.txtFieldName.text="something";
Flex will actually be able to autocomplete the property name on the class, so you'll easily be able to know if things worked out or not.
Hope this helps.

Related

How to get gwt widget default stylename

In gwt how to get a widget's default style(CSS Selector).For example, gwt button has style name "gwt-button" which is referenced in gwt theme css file.
How to got that programmatically.
Is there any,
DOM.getStyleAttribute();
to accomplish this. GWT experts please help.
In your example of button (or any object that is a child of UIObject) can call getStyleName()
UIObject documentation
String com.google.gwt.user.client.ui.UIObject.getStyleName()
Gets all of the object's style names, as a space-separated list. If you wish to retrieve only the primary style name, call getStylePrimaryName().
Now as to why you need this information is the real question. It is my guess that you want to change the styling of an object (add or remove). This would best be done by either of the following methods.
1) Supplying a custom resources file to the object that has your styling
2) creating a class that extends Composite and create a custom UIBinder class with all of your styles within it.

Now able to get Id property for flex components

I am not able to get the Id property for flex components in my flex application(swf file) using Test Object Inspector in Rft Tool.
How can i get them?
You can't. Flex mxml component ids are only used as a hash within the containing parent. They're only used for referencing objects and are discarded at compile time.
If you have an id property for your flex component then there are a couple of ways to find out the id property of your desired control.
Make sure you have embeded your .swf file inside an html wrapper(as suggetsed by RFT) and displaying it in an enabled IE browser.
Hover over the component, say a button(and you should see automation name as well as id value).
Else you can do a simple script call to get the id of desired component:
System.out.println(desired_object().getProperty(".id"));

flex core api hidden

is there any way to change file mode to hidden by flex?
for example
var myFile:File = new File(File.applicationDirectory.nativePath + File.seperator + "a.txt");
myFile.setHidden
I'll suppose you mean Adobe Air, since the File class is not available in Flex.
Still, no, you can't change file attributes. You can access them (isHidden, for example) but unfortunatelly they're read-only. Here's the reference for the File class.

Accessing children elements in a SWC

Does anyone know if its possible to access children elements in a SWC? I have created some MC's and inside of some of these MC's I have some dynamic textFields. I export the content to a SWC and load it into my Flex project. No problem loading it or accessing the parent elements, they display fine. But I want to access the textfields nestes in the MC's and modify the text. When I debug the app, I can see the textfields as child elements. It's typed as a TextField and the Instance Name is the same as input in the Flash IDE but I cannot access it. When Flex compiles it throws an error saying it doesn't recognize the method. I've tried to insert actionscript on the timeline, linked external classes and nothing can be accessed. Does anyone know of a way to do this?
It's hard to say since you're not showing your code that fails, but I suspect you're doing:
import myswc.*;
myswc.Symbol1.myTextField.text = "Foo"
instead of
var clip:MovieClip = new myswc.Symbol1();
clip.myTextField.text = "Foo"
I just bumped into this as well, and am curious as to why you're suggesting he's NOT using the instance name since myTextField is obviously an instance name for the TextField he's using....

Displaying content from bulkLoader which is typed as MovieClip in Flex app

I know this is somehow trivial, but I couldn't find appropriate solution so please help me :)
I am using bulkLoader to load dozens of SWFs into my Flex app, and all of SWFs are static (1 frame only). 'Everything' works fine, however, I'm not sure how to handle data from bulkLoader... I am getting MovieClip types for all of my SWFs, and I am not sure how to tell to Image or SWFLoader classes to use some of those MovieClips as source...
Thanks for any help really :)
m.
The source property of the Image or SWFLoader class only stores the location of the file (URL or local path) as a string. If you set this property the class tries to load that file (with bindable blabla)
So, you can't overwrite the source property with a movie clip.
Maybe you could cast the MovieClip to an Image component using
var image:Image = bulkLoaderMovieClip as Image;
bye,
tux

Resources