• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 03:51
CET 09:51
KST 17:51
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2
Community News
BSL Season 2025 - Full Overview and Conclusion6Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)16Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7[BSL21] Non-Korean Championship - Starts Jan 105
StarCraft 2
General
Stellar Fest "01" Jersey Charity Auction SC2 All-Star Invitational: Tournament Preview Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets When will we find out if there are more tournament SC2 Spotted on the EWC 2026 list?
Tourneys
SC2 All-Star Invitational: Jan 17-18 Sparkling Tuna Cup - Weekly Open Tournament SC2 AI Tournament 2026 $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) OSC Season 13 World Championship
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone
Brood War
General
Video Footage from 2005: The Birth of G2 in Spain [ASL21] Potential Map Candidates BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ BSL Season 2025 - Full Overview and Conclusion
Tourneys
[Megathread] Daily Proleagues [BSL21] Non-Korean Championship - Starts Jan 10 Small VOD Thread 2.0 Azhi's Colosseum - Season 2
Strategy
Soma's 9 hatch build from ASL Game 2 Simple Questions, Simple Answers Game Theory for Starcraft Current Meta
Other Games
General Games
Stormgate/Frost Giant Megathread Beyond All Reason Awesome Games Done Quick 2026! Nintendo Switch Thread Mechabellum
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Canadian Politics Mega-thread European Politico-economics QA Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
My 2025 Magic: The Gathering…
DARKING
Physical Exercise (HIIT) Bef…
TrAiDoS
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1550 users

The Big Programming Thread - Page 124

Forum Index > General Forum
Post a Reply
Prev 1 122 123 124 125 126 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2012-03-12 23:02:03
March 12 2012 23:01 GMT
#2461
On March 13 2012 06:58 Manit0u wrote:
Might I ask a question about design and theory? We've decided with a couple of buddies to make a simple 2D turn based space combat game. The problem is, it's been ages since I did any real maths/physics and I'm not sure how to approach one thing...

Stuff I need:
1. Ship position - pretty obvious, (x, y) coordinates on a grid.
2. Ship bearing and speed - also obvious, vector originating from ship position.
3. Ship relation to each other - this one is problematic.

What I need:
I must know in which of the 4 90 degrees arcs of a ship is another ship. One way to do it (although I'm not sure if that's the optimal way) would be to get another grid centered on the ship position and rotated 45 degrees. This way, by checking other ship's position on this "personal" grid I'd know in which arc it is (x, y) = front, (-x, y) = left, (x, -y) = right, (-x, -y) = rear. Comparing the vectors will then also give me info if the ships are closing, abeam or moving away in certain arc.

Is there a better way of doing it?

To figure out what quadrant the angle lies in you could use atan2 to get the angle between two points. You can then do whatever you like with that angle. I believe atan2 returns a range of pi through -pi representing a full 360 degree rotation.

http://cecilsunkure.blogspot.com/2012/02/basic-2d-vector-physics.html
delHospital
Profile Blog Joined December 2010
Poland261 Posts
Last Edited: 2012-03-12 23:11:46
March 12 2012 23:09 GMT
#2462
Ship 1 (a,b)
Ship 2 (c,d)

Look at the line defined by points (a,b) and (a+1,b+1). Now knowing whether Ship 2 is to the left or to the right of the line will give you half of what you want. Next you need to see if Ship 2 is to the left or to the right of the line (a,b), (a+1,b-1) and now you can easily tell which arc Ship 2 is in (left, left -> the left arc; right, left -> behind and so on).

How do you tell if a point is to the left or to the right of a vector? You can find a nice description here (in Polish).

E: Yeah, well, you can cheat with trigonometric functions, but that's ugly floating point calculations.
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
March 12 2012 23:13 GMT
#2463
have a look at affine linear transformations. That's the proper math to do coordinate system transformations. Maybe look for material addressing 2d math specifically, that's easier to understand than 3d or even the generalized approach. And since you only need 2d, that would suffice.

or, for the easy way out: you could use atn2(dy,dx) to find the angle from one ships x-axis to the vector (dx,dy) pointing towards another ship. If you need this rotated with the first ship you can just add the ships own angle to that (you can calculate that with atn2 as well).
Gold isn't everything in life... you need wood, too!
heishe
Profile Blog Joined June 2009
Germany2284 Posts
March 12 2012 23:27 GMT
#2464
Simply calculate the angle of the vector between your ship and the relative ship, and then subtract the current rotational angle of your ship to that angle. If the result is 0-90° (or 0- 0.5*Pi) it's in the first quadrant relative to your ship, and so forth around the clock.

