

<< Prev 5 |
Next 5
AS 2.0 : Simpel Animation class
 |
 |
dynamic class Animate {
private var objRef:Object;
var addListener:Function;
private var parentObj:Object;
public function Animate(objRef:Object)
{
AsBroadcaster.initialize(this);
this.addListener(this);
if(objRef!=null)
{
this.objRef=objRef;
}
}
function fadeIn(toX:Number,toY:Number,alpha:Number,alphaSteps:Number,speed:Number,margin:Number):Void
{
var obj=this;
if(objRef!=null)
{
if(toX==null){
objRef.toX=objRef._x;
} else {
objRef.toX=toX;
}
if(toY==null){
objRef.toY=objRef._y;
} else {
objRef.toY=toY;
}
if(alpha!=null) objRef._alpha=alpha;
if(alphaSteps==null) alphaSteps=0;
objRef.alphaSteps=alphaSteps;
if(speed==null) speed=5;
objRef.speed=speed;
if(margin==null) margin=0.5;
objRef.margin=margin;
objRef.onEnterFrame=function()
{
this._x+=(this.toX - this._x) / this.speed;
this._y+=(this.toY - this._y) / this.speed;
this._alpha+=this.alphaSteps;
var diffX:Number=this.toX - this._x;
if(diffX<0)
{
diffX=diffX*-1;
}
var diffY:Number=this.toY - this._y;
if(diffY<0)
{
diffY=diffY*-1;
}
if( (diffX <= this.margin) && (diffY <= this.margin) )
{
this._x=toX;
this._y=toY;
if(this._alphaSteps!=0)
{
this._alpha=100;
}
delete this.toX;
delete this.toY;
delete this.alphaSteps;
delete this.speed;
delete this.margin;
delete this.onEnterFrame;
obj.doneAnimated();
}
}
} else {
var errorStr:String="No target object";
obj.error(errorStr);
}
}
public function setObj(objRef):Void
{
if(objRef!=null)
{
this.objRef=objRef;
}
}
private function error(msg:String)
{
this.broadcastMessage("onError",msg);
}
private function doneAnimated()
{
this.broadcastMessage("onDone",true);
delete this.onDone;
}
}
stop();
import Animate;
var myAnim:Animate=new Animate(this.myRectangle);
myAnim.onDone=function(p_success:Boolean)
{
trace("done");
}
myAnim.onError=function(msg:String)
{
trace(msg);
}
myAnim.fadeIn(400,300,0,5,5,0.5);
Posted by: Fransjo Leihitu | website
http://www.leihitu.nl
|
 |
 |
 |
AS3 LocalDebugger
 |
 |
package com.ericfeminella.debugger {
import flash.net.LocalConnection;
import flash.events.StatusEvent;
import flash.events.ErrorEvent;
import flash.events.AsyncErrorEvent;
import mx.controls.Alert;
public final class LocalDebugger {
public static function trace(obj:Object, useRecursion:Boolean = false):void
{
var connection:LocalConnection = new LocalConnection();
if (useRecursion)
{
LocalDebuggerTraceHelper.iterate(obj, useRecursion);
}
connection.send(LocalConnectionSettings.CONNECTION_NAME, LocalConnectionSettings.CONNECTION_METHOD, obj);
connection.addEventListener(StatusEvent.STATUS, onStatus);
connection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onASYNCFault);
}
public static function show(message:String):void
{
Alert.show(message);
}
private static function onStatus(event:StatusEvent):void
{
if (event.level == ErrorEvent.ERROR)
{
Alert.show(event.toString());
}
}
private static function onASYNCFault(asyncError:AsyncErrorEvent):void
{
Alert.show(asyncError.toString());
}
}
}
Posted by: Eric Feminella | website
http://www.ericfeminella.com
|
 |
 |
 |
Automatic scroller of dynamic text
 |
 |
//This script will scroll any size box of text w/ any size text, unless it is
//too small to scroll. When it reaches the end of the scroll length, it
//"bounces" back to the top after a delay, very easy...(i've only been doing
//this for 3 days, somewhat difficult for me) put the text in like the 1st frame
//or something like that...works great! (working on a complex "smooth" version)
//PS, works great with wordwrap on or off!!!
//START script
scrollerSolved = false
goBackwards = false
APause = setInterval(ScrollBaby, 750);
//calls a function called ScrollBaby every 500 hundreths of a second
//(or .5 second)
function ScrollBaby() {
if (goBackwards != true) {
_root.textInstance.scroll += 1;
}
if (goBackwards == true) {
_root.textInstance.scroll -= 1;
}
//the actual "moving" of the text
if (scrollerSolved != true) {
numberOfLinesExisting = _root.text.scroll;
numberOfLinesCounted += 1;
if (numberOfLinesExisting<=numberOfLinesCounted) {
numberOfLinesCounted = numberOfLinesExisting;
goBackwards = true;
scrollerSolved = true;
}
}
//my algorithm to get the length of the text in the field in lines
temp = _root.text.scroll;
if (temp == numberOfLinesCounted ) {
goBackwards = true;
setInterval(null, 2000) //bounce delay
}
if (1 == _root.text.scroll) {
goBackwards = false;
setInterval(null, 2000) //bounce delay
}
}
Posted by: Alex Songe | website
http:\\www.galileo.spaceports.com/~dths/
|
 |
 |
 |
basic scroll text
 |
 |
texto="Copia aquí el texto que deseas scrolear. Paste the text to scroll here"
up.onRelease = function() {
texto.scroll -= 1;
};
dwn.onRelease = function() {
texto.scroll += 1;
};
Posted by: aRiel | website
http://www.3x3interactive.com
|
 |
 |
 |
BenchMark
 |
 |
_global.BMark=new Object();
_global.BMark.start=function(ID){
if(this[ID].$start==null){ this[ID]={$start:getTimer()} }
};
_global.BMark.stop=function(ID){
this[ID].$final=getTimer();
this[ID].$elapsed=this[ID].$final - this[ID].$start;
if(this[ID].$elapsed<=59999) trace(this[ID].$elapsed/1000);
else trace(this[ID].$elapsed/1000/60);
delete this[ID];
};
Posted by: Red Penguin | website
http://www.komielan.com
|
 |
 |
 |
<< Prev 5 |
Next
5