• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 23:10
CEST 05:10
KST 12:10
  • 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
[ASL22] Ro8 Preview: In A Tizzy5[ASL22] Ro16 Preview: Holy Diver5[ASL22] Ro16 Preview: Rough Waters10[ASL22] Ro24 Preview: Siren's Call8[ASL22] Ro24 Preview: Summer's End9
Community News
BSL Season 234Weekly Cups (Sep 7-12): SHIN, ByuN, MaxPax double down1StarCraft open world shooter announced at BlizzCon101Weekly Cups (Aug 30-Sep 7): herO thrives amid growing schism10Official StarCraft website teases new content ahead of BlizzCon?179
StarCraft 2
General
Balance hotfix patch 5.0.16b (July 16) StarCraft open world shooter announced at BlizzCon SC4ALL II: StarCraft 2 Player Announcement 8/8 The Death of Cheese: From a Professional Cheeser Yamato Cup Series
Tourneys
2026 GSTL Announcement Sparkling Tuna Cup - Weekly Open Tournament RSL Revival: Season 6 - Qualifiers and Main Event RSL goes to London! 2026 Offline Finals Nov 21-22 SC2 AI Tournament 2026 Fall
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
Mutation # 544 Double Trouble The PondCast: SC2 News & Results Mutation # 543 Enhanced Defenses Mutation # 542 The Ascended
Brood War
General
[ASL22] Ro8 Preview: In A Tizzy an AI researcher's take on the ladder bot Syncronization issues and can't find games BSL Season 23 Bot on ladder
Tourneys
[ASL22] Ro8 Day 1 [BSL23] SM: Ret vs TerrOr -> DragOn vs StRyKeR [Megathread] Daily Proleagues [ASL22] Ro16 Group D
Strategy
Cliff Jump Revisited (1 in a 1000 strategy) Replay Review Process - What do you do? Simple Questions, Simple Answers Odyssey Mineral Stack Saturation
Other Games
General Games
Nintendo Switch Thread Warcraft III: The Frozen Throne Stormgate/Frost Giant Megathread EVE Corporation Diablo IV
Dota 2
Dota 2 Champions League Season 3 Begins April 25! Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine All you football fans (soccer)! Russo-Ukrainian War Thread Canadian Politics Mega-thread
Fan Clubs
MarineLorD Fan Club The Creator Fan Club The ShoWTimE Fan Club
Media & Entertainment
Movie Discussion! [Manga] One Piece Diablo Animated Series on Netflix
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Gaming Intensity, Problemati…
TrAiDoS
38 yo Retired SWE loo…
PurE)Rabbit-SF
Can Bots Beat Pros?? Starcr…
namkraft
[meme] I finally understa…
LUCKY_NOOB
Regacy Esports:Our Goa…
regacyesports
Dreaming of BW patches (mod…
c3rberUs
Customize Sidebar...

Website Feedback

Closed Threads



Active: 12158 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
Poland17843 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
Hyrule19257 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
Replay Cast
00:00
2026 GSTL: Playoffs Round 2
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft511
RuFF_SC2 195
StarCraft: Brood War
Britney 14075
Rain 2176
GuemChi 1539
Dota 2
monkeys_forever345
NeuroSwarm183
League of Legends
Doublelift5632
Counter-Strike
taco 380
Super Smash Bros
hungrybox623
amsayoshi81
Heroes of the Storm
Khaldor196
Other Games
JimRising 691
Maynarde199
Livibee133
ViBE57
Mew2King37
[ Show 13 non-featured ]
StarCraft 2
• Hupsaiya 99
• mYiSmile15
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• masondota21805
League of Legends
• Lourlo328
Other Games
• Scarra1133
Upcoming Events
Afreeca Starleague
6h 50m
Shine vs Rush
WardiTV Weekly
7h 50m
Monday Night Weeklies
12h 50m
Sparkling Tuna Cup
1d 6h
Afreeca Starleague
1d 6h
Light vs EffOrt
OSC
1d 8h
PiGosaur Cup
1d 20h
Kung Fu Cup
2 days
The PondCast
3 days
Replay Cast
3 days
[ Show More ]
Korean StarCraft League
5 days
CranKy Ducklings
5 days
GSL
6 days
Yamato Cup
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Super Anchor Qualifying S3
Blizzard Classic Cup 2026
Big Dog Cup 2026 Div 1

Ongoing

ASL Season 22
CSL 2026 AUTUMN (S22)
Acropolis #5
Acropolis #5 - GSA
Calamity Invitational
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026

Upcoming

Acropolis #5 - GSB
Acropolis #5 - GSC
BSL Season 23
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Copium Cup
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
Stake Ranked Episode 5
PGL Masters Bucharest 2026
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #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.