Hmm, well that pokes a hole in that plan.  If I have to create a 
bunch of different files it kinda is contrary to my goal of combining 
things into one main generic library :(

--- In flexcoders@yahoogroups.com, "Geoffrey Williams" <[EMAIL PROTECTED]> 
wrote:
>
> You can only have one public function / class / prop per .as file. 
Also, the
> .as files name must match that of the function / class / prop.
> 
> -----Original Message-----
> From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
> Behalf Of Greg Johnson
> Sent: Tuesday, November 01, 2005 9:43 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Flex 2:Package/Class problem
> 
> I am tryinig to create a class with functions that I use repeatedly 
> so I can just include them in different components/applications.  
As 
> far as I can tell I have written it correctly, but when I use an 
> include, and they try calling one of the functions, it doesn't work.
> 
> Here is the package
> package mrstd{
>       // Imported Libraries
>       import mx.managers.PopUpManager;
>       import mx.containers.TitleWindow;
>       import mx.controls.gridclasses.DataGridColumn;
>       import mx.managers.DragManager;
>       import mx.events.DragEvent;
>       import mx.formatters.*
>       import flash.util.Timer;
> 
>       // Standard Library Class
>       public class stdlib {
>               // Does what it says, used when a function has to be 
> called, but you don't actually want to do anything
>               public function doNothing():Void {}             
> 
>               // Get Today's Date as a string
>               public function getToday():String {
>                       var today_date:Date = new Date();
>                       var date_str:String = ((today_date.getMonth()
> +1)+"/"+today_date.getDate()+"/"+today_date.getFullYear());
>                       return date_str;
>               }
>       }
>       
>       // Mouse Related Functions
>       public class mouseHandlers {
>               // Handles drag and drop events.
>               public function doDragDrop(event:DragEvent):Void {
>                       private var items:Array = 
> event.dragSource.dataForFormat("items");
>                       private var dest:Object = event.currentTarget;
>                       private var dropLoc:int = dest.getDropLocation
> ();
>                       dest.hideDropFeedback(event);
>                       items.reverse();
>                       var l:int = items.length;
>                       for(var i:int = 0; i < l; i++) {
>                               dest.dataProvider.addItemAt(items[i], 
> dropLoc);
>                       }
>                       event.preventDefault();
>               }               
> 
>               // Variables used for detectDoubleClick function
>               private var lastClick:int = 0;
>               private var lastObject:Object = new Object();;
>               private var lastIndex:int = 0;
>               private var maxTicks:int = 300;
> 
>               // Detect if a double click was made and if so, call 
> a function
>               public function detectDoubleClick(event:Object, 
> functionToCall:Function, ... args):Void {
>                       var currentClick:int;
>                       var currentObject:Object;
>                       var currentIndex:int;
>                       var clickDif:int;
>                       currentClick = getTimer();
>                       currentObject = event.target;
>                       currentIndex = event.index;
>                       clickDif = currentClick - lastClick;    
>                       if( clickDif <= maxTicks && currentObject == 
> lastObject && currentIndex == lastIndex ) {
>                               lastClick = currentClick;
>                               lastObject = currentObject;
>                               lastIndex = currentIndex;
>                               if (args[0] == null) {
>                                       functionToCall();
>                               } else {
>                                       functionToCall(args);
>                               }
>                       }
>                       lastClick = currentClick;
>                       lastObject = currentObject;
>                       lastIndex = currentIndex;
>               }
>       }
>       
>       // Standard Formaters
>       public class formaters {
>               private var StdMoneyFormat:CurrencyFormatter = new 
> CurrencyFormatter();
>               private var StdDateFormat:DateFormatter = new 
> DateFormatter();
>               StdMoneyFormat.precision=2;
>               // Formats a dataGrid cell as money
>               public function formatMoney(dpItem:Object, 
> dgColumn:DataGridColumn):String {
>                       return StdMoneyFormat.format(dpItem
> [dgColumn.columnName]);
>               }
> 
>               // Formats a dataGrid cell as a date            
>               public function formatDate(dpItem:Object, 
> dgColumn:DataGridColumn):String {
>                       return StdDateFormat.format(dpItem
> [dgColumn.columnName]);
>               }
> 
>               // Formats a dataGrid cell as a string that is x 
> characters long followed by an elipse
>               public function shortString(dpItem:Object, 
> dgColumn:DataGridColumn, x:Number):String {
>                       var tmpString:String;
>                       tmpString = dpItem[dgColumn.columnName];
>                       if (tmpString.length > x) {
>                               tmpString = tmpString.substr(0,x);
>                               tmpString = tmpString.concat('...');
>                       }
>                       return tmpString;
>               }
>       }
> 
>       // General Error Window Handlers        
>       public class errHandlers {
>               // CFC Error Handler Function
>               public function cfcerr(cfcName:String, 
> functionName:String, faultCode:String, faultString:String, 
> description:String, details:String):Void {
>                       var cfcErrPopUp:cfcError = cfcError
> (PopUpManager.createPopUp(this, cfcError, true));
>                       cfcErrPopUp.cfcName.text = cfcName;
>                       cfcErrPopUp.functionName.text = functionName;
>                       cfcErrPopUp.faultCode.text = faultCode;
>                       cfcErrPopUp.faultString.htmlText = 
> faultString;
>                       cfcErrPopUp.description.htmlText = 
> description;
>                       cfcErrPopUp.detail.htmlText = details;
>               }
> 
>               // Error Handler Function
>               public function err(message:String, 
> source:String):Void {
>                       var errpop:stdErr = stdErr
> (PopUpManager.createPopUp(this, stdErr, true));
>                       errpop.source.text = source;
>                       errpop.message.text = message;
>               }
>       }
> }
> 
> In the .as file I put
> 
> import mrstd.errHandlers.err;
> 
> and then down in the script I make a call to the err function
> 
> err("sometext","sometitle");
> 
> But I get an error at that line saying "Access of undefined 
property 
> err"
> 
> 
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%
40yahoogroups.com 
> Yahoo! Groups Links
>









------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to