the first trace is called, showing that it actually does get here, but the 2nd one isent. This suggests that it is not passing the if statement, but i cant see why because it was working perfectly when it was attached to the button itself...
Wow, I feel left out. I didn't notice the "page 2" button, so I was still back on the question about scrolling. I came up with what is posted here below, but now that I've discovered this whole new second page of posts, OldNewbie's recommended tutorial does it too. My method might be a bit easier, but it will only work with MX.
I have a .fla with three symbols in the library. One is a tall rectangle placed on the stage with an instance name of "content_mc" (this is what will be scrolled). The other two are standard buttons named "up_btn" and "down_btn" respectively. The two buttons can be anywhere on the stage, as can the "content_mc".
(the .fla is zipped and attached below)
Then you simply paste in this code:
PHP Code:
// -----------------------------------------------------------
// click handlers for the mouse buttons
// -----------------------------------------------------------
// do this when up_btn is clicked
_root.up_btn.onPress = function() {
pressInterval = setInterval(moveUp,10); // execute moveUp() every 10 milliseconds
} // end onPress() function
// do this when down_btn is clicked
_root.down_btn.onPress = function() {
pressInterval = setInterval(moveDown,10); // execute moveDown() every 10 milliseconds
} // end onPress() function
// -----------------------------------------------------------
// functions which control the movement of content_mc
// -----------------------------------------------------------
// move content_mc up 5 px
function moveUp() {
_root.content_mc._y = _root.content_mc._y - 5;
} // end moveUp()
// move content_mc down 5 px
function moveDown() {
_root.content_mc._y = _root.content_mc._y + 5;
} // end moveUp()
// -----------------------------------------------------------
// define the mouse listener
// -----------------------------------------------------------
// create an object which will serve as the "listener"
var mouseListener = new Object();
// create an event to "listen" for (in this case, when the mouse button is released)
mouseListener.onMouseUp = function() {
clearInterval(pressInterval); // stop pressInterval from executing every 100 milliseconds
} // end onMouseUp()
// register the listener with the Mouse object
Mouse.addListener(mouseListener);
// end of code //
It makes use of two important functions: (1) "setInterval()" and (2) a "listener".
(1) setInterval() simply executes a function every x number of seconds. In this case, the function "moveUp()" or "moveDown()" (depending on which button is clicked) is executed every 10 milliseconds, so content_mc is moved 5px in the proper direction each iteration.
At this point the trick is to get the setInterval() to stop doing this every 10 milliseconds. You'll notice that I named the setInterval() process as "pressInterval". To stop an Interval from executing, you use the command "clearInterval(name_of_interval);".
(2)However, we need to stop the Interval only when the mouse button is released. That's where the "listener" comes in. This last part may be a little tricky to follow, but don't worry about it if that's the case. It works, so just copy the code. In any case, here's an explanation:
First we create an object which we will use as a "listener" (called "mouseListener"). Then we add an event to that object: onMouseUp(). Finally, we register this object with the Mouse object as a "listener" with the last line of code. Once registered, the Mouse object will keep its eye on "mouseListener", watching for "onMouseUp" to happen. When it occurs, then the code in the .onMouseUp() function will be executed (in this case, it clears pressInterval, hence the scrolling stops).
(Technically, .onMouseUp() is a global listener event, so it will execute anytime the mouse button goes up. However, unless the user has clicked on a button, no pressInterval will have been defined, so nothing happens. But that's exactly what we want.)
Anyways, as you can see, the code can all be located on one frame rather than strewn all over the place like the tutorial mentioned above has it. This makes it much easier to debug and use again in other .flas.
Well, I'm probably too late since you guys been chatting here for a while, but that's the way I do the scrolling thing.
"I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass
Click on the "Resident" link to see the scrollbar. I believe this can be done by "skinning" the components. Or if not, it could easily be done via the coding logic we've covered in this thread. It's not a wild departure from linear design, but it's a start!
"I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass
"I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass
hey retrotron!
sorry i forgot to keep you updated!
well i got the scroller working and stuff. unfortunately i got really busy doing 3D and other stuff, so i still didnt manage to finish all the design and content (actually there is almost no content yet)
but im still doing it once i can get some time.
well if you want to have a look at the progress so far you can, but remember its still at a very simple stage.
the only section of the navigation that works now is "background".
by the way, this site is a support website for what will be my final project in my course if you are wondering what its about
if you remember, we talked about the design being inspired by kanji...
you can see that the shape of the navigation and content area is defined by the kanji meaning "to make" (tsukuru)
as this is a production report site for the short film i will make.
(as you can tell, I very much like your idea to use the character as the layout inspiration).
In the meantime I've pursued other ways of doing the scrolling thing, and one simple way is using a simple onRollOver to start a setInterval which moves the desired content, and a simple OnRollOut to clear that interval. It's much simpler than all the stuff we figured out before:
myBtn_btn.onRollOut = function() {
clearInterval(scrollInterval);
} // end onRollOut()
function moveContent() {
myContent_mc._y += 5;
} // end moveContent()
Anyways, I've attached two separate scrolling studies if you wish to look at/use the code. One rotates the content (_rotation += 5), the other just scrolls it (_y += 5).
I hope your time allows you to finish well. Good luck!
"I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass
cool!
thanks very much, i'll see if i cam put some of that stuff to good use
and i'll keep you updated with my progress if you want. im gunna try and do some cool interactive stuff when i have time.
if you want, pm me with your email or icq/msn detail
"I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass