1

I think I'm doing it right as I have some references from this forum. My question is (not only for me but for some co-colleagues and I also think it can help other users). I have this original frame, imagine something as a map, and then I press a button that goes to another frame (a room, for example). When I get back from that room to my map I want that exact button I used to be disabled so I can't play on that room again.

I've tried some based on this kind of script:

myBtn.onRelease = function() {
    this.enabled = false;
}

and this...

btn.enabled = false;
btn.on(MouseEvent.CLICK, hideObject);

myClip.mouseEnabled = false;
myClip.mouseChildren = false;

And some other scripts I've lost track!

But I think it has something about mouse events, disable or visible?

I must admit I'm noob now. I've tried a lot of things but I can't find the right answer that works!

Please tell me if this was answered before because I can't find it anywhere.

Thank you! I can't thank you enough!

As requested, I currently have this: actions on frame label "f1"

this.f1library_btn.on ("click", function() {
    root.gotoAndStop("f1r4");
});

It works nice! And then, on frame label "f1r4" I have:

this.f1back_btn.on ("click", function() {
    root.gotoAndStop("f1");
});

You interact with some content on frame label f1r4. Nice flow. When I click on this button /f1back_btn, I come back to "f1" where I want to disable the the button "f1library_btn" so I can't go to frame label "f1r4" more than once.

At this point, I feel like you are mostly doing work for me (which is not what I mean), but as I said, I just really need an explanation on how to make it work!

Thank you!

Sara Silva
  • 85
  • 2
  • 8
  • What is the difference between `myBtn`, `btn` and `myClip`? – BadFeelingAboutThis Nov 28 '17 at 22:49
  • These are some copy/paste of as3 I've searched according to my problem... In this case they're all from different topics but I lost track while I was trying them and I don't have all the code. I don't know how to explain my problem as I already kind of found some answers as a base to progress but can't make it work! – Sara Silva Nov 28 '17 at 22:59
  • Do you have instance names set on your buttons? This is what you want: `buttonInstanceName.addEventListener(MouseEvent.CLICK, hideObject);` Then you need a `hideObject` function that actually hides the button `buttonInstanceName.enabled = false` (if a SimpleButton) or `buttonInstanceName.mouseEnable = false` (if a MovieClip) or `buttonInstanceName.visible = false` to altogether hide it. – BadFeelingAboutThis Nov 28 '17 at 23:02
  • I will try to explain what I have. I have this button, which instance name is f1library_btn; when I click on this, I get to another frame label which has something to complete and then I go back to where that f1library_btn button access is. However, I want it to work only once, which means, I want to block/disable it after using it once. And thank you so much for helping me already! I'm so glad! I don't know how to properly thank you enough. I'll try this! Thank you! – Sara Silva Nov 28 '17 at 23:06
  • What code do you currently have? (for going to another frame and coming back again) - put that in your question. – BadFeelingAboutThis Nov 28 '17 at 23:18
  • I did it, I'm now trying to solve my problem using what you posted here! Thank you so much! – Sara Silva Nov 28 '17 at 23:26
  • Are you using Actionscript or Javascript? Looks like you are not using AS3 but targeting HTML5? – BadFeelingAboutThis Nov 28 '17 at 23:45
  • I'm not quite sure? I'm using what my current teacher told me to (the root part and gotoandstop) on animate (html5 canvas). Am I doing something wrong? Could you please explain If this isn't boring you? I'm sorry if I sound ignorant, it's my first time trying this kind of software. – Sara Silva Nov 28 '17 at 23:48
  • You're not doing anything wrong, but AS3 is for Flash/AIR output, and is different code (though similar) to using HTML5 Canvas output. I took the AS3 tag off your question and added some more appropriate ones. – BadFeelingAboutThis Nov 28 '17 at 23:52
  • I'm not terribly experienced with the HTML5 Canvas side of AdobeAnimate, but I think putting: `this.f1library_btn.visible = false` right before `root.gotoAndStop("f1r4");` should do what you want. – BadFeelingAboutThis Nov 28 '17 at 23:54
  • I now get the difference! Thank you already for this and the new tags! – Sara Silva Nov 28 '17 at 23:54
  • I get how that works! But is not doing what I want since it isn't visible but still "clickable" but I think I get how to solve this now and I can't thank you enough... How can I make this up to you... There should be more people like you. I must update this thread with the right solution if others need this, right? – Sara Silva Nov 29 '17 at 00:18

1 Answers1

0

Here is an example of what you could do:

If your button is on the same timeline as the frame you move on to, you can simple disable or hide it:

this.f1library_btn.on("click", function(e) {
    //the clicked button can be referenced with the event's (e) current target property
    e.currentTarget.visible=false;  //hide the button or e.currentTarget.mouseEnabled=false to disable the button
    root.gotoAndStop("f1r4");
});
BadFeelingAboutThis
  • 14,445
  • 2
  • 33
  • 40
  • Sir, you are amazing! It works and I could understand how and why, which is great! Thank you so much! May I ask just one question, how did you solve this? From experience? – Sara Silva Nov 29 '17 at 00:32
  • Mostly, I decided to actually try it, and noticed in EaselJs (the javascript library that drives HTML5 Canvas in AdobeAnimateCC) the scope in your button handler overrides `this`, so `this.f1library_btn` is not accessible in the click handler. As an alternative, instead of using `e.currentTarget` you could just do (above the code shown) `var f1library_btn = this.f1library_btn;`, then you could access it inside that function by doing `f1library_btn.visible = false;` – BadFeelingAboutThis Nov 29 '17 at 00:43
  • I'll try that also so I can fully get all the alternatives! But it works anyways! Thank you so much. Forgive me for bothering you! You explain so well! – Sara Silva Nov 29 '17 at 00:58