[> ScrollReel Actionscript 3.0 Component <]
Category : [> Coding <]
This is a little Actionscript 3.0 CustomComponent i build for Rehearsal
its Opensource. This is how you add it on Stage :> Feel free to extend the Scroll Up/Down Behaviour <
>> Get it here :ScrollReel
package
{
/**
* @author matuser
*/
import flash.display.MovieClip;
import flash.events.*;
import caurina.transitions.*;
import fl.data.DataProvider;
import mat3d.yugopReel.ScrollReel;
import mat3d.yugopReel.model.events.*;
import mat3d.textarea.Area;
import nl.demonsters.debugger.MonsterDebugger;
public class YugopReelSW extends MovieClip
{
private var debugger:MonsterDebugger;
public var curTxt : String = new String();
public var xt:ScrollReel;
public var xxt:Area;
public function YugopReelSW()
{
debugger = new MonsterDebugger(this);
build();
}
public function build()
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
xt = new mat3d.yugopReel.ScrollReel();
xt.name = "myScrollReel";
xt.Width = 2772;
xt.Height = 362;
xt.x = -924;
xt.y = 0;
xt.buttonHeight = 362;
xt.buttonWidth = 924;
xt.AutoScroll = false;
xt.ScrollInit = "_x";
xt.StepControl = false;
xt.StepBehaviour = "easeInOutQuart";
xt.ScrollTime = 1.2;
xt.FileType = "XML";
xt.File = "inhaltone.xml";
xt.addEventListener(ScrollReelEvent.ON_START, doStart);
xt.alpha = 0;
addChild(xt);
/*
xxt = new mat3d.textarea.Area();
xxt.name = "myArea";
xxt.Width = 632;
xxt.Height = 150;
xxt.x = 420;
xxt.y = 150;
xxt.alpha = 100;
xxt.FileType = "XML";
xxt.File = "menuconfig.xml";
xxt.addEventListener("onInit", initialize);
xxt.addEventListener("onLink", linkId);
addChild(xxt);
*/
setChildIndex(LeftBtn, numChildren - 1);
setChildIndex(RightBtn, numChildren - 1);
LeftBtn.addEventListener(MouseEvent.CLICK, doClick);
RightBtn.addEventListener(MouseEvent.CLICK, doClick);
LeftBtn.addEventListener(MouseEvent.ROLL_OVER, doRollOver);
RightBtn.addEventListener(MouseEvent.ROLL_OVER, doRollOver);
LeftBtn.addEventListener(MouseEvent.ROLL_OUT, doRollOut);
RightBtn.addEventListener(MouseEvent.ROLL_OUT, doRollOut);
jumpbtn1.addEventListener(MouseEvent.CLICK, jump1);
jumpbtn2.addEventListener(MouseEvent.CLICK, jump2);
}
public function jump1(me :MouseEvent):void
{
xt.Jump("1");
}
public function jump2(me:MouseEvent):void
{
xt.Jump("4");
}
public function mouseMove(me : MouseEvent):void
{
//trace("MouseMove" + me.stageX + ">>" + me.stageY);
if (me.stageX < -50 || me.stageX > 964 || me.stageY < 0 || me.stageY > 362)
{
xt.myModel.VIEW.isOver = false;
//trace(">>>outside");
}
else
{
xt.myModel.VIEW.isOver = true;
//trace(">>>inside");
}
}
public function doClick(me : MouseEvent):void
{
switch (me.target.name)
{
case "LeftBtn" :
//trace("LeftClick");
if (xt.myModel.VIEW.ismoving == true)
{
}
else
{
xt.MoveRight();
}
break;
case "RightBtn" :
//trace("RightClick");
if (xt.myModel.VIEW.ismoving == true)
{
}
else
{
xt.MoveLeft();
}
break;
}
}
public function doRollOver(me : MouseEvent):void
{
switch (me.target.name)
{
case "LeftBtn" :
//xt.myModel.VIEW.isOver = true;
break;
case "RightBtn" :
//xt.myModel.VIEW.isOver = true;
break;
}
}
public function doRollOut(me : MouseEvent):void
{
switch (me.target.name)
{
case "LeftBtn" :
//xt.myModel.VIEW.isOver = false;
break;
case "RightBtn" :
//xt.myModel.VIEW.isOver = false;
break;
}
}
public function doStart($r : ScrollReelEvent)
{
//trace("DO STRAT >>" + $r.params.param2);
//curTxt = $r.params.param2;
Tweener.addTween(xxt, {alpha:0, time:0.4, transition:"easeInOutQuart", delay:0, onComplete:txtAlp});
}
public function txtAlp()
{
//trace(">>>txtAlphacallback<<<"+curTxt);
//xxt.setText(curTxt);
Tweener.addTween(xxt, {alpha:1, time:0.3, transition:"easeInOutQuart", delay:0.8});
}
public function doTestCase($e : ScrollReelEvent)
{
switch ($e.type)
{
case "onClicked" :
trace("TYPE: " + $e.type);
break;
case "onMoved" :
trace("TYPE: " + $e.type);
break;
case "onStart" :
trace("TYPE: " + $e.type + ">>>" + $e.params.param2);
break;
}
//trace("TYPE: " + $e.type + "\nTARGET: " + $e.target + "\nFIRST CUSTOM PARAM: " + $e.params.param1 + "\nSECOND CUSTOM PARAM: " + $e.params.param2);
}
public function initialize(e : Event)
{
}
public function linkId(e : Event)
{
}
public function sronClicked(e : Event)
{
trace(">>>" + e.target);
}
}
}