SO, it’s been a while since I’ve done actionscript 3 again, been mostly busy with iOS programming..
Anyway, what I’m trying to create is a sliding panels.
So far they work but I’m having some troubles, And everything I try does not do what I want hehe.
The panels work, I generate 5 of them in a for loop, they slide open and close when clicked using greensock.
But, They all have a label, which needs to slide with it instead of staying on the same position.
Plus, I have a if/else to check if a panel is open, but I want to check this individually instead of overall.
The full code is:
import com.greensock.TweenLite;
import flash.geom.ColorTransform;
import flash.text.engine.TabStop;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
// Define shizz
var _tabs:mainTab;
var stageW = 950;
var stageH = 550;
var isOpen:Boolean = false;
function init() {
trace("initialize");
var colorArr:Array = [0x00b2c1, 0xdf007a, 0xf39b24, 0xeb690b, 0xa1c438, 0xd5d931];
var titleArr:Array = ["papier", "kunststof", "glas", "hout", "metaal", "batterijen"];
for (var i:Number = 0; i < 6; i++) {
_tabs = new mainTab();
_tabs.x = 91+_tabs.width*i;
_tabs.y = -160;
_tabs.slide_mc.title_mc.text = titleArr[i];
_tabs.slide_mc.title_mc.mouseEnabled = false;
var newColor:ColorTransform = _tabs.slide_mc.box_mc.transform.colorTransform;
newColor.color = colorArr[i];
_tabs.slide_mc.box_mc.transform.colorTransform = newColor;
_tabs.slide_mc.box_mc.addEventListener(MouseEvent.CLICK, doSomething);
this.addChild(_tabs);
}
}
function doSomething(e:Event):void {
var clickMC = e.target;
if (isOpen) {
trace("is Open");
var dropTab:TweenLite = new TweenLite(clickMC, 0.5, {y: -8});
dropTab.play();
isOpen = !isOpen;
} else {
trace("is Closed, Text is:");
var dropTab2:TweenLite = new TweenLite(clickMC, 0.5, {y: 177});
dropTab2.play();
isOpen = !isOpen;
}
}
init();
Here is the file.
So what Do I need help with?
– How do I get the title’s in the sliding panels to animate with the panel itself.
– a way to check if the current clicked panel is open or not (check individually).
thanks in advance!
looks like
_tabs.slide_mc.title_mc.text = titleArr[i];causes that text is draged with slider. You need to inserttitle_mcto other clip