May 15, 2009

Class SoundSlider

Filed under: AS, usefull codes, AS2 — admin @ 8:16 pm

**
* vers 1.0
* @author bloba
*
* Requires:
* a MovieClip as registration and in that clip two further clips: on xpos/ypos: 0/0
*     base 100 x10 px
*     bar 10 x 10 px
*
*
* usage:
*
*
*     var mySound:Sound = new Sound();
mySound.loadSound(”my.mp3″,true);

var s:SoundSlider = new SoundSlider (controll_clip , mySound , 100);

*/

class utils.SoundSlider
{
private var 
loc:MovieClip;
private var 
drag:MovieClip;
private var 
base:MovieClip;

private static var maxVal:Number 100;
private static var 
minVal:Number 0;
private var 
aktVal:Number;

private var soundObj:Sound;

function SoundSlider(_clip:MovieClip,_snd:Sound,_startVolume )
{
aktVal _startVolume;

this.loc _clip;
this.soundObj _snd;
this.run ();
}

private function run():Void
{
trace (“new SoundSlider”);
this.loc.drag._x aktVal;
if (
this.loc.drag._x 90)
{
this.loc.drag._x 90}

this.loc.drag._y 0;
this.contolls();
this.calcVals(aktVal);// autostart;)
}

private function contolls ():Void
{
var 
scope:Object this;
this.loc.drag.onPress = function()
{
this.startDrag (falseminVal0maxVal this._width0);
scope.startWatcher();

}

this.loc.drag.onRelease =    this.loc.drag.onReleaseOutside= function()
{
this.stopDrag();
scope.stopWatcher();

}

this.loc.base.onPress = function ()
{
scope.loc.drag._x this._xmouse;
scope.calcVals(scope.loc.drag._x);

if (this._xmouse 90)
{
scope.loc.drag._x 90}
}
}

private function startWatcher():Void
{
var 
scope:Object this;
this.loc.drag.onEnterFrame = function()
{
scope.calcVals(this._x);

}
}

private function stopWatcher():Void
{
delete (this.loc.drag.onEnterFrame);

}

private function calcVals (_xpos:Number):Void
{
aktVal Math.floor(_xpos .9);
this.soundObj.setVolume(aktVal);
}

October 10, 2008

Email?

Filed under: AS, usefull codes, AS2 — admin @ 1:50 am

function validMail(_testValue:String):Boolean
{
var 
retValue:Boolean false;

if ((_testValue.indexOf(“@”) != -1) && (_testValue.indexOf(“.”) != -1) && (_testValue.indexOf(“@”)<_testValue.lastIndexOf(“.”))) {
retValue true;
}
return 
retValue;

}

var testMail1:String “email@domain.tld”;
var 
testMail2:String “email@domain  tld”;
trace(validMail(testMail1));
// traces true

trace(validMail(testMail2));
// traces false  

August 26, 2008

setMask

Filed under: AS, usefull codes — admin @ 5:20 am

class utils.Mask
{

private static var _class:Mask;
function 
Mask()
{}

public static function create(_loc:MovieClip_xpos:Number_ypos:Number_mwidth:Number_mheight:Number_masked:MovieClip ):Void
{
var 
clip:MovieClip _loc.createEmptyMovieClip(“___mask”_loc.getNextHighestDepth());
clip._x _xpos;
clip._y _ypos;

_masked.setMask(drawRectangle(clip_mwidth_mheight0×000000100));
}

private static function drawRectangle(_target_mc:MovieClipboxWidth:NumberboxHeight:NumberfillColor:NumberfillAlpha:Number):MovieClip
{
with (_target_mc)
{
beginFill(fillColorfillAlpha);
moveTo(00);
lineTo(boxWidth0);
lineTo(boxWidthboxHeight);
lineTo(0boxHeight);
lineTo(00);
endFill();
}
return 
_target_mc
}

August 13, 2008

Class Arrange

Filed under: AS2 — admin @ 6:20 pm

class Arrange
{

private var anzahl:Number;
private var
clips:Array;
private var
location:MovieClip;
private var
txtInfo:Array;

private var lineBreak:Number;
private var
startX:Number;

private var zeilenArr:Array;
private var
zeilenCount:Number;
private var
align:String;

function Arrange(){}

public function alignClips (_infoArr:Array,_align:String):Void
{
this.txtInfo = _infoArr;

this.location = _level0;
this.anzahl = _infoArr.length;
this.clips = new Array();

this.arrangeObjects(_align);
}

public function arrangeObjects (_align:String):Void
{

var xpos:Number = 0;
var
ypos:Number = 0;
var
abstX:Number = 10;
var
abstY:Number = 60;// je nach punktgösse

this.startX = 0;
this.lineBreak = 300//400;

this.zeilenCount = 0;
this.zeilenArr = new Array();

this.zeilenArr[this.zeilenCount] = new Array();
for (var
i = 0; i < this.anzahl; i++)
{
this.clips[i] = this.location.attachMovie(“txt_template”, “h” + i, i,{_alpha:100});
this.clips[i].txt.autoSize = true;
this.clips[i].txt.text = this.txtInfo[i];

this.clips[i]._x = xpos+startX;
xpos += this.clips[i]._width + abstX;

this.clips[i]._y = ypos+abstY;
this.zeilenArr[this.zeilenCount].push(this.clips[i]);

if (this.clips[i]._x+this.clips[i]._width > this.lineBreak)
{
xpos = 0;
ypos += abstY;
this.zeilenCount++;
this.zeilenArr[this.zeilenCount] = new Array();

}

}
switch (_align)
{
case
“center”:
this.alingCenter();
break;
case
“right”:
this.alingRight();
break;

}

}

private function alingCenter():Void
{
var
i:Number;
for (var
index:Number = 0; index < this.zeilenArr.length ; index++ )
{
if (
this.zeilenArr[index].length == 1)
{

this.zeilenArr[index][[0]]._x = Stage.width/2 - this.zeilenArr[index][[0]]._width / 2;

}else
{
var poses:Array = new Array ();
for (
i= 0; i < this.zeilenArr[index].length; i++ )
{
var
pos:Object = new Object();
pos.x = this.zeilenArr[index][[i]]._x;
pos._x = this.zeilenArr[index][[i]]._y;
poses.push(pos);
}

var lastIndex:Object = this.zeilenArr[index].length - 1;
var
gesamtdist:Number = (this.zeilenArr[index][[lastIndex]]._x + this.zeilenArr[index][[lastIndex]]._width) - this.zeilenArr[index][[0]]._x;
var
startXneu:Number = (Stage.width -gesamtdist )/2 ;

for ( i = 0; i < this.zeilenArr[index].length; i++)
{
this.zeilenArr[index][[i]]._x = poses[i].x+startXneu;
}
}
}
}

private function alingRight():Void
{
var
i:Number;
for (var
index:Number = 0; index < this.zeilenArr.length ; index++ )
{
if (
this.zeilenArr[index].length == 1)
{
this.zeilenArr[index][[0]]._x = Stage.width - this.zeilenArr[index][[0]]._width;

}else
{

var poses:Array = new Array ();
for (
i= 0; i < this.zeilenArr[index].length; i++ )
{
var
pos:Object = new Object();
pos.x = this.zeilenArr[index][[i]]._x;
pos._x = this.zeilenArr[index][[i]]._y;
poses.push(pos);
}

var lastIndex:Object = this.zeilenArr[index].length - 1;
var
gesamtdist:Number = (this.zeilenArr[index][[lastIndex]]._x + this.zeilenArr[index][[lastIndex]]._width) - this.zeilenArr[index][[0]]._x;

var startXneu:Number = (Stage.width -gesamtdist );

for ( i = 0; i < this.zeilenArr[index].length; i++)
{
this.zeilenArr[index][[i]]._x = poses[i].x+startXneu;
}
}
}
}

}

/ ihr müsst in der libary ein movieclip haben (idname:”txt_template”) mit einem einer textgfeld instanz namens “txt”

und so ruft ihr das ganze auf

var arr:Array = [“gaanz-langesWort ”,“hallo welt”“willkommen im FF;)”,“test”“sauber”,“nochmal-test”,“hallo”,“hehe”]
var 
= new Arrange();
a.alignClips(arr,“right”); 

February 22, 2008

Class MultiTween

Filed under: AS, AS2 — admin @ 2:59 am

/**
* Class MultiTween
* loops an motion permanently
* Usage:
* var mt = new MultiTween([anzahl],[clipname],[prop],[min],max)
* methods :
*
* startTween ,stopTween

*
* @author Bloba
* @version 0.1
*/

import mx.transitions.Tween;
import mx.transitions.easing.*;

class MultiTween {

private var anz:Number;
private var 
clipName:String;
private var 
tweenProp:String;
private var 
defaultMin:Number;
private var 
defaultMax:Number;

private var clipList:Array;
private var 
location:MovieClip;
private var 
tweenSpeed:Number;

function MultiTween(_anz:Number_clipName:String,_tweenProp_dMin_dMax)
{

this.anz _anz;
this.clipName _clipName;
this.tweenProp _tweenProp;
this.defaultMin _dMin
this
.defaultMax _dMax

this.location _level0;
this.clipList = new Array();
this.tweenSpeed 2;

this.startTween();

}

public function startTween ():Void
{
var 
i:Number 1;
var 
_sc:Object this;
for (; 
<=this.anzi++ )
{
this.clipList[i] =  new Tween(this.location[this.clipName+i], [this.tweenProp], Strong.easeOutthis.location[this.clipName+i][this.tweenProp], 180this.tweenSpeedtrue);
this.clipList[i].onMotionFinished = function()
{

if (this.sig == false )
{
this.sig true;
this.pos random(_sc.defaultMax) +_sc.defaultMin;

}else{

this.sig false;
this.pos _sc.defaultMin;
};

this.continueTo(this.posthis.tweenSpeed);

}
}

}

public function stopTween ():Void
{
var 
i:Number 1;
for (; 
<=this.anzi++ )
{
this.clipList[i].stop()
}

}

February 8, 2008

deeplink

Filed under: AS, usefull codes — admin @ 11:46 pm

/* Deeplink AS1

Class deeplink [Requires ”index.php” with embeddvar : showId]
USAGE
var d = new Deeplink(showId);
// read
d.getId();
// write
d.setId([NUMBER]));

*/
deeplink = function (n)
{
var 
id Number(n);
this.init(n);
this.init = function(n)
{
if (!
this.checkUp()) {
id 0;
}
};
this.checkUp = function()
{
var 
ret false;
if (!
isNaN(id)) {
ret true;
}
return 
ret;
};
this.setId = function(val)
{
getURL(“index.php?showId=” val);
};
this.getId = function()
{
return 
id;
};
};

Filed under: AS — admin @ 11:46 pm

Class Deeplink (PHP)

Filed under: AS, usefull codes, AS2 — admin @ 10:24 pm

/*
<.php

# init value
$showId 0;

# define allowed values for ’showId’

# check check…
if (isset ($_GET[’showId’])) {
$showId $_GET[’showId’];
}

?>
< H T M L >
< H E A D >

< T I T L E>xx< / T I T L E >
< / H E A D >
< B O D Y bgcolor="#FFFFFF">

< O B J E C T classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="500" HEIGHT="38" ALIGN="">
echo($showId); ?>“ />

echo ($showId); ?>“ quality=”best”  WIDTH=”500″ HEIGHT=”38″ NAME=”urlvar” ALIGN=”" TYPE=”application/x-shockwave-flash” PLUGINSPAGE=”http://www.macromedia.com/go/getflashplayer”>
< / O B J E C T >

< / B O  D Y >
< /  H T M L >
*/

Class Deeplink

Filed under: AS, usefull codes, AS2 — admin @ 9:59 pm

*
* …
* @author bloba
* @version 0.1
*
Class Deeplink [Requires ”index.php” with embeddvar : showId]
USAGE
var d = new Deeplink(showId);
// read
d.getId();
// write
d.setId([NUMBER]));

*/

//     Construktor

class Deeplink {

public var id :Number

function Deeplink (s:String)
{
this.init(s);

}

//     Private Functions

private function init(n:String) :Void
{
this.id  Number (n);

if (!this.checkUp()) {    this.id 0;}

}

private function checkUp():Boolean
{
var 
ret :Boolean false;

if (!isNaN(this.id)) { ret true; }

return ret;
}

//     Public Functions

public function setId(value:Number):Void
{
getURL(“index.php?showId=” value);

}

public function getId():Number
{
return 
this.id;

}
}

January 23, 2008

Class Simplenavi

Filed under: usefull codes, AS2 — admin @ 2:37 am

/*
* class Simplenavi v0.1  @ bloba
* www.flash.andihaas.de
*
*
* IMPORTANT readParameter is ’id’
*
* USAGE
* var x:Simplenavi = new Simplenavi(4, ”btn”, test, this);
function test()
{
trace(”-test-” + this.id);
}

*
*
*
*
* */

class Simplenavi {

private var anz        :    Number;
private var 
fnc        :    Function;
private var 
location :     MovieClip;
private var 
btnName :     String;

function Simplenavi (_anz :Number ,_btnName :String,_fnc :Function,_location :MovieClip) {

this.anz _anz;
this.btnName _btnName;
this.fnc _fnc;

if (_location == undefined)
{
this.location _level0;
}else {

this.location  _location;

}

this.init();

}
function init():Void
{

for (var i:Number 1anzi++ ) {

this.location[this.btnName i].id i;
this.location[this.btnName i].onPress fnc;

}

}

Next Page »

Powered by WordPress