Re: [Flashcoders] Some feedback on a coding design question
Jiri, Sounds like the state pattern would be helpful here. Define a class for each state of the application. Each class will contain methods for actions the user can take in that state, like selectListItem. When the user takes the given action (ex., selecting a list item), the associated function in the current state is called, and the correct actions are performed. Once those actions are performed, move the application to the new state. Essentially the current state class decides what actions to take in response to user interaction with the application. Thanks, Raymond Simmons - Original Message - From: Jiri Heitlager [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Tuesday, April 01, 2008 6:03 AM Subject: [Flashcoders] Some feedback on a coding design question Hello List, I am currently building an application that uses panels. The Panels implement a Composite Pattern. The panel holds instances of panelButtonSets class. The panel displays certain sets based on a selected item in the client code. Now my question is, how do I get around a lot of if statements in the panel like so: if(clientcode.selecteditem.type == 1){ panel.addSet(position_panel) panel.addSet(rotation_panel) panel.addSet(edit_panel) }else if(clientcode.selecteditem.type == 2){ //different sets of button sets } etc... One solution I am thinking about is the following, but I would like to get some feedback on this approach. BasicButtonSet() { addSets(new panelButtonSets(position_panel)) addSets(new panelButtonSets(rotation_panel)) } ColorButtonSet() extends BasicButtonSet { addSets(new panelButtonSets(color_panel)) addSets(new panelButtonSets(brightness_panel)) } var basicSet:ButtonSet = new BasicButtonSet(); var colorSet:ButtonSet = new ColorButtonSet(); Then the selected item holds a reference to a certain set that can be loaded into the panel. var set = selectItem.GetButtonSet(); Panel.loadSetObject(set ) { for every set in the parameter set, call its render method and place it at the right position }; The thing in this solution is that every set is allready instantiated and therefore is probably a quit expensive solution? Jiri ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Shared Fonts in Flash 7
What's the best approach for sharing a font in Flash 7? In Flash 6, I could place the font in a base movie and create text fields in loaded movies dynamically using the font in base. This doesn't appear to work in Flash 7. There were lots of problems using shared fonts in Flash 6. Branden Hall outlined these a long time ago: http://chattyfig.figleaf.com/pipermail/flashcoders/2002-August/045588.html. Have things changed? Do shared fonts work properly in Flash 7? Thanks, Raymond Simmons ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Creating dynamic text field using font embedded in parent movie clip
Adrian, Thanks for your reply. I'm afraid I might be missing something, but with the technique you described for Flash 7, wouldn't the end result be that the child FLAs are exported with the font as well? By adding the font symbols to the libraries of the child FLAs, that's causing the font to be included in the both the base SWF and the child SWFs, which would explain why the technique works :( Please help me see if I've missed something. My hope is to avoid embedding the font in the child FLAs. That way if the font changes, I only have to change it in one place. Also, if we have to work with a Mac-only font, it can be embedded in base.fla, and the folks working on PCs can still develop the child FLAs even though they don't have the font. Kind regards, Raymond Simmons - Original Message - From: Adrian Park [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Wednesday, July 26, 2006 12:55 AM Subject: Re: [Flashcoders] Creating dynamic text field using font embedded inparent movie clip I have successfully used this exact technique when targeting Flash 6 but, as I think about it, I haven't used it in any Flash 7 projects yet. That said, due to a quirk in the way a current project has evolved, it has ended up using this technique but with the addition of identical Symbols in the library of 'base.fla' and every child .fla. So, base.fla has 2 Font Symbols in the library for the Normal and Bold versions of the Font. 2 text fields exist on stage with the fonts embedded (we've assigned the Font name given to the Symbols to the text field, not the original font). The font symbols are then duplicated in each sub library but the text fields are not. This seems to be working with no problems. I'm doing a bit of optimisation at the moment and was considering using a Shared Font Library to tidy things up but you hav me worried now :) HTH Adrian On 7/26/06, Raymond Simmons [EMAIL PROTECTED] wrote: In Flash 6, I was able to embed a font in an FLA (we'll call it base.fla), load into base.swf an external SWF (we'll call it main.swf), and create a text field in main.swf using the font embedded in base.swf. However, I can't seem to get this approach to work in Flash 7. More specifically, in Flash 6, I can add a text field off stage in base.fla, and embed the font. Let's say the font is Proxima Nova Bold. In main.fla, I can create a text field using the Proxima Nova Bold font with the following code: createTextField(myText,1,0,0,100,25); var myStyle = new TextFormat(); myStyle.font = Proxima Nova Bold; myText.setNewTextFormat(myStyle); myText.embedFonts = true; myText.text = Hello World!; But if I export main.fla as Flash 7, the technique no longer works. Has anyone else used this approach successfully in Flash 6, and found that it does not work in Flash 7? Or is it possible I'm missing something. I would rather avoid the use of a shared font library, because I've heard they have the potential to corrupt FLAs. However, if anyone would like to convince me my fears are unfounded, I'm open to being convinced. Thanks, Raymond Simmons ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Creating dynamic text field using font embedded in parent movie clip
In Flash 6, I was able to embed a font in an FLA (we'll call it base.fla), load into base.swf an external SWF (we'll call it main.swf), and create a text field in main.swf using the font embedded in base.swf. However, I can't seem to get this approach to work in Flash 7. More specifically, in Flash 6, I can add a text field off stage in base.fla, and embed the font. Let's say the font is Proxima Nova Bold. In main.fla, I can create a text field using the Proxima Nova Bold font with the following code: createTextField(myText,1,0,0,100,25); var myStyle = new TextFormat(); myStyle.font = Proxima Nova Bold; myText.setNewTextFormat(myStyle); myText.embedFonts = true; myText.text = Hello World!; But if I export main.fla as Flash 7, the technique no longer works. Has anyone else used this approach successfully in Flash 6, and found that it does not work in Flash 7? Or is it possible I'm missing something. I would rather avoid the use of a shared font library, because I've heard they have the potential to corrupt FLAs. However, if anyone would like to convince me my fears are unfounded, I'm open to being convinced. Thanks, Raymond Simmons ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com