I wrote this from scratch & you can probably tell. Its terribly coded, but i was just wondering if there was a better way to do it, basically it tweens in a box, displays text, and x’s out of it when you click on the X
and example is here
http://splitheartimages.com/addchild%20tests.swf
I have like 34 of these to display, so i don’t want to write like 10 lines of code for each one. I was looking into writing my own classes, maybe somebody could help me make this more efficiant or point me into a good custom classes tutorial that would fit my needs. Thanks alot
Heres the code
import gs.TweenMax;
stop()
var dptimer1:Timer = new Timer(1000, 1);
dptimer1.addEventListener(TimerEvent.TIMER, dptxt1);
var dptimer2:Timer = new Timer(1000, 1);
dptimer2.addEventListener(TimerEvent.TIMER, dptxt2);
var dptimer3:Timer = new Timer(1000, 1);
dptimer3.addEventListener(TimerEvent.TIMER, dptxt3);
function dptxt1(event:TimerEvent):void
{
addChild(text1)
text1.x = 100
text1.y = 25
text1.alpha = 1
}
function dptxt2(event:TimerEvent):void
{
addChild(text2)
text2.x = 100
text2.y = 25
text2.alpha = 1
}
function dptxt3(event:TimerEvent):void
{
addChild(text3)
text3.x = 100
text3.y = 25
text3.alpha = 1
}
var dpBox:box = new box();
var text1:tf1 = new tf1();
var text2:tf2 = new tf2();
var text3:tf3 = new tf3();
var mc_x:x1 = new x1();
text1.alpha = 0
text2.alpha =0
text3.alpha = 0
mc_s.buttonMode = true;
mc_h.buttonMode = true;
mc_d.buttonMode = true;
mc_x.addEventListener(MouseEvent.CLICK, exit)
function exit(event:MouseEvent):void
{
removeChild(mc_x)
removeChild(dpBox)
dptimer1.stop()
dptimer2.stop()
dptimer3.stop()
{
if(text1.alpha == 1)
{
text1.parent.removeChild(text1)
text1.alpha = 0
text2.alpha =0
text3.alpha = 0
}
if(text2.alpha == 1)
{
text2.parent.removeChild(text2)
text1.alpha = 0
text2.alpha =0
text3.alpha = 0
}
if(text3.alpha == 1)
{
text3.parent.removeChild(text3)
text1.alpha = 0
text2.alpha =0
text3.alpha = 0
}
}
}
mc_s.addEventListener(MouseEvent.CLICK, displays)
mc_h.addEventListener(MouseEvent.CLICK, displayh)
mc_d.addEventListener(MouseEvent.CLICK, displayd)
function displays(event:MouseEvent):void
{
addChild(mc_x)
mc_x.x = 500
mc_x.y = 40
dptimer1.start();
addChild(dpBox)
TweenMax.allTo([dpBox], 0,{x:250,y:170, height:20, width:20});
TweenMax.allTo([dpBox], 1,{height:300,width:300});
}
function displayh(event:MouseEvent):void
{
addChild(mc_x)
mc_x.x = 500
mc_x.y = 40
dptimer2.start();
addChild(dpBox)
TweenMax.allTo([dpBox], 0,{x:250,y:170, height:20, width:20});
TweenMax.allTo([dpBox], 1,{height:300,width:300});
}
function displayd(event:MouseEvent):void
{
addChild(mc_x)
mc_x.x = 500
mc_x.y = 40
dptimer3.start();
addChild(dpBox)
TweenMax.allTo([dpBox], 0,{x:250,y:170, height:20, width:20});
TweenMax.allTo([dpBox], 1,{height:300,width:300});
}
Any help is much apreciated