To get the angle of the line that the vector between your ship and the relative ship represents, you just get either acos() of relship.x - yourship.x or asin() of relship.y - yourship.y

delHospitals version won't work if your ship is rotating around at all. However, if it's static always looking straight ahead, his method will work and it's also faster.

No guarantee that this is 100% right, since I just thought it up in my head, but I reckon it should work, or at least it will work with slight adjustments if you understand the math behind what I posted.
If you value your soul, never look into the eye of a horse. Your soul will forever be lost in the void of the horse.
Manit0u
Profile Blog Joined August 2004
Poland17610 Posts
Last Edited: 2012-03-12 23:41:50
March 12 2012 23:28 GMT
#2465
Well, at this stage (brainstorming mostly) I won't have much use for vectors per se, I want to add them just to indicate ship facing (and speed but that can be solved in many different ways). What's really important for me is point-to-point calculations and point-to-sphere (signature radius around the point).

Also, note that for the "space" I'll be using just one quadrant of the basic X, Y axes grid as I have no need to go into the negatives. This would make all the calculations a bit easier.

Another thing that should make it simpler (I think) is that I can round everything up as ultimately I won't have to deal with floats and will be just using natural numbers as end results.

I guess I'll show it to a friend of mine, he's doing his trigonometry/engineering exam this week so he'll have fresh knowledge. My trigonometry and analytic geometry courses were years ago and I hated them.
Time is precious. Waste it wisely.
Fryght
Profile Joined August 2010
Netherlands254 Posts
March 13 2012 00:06 GMT
#2466
http://mijingo.com/products/screencasts/python-for-php-developers/
This convinced me to pick up Python for web dev. Never hurts to add another language on to my skill set and Python does seem pretty cool :D

Aside from this, Ruby/RoR never really appealed to me. Should I invest time in RoR too (or maybe only Ruby)?
chaynesore
Profile Joined October 2011
Australia175 Posts
Last Edited: 2012-03-13 03:36:18
March 13 2012 03:32 GMT
#2467
Hey guys, I've got what I assume is a very simple task but I can't work it out using Google search because I have no knowledge of the basics I assume. I've got a basic understanding of programming (as a mechanical engineer) and how it works etc, but next to no knowledge of javascript and web programming, etc.


THE GOAL:

I want to create a simple web page for my clan that has a list of all members, with contact information, real id emails, etc, and also have it link to data extracted from Sc2Ranks (namely, League, Rank, Win/Loss, Race, etc). It's basically a customizable list of our team members, that talks to Sc2Ranks. I think this should be pretty simple, but I am clueless.


WHAT I'VE WORKED OUT:

I've worked out that I need to use the API from Sc2Ranks to achieve this ( http://sc2ranks.com/api ). Reading this, I've worked out how to correctly construct the API URL. For example, my account for "Character with Base Team Info" would be as follows, for the three available outputs:

http://sc2ranks.com/api/char/teams/sea/FaDeChaynes!401514/1/0?appKey=zxq.com (XML)
http://sc2ranks.com/api/char/teams/sea/FaDeChaynes!401514/1/0.json?appKey=zxq.com (JSON)
http://sc2ranks.com/api/char/teams/sea/FaDeChaynes!401514/1/0.json?jsonp=foobar&appKey=zxq.com (JSONP)


THE PROBLEM:

I have no idea what to do next. I can't seem to find anything on Google that simply tells me how to tell my web page to talk to these API URLs and manipulate the data so that I can put it in a table as I need to. I'm sure this is an extremely simple task, but I've spent hours looking and am just completely stuck. Please can anyone help?! :S
"When things get weird, I'm in my element." - Liquid`TLO
alwinuz
Profile Joined September 2011
Netherlands77 Posts
March 13 2012 03:58 GMT
#2468
You can use javascript (with jQuery for example) to load the API url, and then insert the loaded JSON data into your webpage.
In other words, you have to do some programming inside your web page.

Here's a tutorial that shows how to do that:
http://coding.smashingmagazine.com/2012/02/09/beginners-guide-jquery-based-json-api-clients/
Here's the help (with examples) how to load and use JSON with jQuery:
http://api.jquery.com/jQuery.getJSON/

Important: there are security risks with loading 'normal' JSON from an other website. JSONP is used to work around this. (This is also mentioned in the links above.)
So I think you need to use the JSONP version of the sc2ranks API.
cyst
Profile Joined August 2010
United States9 Posts
March 13 2012 08:24 GMT
#2469
On March 12 2012 05:01 Sluggy wrote:
Show nested quote +
On March 12 2012 00:24 IMlemon wrote:
On March 11 2012 13:01 Sluggy wrote:
edit: Forgot to mention this is C# 4.0

What is wrong with this regex?

The program input is coming from an html file. I am reading that html file line by line and dumping that in to a StringWriter. The StringWriter is then passing the body of text as a single string (THE INCOMING TEXT HAS \r\n's (NOT SHOWN) after each <br> tag IF THAT IS RELEVANT):


<!-- saved from url=(0126)http://www.wunderground.com/history/airport/KMTO/2012/3/9/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA&format=1 -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>.....truncated<br>
12:53 AM,34.0,27.0,75,30.39,10.0,West,10.4,-,N/A,,Clear,280,2012-03-09 06:53:00<br>
1:53 AM,35.1,26.1,70,30.40,10.0,West,8.1,-,N/A,,Clear,270,2012-03-09 07:53:00<br>
2:53 AM,36.0,25.0,64,30.39,10.0,West,9.2,-,N/A,,Clear,260,2012-03-09 08:53:00<br>
3:53 AM,36.0,25.0,64,30.39,10.0,WSW,6.9,-,N/A,,Clear,250,2012-03-09 09:53:00<br>
4:53 AM,36.0,25.0,64,30.42,10.0,West,10.4,-,N/A,,Clear,270,2012-03-09 10:53:00<br>
5:53 AM,34.0,26.1,73,30.44,10.0,WNW,11.5,-,N/A,,Clear,290,2012-03-09 11:53:00<br>
6:53 AM,34.0,26.1,73,30.45,10.0,WNW,15.0,-,N/A,,Clear,300,2012-03-09 12:53:00<br>
7:53 AM,36.0,26.1,67,30.49,10.0,NW,18.4,-,N/A,,Clear,320,2012-03-09 13:53:00<br>
8:53 AM,37.0,25.0,62,30.51,10.0,NNW,18.4,-,N/A,,Clear,330,2012-03-09 14:53:00<br>
10:53 AM,41.0,23.0,49,30.54,10.0,NW,17.3,21.9,N/A,,Clear,320,2012-03-09 16:53:00<br>
11:53 AM,43.0,19.9,40,30.54,10.0,NNW,11.5,23.0,N/A,,Clear,340,2012-03-09 17:53:00<br>
12:53 PM,44.1,19.9,38,30.52,10.0,North,12.7,23.0,N/A,,Clear,350,2012-03-09 18:53:00<br>
1:53 PM,45.0,21.0,39,30.51,10.0,North,11.5,-,N/A,,Clear,350,2012-03-09 19:53:00<br>
2:53 PM,46.0,21.9,39,30.50,10.0,North,-9999.0,-,N/A,,Clear,0,2012-03-09 20:53:00<br>
3:53 PM,45.0,21.0,39,30.50,10.0,North,11.5,-,N/A,,Clear,350,2012-03-09 21:53:00<br>
4:53 PM,44.1,19.9,38,30.50,10.0,North,10.4,-,N/A,,Clear,360,2012-03-09 22:53:00<br>
5:53 PM,39.0,21.0,49,30.51,10.0,North,6.9,-,N/A,,Clear,360,2012-03-09 23:53:00<br>
6:53 PM,36.0,21.0,55,30.52,10.0,North,5.8,-,N/A,,Clear,350,2012-03-10 00:53:00<br>
7:53 PM,35.1,21.9,59,30.53,10.0,North,4.6,-,N/A,,Clear,10,2012-03-10 01:53:00<br>
8:53 PM,30.9,21.0,67,30.53,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 02:53:00<br>
9:53 PM,32.0,19.9,61,30.53,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 03:53:00<br>
10:53 PM,33.1,16.0,50,30.52,10.0,East,3.5,-,N/A,,Clear,80,2012-03-10 04:53:00<br>
11:53 PM,33.1,15.1,48,30.52,10.0,Calm,Calm,-,N/A,,Clear,0,2012-03-10 05:53:00<br>
</body></html>


I wrote a regular expression that is intended to grab each of the timestamps up until the line break, but it only gets the first..

Relevant Code:


private static void ProcessBody(string text)
{
Regex CONTENT = new Regex(@"(?<content>\d{1,2}:\d{1,2} [AP]M.+)<br>", RegexOptions.Multiline);;

if (text != string.Empty)
{
Match contentMatch = CONTENT.Match(text);

if (contentMatch.Success)
{
Console.WriteLine(contentMatch.Groups["content"].Captures.Count);
Console.WriteLine(contentMatch.Groups["content"].Captures[0]);
}
}
}



The output of this program is:

1
12:53 AM,34.0,27.0,75,30.39,10.0,West,10.4,-,N/A,,Clear,280,2012-03-09 06:53:00

Any ideas of how to get it to capture all of them?


http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

Use a tool for parsing html instead of regular expressions.


Your comment lead me to check out HtmlAgilityPack which helped do what I needed here and greatly simplify another portion of the program (pulling stuff directly from the site), so thanks for that

That being said, I know html and regex don't always go well together, but I think for this example getting 23 captures out of that should be possible. I don't think it's the <br> tags that are breaking the code. So if someone could either explain the details of why I can't do this simple task with regex, or show the proper way, I would appreciate it!.


Check out the API spec for Regex.Match. The first sentence says that it returns the first occurrence of a matching string, and you call Match.NextMatch() to move to the next one. Also, I am not sure what the "<content>" part of your regex is doing, unless it is part of the removed document. It seems like your regex would look for "<content>" at the beginning of every match. Also, I am not sure if that is the correct way to use groups, as they are normally indexed starting from 0,1... and on.
minimat
Profile Blog Joined December 2010
Australia344 Posts
March 13 2012 13:10 GMT
#2470
ActionScript 3 here.

The font named _sans is not compatible with TLF text. TLF text using this font will not display properly.
ReferenceError: Error #1065: Variable TCMText is not defined.

I am getting that error in the output even after I've deleted all the font changing lines of code, anyone know whats up?
fabiano
Profile Blog Joined August 2009
Brazil4644 Posts
Last Edited: 2012-03-13 18:12:08
March 13 2012 18:10 GMT
#2471
I need help with something that should be trivial yet I can't seem to figure out it because I suck at javascript/jquery.

I want to implement the same function of the spoiler tag here on TL
+ Show Spoiler +
like this


which means, when the user clicks on the element, it shows/hides some content.

Fiddling around I made it halfway there I guess, but I can't seem to make it work properly (check it out here: http://ladderlauncher.tk/DRTL2/streams.php )

As you can see, the second "spoiler" doesnt respond to the clicks.

Here is the code I'm using for that:
+ Show Spoiler +
$(document).ready(function() {
$("#hidden").hide();
$("#stream_box_header").toggle(
function() {
$("#hidden").show();
},
function() {
$("#hidden").hide();
}
);
});


What am I doing wrong?
"When the geyser died, a probe came out" - SirJolt
Yiko
Profile Joined August 2010
Germany104 Posts
March 13 2012 19:09 GMT
#2472
On March 14 2012 03:10 fabiano wrote:
I need help with something that should be trivial yet I can't seem to figure out it because I suck at javascript/jquery.

I want to implement the same function of the spoiler tag here on TL
+ Show Spoiler +
like this


which means, when the user clicks on the element, it shows/hides some content.

Fiddling around I made it halfway there I guess, but I can't seem to make it work properly (check it out here: http://ladderlauncher.tk/DRTL2/streams.php )

As you can see, the second "spoiler" doesnt respond to the clicks.

Here is the code I'm using for that:
+ Show Spoiler +
$(document).ready(function() {
$("#hidden").hide();
$("#stream_box_header").toggle(
function() {
$("#hidden").show();
},
function() {
$("#hidden").hide();
}
);
});


What am I doing wrong?


Using the same id multiple times in a document is wrong, they are meant to be unique. If you want them to react the same use classes instead. Take another look at http://api.jquery.com/toggle/ . There is a small working example of what you want using the click() event. On another note, i don't see a toggle() function with two functions as parameters, like you use it. There is something strange about that too

If you need more help ask away.

supereddie
Profile Joined March 2011
Netherlands151 Posts
March 13 2012 19:21 GMT
#2473
Why not use just normal javascript? Can't be that hard to create a toggle function...
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
tofucake
Profile Blog Joined October 2009
Hyrule19189 Posts
March 13 2012 19:26 GMT
#2474
I use this in a few places. It's a bit inefficient, but it's intended as an example of some simple jQuery

<script>
$('a[id^="spoiler"]').click(
function()
{
var l = $(this).attr('id').split('_')[0];
$('#' + l).toggle();
$('a[id^="' + l + '"]').toggle();
});
$(document).ready(function(){$('div[id^="spoiler"]').toggle();$('a[id*=_spoiler2]').toggle();})
</script>

<a href="#" id="spoiler1_label1">++ show ++</a>
<a href="#" id="spoiler1_label2">-- hide --</a>
<div id="spoiler1" style="border: 1px solid black; width: 400px; padding: 2 2 2 2;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eget neque felis. Nunc ut accumsan nisi. Mauris feugiat tortor nec elit aliquam consectetur. Proin vel tincidunt erat. Donec leo orci, ultrices vitae vestibulum non, vulputate ut neque. Praesent consectetur mauris quis nisi auctor quis lobortis sem iaculis. Ut quam nibh, dignissim vel fermentum ac, rutrum eget tellus. Aliquam porttitor iaculis enim ac pretium. Aenean tellus metus, tempor eu facilisis ac, mattis quis justo. Nulla eu lectus nibh, sit amet aliquet ipsum. Fusce ac lacus justo, a tempor erat. Sed ipsum quam, convallis ac ultricies vitae, pharetra in nibh. Suspendisse nec augue sed tellus molestie bibendum in sit amet quam. Proin facilisis mauris quis nisl commodo eu varius mauris mattis. Etiam magna mauris, tincidunt ac gravida ut, posuere eu dolor. Sed varius arcu ut nisi volutpat vitae accumsan est euismod.
</div>


It's better to set the css so things are just styled with hidden in the first place.
Liquipediaasante sana squash banana
Kentor *
Profile Blog Joined December 2007
United States5784 Posts
Last Edited: 2012-03-14 00:23:45
March 14 2012 00:22 GMT
#2475
Here's my implementation of hide/show spoiler, it could probably be improved.

$("a.spoiler").click(function() {
var el = $(this);
var title = el.attr("title");
if (title != "") {
title = " [" + title + "]";
}
if (el.text().match(/^\+/)) {
el.text("- Hide Spoiler" + title + " -");
}
else {
el.text("+ Show Spoiler" + title + " +");
}
el.next(".bbspoiler").toggle();
return false;
});

$(".bbspoiler").css("display", "none");


<a href='#' class='spoiler monospace' title='asdf'>+ Show Spoiler [asdf] +</a>
<div class='bbspoiler'>test</div>
fabiano
Profile Blog Joined August 2009
Brazil4644 Posts
March 14 2012 01:54 GMT
#2476
Yesss!!

Thanks everyone, got it working!
"When the geyser died, a probe came out" - SirJolt
Yiko
Profile Joined August 2010
Germany104 Posts
Last Edited: 2012-03-14 07:27:51
March 14 2012 07:27 GMT
#2477
On March 14 2012 04:21 supereddie wrote:
Why not use just normal javascript? Can't be that hard to create a toggle function...


You are right, it really isn't. But why would you not use a library that makes that even easier, produces easy to understand code and specialises in element selection and manipulation, which is exactly what was wanted in the first place? I have to admit, i often use JQuery even in places where plain JavaScript would easily suffice, because it is just so powerful and convenient.
supereddie
Profile Joined March 2011
Netherlands151 Posts
March 14 2012 11:12 GMT
#2478
On March 14 2012 16:27 Yiko wrote:
Show nested quote +
On March 14 2012 04:21 supereddie wrote:
Why not use just normal javascript? Can't be that hard to create a toggle function...


You are right, it really isn't. But why would you not use a library that makes that even easier, produces easy to understand code and specialises in element selection and manipulation, which is exactly what was wanted in the first place? I have to admit, i often use JQuery even in places where plain JavaScript would easily suffice, because it is just so powerful and convenient.

I don't know... I think JQuery promotes lazyness and sloppy markup (much like PHP), especially for beginners, by not properly introducing DOM and html/css/javascript. Not knowing the right element to use in your markup is a sign to this.

Take Kentor's markup:
<a href='#' class='spoiler monospace' title='asdf'>+ Show Spoiler [asdf] +</a>
<div class='bbspoiler'>test</div>

This is 'wrong' on a few levels. Firstly, the A shouldn't be an A. It should either be a SPAN, or a DIV. An A is used to redirect to a different page or to an anchor on the same page. Both of these are not used here - instead the A is used only for the onclick event, for which you can easliy use the more appropiate elements. Whenever you find yourself setting the href attribute to "#" and attaching an onclick event, consider using a SPAN or DIV element instead.

Second, for a structured layout, the .bbspoiler DIV should be inside the element that has the onclick event so everything is nicely grouped together. In addition, one might also move the 'Show Spoiler' text into the grouped div.

Here's my version (I had a few spare minutes):
+ Show Spoiler +

<html>
<head>
<title>Toggle</title>
<style>
.spoiler{ background-color: white; width: 600px; }
.spoiler:hover{ cursor: pointer; }
.spoiler > span {color:grey;}
.spoiler > div { border: 1px solid black; display: none; margin: 0 10px 10px 10px; }
</style>
<script type="text/javascript">
function toggle(element)
{
d = element.getElementsByTagName('div')[0];
s = element.getElementsByTagName('span')[0];
title = element.getAttribute('title');
text = "Spoiler ";
if(title !== null)
text += "[" + title + "]";

if(d.style.display === 'block')
{
s.childNodes[0].nodeValue = '+ Show ' + text + ' +';
d.style.display = 'none';
}
else
{
s.childNodes[0].nodeValue = '- Hide ' + text + ' -' ;
d.style.display = 'block';
}
}
</script>
</head>

<body>
<div class='spoiler' title='asdf' onclick="toggle(this)">
<span>+ Show Spoiler [asdf] +</span>
<div>test asdjdsf sdf df </div>
</div>
</body>
</html>


"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
minimat
Profile Blog Joined December 2010
Australia344 Posts
March 14 2012 11:27 GMT
#2479
package
{

import flash.display.MovieClip;


public class mousefollow extends MovieClip
{
var myObject:object

public function mousefollow()
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, followObject)

}
function followObject(event:MouseEvent)
{
object.x = mouseX;
object.y = mouseY;
addChild(object);
}
}

}


Trying to make the mc follow the mouse, anyone know why it isnt working?
Ethenielle
Profile Blog Joined December 2005
Norway1006 Posts
March 14 2012 11:39 GMT
#2480
Not even sure how that runs without any errors? Your (uninitialized)variable is named myObject, yet you try to change the values of "object".

You're not linking that "object" with your movieclip either, so flash has no idea what you're talking about. Usually you give your mc's a custom class, so you want to initialize a variable of that. You don't need to addChild it every time you move the mouse either.
Theres a fine line between fishing and just standing on the shore like an idiot.
Prev 1 122 123 124 125 126 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 9m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft548
SortOf 157
Livibee 115
StarCraft: Brood War
Calm 1737
Horang2 449
Rain 442
Larva 376
JulyZerg 308
Zeus 298
Hm[arnc] 102
Aegong 95
ajuk12(nOOB) 75
Shuttle 74
[ Show more ]
Sharp 47
EffOrt 23
zelot 13
Bale 12
ivOry 10
Dota 2
NeuroSwarm97
League of Legends
JimRising 704
C9.Mang0522
Counter-Strike
shoxiejesuss760
allub126
Super Smash Bros
Mew2King81
Other Games
summit1g10032
Happy34
Organizations
Other Games
gamesdonequick2112
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• Berry_CruncH90
• LUISG 14
• IndyKCrew
• AfreecaTV YouTube
• intothetv
• sooper7s
• Kozan
• Migwel
• LaughNgamezSOOP
• Laughngamez YouTube
StarCraft: Brood War
• iopq 5
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Lourlo1576
• Stunt386
• HappyZerGling156
Upcoming Events
Replay Cast
9m
CranKy Ducklings4
Wardi Open
3h 9m
Monday Night Weeklies
8h 9m
PiGosaur Monday
16h 9m
OSC
1d 2h
The PondCast
2 days
OSC
2 days
Big Brain Bouts
4 days
Serral vs TBD
BSL 21
5 days
BSL 21
6 days
Liquipedia Results

Completed

IPSL Winter 2025-26
SC2 All-Star Inv. 2025
NA Kuram Kup

Ongoing

C-Race Season 1
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
OSC Championship Season 13
Underdog Cup #3
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025

Upcoming

Escore Tournament S1: W5
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Rongyi Cup S3
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.