Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

Slider Bar & Collision Detection question

 
Jump to:  
 
rclifto2
PostPosted: Wed Jun 18, 2008 8:16 pm    Post subject: Slider Bar & Collision Detection question
       
I have been unable to find anything to help resolve my problem through my
various searches and have turned to posting. First off - I am strictly a
hobbyist and am attempting to create a Biography Timeline for a genealogy site
I am building.
I have a slider bar with a pocket watch graphic as the dragger. What I am
hoping to achieve is that when the watch is slid along the timeline and stopped
on a marker (Indicated as a year), I would like text to pop up relevant to that
date in time.

My slider is a movieclip and the year markers are buttons. Through my
searcging, it appears as though I need to utilize both collision detection and
some type of load script attached to it. It is quite possible that I am
overreaching my skill level, but I wanted to reach out in the event that there
may be help for me.

I really don't have any code to post as I am very uncertain as to what would
be the appropriate code to start with. The example of what I am trying to
accomplish can be seen here -->
LINK

I currently have the text attached to the "over" frame within the button as an
example.

Thank you in advance,
Randy:confused;
 

 
Noelbaland
PostPosted: Thu Jun 19, 2008 6:29 am    Post subject: Re: Slider Bar & Collision Detection question
       
Hello there,

A quick fix for your situation that doesn't involve collison detecting is to
instead, track the x position of your clock dragger movieclip. You can use
collision detecting if you want, but by the way you've set up your movie, it'll
involve a lot of targeting and property retrieving. This way requires you only
add some lines to some code you already have.

Follow these steps

1) From the main stage, double click into your mc with the clock and line in
it. Create a new layer and put 2 dynamic textboxes on it. Give the first
textbox an instance name of "xpos" and the other one an instance name of
"marker". Position xpos near the bottom right of the stage and marker on the
opposite side. We will be using these boxes for testing.

2) Click on the Actions Layer and find the line that says
ratio = Math.round(this._x);
type this under it
xpos.text = ratio;
Test your movie and you should see your x position update in the bottom corner
as you drag the clock. Working? Good, thats what we want.

3) Under the last line type in the following

var space = 3;
if(ratio > 36-space && ratio < 36+space){
marker.text = "1900";
} else
if(ratio > 172-space && ratio < 172+space){
marker.text = "1915";
} else
if(ratio > 399-space && ratio < 399+space){
marker.text = "1945";
}

OK - explanation - what's going on here is we're testing whether the clock is
over one of the markers and sending the right text information to the other
marker textbox we created earlier. If you test your movie and drag to the
centre of the 1900 marker you'll see it's x position is about 36. The space
variable adds or subtracts 3 from that position so that we have a good size
"hit area". In other words if the x position is between 33 and 39 then we are
over the 1900 marker. The same with the other two - between 169 and 175 is
1915 marker, between 396 and 402 is 1945 marker.

You can now replace the marker.text="1900" line with whatever you want. You
could make the marker textbox a movieclip and have it fade or slide in with
the information you want.

If this helps, then don't forget to delete the xpos textbox off the stage and
delete the line of script that uses it. It was just for testing.

Here's the full code
 

 
rclifto2
PostPosted: Thu Jun 19, 2008 7:26 pm    Post subject: Re: Slider Bar & Collision Detection question
       
Works perfectly!!!
I sincerely appreciate you taking the time to offer me assistance - I'm
grinning from ear to ear knowing that I'll be able to add this great feature to
my genealogy site.
I also appreciate you explaining the meaning of the code as I'll add this to
my knowledge pool and hopefully build on it in the future.
A very thankful,
Randy
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

wymiana linkow proces pobierania linkow trwa pobierania linkow pobieranie linkow system wymiany linkow