Zurück   Flashforum > Flash > Stuff

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 24-12-2006, 14:28   #1 (permalink)
class public{}
 
Benutzerbild von public
 
Registriert seit: Feb 2004
Ort: dessau
Beiträge: 1.406
[STUFF] Weihnachstgeschenk für euch...LoadBar Komponente

wie es der title schon sagt....
Zitat:
LoadBar Class [scripted by public (Sebastian Vogt)]

Komponentenparameter: [Parmeter, Propertie, Default Value]
- Color = color = #CCCCCC
- Depth = depth = 100
- Duration = duration = 40
- Easing = easing = true
- Height = height = 10
- Info Text = infoText = "Loading..."
- Width = width = 200

Properties:
- path:String
- target:MovieClip
- color:Number
- width:Number
- height:Number
- infoText:String
- easing:Boolean
- duration:Number
- x:Number
- y:Number
- depth:Number
- isloading:Boolean <--- only read

Methodes:
- init():LoadBar
- update():LoadBar
- load(target:MovieClip,path:String):LoadBar
- getPercentLoaded():Number
- move(x:Number,y:Number,center:Boolean):LoadBar
- centerToStage():LoadBar

Events:
- onLoadStart
- onLoadProgress
- onLoadFinish
class:
PHP-Code:
/*
LoadBar Class [scripted by public (Sebastian Vogt)]

Komponentenparameter: [Parmeter, Propertie, Default Value]
    - Color = color = #CCCCCC
    - Depth = depth = 100
    - Duration = duration = 40
    - Easing = easing = true
    - Height = height = 10
    - Info Text = infoText = "Loading..."
    - Width = width = 200

Properties:
    - path:String
    - target:MovieClip
    - color:Number
    - width:Number
    - height:Number
    - infoText:String
    - easing:Boolean
    - duration:Number
    - x:Number
    - y:Number
    - depth:Number
    - isloading:Boolean <--- only read
    
Methodes:
    - init():LoadBar
    - update():LoadBar
    - load(target:MovieClip,path:String):LoadBar
    - getPercentLoaded():Number
    - move(x:Number,y:Number,center:Boolean):LoadBar
    - centerToStage():LoadBar

Events:
    - onLoadStart
    - onLoadProgress
    - onLoadFinish
    
*/
import mx.transitions.Tween;
import mx.transitions.easing.*;
class 
LoadBar extends MovieClip {
    
//
    // PRIVATE
    //
    
private var __path:String;
    private var 
__target:MovieClip;
    private var 
__x:Number;
    private var 
__y:Number;
    private var 
__isLoading:Boolean false;
    
//
    // EVENTS
    //
    
public var onLoadStart:Function;
    public var 
onLoadProgress:Function;
    public var 
onLoadFinish:Function;
    
//
    // BROADCASTER
    //
    
private var broadcastMessage:Function;
    private var 
addListener:Function;
    private var 
removeListener:Function;
    
//
    // KOMPONENTENPARAMETER
    //
    // Color
    
[Inspectable(name="Color",type=Color,defaultValue=0xCCCCCC)]
     private var 
__color:Number;
    
// Width
    
[Inspectable(name="Width",defaultValue=200)]
     private var 
__width:Number;
    
// Height
    
[Inspectable(name="Height",defaultValue=10)]
     private var 
__height:Number;
    
// Text
    
[Inspectable(name="Info Text",defaultValue="Loading...")]
     private var 
__infoText:String;
    
// Easing
    
[Inspectable(name="Easing",defaultValue=true)]
     private var 
__easing:Boolean;
    
// Duration
    
[Inspectable(name="Duration",defaultValue=40)]
     private var 
__duration:Number;
    
// Depth
    
[Inspectable(name="Depth",defaultValue=100)]
     private var 
__depth:Number;
    
//
    //GETTER/SETTER
    //
    // path
    
function set path (value:String):Void {
        
this.__path value;
    }
    function 
get path ():String {
        return 
this.__path;
    }
    
// target
    
function set target (value:MovieClip):Void {
        
this.__target value;
    }
    function 
get target ():MovieClip {
        return 
this.__target;
    }
    
// color
    
function set color (value:Number):Void {
        
this.__color value;
    }
    function 
get color ():Number {
        return 
this.__color;
    }
    
// width
    
function set width (value:Number):Void {
        
this.__width value;
    }
    function 
get width ():Number {
        return 
this.__width;
    }
    
// height
    
function set height (value:Number):Void {
        
this.__height value;
    }
    function 
get height ():Number {
        return 
this.__height;
    }
    
// text
    
function set infoText (value:String):Void {
        
this.__infoText value;
    }
    function 
get infoText ():String {
        return 
this.__infoText;
    }
    
// easing
    
function set easing (value:Boolean):Void {
        
this.__easing value;
    }
    function 
get easing ():Boolean {
        return 
this.__easing;
    }
    
// duration
    
function set duration (value:Number):Void {
        
this.__duration value;
    }
    function 
get duration ():Number {
        return 
this.__duration;
    }
    
// x
    
function set x (value:Number):Void {
        
this.__x value;
    }
    function 
get x ():Number {
        return 
this.__x;
    }
    
// y
    
function set y (value:Number):Void {
        
this.__y value;
    }
    function 
get y ():Number {
        return 
this.__y;
    }
    
// depth
    
function set depth (value:Number):Void {
        
this.swapDepths (value);
        
this.__depth value;
    }
    function 
get depth ():Number {
        return 
this.__depth;
    }
    
// isLoading
    
function get isLoading ():Boolean {
        return 
this.__isLoading;
    }
    
//
    // KONSTRUKTOR
    //
    
function LoadBar () {
        
AsBroadcaster.initialize (this);
        
this.addListener (this);
        
this._visible false;
        
this.__x this._x;
        
this.__y this._y;
    }
    
//
    // init():Void
    //
    
function init ():LoadBar {
        
this._visible false;
        var 
ref:Object this;
        
//
        
ref.progress_mc._width 0;
        
ref.progress_mc._height this.__height;
        
ref.frame_mc._width this.__width;
        
ref.frame_mc._height this.__height;
        
//
        
this.setColor (ref.progress_mcthis.__color);
        
this.setColor (ref.frame_mcthis.__color);
        
// TextField and TextFormat
        // TextFormat
        
var tf:TextFormat = new TextFormat ();
        
tf.color this.__color;
        
// TextField
        
ref.info_txt.autoSize true;
        
ref.info_txt.text this.__infoText;
        
ref.info_txt.setTextFormat (tf);
        return 
this;
    }
    
//
    // update():Void
    //
    
function update ():LoadBar {
        
this.init ();
        return 
this;
    }
    
//
    // load():Void
    //
    
function load (t:MovieClipp:String):LoadBar {
        
this.removeListener();
        if (
this.__easing) {
            
easeType Strong.easeOut;
        } else {
            
easeType None.easeNone;
            
this.__duration 1;
        }
        
this.__target t;
        
this.__path p;
        
this._visible true;
        var 
ref:Object this;
        var 
mcl:MovieClipLoader = new MovieClipLoader ();
        var 
mclObj:Object = {};
        var 
easeType:Function;
        var 
tween:Tween;
        
mclObj.onLoadStart = function () {
            
ref.broadcastMessage ("onLoadStart");
            
ref.__target._visible false;
            
ref.progress_mc._width 0;
        };
        
mclObj.onLoadProgress = function () {
            
ref.broadcastMessage ("onLoadProgress");
            
ref.__isLoading true;
            
tween = new Tween (ref.progress_mc"_width"Strong.easeOutref.progress_mc._widthref.getPercentLoaded () / 100 ref.__widthref.__durationfalse);
            
tween.onMotionChanged = function () {
            };
        };
        
mclObj.onLoadComplete = function () {
        };
        
mclObj.onLoadInit = function () {
            
tween.onMotionFinished = function () {
                
ref._visible false;
                
ref.__isLoading false;
                
ref.broadcastMessage ("onLoadFinish");
                
ref.__target._visible true;
                
ref.progress_mc._width=0;
            };
        };
        
mcl.addListener (mclObj);
        
mcl.loadClip (this.__paththis.__target);
        return 
this;
    }
    
//
    // getPercentLoaded():Number
    //
    
function getPercentLoaded ():Number {
        return 
this.__target.getBytesLoaded () / this.__target.getBytesTotal () * 100;
    }
    
//
    // move (x:Number, y:Number, center:Boolean):LoadBar
    //
    
function move (x:Numbery:Numbercenter:Boolean):LoadBar {
        
center center == undefined false center;
        if (!
center) {
            
this._x x;
            
this._y y;
            
this.__x this._x;
            
this.__y this._y;
            return 
this;
        } else {
            
this.move (this._width 2this._height 2);
            return 
this;
        }
    }
    
//
    // centerToStage ():LoadBar
    //
    
function centerToStage ():LoadBar {
        
this.move ((Stage.width 2) - (this.__width 2), (Stage.height 2) - (this.__height 2));
        return 
this;
    }
    
//
    // setColor(mc:MovieClip,color:Number):Void
    //
    
private function setColor (mc:MovieClipcolor:Number):Void {
        var 
c:Color = new Color (mc);
        
c.setRGB (color);
    }

example:
PHP-Code:
function alphaTo (target:MovieClipalpha:Numberduration:Number):Void {
    new 
mx.transitions.Tween (target"_alpha"mx.transitions.easing.Strong.easeOut0alphadurationfalse);
}
var 
con:MovieClip this.createEmptyMovieClip ("__container_mc"10);
loader.init ();
loader.centerToStage ();
loader.load (con"pics/01.jpg");
loader.onLoadStart = function () {
    
trace ("onLoadStart");
    
con._alpha 0;
};
var 
o:Object = {};
o.click = function (e:Object) {
    if (
e.target.label=="Picture 1") {
        
loader.load (con"pics/01.jpg");
    }
    if (
e.target.label=="Picture 2") {
        
loader.load (con"pics/02.jpg");
    }
    if (
e.target.label=="Picture 3") {
        
loader.load (con"pics/03.jpg");
    }
};
pic1_btn.addEventListener ("click"o);
pic2_btn.addEventListener ("click"o);
pic3_btn.addEventListener ("click"o);
loader.onLoadFinish = function () {
    
trace ("onLoadFinish");
    
alphaTo (con10080);
}; 
angucken
saugen

Geändert von public (24-12-2006 um 14:51 Uhr)
public ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 18:43 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele