View unanswered posts | View active topics



Reply to topic  [ 6 posts ] 
Accessing component properties 
Author Message
Member

Joined: Mon Nov 16, 2009 5:01 pm
Posts: 4
Hi Guys,

I am very new to flash, like couple of weeks new. After much research I figured FlashDevelop is the way to go because it is easy to manage and write large amount of AS3 codes. But I am facing few setbacks, and will appreciate your help.

I am trying to build a GUI for my C# application. I want to build the GUI in flash and not use Windows form. I have successfully build small projects and incorporated them to test c# applications. Right now I am trying to build a larger GUI project in flash CS3 and FlashDevelop.

I am designing the flash components in Flash CS3 and exporting them as .swc files and using these components in AS3 code in flashdevelop. In my current project, the main GUI opens with couple of buttons (eg; "Create group" and "Delete group") at the top. When "Create group" button is clicked a popup box appears in the lower portion of the GUI (it is just a symbol exported from CS3 that I add to the stage using addChild() function) in this pop up there are components like TextInput, ColorPicker, TileList and buttons (Ok and Cancel).

Now what I want to do is take the input from these components and store them in variables in my AS3 code and use the values of these variables to manipulate features of other components that I have exported (.swc file).

Let me expalin how I export the components from flash CS3. For the pop up I created a rectangular container and then created its symbol (by pressing F8) and also exported it (say I named the symbol as PopUPWindow and checked the checkbox "Export for ActionScript"). Now I go to "Edit Symbols" drop down and choose "PopUpWindow" symbol. Then I add other components to "PopUPWindow" like TextInput, ColorPicker, TileList and buttons, I create a symbol for all these components (e.g.; PopUpColorPicker for ColorPicker) but I do not export them. At the same time I also create instances of these symbols using the properties window.

Finally I publish the .swc file where I need it.

Now in FlashDevelop, I create a class for the "PopUpWindow" that I exported say classPopUpWindow. Then I create an instance of this class in Main.as, say
Code:
public var testPopup:classPopUpWindow = new classPopUpWindow();


Now, when I use this object "testPopup", and use the (.) period operator after that object I can access all the symbols that I created in Flash CS3 under "PopUpWindow" symbol (the FlashDevelop intellisense shows them in the IDE).
eg;
Code:
testPopup.PopUpColorPicker

The color picker is above accessible, but when I try to use another (.) period and try to access the selectedColor property of colorPicker symbol
Code:
testPopup.PopUpColorPicker.selectedColor

it is not accessible. Similar things happen to other symbol's properties, like text property of TextInput symbol of the PopUpWindow is also not accessible.

But when I try to addEventListener like this

Code:
testPopup.PopUpColorPicker.addEventListener(Event.CHANGE, ...);


it works.

Suggestion on this are greatly appreciated.
Also if you know then please point me to some tutorials or books that explain how to export the different components/Symbols from flash CS3 and access their properties in flashdevelop.

Note: all these components I have talked about are exported in a single .swc file from Flash CS3. And also for the smaller projects that worked for me earlier all the Symbols were exported for the ActionScript.


Mon Nov 16, 2009 5:53 pm
Profile
Member

Joined: Mon Nov 16, 2009 5:01 pm
Posts: 4
Someone???


Mon Nov 16, 2009 8:26 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 11581
Location: Paris, France
Press F4 on ClassPopUpWindow to see what FD extracts from the SWC.

What do you mean by "create a symbol for all these components"?

Do you 1. place directly the components inside the PopUpWindow symbol (you should)? or 2. create additional symbols containing the components (so it's a MovieClip containing the component)?

PS: this is a somewhat low traffic forum so you may not get an answer the same day.


Mon Nov 16, 2009 8:31 pm
Profile WWW
Member

Joined: Mon Nov 16, 2009 5:01 pm
Posts: 4
When I press F4 on ClassPopUpWindow I can see the followin lines of code (I added the comments):

Code:
package
{
   import flash.display.MovieClip;

   public class ClassPopUpWindow extends MovieClip
   {
      public var PopBtnCancel : MovieClip;                            //This is a Cancel button
      public var PopBtnOk : MovieClip;                                 //This is an OK button
      public var PopUpColorPicker : MovieClip;                       //This is a ColorPicker
      public var PopTeamName : MovieClip;                          //This is a TextInput
      
      public function ClassPopUpWindow ();
   }
}


So it looks like all the components are being extracted from the SWC.

Quote:
What do you mean by "create a symbol for all these components"?


When I create the rectangular container and then made it a symbol (by pressing F8) and also exported it (say I named the symbol as PopUPWindow and checked the checkbox "Export for ActionScript"), then I add other components like the buttons, ColorPicker and TextInput and for each of these components I hit F8 and make them a symbol, but this time I do not check the checkbox "Export for ActionScript", instead I create an instance (by going to the Properties window and typing an instance name there).

Do you 1. place directly the components inside the PopUpWindow symbol (you should)?
Yes I do. When I am placing these components on the PopUpWindow, all the other Symbols in the main document are hidden and only PopUpWindow is displayed (I selected the PopUpWindow by going to the "Edit Symbols" drop down in the main working window), along with these new components I have just placed on it.

Thank you for your response.


Mon Nov 16, 2009 8:57 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 11581
Location: Paris, France
The problem is that you should NOT press F8 / Make symbol for the component instances you placed inside your popupwindow symbol. Components are already symbols.


Tue Nov 17, 2009 8:26 am
Profile WWW
Member

Joined: Mon Nov 16, 2009 5:01 pm
Posts: 4
Got it. Thank you!


Tue Nov 17, 2009 1:59 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: JasonMBryant and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.