button inside a sliding bar doesn't work

  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

Hello good flashers,

(tried to search for it - no results)
I have a sliding bar with a MC inside it.
once you click this MC something blinks. The problem is that nothing happens when i click the MC. When I mark out the sliding bar it works. So I have a feeling it's related to the onEnterFrame in the sliding bar command (I never really fully understood this onEnterFrame thing...)

How would I solve this? do i need to delete the onEnterFrame? i tried. didn't work.
Code: [ Select ]
tpSlide.onRelease = function() {
        this.onEnterFrame = function() {
            this.speedX = (this.speedX*this.friction)+(this.baseX-this._x)*this.ratio;
            this._x += this.speedX;
        };
};
tpSlide.tp1.onRelease = function() {
    dr1.gotoAndPlay(10);
};
  1. tpSlide.onRelease = function() {
  2.         this.onEnterFrame = function() {
  3.             this.speedX = (this.speedX*this.friction)+(this.baseX-this._x)*this.ratio;
  4.             this._x += this.speedX;
  5.         };
  6. };
  7. tpSlide.tp1.onRelease = function() {
  8.     dr1.gotoAndPlay(10);
  9. };

Thank you
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

So my code grew a bit and I am still pulling my hair trying to find a solution.

so "tdSlide" slides into the stage elastically (pretty cool;-) but tpSlide[b].onRelsease below it doesn't happen. why oh why? I tried to delate the enterFrame - no. I tried to set a boolean variable - no.

Please please help...

Code: [ Select ]
tpSlide.onRelease = function() {
    this.onEnterFrame = function() {
        this.speedX = (this.speedX*this.friction)+(this.baseX-this._x)*this.ratio;
        this._x += this.speedX;
    };
};
function blink(num) {
    _root["dr"+num].gotoAndPlay(2);
}
for (var j = 1; j<7; j++) {
    b = "tp"+j;
    tpSlide[b].id = j;
    tpSlide[b].onRelease = function() {
        blink(this.id);
        };
}
  1. tpSlide.onRelease = function() {
  2.     this.onEnterFrame = function() {
  3.         this.speedX = (this.speedX*this.friction)+(this.baseX-this._x)*this.ratio;
  4.         this._x += this.speedX;
  5.     };
  6. };
  7. function blink(num) {
  8.     _root["dr"+num].gotoAndPlay(2);
  9. }
  10. for (var j = 1; j<7; j++) {
  11.     b = "tp"+j;
  12.     tpSlide[b].id = j;
  13.     tpSlide[b].onRelease = function() {
  14.         blink(this.id);
  15.         };
  16. }
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Sounds sorta like a targetting issue to me. An example file showing the situation would help troubleshooting.
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

is there an option here to attach a .fla file?
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Nope, you would have to upload to a server and link to the file :-\
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

test
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

I'm getting a 404 Not Found error.
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

I believe that copying the address to the ie bar rather than clicking on the link will do the job.

thanks
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Nope, still a 404. Odd.
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

sorry, i realized there were problems with the file. here is a new link that should work
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Rofl, ok so now it works, but you must be using MX 2k4 because I am getting an Unexpected File Format error.

Flash MX 2k4 has the ability to save the .fla as Flash MX, can you do that so I can open it?
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

ok I saved as MX. a message came up saying that the file will lose data in the conversion. I hope it all works as you open it.
note: i moved the menu to the center of stage but eventually it'll be out of the stage on the right with only a piece of it sticking out to be pressed.

let me know if it opens.
:D
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5146
  • Loc: SC-USA

Post 3+ Months Ago

I'm sure lostinbeta's answer will be the definitive one, but I think the problem is you're trying to evalutate for multiple onRelease events and in effect it's only evalutating the event singularly on the tpSlide MC.

That's my guess anyway.


btw: I did think the slide was pretty cool. ;)
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

hey thanks digitalMedia.

you know, I thought that in programming (which is new in my world) every actions is executed following a hierarchy so I figured that once flash reads the first onReleased command, it'll finish and then go to the next one and execute it. I guess its more abstract then I think.
Life couldn't be that easy. :?
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5146
  • Loc: SC-USA

