Highlighted

Need help figuring out this code. ClicktoHide

Community Beginner ,
Mar 29, 2020

Copy link to clipboard

Copied

I'm working on a code that has a button that reveal a hidden object. Easy right? But I want the hidden object to reveal on a another frame. 

Like Frame 1: Button that reveal hidden object on Frame 2

        Frame 2: The object is revealed cause the button in Frame 1 is pressed

 

Frame 1:

NameOne.addEventListener(MouseEvent.CLICK, f1_ClickToHide);

function f1_ClickToHide(event:MouseEvent):void
{
NameTwo.visible(2) = true;
}


Frame 2:

NameTwo.visible(1) = false;

 

Don't know how that works. I test and get error

Views

101

Likes

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

Need help figuring out this code. ClicktoHide

Community Beginner ,
Mar 29, 2020

Copy link to clipboard

Copied

I'm working on a code that has a button that reveal a hidden object. Easy right? But I want the hidden object to reveal on a another frame. 

Like Frame 1: Button that reveal hidden object on Frame 2

        Frame 2: The object is revealed cause the button in Frame 1 is pressed

 

Frame 1:

NameOne.addEventListener(MouseEvent.CLICK, f1_ClickToHide);

function f1_ClickToHide(event:MouseEvent):void
{
NameTwo.visible(2) = true;
}


Frame 2:

NameTwo.visible(1) = false;

 

Don't know how that works. I test and get error

Views

102

Likes

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
Mar 29, 2020 0
Adobe Community Professional ,
Mar 29, 2020

Copy link to clipboard

Copied

Hi.

 

In AS3 documents it's not possible to access instances that doesn't exist in the current frame. So you have to create a boolean variable and set it to true when the user presses the button. Then when the user navigates to the frame that contains the hidden instance you set the visibility value of this instance to the variable's value. Like this:

 

AS3

Frame 1

import flash.events.MouseEvent;

var hidden:Boolean = false;

function revealHandler(e:MouseEvent):void
{
	hidden = true;
}

function nextHandler(e:MouseEvent):void
{
	nextFrame();
}

stop();
yourButton.addEventListener(MouseEvent.CLICK, revealHandler);
nextButton.addEventListener(MouseEvent.CLICK, nextHandler);

 

Frame 2:

hiddenObject.visible = hidden;

 

I hope this helps.

 

 

Regards,

JC 

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Mar 29, 2020 0
Community Beginner ,
Mar 29, 2020

Copy link to clipboard

Copied

Oh man. Thank you so much! It really work. I learn something new.

Likes

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
Reply
Loading...
Mar 29, 2020 1
Adobe Community Professional ,
Mar 29, 2020

Copy link to clipboard

Copied

Great! You're welcome!

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Mar 29, 2020 0