• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

setting up variables

Explorer ,
Jan 10, 2013 Jan 10, 2013

Copy link to clipboard

Copied

I have a section in the timeline based website I'm making with Ationscript 3 in Flash CS5.  I want a square with some content in it to slide into frame when a button it pushed but if another button is pushed I want it to slide back out of frame before the content corresponding with the other button enters.  I've seen this done before but I can't remember how.  I think it had something to do with setting up a specific variable but that's about it and it's pretty vague.  haha.

Can anybody help with that or even just point be towards a tutorial or something because I think this is done fairly frequently.

Thanks.

TOPICS
ActionScript

Views

930

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 10, 2013 Jan 10, 2013

Copy link to clipboard

Copied

it's easiest to do that sort of thing using actionscript.  it can be done with the timeline, but it's easier if you use actionscript to tween

can you use actionscript to tween objects (using the Tween class or a 3rd party tweening class like TweenLite)?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 16, 2013 Jan 16, 2013

Copy link to clipboard

Copied

My background is in animation so I usually prefer to work visually if I can as appose to using script, so I no I can't use actionscript to tween objects, lol.  I'm not apposed to learning though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2013 Jan 16, 2013

Copy link to clipboard

Copied

if you're going to use the timeline for that you're pretty much limited to using gotoAndPlay in your button listeners:

btn.addEventListener(MouseEvent.CLICK,btnClickF);

function btnClickF(e:MouseEvent):void{

gotoAndPlay("some frame label");

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 22, 2013 Jan 22, 2013

Copy link to clipboard

Copied

Okay...I think I can handle that...here's something that migth be easier.  I wanna do a similar thing but instead of the object sliding in and out of frame it want it to fade on and off.  I do use the fade in/fade out a movie clip feature from the code snippets fairly often.  But I'm having trouble having it fade out before going to another point on the timeline.  I feel like this should just be an additional line of code to function properly am I right?  And if so what would that line of code be?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2013 Jan 23, 2013

Copy link to clipboard

Copied

yes, you could use the same line (Tween class) line of code you used to fade your object in.  just change the start and end tween parameters.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 23, 2013 Jan 23, 2013

Copy link to clipboard

Copied

Okay I'm not sure if that will achieve what I  mean or not...I started doing it and then I realized I maybe wasn't following you.  To clarify though in case I just presented my question wrong.  I know how the 'fade out a movieclip' code snippet works on it's own.  If I apply it to a movie clip at a certain point on the timeline the movieclip will fade away.  The problem is if the user clicks a button to navigate away from the movieclip I want it to fade away and I can't simply have that fade command on a specific point on the timeline because there's no way of knowing what button the user will click on and thusly what part of the timeline they will then find themselves on.  Is that possible?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2013 Jan 23, 2013

Copy link to clipboard

Copied

LATEST

put the tween in your button listener function.  ie, your button click calls a function and inside that function is the tween.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines