Be a Supporter!

Turning a layer on and off with AS?

  • 269 Views
  • 3 Replies
New Topic Respond to this Topic
MOC-Productions
MOC-Productions
  • Member since: Mar. 27, 2003
  • Offline.
Forum Stats
Member
Level 15
Filmmaker
Turning a layer on and off with AS? 2008-12-28 17:46:44 Reply

Anyone know how to turn a certain layer on and off using actionscript? I want to make a feature that can turn subtitles on or off. Help....

Afro-Ninja
Afro-Ninja
  • Member since: Mar. 2, 2002
  • Offline.
Forum Stats
Moderator
Level 44
Game Developer
Response to Turning a layer on and off with AS? 2008-12-28 18:09:31 Reply

At 12/28/08 05:46 PM, MOC-Productions wrote: Anyone know how to turn a certain layer on and off using actionscript? I want to make a feature that can turn subtitles on or off. Help....

you need to convert your subtitles into a movieclip, give it an instance name on the properties panel, and then do

mc_name._visible=false;
mc_name._visible=true;

when you want to hide/show them

note, do not create a new movieclip for each different piece of subtitle text.

Alternatively, just display your subtitles in a dynamic text box. Store each subtitle into an array, then display the next array index contents every time a new subtitle comes up. IF, subtitles are turned on of course.


BBS Signature
K-Guare
K-Guare
  • Member since: May. 23, 2008
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to Turning a layer on and off with AS? 2008-12-28 18:38:55 Reply

After you do what Afro-Ninja said,
you'll need a boolean variable that changes when
the user switches the options between subtitles/no subtitles.

So when you're coding the play button for the whole movie,
you're going to have to account for that boolean.
Not sure if you know how to do this or not, but, just incase
i'll give you a little example code. :]

myPlayBtn.onRelease = function() {
if(subtitlesOn) {
theSubtitles._visible = true;
play();
} else {
theSubtitles._visible = false;
play();
}
At 12/28/08 06:09 PM, Afro-Ninja wrote: Alternatively, just display your subtitles in a dynamic text box. Store each subtitle into an array, then display the next array index contents every time a new subtitle comes up. IF, subtitles are turned on of course.

Yeah, but if he's already done the subtitles that would take WAY too long to do,
and additionally it's a lot more code as oppose to just using the _visible property.


what

BBS Signature
K-Guare
K-Guare
  • Member since: May. 23, 2008
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to Turning a layer on and off with AS? 2008-12-28 18:40:34 Reply

At 12/28/08 06:38 PM, K-Guare wrote: } else {
theSubtitles._visible = false;
play();
}

Add an extra right curly brace at the end there, oops. :]


what

BBS Signature