[ascoders] AW: Re: MovieClip wird nicht richtig erkannt???

  • From: "Peter Oliver Geller" <nc-gellerpe@xxxxxxxxxxxxx>
  • To: <ascoders@xxxxxxxxxxxxx>
  • Date: Wed, 27 Aug 2003 16:29:24 +0200

Hi Arne,

Also der komplette Player liegt in einem MovieClip auf der
Hauptzeitleiste seines Levels

innerhalb des MC´s auf Keyframe 1 Script Nummer 1

pfeil_ani.stop(); // Stopt eine Animation für den Player
// definiert Text innerhalb von Buttons (in diesem Fall den String
1,2,3,4) 
for(i=1;i<=4;i++){
        this["track"+i+"_btn"].textfeld.text = i;
        if(i>1){
                this["track"+i+"_btn"].textfeld._x -= 1;
        }
}

Und Keyframe Nummer 2  
(bitte entschuldigt meinen Englisch/Deutsch misch masch aber ich habe
dieses Script für mich geschrieben) 

//
========================================================================
==========================
// Textformatierung der Zeitdarstellung
//
========================================================================
==========================

format_timer = new TextFormat();
format_timer.align = "right";

titel_txt.autoSize = true;

//
========================================================================
==========================
// Funktionen
//
========================================================================
==========================


sliderAktive = function(){
        music.stopNow();
        
startDrag(this,false,ladebalken_mc._x,area_mc.y,ladebalken_mc._x+ladebal
ken_mc._width-5,area_mc.y) 
        // Shows Time when Slider moves
        this.onEnterFrame = sTP;

}

sliderInAktive = function(){
        stopDrag();
        delete this.onEnterFrame;
        music.playNow(sliderTimePosition);
}

// Gibt die Zeitposition anhand der x Position des Sliders an das
Zeittextfeld aus
sTP = function(){
                sliderTimePosition = slPosInTime();
                sliderRealtimePosition = sliderTimePosition * 1000;
                zeit_txt.text =  music.getTime(sliderRealtimePosition)
add " of " add music.getTime(music.duration);
}



// Gibt die Zeit anhand der Position des Sliders aus
slPosInTime = function(){
        var trackduration = Math.floor(music.duration/1000);
        var steps = trackduration / (area_mc._width -
slider_btn._width);
        var posInTime = Math.floor((slider_btn._x - area_mc.x) * steps);
        return posInTime;
}

//
========================================================================
==========================
/* Sound Methoden 
 *
 * Sound.playNow()
 * Sound.stopNow()
 * Sound.nextTrack()
 * Sound.moveSlider()
 * Sound.getTime()
 * Sound.setTime()
 * Sound.checkLoadProgress()
 * Sound.clearLoadCheck()
 * Sound.preloadSound()
//
========================================================================
==========================
/*
 * Method: Sound.playNow()
 *   Desc: Spielt den Sound wieder ab an der Stelle wo er gestoppt oder
eingestellt wurde 
 */
Sound.prototype.playNow = function(value){
        play_btn.enabled = false;
        stop_btn.enabled = true;
        pfeil_ani.play();
        this.start(value);
        this.ID_1 = setInterval(this,"setTime",100);
        this.ID_2 = setInterval(this,"moveSlider",1000);
}
/*
 * Method: Sound.stopNow()
 *   Desc: Stoppt den Bewegungsinterval für die Zeitanzeige und den
Schieberegler 
 */
Sound.prototype.stopNow = function(){
        stop_btn.enabled = false;
        play_btn.enabled = true;
        pfeil_ani.stop();
        clearInterval(this.ID_1);
        clearInterval(this.ID_2);
        this.stop();
}

Sound.prototype.nextTrack = function(){
        // Wähle den nächsten Track an
}
/*
 * Method: Sound.moveSlider()
 *   Desc: Errechnet Dauer und aktuelle Position des Stücks, um die
Bewegung der
 *             gezielten Schrittweite des Schiebereglers zu ermitteln
und setze diese
 */
Sound.prototype.moveSlider = function(){
        var trackduration = Math.floor(music.duration/1000);
        var trackposition = Math.floor(music.position/1000);
        var steps = (area_mc._width - slider_btn._width) /
trackduration;
        var areamaxpos = area_mc.x + area_mc._width;
        var slidermopos = slider_btn._x+slider_btn._width;
        
        if (areamaxpos >= slidermopos) {slider_btn._x = slider_btn.x +
(steps * trackposition)}
        else{slider_btn._x = areamaxpos-slider_btn._width}
        
        
}
/*
 * Method: Sound.setTime()
 *   Desc: Der Text der Zeitanzeige wird richtig Ausgerichtet und
Dargestellt 
 */
Sound.prototype.setTime = function(){
        zeit_txt.text = this.getTime(this.position) add " of " add
this.getTime(this.duration);
        zeitdauer_txt.setTextFormat(format_timer);
        zeitablauf_txt.setTextFormat(format_timer);
}
/*
 * Method: Sound.getTime()
 *   Desc: Bekommt eine Zeit in Millisekunden und errechnet daraus den
Minuten und Sekundenwert.
 *                 Dieser Wert wird dann ordentlich geschrieben zur¸ck
gegeben.
 */
Sound.prototype.getTime = function (time){
  var realsecs = Math.floor(time/1000);
  var realmin = Math.floor(realsecs/60);
  var secs = realsecs >= 60 ? realsecs - (realmin * 60) : realsecs;
  var secs = secs < 10 ? "0" add secs : secs;
  var min = realmin;
  var time = min add ":" add secs add " min";
  return time;
}
/*
 * Method: Sound.checkLoadProgress()
 *   Desc: Checks progress of a load(). Called only by preload().
 *         Reports progress by invoking a custom Sound.onBytesLoaded()
handler.
 */
Sound.prototype.checkLoadProgress = function(){
        // Check how many KB have loaded.
        var kbLoaded = Math.floor(this.getBytesLoaded()/1024);
        // Check the size of the file loading, in KB.
        var kbTotal = Math.floor(this.getBytesTotal()/1024);
        // Calculate the percent complete.
        var percentDone = isNaN(Math.floor(kbLoaded/kbTotal * 100)) ? 0
: Math.floor(kbLoaded/kbTotal * 100)
        // Execute onBytesLoaded(), which typically would display load
progress.
        this.onBytesLoaded(this.getBytesLoaded(), this.getBytesTotal(),
kbLoaded, kbTotal, percentDone);
        if (this.getBytesLoaded() > 5 && this.getBytesLoaded() ==
this.getBytesTotal()){
                //...stop calling the checkLoadProgress().
                this.clearLoadCheck();
}
}
/*
 * Method: Sound.clearLoadCheck()
 *   Desc: Cancels an interval calling checkLoadProgress
 */
Sound.prototype.clearLoadCheck = function(){
         // If there is a load interval for this Sound object...
         if (this.loaderID) {
                 //...stop calling it
                 clearInterval(this.loaderID);
        }
 }
 /*
 * Method: Sound.preloadSound()
 *   Desc: Begins the download of a sound file and executes
 *         checkLoadProgress() every 200 ms until the file has loaded.
 */
Sound.prototype.preloadSound = function(url, isStreaming){
        pfeil_ani.play();
        slider_btn._x = area_mc._x;
        // Prüfungsvaribale im Loader für zur Zeit fehlerhafte
Ladefunktion (Soundabspielen bei 0)
        _global.check = 3;
        // Always stop any prevoius preload before proceeding.
        this.clearLoadCheck();
        
        // Load the Sound file
        this.loadSound(url, isStreaming);

        // Call checkLoadProgress() every 200 milliseconds.
        this.loaderID = setInterval(this, "checkLoadProgress", 200);
}

//
========================================================================
==========================
// MovieClip Methoden 
//
========================================================================
==========================
/*
 * Method: MovieClip.getStage()
 *   Desc: Checkt die Koordinaten und Maße von sich selbst und schreibt
Sie in sich.  
 */
MovieClip.prototype.getStage = function(){
        this.width = this._width;
        this.height = this._height;
        this.x = this._x;
        this.y = this._y;
        this.left = this._x;
        this.right = this._x + this.width;
        this.halfwidth = this.width/2;
}


//
========================================================================
==========================
// Button definitionen 
//
========================================================================
==========================
stop_btn.onRelease = function(){music.stopNow()};
play_btn.onRelease =
function(){sTP();music.playNow(sliderTimePosition)};

slider_btn.onPress = sliderAktive
slider_btn.onRelease = sliderInAktive;
slider_btn.onReleaseOutside = sliderInAktive;

dreh_knopf_btn.onPress = rotateMC; // Ist momentan als Führungsebene
definiert, vielleicht liegt es ja daran???

track1_btn.onRelease = function(){
        music.preloadSound(music.trackpath+music.songs[0][0],true);
        titel_txt.text = music.songs[0][1];
        }
track2_btn.onRelease = function(){
        music.preloadSound(music.trackpath+music.songs[1][0],true);
        titel_txt.text = music.songs[1][1];
        }
track3_btn.onRelease = function(){
        music.preloadSound(music.trackpath+music.songs[2][0],true);
        titel_txt.text = music.songs[2][1];
        }
