[flexcoders] Re: importing packages

2008-05-29 Thread Amy
--- In flexcoders@yahoogroups.com, "Tim Hoff" <[EMAIL PROTECTED]> wrote:
>
> 
> Think of a package as a path.  You're mixing apples and oranges 
here a
> little.   First, the way that you have it coded, the name of the 
class
> file should be DPBSubclass.as; not preloaderOverride.as; since 
that's
> the class name.   Second, the statement import preloaderOverride.*; 
is
> saying import all classes in the src/preloaderOverride folder; not 
the
> src folder.
> 
> My preference would be to remove preloaderOverride from the package
> declaration, replace the DPBSubclass class and function names with
> CustomePreloader, and save the class file as CustomPreloader.as in 
the
> src folder.  At that point, (import CustomPreloader;) will work.

Also note that classes in the same package (folder) don't need to 
import other classes in the same folder.  They are 
considered "automatically" imported, since they are in the same 
package.  If all your as files are in the src directory, you don't 
need to import any of them.

HTH;


Amy



[flexcoders] Re: importing packages

2008-05-29 Thread Tim Hoff

Think of a package as a path.  You're mixing apples and oranges here a
little.   First, the way that you have it coded, the name of the class
file should be DPBSubclass.as; not preloaderOverride.as; since that's
the class name.   Second, the statement import preloaderOverride.*; is
saying import all classes in the src/preloaderOverride folder; not the
src folder.

My preference would be to remove preloaderOverride from the package
declaration, replace the DPBSubclass class and function names with
CustomePreloader, and save the class file as CustomPreloader.as in the
src folder.  At that point, (import CustomPreloader;) will work.

-TH

--- In flexcoders@yahoogroups.com, nihilism machine
<[EMAIL PROTECTED]> wrote:
>
> here is my package inside of my src directory named
> preloaderOverride.as:
>
>
> /* Custom Preloader */
> package preloaderOverride {
> import flash.events.Event;
> import flash.events.ProgressEvent;
> import flash.geom.Rectangle;
> import mx.preloaders.DownloadProgressBar;
>
> public class DPBSubclass extends DownloadProgressBar {
>
> public function DPBSubclass() {
> super();
> // Minimum display time after download
> MINIMUM_DISPLAY_TIME = 3000;
> // Set the default text during initialization
> // Progress
> initializingLabel = "Download Complete!\nInitializing...";
> }
>
> // Override label area to display custom text
> override protected function get labelRect():Rectangle {
> return new Rectangle(14, 5, 150, 30);
> }
>
> // Override download progress handler to display
> // Custom Text
> override protected function
> progressHandler(event:ProgressEvent):void {
> super.progressHandler(event);
> label = Math.round(event.bytesLoaded / 1000).toString()
> + "k of " + Math.round(event.bytesTotal / 1000).toString()
> + "k";
> }
>
> // Override to ensure display of progress bar during init and
> download
> override protected function
> showDisplayForDownloading(elapsedTime:int,
> event:ProgressEvent):Boolean {
> return true;
> }
> }
> }
>
> ///
>
> using import preloaderOverride.*; produces an error that it cannot
> be found. what am i doing wrong?
>