No one?

On Fri, Dec 18, 2009 at 6:03 PM, Omar Fouad <[email protected]> wrote:

> Hi all,
>
> I've been working with ActionScript 3.0 since 2006 and I used some
> technique in the last two years. I believed that this way is the best for
> splitting code from design, but today I asked myself whether this approach
> is REALLY professional or not.
> What I do is a create a pure ActionScript project in Flex Builder 3, and I
> create a FLA file with, which has in its library a bunch of assets that I
> use as components or models, such as buttons, list items, image containers
> with masks and so on - then I give each of the "component" a linkage name.
>
> For example, If I need to create a button I just create a MovieClip (or
> Sprite) in my library that represents this simple button designed the way it
> should be, this MovieClip contains a TextField named "label" and it is
> dynamic. It also contains a MovieClip named "background", which is the bg of
> the button behind the label. Finally I give this button a linkage Identifier
> "BasicButton".
>
> After that I publish the FLA and I create a Class that represents this
> button:
>
>
> package {
>
>     import flash.display.Sprite;
>
>     [Embed(source='Lib.swf', symbol='BasicButton')]
>     public class BasicButton extends Sprite{ // and not MovieClip because
> it is based on one frame only
>
>                 // I declare the variables inside of it. They have to be
> public.
>                 public var label                :TextField;
>                 public var background      :Sprite;
>
> public function BasicButton(labelString:String) {
>
> label.text = labelString;
>  this.buttonMode = true;
> this.addEventListener(MouseEvent.ROLL_OVER, onOver);
>                         this.addEventListener(MouseEvent.ROLL_OUT, onOut);
> }
>
>                 private function onOver(e:MouseEvent):void {
>                         //changes the background color on roll over
>                 }
>                 private function onOut(e:MouseEvent):void {
>                        //resets the background color on roll out
>                 }
>
> }
> }
>
> Of course I can create an abstract button class that has all the roll over
> and roll out instructions in it, and just make BasicButton an extension of
> it, but whatever this is just an example.
>
> In the Main class:
>
> package {
>
>     import flash.display.Sprite;
>
>     public class Main extends Sprite{
>
>          private var myButton:BasicButton;
>
>         public function Main() {
>              myButton = new BasicButton("Click Me");
>              myButton.addEventListener(MouseEvent.CLICK, onClick);
>              addChild(myButton);
>         }
>         public function onClick(e:MouseEvent) {
>             trace("button clicked");
>
>         }
>
>
> }
>
> This works and all of course. And I can also embed the button inside of
> Main and give it a variable of type Class, but in this cases I needed to
> have it in a different Class to be able to give it more functions.
> This gives me flexibility when I need to make design tweaks to this button
> (or all the other assets), but I've found a problem, which is that I cannot
> make things encapsulated since the variables "label" and "background" inside
> of BasicButton HAVE to be public (if I declare them as private it won't
> compile). So in a way getters and setters have no use for such instances.
>
> How can I maintain encapsulation in this case? Or it's just this a good way
> to create flash content?
>
> Thank you
>
> Cordially.
>
>
> --
> Omar M. Fouad -
> http://omarfouad.net
> Cellular: (+20) 10 234.66.33
>
>
> This e-mail and any attachment is for authorised use by the intended
> recipient(s) only. It may contain proprietary material, confidential
> information and/or be subject to legal privilege. It should not be copied,
> disclosed to, retained or used by, any other party. If you are not an
> intended recipient then please promptly delete this e-mail and any
> attachment and all copies and inform the sender. Thank you.
>



-- 
Omar M. Fouad - Adobe™ Flash© Platform Developer
http://.omarfouad.net
Cellular: (+20) 1011.88.534 / (+20) 1444.37.175


This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender. Thank you.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to