marshalldean
April 18th, 2008, 04:42 PM
So here is what I am doing.
You click a navigation button on the screen
(artclassNav, eventsNav, exhibitionNav, museumNav)
A box slides onto the screen (infoBox) and the appropriate text fades in
(artclassTxt, eventsTxt, exhibitionTxt, museumTxt)
On the infoBox is a close button (closeNav) which when clicked makes the text and the infoBox go bye bye.
My problem:
closeNav works correctly the first time and maybe the third, but eventually it becomes seemingly random if the text will pop up... infoBox slides in, but text may or may not appear.
Here is my code for the closeNav as of now
infoBox.closeBox.addEventListener(MouseEvent.CLICK , close_CLICK);
function close_CLICK(e:MouseEvent):void
{
Tweener.addTween(infoBox, {x: infoBox.x - 1000, time:1, transition:"easOutBack"});
Tweener.addTween(artclassTxt, {_autoAlpha:0, time:1, transition:"easeOut"});
Tweener.addTween(eventTxt, {_autoAlpha:0, time:1, transition:"easeOut"});
Tweener.addTween(exhibitionTxt, {_autoAlpha:0, time:1, transition:"easeOut"});
Tweener.addTween(museumTxt, {_autoAlpha:0, time:1, transition:"easeOut"});
}
I have tried a few different ways of using removeChild and using if statements... but I'm new to coding, lowly print designer I am. But I'm trying... Please help!
marshalldean
April 18th, 2008, 04:53 PM
Here is the whole section of code if it helps.
// imports tweener functions
import caurina.transitions.*;
// name the objects here
var museumMC:MuseumMC = new MuseumMC();
var infoBox:InfoBox = new InfoBox();
var exhibitionNav:ExhibitionNav = new ExhibitionNav();
var artclassNav:ArtclassNav = new ArtclassNav();
var eventsNav:EventsNav = new EventsNav();
var museumNav:MuseumNav = new MuseumNav();
var artclassTxt:TextField = new TextField();
var eventTxt:TextField = new TextField();
var exhibitionTxt:TextField = new TextField();
var museumTxt:TextField = new TextField();
// adds objects to the stage
addChild(exhibitionNav);
addChild(artclassNav);
addChild(eventsNav);
addChild(museumNav);
addChild(infoBox);
addChild(museumMC);
// places objects at their starting point
museumMC.x = - 1000;
museumMC.y = stage.stageHeight * 0.2;
exhibitionNav.x = - 1000;
exhibitionNav.y = 165;
artclassNav.x = - 1000;
artclassNav.y = exhibitionNav.y + 25;
eventsNav.x = - 1000;
eventsNav.y = artclassNav.y + 25;
museumNav.x = - 1000;
museumNav.y = eventsNav.y + 25;
infoBox.x = - 1000;
infoBox.y = stage.stageHeight * 0.05;
// text fields
artclassTxt.htmlText = "yadda yadda";
artclassTxt.autoSize = TextFieldAutoSize.LEFT;
artclassTxt.multiline = true;
artclassTxt.wordWrap = true;
artclassTxt.textColor = 0xFFFFFF;
artclassTxt.width = 300;
artclassTxt.y = 80;
artclassTxt.x = infoBox.width - (30 + artclassTxt.width);
eventTxt.htmlText = "yadda yadda";
eventTxt.autoSize = TextFieldAutoSize.LEFT;
eventTxt.multiline = true;
eventTxt.wordWrap = true;
eventTxt.textColor = 0xFFFFFF;
eventTxt.width = 300;
eventTxt.y = 80;
eventTxt.x = infoBox.width - (30 + eventTxt.width);
exhibitionTxt.htmlText = "yadda yadda";
exhibitionTxt.autoSize = TextFieldAutoSize.LEFT;
exhibitionTxt.multiline = true;
exhibitionTxt.wordWrap = true;
exhibitionTxt.textColor = 0xFFFFFF;
exhibitionTxt.width = 300;
exhibitionTxt.y = 80;
exhibitionTxt.x = infoBox.width - (30 + artclassTxt.width);
museumTxt.htmlText = "yadda yadda";
museumTxt.autoSize = TextFieldAutoSize.LEFT;
museumTxt.multiline = true;
museumTxt.wordWrap = true;
museumTxt.textColor = 0xFFFFFF;
museumTxt.width = 300;
museumTxt.y = 80;
museumTxt.x = infoBox.width - (30 + artclassTxt.width);
// tween functions
Tweener.addTween(museumMC, {x: 0, delay: .5, time:2, transition:"easeOut"});
Tweener.addTween(exhibitionNav, {x: 650, delay: 1, time: 2, transition:"easOut"});
Tweener.addTween(artclassNav, {x: 643, delay: 1.5, time: 2, transition:"easout"});
Tweener.addTween(eventsNav, {x: 677, delay: 2, time: 2, transition:"easout"});
Tweener.addTween(museumNav, {x:641, delay: 2.5, time: 2, transition:"easout"});
// rollover functions
artclassNav.buttonMode = true;
eventsNav.buttonMode = true;
exhibitionNav.buttonMode = true;
museumNav.buttonMode = true;
infoBox.closeBox.buttonMode = true;
artclassNav.addEventListener(MouseEvent.ROLL_OVER, artclassNav_ROLLOVER);
artclassNav.addEventListener(MouseEvent.ROLL_OUT, artclassNav_ROLLOUT);
function artclassNav_ROLLOVER(e:MouseEvent):void
{
Tweener.addTween(artclassNav, {x: 623, time:2, transition:"easOutBack"});
}
function artclassNav_ROLLOUT(e:MouseEvent):void
{
Tweener.addTween(artclassNav, {x: 643, time:2, transition:"easOutBack"});
}
exhibitionNav.addEventListener(MouseEvent.ROLL_OVE R, exhibitionNav_ROLLOVER);
exhibitionNav.addEventListener(MouseEvent.ROLL_OUT , exhibitionNav_ROLLOUT);
function exhibitionNav_ROLLOVER(e:MouseEvent):void
{
Tweener.addTween(exhibitionNav, {x: 630, time:2, transition:"easOutBack"});
}
function exhibitionNav_ROLLOUT(e:MouseEvent):void
{
Tweener.addTween(exhibitionNav, {x: 650, time:2, transition:"easOutBack"});
}
museumNav.addEventListener(MouseEvent.ROLL_OVER, museumNav_ROLLOVER);
museumNav.addEventListener(MouseEvent.ROLL_OUT, museumNav_ROLLOUT);
function museumNav_ROLLOVER(e:MouseEvent):void
{
Tweener.addTween(museumNav, {x: 621, time:2, transition:"easOutBack"});
}
function museumNav_ROLLOUT(e:MouseEvent):void
{
Tweener.addTween(museumNav, {x: 641, time:2, transition:"easOutBack"});
}
eventsNav.addEventListener(MouseEvent.ROLL_OVER, eventsNav_ROLLOVER);
eventsNav.addEventListener(MouseEvent.ROLL_OUT, eventsNav_ROLLOUT);
function eventsNav_ROLLOVER(e:MouseEvent):void
{
Tweener.addTween(eventsNav, {x: 657, time:2, transition:"easOutBack"});
}
function eventsNav_ROLLOUT(e:MouseEvent):void
{
Tweener.addTween(eventsNav, {x: 677, time:2, transition:"easOutBack"});
}
// click functions
artclassNav.addEventListener(MouseEvent.CLICK, artclassNav_CLICK);
function artclassNav_CLICK(e:MouseEvent):void
{
artclassTxt.visible = true;
Tweener.addTween(artclassTxt, {_blur_blurY: 5, _blur_blurX:5, alpha:0});
Tweener.addTween(infoBox, {x: -10, time:2, transition:"easeOut"});
Tweener.addTween(artclassTxt, {_blur_blurY: 0, _blur_blurX: 0, alpha: 1, time: 1, transition: "easeOut", delay:2});
addChild(artclassTxt);
}
exhibitionNav.addEventListener(MouseEvent.CLICK, exhibitionNav_CLICK);
function exhibitionNav_CLICK(e:MouseEvent):void
{
exhibitionTxt.visible = true;
Tweener.addTween(exhibitionTxt, {_blur_blurY: 5, _blur_blurX:5, alpha:0});
Tweener.addTween(infoBox, {x: -10, time:2, transition:"easeOut"});
Tweener.addTween(exhibitionTxt, {_blur_blurY: 0, _blur_blurX: 0, alpha: 1, time: 1, transition: "easeOut", delay:2});
addChild(exhibitionTxt);
}
museumNav.addEventListener(MouseEvent.CLICK, museumNav_CLICK);
function museumNav_CLICK(e:MouseEvent):void
{
museumTxt.visible = true;
Tweener.addTween(museumTxt, {_blur_blurY: 5, _blur_blurX:5, alpha:0});
Tweener.addTween(infoBox, {x: -10, time:2, transition:"easeOut"});
Tweener.addTween(museumTxt, {_blur_blurY: 0, _blur_blurX: 0, alpha: 1, time: 1, transition: "easeOut", delay:2});
addChild(museumTxt);
}
eventsNav.addEventListener(MouseEvent.CLICK, eventsNav_CLICK);
function eventsNav_CLICK(e:MouseEvent):void
{
eventTxt.visible = true;
Tweener.addTween(eventTxt, {_blur_blurY: 5, _blur_blurX:5, alpha:0});
Tweener.addTween(infoBox, {x: -10, time:2, transition:"easeOut"});
Tweener.addTween(eventTxt, {_blur_blurY: 0, _blur_blurX: 0, alpha: 1, time: 1, transition: "easeOut", delay:2});
addChild(eventTxt);
}
infoBox.closeBox.addEventListener(MouseEvent.CLICK , close_CLICK);
function close_CLICK(e:MouseEvent):void
{
Tweener.addTween(infoBox, {x: infoBox.x - 1000, time:1, transition:"easOutBack"});
Tweener.addTween(artclassTxt, {_autoAlpha:0, time:1, transition:"easeOut"});
Tweener.addTween(eventTxt, {_autoAlpha:0, time:1, transition:"easeOut"});
Tweener.addTween(exhibitionTxt, {_autoAlpha:0, time:1, transition:"easeOut"});
Tweener.addTween(museumTxt, {_autoAlpha:0, time:1, transition:"easeOut"});
}
Pardon my dorky notes, im a noob.
nikefido
April 19th, 2008, 11:25 AM
i think im going to suggest you look up the Caurina transitions package (the Caurina tweener would help you out immensely here I think)
http://code.google.com/p/tweener/
marshalldean
April 19th, 2008, 01:00 PM
I am using Caurina. Is there something in Caurina I am missing that would do the trick here?
marshalldean
April 21st, 2008, 12:42 PM
sorry to do this but... bump.
still having trouble :(
marshalldean
April 22nd, 2008, 08:59 AM
double bump?
after looking closer i notice that when i hit my close button, the text appears for a second... like it is going through the exit animation, but it comes in randomly. weird.
kattkieru
April 22nd, 2008, 02:45 PM
If I had to guess your tweens are fighting with each other, or keeping a reference to the object incorrectly. I'd try removing tweens before the X button close function takes over, certainly before using removeChild.
Dunno what to say if that doesn't work, though, as I haven't used the Caurina ones in a while.
trilec
April 23rd, 2008, 07:07 AM
If I had to guess your tweens are fighting with each other, or keeping a reference to the object incorrectly. I'd try removing tweens before the X button close function takes over, certainly before using removeChild.
you could perhaps try a slightly different approach to the way you initialize and carry out at each step.
Wrapping each process in a function which would also include your initialization stages as well, this means as a tween has finished it carries out a function call upon its completion tweenlite has this, but an example would be something like this
eg:
Tweener.addTween(infoBox, {x: infoBox.x - 1000, time:1, transition:"easOutBack",onComplete:"close_TweenFinished" } );
function close_TweenFinished():void
{
removechildren(...) or whatever
...
}
Another example
// tween functions
function setupTweens():void
{
Tweener.addTween(museumMC, {x: 0, delay: .5, time:2, transition:"easeOut"});
Tweener.addTween(exhibitionNav, {x: 650, delay: 1, time: 2, transition:"easOut"});
Tweener.addTween(artclassNav, {x: 643, delay: 1.5, time: 2, transition:"easout"});
Tweener.addTween(eventsNav, {x: 677, delay: 2, time: 2, transition:"easout"});
Tweener.addTween(museumNav, {x:641, delay: 2.5, time: 2, transition:"easout",onComplete:"setupTweensComplete"});
}
// tween functions
function setupTweensComplete():void
{
//onto next initialization or Tween setup
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.