Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 ViewsThat's strange, when I use getAlphaBounds in AS2 I see there's no such function. What values do the traces return? The closest I could come up to was getBounds, and that returns an Object with properties xMax, xMin, yMax and yMin.
Alternatively, is getAlphaBounds a custom function? If so, what's the code for it?
At 10/16/14 12:23 PM, Aprime wrote: I've actually got the child in a movieclip called contents. So my addChild was contents.addChild
For the code above, I only change it to contents.removeChild(loaders[index]) ?
Yes :)
I've tried this, and it does not remove the child. Any idea?
Hmm, is contents on the stage? Like
stage.addChild(contents)
? What does tracing loaders[index] return?
At 10/16/14 12:08 AM, gearsofwhore wrote: I say if the people support it then who cares? Ive heard of people getting stung with bees and acupuncture. If it makes them feel better than who are we to stop it? It may be a placebo effect but as long as it is helping patients and not harming them then I say fuck it let the treatments roll on!
Except for patients with treatable ailments such as cancer that worsen over time (without treatment) and the placebo effect does jack shit to combat it. I've heard Steve Jobs being quoted as an example: had a treatable form of pancreatic cancer, stopped surgery and had a year (?) of alternative therapy and then it had become worse.
At 10/16/14 08:06 AM, Aprime wrote:At 10/16/14 06:53 AM, Gimmick wrote: Yes, that's correct -- that's because an Array contains type Object (which AFAIK the type is looked up at runtime) and so the array is a collection of items. Same for Vectors, but it contains type <T> (where T is some type, e.g. Loaders, Sprites, Object -- which would be redundant, but still Objects -- or any class, even custom ones). Array and Vector don't have anything defined as "removeChild", so you can't call Array.removeChild() and removeChild accepts only DisplayObjects as parameters, not arrays or anything else. It throws an error because there's no reasonable conversion to DisplayObject, even if it contains DisplayObjects.Thanks, this is very helpful :D
Getting it's index sounds great!
You could have a function that searches for a Loader which has a particular URL loaded and get THAT only, but it's cumbersome compared to getting its index.
If you can get the property of an object and then loop through the array and see whether there's an object with a matching property, and return that object's index (usually in the loop), then such a search function is easy to implement.
Sorry, but how do I apply this to remove the contents?
function getElementAt(index:uint):Object {
return (loaders+index);
removeChild(loaders+index);
}
Please let me know.
OK. Um, there's a problem with that code -- I shouldn't have done it like that. Thing is, that's not really AS3 code that fits the purpose -- I intended that to be more like pseudocode. That function returns an int, actually (if loaders could be converted to an int; since it can't in reality, that code would throw an error) which technically is an Object, but nvm that.
It's not
(loaders+index)
since you can't perform addition operations on an array. It'd be more like
loaders[index]
where loaders is the Array or Vector.
detailed rant/explanation coming up, skip if you want to
This would be an example of what happens when you use the "array index access operator"; in your case, it's loaders[index]:
function getElementAt(index:uint):T
{
return the element that is stored at position index
}
=> this is roughly what happens behind the scenes whenever you do array[i]: a function akin to getElementAt is called, with i as the parameter for index, and gets the instance of type T as a return value; if i is equal to 102, then:
var loader:Loader = array[i]
==> equal to array[102]
==> behind the scenes...
====> is 102 a uint? //it's a number. What type is it? It can either be Number, int or uint
====> Not explicitly specified. //because 102 is not a variable; if you passed a variable of type uint, then there's no conversion
====> Convert "102" to a uint //conversion's possible
====> Success! //you can think of it as a temporary variable of type uint with the value 102
======> array.getElementAt(102 as uint) // getElementAt(index) -> index is 102
=======> this searches for the element at position 102 and returns it
======> gets some object (since it's an array); it's a loader! // getElementAt(index) : T -> T is Loader
======> returns that object //a loader
=====> loader is of type Loader; the object is also a loader! No need for conversion
====> loader is now synonymous with the object (careful here; changing the object loader will _also_ change the loader in the array. It is not a "copy" of the object. That's where some special functions like clone() come in)
==> removeChild(loader)
===> what's loader? Extends DisplayObject? OK
===> does it have a parent / is it on the stage? Yes? Then...
===> loader is removed from the stage
==> what next? :D
But to answer your question directly, you were close -- just have to use the array index access operator; since your array has only loaders, I'll assume T is a Loader:
function getElementAtAndRemoveChild(index:uint): Loader //because it's easier to understand
{
removeChild(loaders[index])
return loaders[index]
}
Side note: Why do I have "return loaders[index]" after "removeChild(loaders[index])"? Surely code execution order wouldn't matter much when the lines are unrelated?
Not when it concerns a "return" or a "break" statement. In a function or in any loop, the "break" statement stops code execution and goes "out" of the loop or function. A "continue" statement would skip the code execution beyond that point and then increase i (in a for loop), or do nothing to the update condition on its own (in a while loop).
Thus, AFAIK, if you have "return loaders[index]" before "removeChild(loaders[index])", then the child wouldn't get removed at all.
If you want to show one at a time, you'd have to have an enterframe event and increment it manually.Yup, that's the plan. I'll probably have to remove them prior to adding new ones?
Not really, you can add all of them without removing any of them if you like. If you want to create a slideshow like effect, i.e. one where you only see one at a time, then you'll have to remove the previous one and add the new one; if you want to create a layering effect, i.e. the image slowly builds up over time, then there's no need to. Alternatively, if it's like a comic strip, where some speech bubbles appear and disappear over time, then you can remove some and add some, and leave the others as they are (on the stage / off the stage), provided you have their indexes. It's up to you.
You've been extremely helpful, thank you for taking the time to help!
You're welcome! Glad to help.
At 10/15/14 06:20 AM, halfblue3 wrote: that warning is already gone. now my game runs slowly again. but not from the start. it slows down the character gets near the item to be collected. inside those item is a bubble image that is used as background for the items description. i remember seeing something that says you need to parse the image to speed up the game. please tell me how do i do that or other alternatives.
cacheAsBitmap? In the image's properties or the movieclip's properties, select Cache as Bitmap or set its cacheAsBitmap property to true. Don't know if it will work, though, since images don't need to be cached as bitmap and will usually just increase the memory usage and not significantly increase performance.
At 10/16/14 06:26 AM, Aprime wrote: I've noticed that for remove child one does not simply add removeChild(loaders);
They must specify which item in the array they are referring to.
Yes, that's correct -- that's because an Array contains type Object (which AFAIK the type is looked up at runtime) and so the array is a collection of items. Same for Vectors, but it contains type <T> (where T is some type, e.g. Loaders, Sprites, Object -- which would be redundant, but still Objects -- or any class, even custom ones). Array and Vector don't have anything defined as "removeChild", so you can't call Array.removeChild() and removeChild accepts only DisplayObjects as parameters, not arrays or anything else. It throws an error because there's no reasonable conversion to DisplayObject, even if it contains DisplayObjects.
Scripting languages and computers in general are good and bad like that: they can't infer anything. Good in case you don't want unexpected things to happen, bad since it has to be spoonfed everything.
Is it not possible to remove it regardless of the number so you don't need to specify it.
I don't understand what you mean but I'll give it a shot. I assume you want an explanation?
Well, it's like a table -- if I have to remove a record from the table, I'll need to know which record to choose. If I'm told to remove the fifth record, then I can remove it. If no fifth record exists, then I'll complain because there's something wrong. The index access operator, [], retrieves an instance in the Array/Vector and returns it to the user. It's a syntactic sugar version of a function that does that for you:
function getElementAt(index:uint):Object
{
return (somename+index)
}
Not exactly the best example, but you get the idea -- somewhere in the class there's an object with somename and index, like obj1, obj2, ..., obj4000, and then if you specify 3, it returns obj3.
You could have a function that searches for a Loader which has a particular URL loaded and get THAT only, but it's cumbersome compared to getting its index. This example is unoptimized, but sorta like this:
function getLoaderWithURL(searchURL:String):Loader
{
for(var i:uint = 0; i < loaders.length; ++i)
{
if(loaders[i].url == searchURL)
{
return loaders[i];
}
}
//because function always has to return a value
return null;
}
If all else fails, I could just have [aNumber] like this, and remove that. Then have aNumber++ to add the new child.
Like this?
removeChild(loaders[aNumber])
and
addChild(loaders[aNumber++])
?
It's better to do ++aNumber because then it'll increment aNumber and then return the instance at aNumber; aNumber++ (post-increment) would return the instance at aNumber, and then increment aNumber; in essence, you'd have removed and added the same child. You could have aNumber++ on a separate/previous line, though.
Or maybe I don't need to remove and add child and just replace. What do I know?
I don't know how well that'd turn out.
for(var i:uint = 0; i < loaders.length; ++i)So would this add several childs in one go?
{
addChild(loaders[i]);
}
Yes, it would. It wouldn't add one child, reload the screen, add another, reload the screen and so on, because all the code in the for loop is executed, and then the frame is rendered. If you want to show one at a time, you'd have to have an enterframe event and increment it manually.
At 10/16/14 02:45 AM, yurgenburgen wrote:At 10/16/14 02:45 AM, Gimmick wrote: Woah shiznits, what's fps like when you play gamesidk I just put everything on max settings
So. Much. Jellyous.
I get 18 fps max on some new games (I can't play most of them at all) on low settings.
At 10/16/14 12:35 AM, WahyaRanger wrote:At 10/15/14 10:49 PM, Gimmick wrote: Snort lactose powder or something first.I never got notified that you replied to me. Strange.
I didn't reply to you directly, I just wrote "At <sometime>, WahyahRanger wrote:" and then saw your name didn't have an extra h in it, and re-edited it back to WahyaRanger. Maybe that's why...
Regardless it's not me, I don't even smoke weed. I feel like this kid is going to end up in prison one day which is a shame because he could go far in life if he stopped being a fuckwit...
Yeah Ik it's not you. If he's a gullible guy, tell him that all drugs are like most meat, they taste like chicken
At 10/16/14 12:14 AM, yurgenburgen wrote: it's this one
Woah shiznits, what's fps like when you play games
Not very feasible. The ebolavirus cannot survive for very long, if at all, outside a host.
At 10/15/14 11:28 PM, tailsbuddy wrote: But still ,if any of you are interested in Eastern medicine, check this out.
Ayurveda > Eastern medicine
Hello, I'm crazy pop-eyed brace-teeth theft guy, today at Alberta Security College I'll be teaching you on how to not get mugged.
At 10/15/14 10:57 PM, Sword-of-Kings wrote: >>25265034
>2014
>using Windows
Hah. Join the free software open source Linux master race.
Moar like "no software Linux pleb race"
Which place is this in?
How do you feel about dying?
What was the crime?
Is this real? Or is this a complicated plan to leave Newgrounds?
Also, do an AMA or something on someplace more active like Reddit where many more people'll respond before your execution.
At 10/15/14 10:53 PM, KillerSkull wrote:At 10/15/14 10:17 PM, Gimmick wrote: Also lol wtf is that gif fromThis video...
Gotta love NAVY EOD
Thanks!
At 10/15/14 10:16 PM, Suprememessage wrote: Pepsi.
1v1 me Coke.
At 10/15/14 10:51 PM, Head-Full-Of-Acid wrote: http://www.newgrounds.com/dump
i'm sure Tom appreciates people usin the grounds for their me mes
I'm envious of y'all with them fancy-schmancy "high bandwidth caps" that you could reupload gifs somewhere for the sake of it and download it each and every time you want to watch it on a whim.
At 10/15/14 10:32 PM, Sword-of-Kings wrote:At 10/15/14 10:23 PM, retro-704 wrote: Point is, and im asking from everyone, what are your friends like age wise? and do you experience the feelings i have.Back when I did have friends in 2006-2009, they were all around my age because they were all in the same grade as me.
My friends in school were all at least a year older than me because I was in the same grade as them.
At 9/9/99 9:59 PM, WahyaRanger wrote: cocaine
Snort lactose powder or something first.
At 10/15/14 10:13 PM, Xenomit wrote:At 10/15/14 10:08 PM, Gimmick wrote: I thought I was the only one.But I've got so many glorious gifs that I want to see on impulse
Suck it (up)? I don't really open gifs apart from inside browsers tbh.
Open them in Chrome, or convert them all to WebM or some other video format if you really want to, then.
Or downgrade to Win XP. It worked for me when I was using XP.
Also lol wtf is that gif from
Nobody said cum? What's wrong with General?
But seriously I usually drink tea and water, currently water.
At 10/8/14 07:08 PM, Lich wrote: Spicy Chai Tea with a small bit of Caramel Syrup in.
Essay Chai Tea.
Run the full test and see the CPU field. Mine's an Intel Core 2 Duo T6400 (bought in 2009), and it's supposed to be about 1217, but after a few years of degradation, it's down to 987. Or maybe mine was always that way. IDK.
Edit: this is when an edit button is useful, an extra "s" at the end of the domain leads to a fuckin parked page.
I thought I was the only one.
Suck it (up)? I don't really open gifs apart from inside browsers tbh.
At 10/15/14 11:54 AM, Aprime wrote:So:Hmmm, I've applied this now and I've added:
var loaders:Array = new Array();
for (var i:uint = 0; i < numberOfImages; i++)
{
var loader:Loader = new Loader();
loader.load(new URLRequest(blah[i]));
loaders.push(loader);
}
Now all of your loaders are in your loaders array, you have access to them later.
addChild(loaders[1])
but this doesn't work
Do you see at least one item on the stage? Because what you're doing is accessing the second element and passing that as a parameter to addChild. Not sure if typo or not, but if it's
addChild(loaders[1])
then it'll only add that one to stage; there should be another for loop and addChild through that, i.e.
for(var i:uint = 0; i < loaders.length; ++i)
{
addChild(loaders[i]);
}
As a sidenote, it's usually better to name the arrays longer, a single letter difference can make things confusing.
Vectors are also faster than Arrays, better if you're storing things that are only of 1 type (in this case, only Loaders)
Cashew nuts and raisins for me too. If it isn't a vegetable, it shouldn't belong in a meal.
except for tomatoes.
Also: LOL at plebs who receive a rather delicious meal at <some place> and proceed to douse the entire thing in ketchup / hot sauce / whatever else.
No, but I've a feeling I perforated my ear drum. Feel like going to the ENT clinic, but at the same time too lazy to. Maybe it'll heal on its own quickly.
10-year old me was the equivalent of typical 13-year olds here. (I signed up when I was 10 heh)
As everyone, I'm ashamed of my past posts. Feel free to peruse them, but you'd just be wasting your time.
At 10/15/14 01:51 PM, WahyaRanger wrote:At 10/15/14 01:46 PM, Monster-64 wrote: Or I'll just piss on a bear in hibernation. I mean, I live next to Big Bear, where there's apparently thousands of bears everywhere.Make sure you bring a GoPro. I want a fully documented record of your mutilation.
As if his piss is warm enough to wake up a hibernating bear.
Nope, never. Not after all they've done for me. Not in the slightest.
At 10/15/14 11:23 AM, Satan wrote: From what I remember one - two character domains tend to cost more than a solid gold yacht.
Ones that are reserved. It may be possible to backorder them, though. Or search for some domain that doesn't have it reserved.
All 1 to 2 letter CO domains are reserved, by the CO registry itself. Whoop-de-fuck. Also: parked domains "courtesy <hosting site>".