• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 21:37
CEST 03:37
KST 10:37
  • 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
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
StarCraft II 5.0.15 PTR Patch Notes60BSL 2025 Warsaw LAN + Legends Showmatch0Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8
StarCraft 2
General
StarCraft II 5.0.15 PTR Patch Notes #1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast
Tourneys
SC2's Safe House 2 - October 18 & 19 RSL: Revival, a new crowdfunded tournament series Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
Soulkey on ASL S20 ASL20 General Discussion BW General Discussion ASL TICKET LIVE help! :D NaDa's Body
Tourneys
[ASL20] Ro16 Group D [ASL20] Ro16 Group C Small VOD Thread 2.0 [Megathread] Daily Proleagues
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Borderlands 3 Path of Exile Nintendo Switch Thread General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
UK Politics Mega-thread US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Canadian Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
i'm really bored guys
Peanutsc
I <=> 9
KrillinFromwales
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1930 users

The Big Programming Thread - Page 124

Forum Index > General Forum
Post a Reply
Prev 1 122 123 124 125 126 1031 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
Poland17342 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
Hyrule19087 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 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 8h 23m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft456
RuFF_SC2 120
CosmosSc2 66
Vindicta 22
StarCraft: Brood War
Aegong 1271
Artosis 692
Shuttle 514
Light 123
NaDa 20
ajuk12(nOOB) 11
Dota 2
monkeys_forever864
NeuroSwarm166
Counter-Strike
Stewie2K584
Fnx 387
PGG 72
Super Smash Bros
C9.Mang0373
Mew2King36
Other Games
summit1g7612
shahzam902
JimRising 628
Trikslyr55
ViBE40
Nina20
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• davetesta26
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• RayReign 15
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift4671
Other Games
• Scarra1043
Upcoming Events
RSL Revival
8h 23m
Zoun vs Classic
Map Test Tournament
9h 23m
Korean StarCraft League
1d 1h
BSL Open LAN 2025 - War…
1d 6h
RSL Revival
1d 8h
Reynor vs Cure
BSL Open LAN 2025 - War…
2 days
RSL Revival
2 days
Online Event
2 days
Wardi Open
3 days
Monday Night Weeklies
3 days
[ Show More ]
Sparkling Tuna Cup
4 days
LiuLi Cup
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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 © 2025 TLnet. All Rights Reserved.