track4_btn.onRelease = function(){
        music.preloadSound(music.trackpath+music.songs[3][0],true);
        titel_txt.text = music.songs[3][1];
        }

//
========================================================================
==========================
// Code Ausfuehren 
//
========================================================================
==========================

// Check Stagesize for preloadbar and timeslider
area_mc.getStage();
slider_btn.getStage();

// Create a Sound object 
music = new Sound();
// Erstelle Musikliste
var song1 = ["mr_cool.mp3","MR COOL"];
var song2 = ["reason_why.mp3","REASON WHY"];
var song3 = ["the_world_inside.mp3","THE WORLD INSIDE"];
var song4 = ["my_chasing_mind.mp3","MY CHASING MIND"];
music.songs = new Array(song1,song2,song3,song4)


// Erstelle http:// Pfad
music.trackpath = "http://www.sweetwilliam.de/tracks/";;

// Wenn die Musik geladen ist...?
music.onLoad = function(success){
        // If the load was successful...
        if (success) {
                slider_btn._x = sliderbtn.x;
                if (_global.ladeStatusWarAktiv == false){
                        clearInterval(this.ID_1);
                        clearInterval(this.ID_2);
                        this.playNow();
                }
        }else{
        // otherwise, perform failure operations and cancel the preload
interval
        }
}

// Wenn der Track fertig ist
music.onSoundComplete = function(){
        // Naechster Track
        this.nextTrack();
}

// Laedt die Musik und zeigt den Status im Preloader an
music.onBytesLoaded = function(bytesLoaded, bytesTotal, kbLoaded,
kbTotal, percentLoaded){
        textfield.text = "Lade "+ kbLoaded + "Kb von " + kbTotal + " Kb
des Musiktitels";
        ladebalken_mc._width = Math.floor(percentLoaded *
(area_mc.width/100));
        _global.check -= 1;
        if(_global.check >= -10){
                _global.ladestatusWarAktiv = false;
        }else{_global.ladestatusWarAktiv = true;}
}

// Track laden
        music.preloadSound(music.trackpath+music.songs[0][0],true);
        titel_txt.text = music.songs[0][1];
        music.playNow()
stop();


So sieht es bisher aus, noch nicht optimiert aber eigentlich
funktioniert es schon ganz nett,
momentan fuckt es mich aber ab das ich den MovieClip in dem der Player
nun sitzt nicht ansprechen kann.

Nun ja , danke erstmal

Peter

  

-----Ursprüngliche Nachricht-----
Von: ascoders-bounce@xxxxxxxxxxxxx
[mailto:ascoders-bounce@xxxxxxxxxxxxx] Im Auftrag von Arne Oberländer
Gesendet: Mittwoch, 27. August 2003 11:13
An: ascoders@xxxxxxxxxxxxx
Betreff: [ascoders] Re: MovieClip wird nicht richtig erkannt???


MovieClip wird nicht richtig erkannt???Hi Peter,

klingt nach enem Scope - Problem, aber da kann man etwaige Tippfehler
und so Zeug ohne Code nicht mitjagen.

Gruß
_____
Arne


----- Original Message -----
From: Peter Oliver Geller
To: ascoders@xxxxxxxxxxxxx
Sent: Tuesday, August 26, 2003 8:28 PM
Subject: [ascoders] MovieClip wird nicht richtig erkannt???


Hi Liste,
ich habe einen MP3 Player gebastelt der auch wunderbar funktioniert,
allerdings habe ich festgestellt das ich den Player nachdem ich ihn in
einen MovieClip umfunktioniert habe nicht mehr ansprechen kann. Von
Flash selber wird diser auch nur als Instance erkannt, obwohl es ein
MovieClip ist. Was könnte denn da wieder passiert sein :-? Gruß Peter
::::::::::::::::::::::::::::::::::::::::::::::
Peter Oliver Geller
(design / development)
In den Räumen der Agentur
VMS Schäfer GmbH
Mozartstr. 7   50674 Köln
(0221) 92 44 8 31 telefon
(0221) 92 44 8 51 telefax
www.pixel-gallery.net
info@xxxxxxxxxxxxxxxxx
::::::::::::::::::::::::::::::::::::::::::::::

------------------------------------------------------
Archiv   : //www.freelists.org/archives/ascoders/
Optionen : //www.freelists.org/list/ascoders
------------------------------------------------------

------------------------------------------------------
Archiv   : //www.freelists.org/archives/ascoders/
Optionen : //www.freelists.org/list/ascoders
------------------------------------------------------

Other related posts:

  • » [ascoders] AW: Re: MovieClip wird nicht richtig erkannt???