Home Tutorials Forums Articles Blogs Movies Library Employment Press

<< Prev 5 | Next 5

Check Bytes Loaded and Time Elapsed

// CREATOR     HELMUT GRANDA
// VERSION     1.0 (compatible with Flash MX)
// CREATED     30 OCTOBER 2002
// SUMMARY     Checks if you the movie has been loaded
//             And if the waiting time has expired.
//             TimeWaiting is the only Varialbe to Change
//             www.helmutgranda.com

var TimePassed = Int(getTimer() / 1000)
var TimeWaiting = 10
var TotalToLoad = _root.getBytesTotal();
var Loaded = _root.getBytesLoaded();
Trace (TimePassed);
function CheckTime(){
        if(TimePassed == TimeWaiting){
                Time = "passed";
        }
}
function CheckLoaded(){
        if(Loaded == TotalToLoad){
                Loading = "passed";
        }
}
CheckTime();
CheckLoaded();
if (Time == "passed" && Loading == "passed"){
        gotoAndPlay("loaded")
}else{
        gotoAndPlay("loading")
}

Posted by: HELMUT GRANDA | website http://www.helmutgranda.com
Class Prreloader
class Preloader{
	

/*
Class Preloader 10-09-07
vers 1.0
 { info }
 
 > requires MovieClip with 100 Frames;
 > TextField with instance name 'txt';(optional)
 
Setup your fla:
	Frame 1:
	loader
	Frame 2: 
	your content



usage: 

 var x:Object = new Preloader([clipname- with 100-frames],[textfieldname],[language(eng or de) is set on eng by default]);

*/

private var total:Number ;
private var loaded:Number ;

private var timeline:MovieClip;
private var clip:MovieClip;
private var display:MovieClip
private var txt:TextField;
private var proz:Number;
private var language:String;

// Constructor

function Preloader(d:MovieClip,t:TextField,l:String){
	
	if (d != undefined){
		display = d;
		}
	if (t != undefined){
		txt = t;
		}	
	if (l =="de") {
		language = "% geladen."
		}else{
		//by default eng
		language = "% loaded."
			}

	timeline = _level0; 
	display.gotoAndStop(1);
	proz = 0;
	timeline.stop();
	this.init ();
	
	}

	private	function init (){
		
	var t = timeline.createEmptyMovieClip("__oefGohst",timeline.getNextHighestDepth());
		total = timeline.getBytesTotal();
		loaded = timeline.getBytesLoadedl();
		
		var scope:Object = this 
		
		t.onEnterFrame =function(){
		
			scope.proz =Math.floor( scope.timeline.getBytesTotal()/scope.timeline.getBytesLoaded())*100;
			scope.display.gotoAndStop(scope.proz);
			scope.txt.text =scope.proz +scope.language
			
			if( scope.timeline.getBytesLoaded()  >=  scope.timeline.getBytesTotal() ){
					
				delete t.removeMovieClip(this);
				scope.timeline.nextFrame();
										
				
				}
	
			}
		
		
		}

}

Posted by: andihaas | website http://flash.andihaas.de
clean array
//clean array
// all strings wihtout ".pdf" become cleared
function cleanArray(arr) {
        var filename = ".pdf";
        var tmparr = [];
        var t
        for (var i in arr) {
                t = arr[i].indexOf(filename, 0);
                if (t == -1) {
                        tmparr.push(i);
                }
        }
        for (var i = 0; i<tmparr.length; i++) {
                arr.splice(tmparr[i], 1);
        }
        return (arr);
}
arr = ["test_0.pdf", "testbild.jpg", "testmovie.mov", "test2.pdf", "testfile.doc"];
trace(arr);
trace(cleanArray(arr));

Posted by: andihaas | website http://.flash.andihaas.de
clean Array V2
// cleans up an array
// only allowed suffixes rest in the array
function cleanArray(arr) {
        var filename = [".pdf", ".jpg"];
        var tmparr = [];
        for (var j = 0; j<filename.length; j++) {
                for (var i = 0; i<arr.length; i++) {
                        if (arr[i].indexOf(filename[j], 0) != -1) {
                                tmparr.push(arr[i]);
                        }
                }
        }
        return (tmparr);
}
var myArray = ["Mein.pdf", "Test.doc", "Super.jpg", "Dein.pdf"];
trace(cleanArray(myArray));

Posted by: andihaas | website http://flash.andihaas.de
Clip Timer/Pause timer
//timer
onClipEvent (load) {
        _root.stop();
        
        //fill in movie's frame rate here
        this.frameRate = 12;
        
        //frame rate multiply by seconds required
        this.pauseTime = (this.frameRate)*5;
        
        this.pauseCount = 0;
}
onClipEvent (enterFrame) {
        if (this.pauseCount>=this.pauseTime) {
                _root.gotoAndPlay(17);
        } else {
                this.pauseCount++;
        }
}

Posted by: Click Design | website http://www.clickdesign.com.au

<< Prev 5 | Next 5

Copyright 2000-2010 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.