Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-15-2007, 10:10 PM   #1
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default Extending a basic framework for specific needs.

Do you guys see anything wrong with this? Or more importantly, is it a correct OO implementation?

Basic frame work to be extended for specific needs:
ActionScript Code:
package com.as.ui {         public class Window extends Sprite     {         // define in subclass         protected var _title:TextField;         protected var _mainTxt:TextField;         protected var _mask:Sprite;         protected var _txtContainer:Sprite;         protected var _handle:Sprite;         protected var _guide:Sprite;         protected var _close:SimpleButton;         protected var _drag:SimpleButton;                 // used in this class         protected var _scrollbar:CustomScrollBar = new CustomScrollBar();         protected var _starts:Dictionary = new Dictionary();                         public function set title(v:String):void { _title.htmlText = v; }         public function set mainTxt(v:String):void         {             _mainTxt.condenseWhite = true;             _mainTxt.htmlText = v;             _mainTxt.autoSize = TextFieldAutoSize.LEFT;                         _txtContainer.y = _starts[_txtContainer];             if (_handle != null)             {                 _handle.y = _starts[_handle];                 _scrollbar.showGear();             }                     }                 public function Window()         {             //         }                 protected function init():void         {             // set up basic scene and properties needed             _txtContainer.mask = _mask;             _starts[_handle] = _handle.y;             _starts[_txtContainer] = _txtContainer.y;                         // configure scene             _title.mouseEnabled = false;             if (_close != null) _close.addEventListener(MouseEvent.CLICK, closeClick);             if (_drag != null)             {                 _drag.useHandCursor = false;                 _drag.addEventListener(MouseEvent.MOUSE_DOWN, dragPress);                 _drag.addEventListener(MouseEvent.MOUSE_UP, dragRelease);             }                                     // set up scrolling             if (_handle != null) _scrollbar.assets(_txtContainer, _mask, _handle);             if (_guide != null) _scrollbar.addGuide(_guide);         }                 protected function closeClick(e:MouseEvent):void         {             this.visible = false;         }                 protected function dragPress(e:MouseEvent):void         {             this.startDrag(false);             this.stage.addEventListener(MouseEvent.MOUSE_UP, dragRelease);         }                 protected function dragRelease(e:MouseEvent):void          {             this.stopDrag();             this.stage.removeEventListener(MouseEvent.MOUSE_UP, dragRelease);         }     } }
The specific implementation:
ActionScript Code:
package template.ui {     import com.as.ui.Window;         public class Window extends com.as.ui.Window     {                 public function Window()         {             _title = title_txt;             _mainTxt = content_mc.main_txt;             _mask = mask_mc;             _txtContainer = content_mc;             _handle = handle_mc;             _guide = guide_mc;             _close = close_btn;             _drag = drag_btn                         init();         }     } }

I have a lot of site that want a window. However, each site wants its own window. I think by extending a basic window, I'm allowing for more flexibility and customization.

Am I breaking an OO principles here?

P.S. I'm doing the same thing for a lot of other components as well. So while this question is rather basic, it applies to my whole framework of sites.
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 09-16-2007, 07:38 AM   #2
Assertnfailure
as[org].addListener(this)
 
Assertnfailure's Avatar
 
Join Date: Dec 2005
Location: LA, California
Posts: 837
Default

I hate using _ prefix for variables in any namespace besides private. It just looks kind of dirty to me when it's something that is exposed outside of your class.

Additionally, properties like title probably don't have to be listed as protected at all, because you've got a public setter for it.

You're not breaking principles, though. You're using abstract base classes that act as templates to your custom window subclasses.
Assertnfailure is offline   Reply With Quote
Old 09-17-2007, 12:13 AM   #3
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

Great! Thanks for the suggestions too.

I was a little concerned because I'm using a lot of inheritance. Some of them get pretty deep:
Info2 -> Info1 -> BasicInfo -> BasicModule ->IModule

I appreciate your input. I would have built the whole thing unsure.

__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash MX or any other VER. Basic Skills??? Jose Antonio Other Flash General Questions 2 04-10-2007 08:56 AM
Effects Framework praufet ActionScript 3.0 5 02-13-2007 04:49 PM
basic PHP prob ?? vosgien Server-Side Scripting 11 08-14-2004 03:23 AM
Extending Color Stimpson ActionScript 2.0 4 01-24-2004 12:31 PM
A few really basic questions about Flash MX Denaes Components 1 12-08-2003 03:25 AM


All times are GMT. The time now is 03:42 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.