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

How do I stop a function

New Here ,
Oct 28, 2008 Oct 28, 2008
Hello:
I have created a function and I am calling it under a button click event.

For example; *** showSlides(); ****

When I click the button, the function activates just as I want it to.
However, the problems is that I do not know how to exit, end, or stop the function. In other words, I want to deactivate the function from another button but do not know what codes to place with the function that will cause the function to end.

I have tried, for about 3hours now, many possibilities that are not working. I am out of solutions and need some help.
TOPICS
ActionScript
933
Translate
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
Guest
Oct 28, 2008 Oct 28, 2008
Try something like this (in stead of using EnterFrame you might start/stop a Timer):

Translate
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
New Here ,
Oct 28, 2008 Oct 28, 2008
I guess I could take some of slide show codes and tie it up with add and remove event listeners, although I was looking for an easier way.

I just can not understand why. I can practically place a one word function almost anywhere in the action script in which will activate all of the codes in the function. So why isn't it possible to place a few words next to the function to recall and make the funtion end?
Translate
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
LEGEND ,
Oct 28, 2008 Oct 28, 2008
Because that is how functions work. They are designed to be called like so:

myFunction();

and then to run their code. Generally they have some amount of code in the function declaration and it runs within a few milliseconds and it is done. So really there generally isn't anything to stop. As a generally rule you can't "stop" a function. Do you have some code in your function that makes it continually execute? In that case you have something happening over time and you want to stop it, not the "function" per se. You really haven't explained what you are trying to do.

I think perhaps you need a second function? Perhaps stopSlides() or something like that? Without know what is in your showSlides() function it is hard to know what you need to do.
Translate
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
New Here ,
Oct 28, 2008 Oct 28, 2008
I am referencing to a function that I have created. This function that I have created has other nested functions and their instructions. After the call, the function places a slide show (sprite) on the screen. However, this slide show display does not have any exit buttons. So, the problem is, how do I get the slide show off the screen. I have tried some scenarios such as for example: stop.slideShow(); , retrun slideShow(); and so forth.

Yes, I do have a timer attached, but it is only for the photos transitions. Anyway, as I have indicated, I was just loooking for something easier, in that I am somewhat new to this and do not know it all. I do know how to attach a removelistner, and as I see it now, this will proabably be the easiest way of getting the slideshow to disapear.

Some added information, I am trying to acomplish this with action script only (one frame). No time line with this one.
Translate
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
LEGEND ,
Oct 28, 2008 Oct 28, 2008
Yup. Just like you had to put together a complex string of various commands in your showSlides() function definition you will need to put together a string of things that will happen in a stopSlides() function.

You can't just try stop.slideShow() because that doesn't make any sense to Flash. You have to make your own function that tells it what to do. Computers (for the most part) do what we tell them not what we want.

So what should happen when you click the stop button. Should the whole screen go dark? Should the show just pause on the slide that is currently showing? Should it go back to the beginning? Those are just three possible things and there countless other things that you could want. How would flash know what to do?

If you have a timer then you certainly will want to stop the timer. You say it is only for the photo transitions, but that seems to be the thing you want to stop, right. So that is really at the heart of what you need to deal with.

You might want to change the visibilty of the current slide or not? What if they start the show again? Should it remember where it was? Should it go back to the beginning? These are all things you would put in your new function.

There is no easy way out -- well the easy way out is just to not have a exit button! Programming is all about planning what you want to happen and making it happen. There isn't anything Flash can do to take over that responsibility for you.
Translate
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
New Here ,
Oct 28, 2008 Oct 28, 2008
see next reply
Translate
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
New Here ,
Oct 28, 2008 Oct 28, 2008
Also, looking at the number of post that you have placed, you probably could quicly answer the question following:
How can I center the page? Direct to a tutorial or give the info. Either way is ok.
ThankYou
Translate
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
LEGEND ,
Oct 28, 2008 Oct 28, 2008
Let's think about centering a 5 x 3 index card on an 11 by 8 1/2 piece of paper. (I've done the sizes in that order so that x/across is first and y/updown is second just like x,y in flash and if you aren't from the US those dimensions may seem totally random, but here they are common sizes that paper comes in.). I don't know where your registration points are, but since Flash loads dynamic content with the registration point in the upper left corner we'll go with that.

Sof first we want to find the center of the bigger sheet (or the stage in Flash) In this case it is 11 accross so we divide by two and that puts the center at 5.5. To get how big the stage is across you can ask for the stage width:

var xCenter:Number=stage.StageWidth/2

(I think that is the correct way in AS3, I knew this off the top of my head in AS2, but it changed a bit in AS3.) I bet you can figure out you to get yCenter...

var myCard.x=xCenter;

Now if I put the upper left corner of my index card there it still isn't centered. So I need to move my index card up and to the left, but by how much?

It needs to go half the width of the card to the left. So if the card is 5 we need to slide it 2.5 to the left. So in our case 11/2-5/2=3. So the left edge of the index card would go 3 from the left edge of the note paper. So I can do something like this:

myCard.x=xCenter-myCard.width/2

Using that w from before. And the trick for the y direction is exactly the same, but with the height of the clip. Of course if you have changing dimensions of your clip then you need to work on some other solution but the same idea should work out.
Translate
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 ,
Oct 28, 2008 Oct 28, 2008
var master:Rothrock = new Rothrock ( );
if (master >= flash forums longest standing member){

say yes!;
} else{ Laugh and say no!;}
Translate
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 ,
Oct 28, 2008 Oct 28, 2008

var master:Rothrock = new Rothrock ( );
if (master.membership >= flash forums longest standing member){

say yes!;
} else{ Laugh and say no!;}
Translate
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
LEGEND ,
Oct 28, 2008 Oct 28, 2008
I wish. kglad, david stiller, and _urami have all been here longer than I. (And they are all a lot smarter than me.)

But thanks for noticing! 🙂
Translate
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
New Here ,
Oct 29, 2008 Oct 29, 2008
Roth:
The registration point does make sense and would explain why the contents are on the left hand side of the page rather than the center. With the registration points, I was thinking more in terms of motion and neglecting issues with placement.
The information that you have provided is well explained and of course makes sense.
Thank You.
Translate
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
LEGEND ,
Oct 29, 2008 Oct 29, 2008
LATEST
So that is working for you? Motion is just placement plus time.

So is it taking shape for you?
Translate
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