Post 3+ Months Ago

meAsking wrote:
hey thanks digitalMedia.

you know, I thought that in programming (which is new in my world) every actions is executed following a hierarchy so I figured that once flash reads the first onReleased command, it'll finish and then go to the next one and execute it. I guess its more abstract then I think.
Life couldn't be that easy. :?


hehehe. Yes, I would expect logic to logical as well. But then again, when we use Flash, we're only working within the logic of the people at Macromedia who develop Flash.

If my assertion is correct, you might be able to get rid of the tpSlide container and apply you're slide function to each button in unison to achieve the same effect.

btw: You might consider increasing the frame rate to 24fps. When I was playing with your file last night, it seemed be a little smoother that way.

Good Luck, and please let us know when you're done with this so we can have a look.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Ok, i'm sort of confused on what the exact problem is here.

Here's why.

1) I noticed your dr# clips stick if you click on another one before the other is finished opening or closing.

and

2) If it involves the bottom navigation panel that bounces in (which took me a while to figure out that that had a problem since all that code was commented out so I didn't bother to read it) then that problem is indeed because of how you are calling the onRelease.


If it is problem #1, the situation sadly would require a code re-write since the way you set up your if statements makes flash stop worrying about the previous clip and start focusing on the newly clicked clip.

If it is problem #2, then it's just a rearrangement of what to click. The reason this problem occurs is actually pretty simple. onRelease is a button handler that tells flash that when this clip is released, run these actions. Now, if the clip that contains this handler is the main container, nothing inside can be clicked upon because you will always be clicking the container that holds them.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

If it is problem #2, here is a quick re-write to the elastic function.

Code: [ Select ]
tpSlide.tab.onRelease = function() {
    if (_root.tpSlide._x>=765) {
        _root.tpSlide.onEnterFrame = function() {
            this.speedX = Math.floor((this.speedX*this.friction)+(this.baseX-this._x)*this.ratio);
            this._x += this.speedX;
        };
    }
};
  1. tpSlide.tab.onRelease = function() {
  2.     if (_root.tpSlide._x>=765) {
  3.         _root.tpSlide.onEnterFrame = function() {
  4.             this.speedX = Math.floor((this.speedX*this.friction)+(this.baseX-this._x)*this.ratio);
  5.             this._x += this.speedX;
  6.         };
  7.     }
  8. };



I targetted the tab clip within the tpSlide as the button to execute the elastic entry. This allows for the other clips to still be clickable.






Oh yeah, and in your first post you said you didn't understand the whole onEnterFrame thing.


onEnterFrame is the dynamic event handler (can be created/defined dynamically via AS) form of onClipEvent(enterFrame). A few of the plusses of onEnterFrame are...

1) Can be created/defined dynamically via AS
2) Helps cleaner code by having it all contained in a frame instead of scattered clips
3) Is deleteable via delete clipName.onEnterFrame; (note that you don't use the () at the end in this statement).
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

Thank you.
I'll difinitely let you know when finished (god help me ;-)
(and hopefully lostinbeta too...)
:lol:
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

sorry lostinbeta, i didn't notice there is another page.
i'm reading your post now.
  • meAsking
  • Beginner
  • Beginner
  • meAsking
  • Posts: 38

Post 3+ Months Ago

lostinbeta U R D BEST :kingwithcrown:

it works!! I can't believe it's such a simple modification.
I only needed to target an element inside the bar otherwise it will always be like I'm clicking the whole bar (which is a bit weird because I'm specifying the name of what I'm clicking on i.e. tpSlide.tp1)

anyway, it works. yeepee. Now, I can go on with the other 1000 hours I still need to spend on this.

thank you! :dance2:
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Yes you are specifying the name of the clip, but the clip is within the main clip. So if you apply an onRelease action to the main clip, it considers all content inside it to be part of the main clip (as it is actually what makes up the main clip). So all other button handler actions within it are over-ridden.


Glad I could help btw :)

Post Information

  • Total Posts in this topic: 21 posts
  • Users browsing this forum: No registered users and 4 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.