PDA

View Full Version : Play backwards while holding button



belsidaam
12-14-2006, 08:21 AM
Hi folks
I have a simple but disheartingly frustrating task that I would like to achieve. But since I am a bloody noob, grrrr....
Ok have a look here:
http://www.binarylooks.com/projects/anjagallery/index.php

The top panel with the thumbs is what concerns me.I want the left button to scroll it back and the right button to scroll it forward. The thumbs panel is a simple movie with two keyframes to make it move.
The right arrow says something simple like:

on(press) {
play();
}
on(release) {
stop();
}
For the back button, it is more problematic.
I tried:

on(press) {
for (i=panel._currentframe; i>0; i--) {
gotoAndStop(i);
}
As you see, it does not work smoothly.
I tried googling it, and it seems thaht this is a common frustration. Sadly, I did not find an easy answer.
Somebody has solved this particularly problem?

Thanks

BLiZZaRD
12-14-2006, 08:53 AM
Here is a very simple tutorial (http://flashscript.biz/utilities/backward/backward.html) on playing the time line backwards.

Note that is using onEnter(load) which will rewind at current FPS. If you need it to go faster you will have to use setInterval instead.

belsidaam
12-14-2006, 09:47 AM
Thanks BLiZZaRD for the quick answer
I'll check it out tonight.

belsidaam
12-14-2006, 09:57 AM
Ok, Ij ust had look at it but have not tested it yet. Here is the code mentioned at the link. (Ok, I know I should work when at work but the net is just stronger :-)):

backward=0;
function goBack(){
_root.onEnterFrame=function(){
if(backward==0){
nextFrame();
textField.text="forward";
}
if(backward==1){
prevFrame();
textField.text="backward";
}
}
}
goBack();

1) Right now I wonder where the "one frame after the other" comes from. Is it the onFrameEnter? As soon as he enters a new frame he is told to go back one frame which atutomatiocally calls the onFrameEnter again?. I tried to achieve this with the for loop but it was too fast obviously.
2) Ok, so I will use:
onPress() {_root.onFrameEnter....}
and onRelease {stop();}

probably the stop command is not even needed. Is this correct?

BLiZZaRD
12-14-2006, 10:08 AM
Not quite.

You will write this function (here called "goBack") in your scripts layer or such.

Then on your buttons you will simply use:



on(press){
goBack();
}


You can add on(release) and on9mouseOver) if you wish to add more elements to it, but it shouldn't be needed.

belsidaam
12-14-2006, 10:14 AM
Yes, of course. Much cleaner. Stupid me :rolleyes:

BLiZZaRD
12-14-2006, 10:18 AM
Note that I have never used play back from with in my own movies, so this is all hearsey. If you have any problems though, the code is straight forward enough, just ask and I should be able to get an answer for you :D

belsidaam
12-18-2006, 07:42 AM
Thanks a lot BLiZZARD It worked perfectly fine.
Here's the final movie. (http://www.binarylooks.com/projects/anjagallery/index.php)

BLiZZaRD
12-18-2006, 09:04 AM
Very nice! I like it a lot! Just one tiny little thing (asthetics mostly)

When scrolling left and right do you think you could/should put some sort of stop notice on the far edges?

even a left/right arrow on the respective end something like:

>> [][][][][][][] <<

One little "usability problem" is that the arrows are active regardless of where the menu is, so I try to push the left arrow and nothing happens. likewise if I am at far right I can continue to push the right arrow and nothing happens.

If visitors had a visual "end of film" type notice it would help, asthetically speaking.

Just an idea.

BLiZZaRD
12-18-2006, 09:28 AM
One other thing... noticed your "Does not work with IE" at the top. You can correct this very easily.

First download the file attatched. inside are 2 JS files, in a folder named "scripts" upload that folder to your root directory, as is. no need to edit the files at all.

then find this area in your source:



<div style="margin-left:100px;">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="503" height="578" id="anjagallery" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="anjagallery.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ece9d8" /><embed src="anjagallery.swf" quality="high" bgcolor="#ece9d8" width="503" height="578" name="anjagallery" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

</div>


And replace it with this:



<div style="margin-left:100px;">
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="503" height="578" id="anjagallery" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="anjagallery.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ece9d8" />
</object></noscript>
<script language="JavaScript" type="text/javascript" >
<!--
AC_RunFlContentX ("movie", "anjagallery", "quality", "high", "src", "anjagallery", "width", "503", "height", "578" );
//-->
</script>
</div>


then add this inside your <head></head> tags:



<script src="/scripts/AC_RunActiveContent.js" language="JavaScript" type="text/javascript"></script>
<script src="/scripts/AC_Flash.js" language="JavaScript" type="text/javascript"></script>


Save and upload the HTML file to the server. Done deal. now it is valid HTML and will work with any IE and NS browser 5.5 or higher. :D

For future reference on how this is done bookmark this link:

http://learningflashmx.com/fix_activex.htm

also note as long as you have this line:



<param name="movie" value="anjagallery.swf" />


You can remove the <embed...blah blah /> tag from the code ;)

belsidaam
12-18-2006, 04:02 PM
Hey. This is really cool of you. I'll implement your suggestions as soon as I get to it.
Comments like this are really motivating... Especially since I will try to change profession in a year or so. My current job is just so boring and I love combining art and programming. Paradoxal?

djr33
12-18-2006, 09:06 PM
Paradox? Well... discuss that here:
http://www.dynamicdrive.com/forums/showthread.php?t=15607
:p

BLiZZaRD
12-19-2006, 08:09 AM
Did I not attatch the zip file? I thought for sure I did..

hmmm allow me to try again.

remember to make a folder on your server named scripts and place these 2 files inside it :)