• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:41
CET 11:41
KST 19:41
  • 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
[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy7ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289
Community News
Weekly Cups (March 16-22): herO doubles, Cure surprises3Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool48Weekly Cups (March 9-15): herO, Clem, ByuN win42026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12
StarCraft 2
General
What mix of new & old maps do you want in the next ladder pool? (SC2) Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Weekly Cups (March 16-22): herO doubles, Cure surprises Weekly Cups (August 25-31): Clem's Last Straw? Team Liquid Map Contest #22 - Presented by Monster Energy
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament World University TeamLeague (500$+) | Signups Open RSL Season 4 announced for March-April WardiTV Team League Season 10 KSL Week 87
Strategy
Custom Maps
[M] (2) Frigid Storage Publishing has been re-enabled! [Feb 24th 2026]
External Content
The PondCast: SC2 News & Results Mutation # 518 Radiation Zone Mutation # 517 Distant Threat Mutation # 516 Specter of Death
Brood War
General
RepMastered™: replay sharing and analyzer site mca64Launcher - New Version with StarCraft: Remast ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Soulkey's decision to leave C9
Tourneys
[ASL21] Ro24 Group C [ASL21] Ro24 Group B 2026 Changsha Offline Cup [ASL21] Ro24 Group A
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2
Other Games
General Games
General RTS Discussion Thread Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
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
TL Mafia Community Thread Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Things Aren’t Peaceful in Palestine YouTube Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books Movie Discussion! [Manga] One Piece
Sports
2024 - 2026 Football Thread Cricket [SPORT] Formula 1 Discussion Tokyo Olympics 2021 Thread General nutrition recommendations
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 6011 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
Poland17700 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
Hyrule19197 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
Afreeca Starleague
10:00
Ro24 Group C
hero vs YSC
Larva vs Shine
Afreeca ASL 7672
StarCastTV_EN212
Liquipedia
Replay Cast
09:00
KungFu Cup 2026 Week 1
CranKy Ducklings118
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 128
ProTech122
Rex 0
StarCraft: Brood War
Calm 11187
Sea 8607
Jaedong 2649
Horang2 1415
Mini 918
EffOrt 543
Zeus 445
actioN 357
ZerO 341
Pusan 295
[ Show more ]
ggaemo 193
Mind 119
Leta 108
Last 91
ToSsGirL 74
Backho 63
Sharp 59
Rush 57
Light 53
Aegong 52
Bale 21
Barracks 21
sorry 17
GoRush 17
Terrorterran 14
ajuk12(nOOB) 13
Sacsri 11
Noble 7
Dota 2
BananaSlamJamma513
XaKoH 456
XcaliburYe149
febbydoto5
Counter-Strike
olofmeister1235
shoxiejesuss1208
Other Games
singsing1503
Liquid`RaSZi650
ceh9571
XBOCT273
crisheroes210
Fuzer 134
Sick104
Organizations
Other Games
gamesdonequick747
StarCraft: Brood War
UltimateBattle 253
Dota 2
PGL Dota 2 - Main Stream88
StarCraft: Brood War
lovetv 11
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• StrangeGG 39
• CranKy Ducklings SOOP4
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Upcoming Events
Kung Fu Cup
19m
Replay Cast
13h 19m
KCM Race Survival
22h 19m
The PondCast
23h 19m
WardiTV Team League
1d 1h
OSC
1d 1h
Replay Cast
1d 13h
WardiTV Team League
2 days
RSL Revival
2 days
Cure vs Zoun
herO vs Rogue
WardiTV Team League
3 days
[ Show More ]
Platinum Heroes Events
3 days
BSL
3 days
RSL Revival
3 days
ByuN vs Maru
MaxPax vs TriGGeR
WardiTV Team League
4 days
BSL
4 days
Replay Cast
4 days
Replay Cast
4 days
Afreeca Starleague
4 days
Light vs Calm
Royal vs Mind
Wardi Open
5 days
Monday Night Weeklies
5 days
OSC
5 days
Sparkling Tuna Cup
5 days
Afreeca Starleague
5 days
Rush vs PianO
Flash vs Speed
Replay Cast
6 days
Afreeca Starleague
6 days
BeSt vs Leta
Queen vs Jaedong
Liquipedia Results

Completed

Proleague 2026-03-23
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
BSL Season 22
CSL Elite League 2026
CSL Season 20: Qualifier 1
ASL Season 21
Acropolis #4 - TS6
RSL Revival: Season 4
Nations Cup 2026
NationLESS Cup
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

2026 Changsha Offline CUP
CSL Season 20: Qualifier 2
CSL 2026 SPRING (S20)
Acropolis #4
IPSL Spring 2026
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
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.