获取复选框保留在返回自己的状态帧 [英] Getting Checkboxes to retain their state on return to frame

查看:133
本文介绍了获取复选框保留在返回自己的状态帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您抽出宝贵时间阅读本。

让我preface这个说我非常新的Flash / ActionScript和没有做任何编码约15年。基本上,我一直在问我的雇主创造了presentation一个客户端。这presentation使用复选框来显示图像(实际按键)的不同部分。反过来链接到有关的章节信息,其他帧这些按钮,他们点击。

到目前为止,所有的工作,我已经得到了我所有的复选框链接到按钮与检查所有/取消所有按钮..在那里我挣扎越来越闪存记住什么状态复选框是在我离开的时候了图框。

  Area_1_Chk.addEventListener(Event.CHANGE,toggleArea_1_Btn,假,0,真正的);
Area_2_Chk.addEventListener(Event.CHANGE,toggleArea_2_Btn,假,0,真正的);

/ *确保所有复选框开始在关断状态。
* /
Area_1_Btn.visible = FALSE
Area_2_Btn.visible = FALSE

/ *定义显示的所有复选框,并设置状态为真/假
* /

ShowAll_Chk.addEventListener(Event.CHANGE,toggleMulti,假,0,真正的);
功能toggleMulti(五:事件):无效
{
VAR SAC:布尔= e.target.selected;
如果(SAC)
{
Area_1_Chk.selected = TRUE;
Area_1_Btn.visible = TRUE;
Area_2_Chk.selected = TRUE;
Area_2_Btn.visible = TRUE;
    }
其他
{
Area_1_Chk.selected = FALSE;
Area_1_Btn.visible = FALSE;
}
}

功能toggleArea_1_Btn(五:事件):无效
{
Area_1_Chk.selected? Area_1_Btn.visible =真:Area_1_Btn.visible = FALSE;
}
功能toggleArea_2_Btn(五:事件):无效
{
Area_2_Chk.selected? Area_2_Btn.visible =真:Area_2_Btn.visible = FALSE;
}

Area_1_Btn.addEventListener(MouseEvent.CLICK,A1_ClickToGoToAndStopAtFrame);
Area_2_Btn.addEventListener(MouseEvent.CLICK,A2_ClickToGoToAndStopAtFrame);

/ *设置链接到帧* /

功能A1_ClickToGoToAndStopAtFrame(事件:MouseEvent)方法:无效
{
gotoAndStop(2);
}
功能A2_ClickToGoToAndStopAtFrame(事件:MouseEvent)方法:无效
{
gotoAndStop(3);
}
停止();
 

解决方案

最简单的事情是把它们放在继续框架3存在一层,而是让他们从code看不见的。

其他选项包括具有2变量保存状态和手动当返回到框架赋予它们(变量是跨框架访问),永远不会改变帧在所有(只显示和隐藏物品),把它们放在框架3之外舞台区等。

thanks for taking the time to read this.

let me preface this by saying I'm extremely new to Flash/Actionscript and haven't done any coding in about 15years. Basically I've been asked by my employer to create a presentation for a client. This presentation uses checkboxes to display different segments of an image (actually buttons). These buttons in turn link to other frames with information about the section they clicked on.

So far all is working, I've got all my checkboxes linked to buttons with a check all/ uncheck all button .. where I'm struggling is getting flash to remember what state the checkboxes were in when I left the 'map frame'.

Area_1_Chk.addEventListener(Event.CHANGE, toggleArea_1_Btn, false, 0, true);
Area_2_Chk.addEventListener(Event.CHANGE, toggleArea_2_Btn, false, 0, true);

/* Ensures that all checkboxes begin in the off state.
*/
Area_1_Btn.visible = false
Area_2_Btn.visible = false

/* Defines the Show All Checkbox and sets states to true/false
*/

ShowAll_Chk.addEventListener(Event.CHANGE, toggleMulti, false, 0, true);
function toggleMulti(e:Event):void
{
var SAC:Boolean = e.target.selected;
if(SAC)
{
Area_1_Chk.selected = true;
Area_1_Btn.visible = true;
Area_2_Chk.selected = true;
Area_2_Btn.visible = true;
    }
else
{
Area_1_Chk.selected = false;
Area_1_Btn.visible = false;
}
}

function toggleArea_1_Btn(e:Event):void
{
Area_1_Chk.selected ? Area_1_Btn.visible = true : Area_1_Btn.visible = false;
}
function toggleArea_2_Btn(e:Event):void
{
Area_2_Chk.selected ? Area_2_Btn.visible = true : Area_2_Btn.visible = false;
}

Area_1_Btn.addEventListener(MouseEvent.CLICK, A1_ClickToGoToAndStopAtFrame);
Area_2_Btn.addEventListener(MouseEvent.CLICK, A2_ClickToGoToAndStopAtFrame);

/* Sets link to frame */

function A1_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
gotoAndStop(2);
}
function A2_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
gotoAndStop(3);
}
stop(); 

解决方案

Easiest thing would be to put them on a layer that continues to exist in frame 3, but make them invisible from code.

Other options include having 2 variables that hold the states and manually assigning them when returning to the frame (variables are accessible across frames), never changing the frame at all (just showing and hiding items), put them on frame 3 outside the stage area, etc..

这篇关于获取复选框保留在返回自己的状态帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