View Full Version : mx or flash GURU, slacker, AS KING, anybody, a little "COLOR" in your life...!?!
morse
December 10th, 2002, 11:28 PM
Hey folks, just a question about colors. Some guy a while back asking about background color struck me off to experiment... I'm having trouble, ofcourse...
See if the code is legal...
myColor = new Color(MC);//MC is a movie clip instance
Time = new Date();
Hours = Time.getHours();
if (Hours="1") {
myColor.setRGB(0x000066);
} else if (Hours="2") {
myColor.setRGB(0x003366);
} else if (Hours="3") {
myColor.setRGB(0x000099);
} else if (Hours="4") {
myColor.setRGB(0x003399);
} else if (Hours="5") {
myColor.setRGB(0x0033cc);
} else if (Hours="6") {
myColor.setRGB(0x0000ff);
} else if (Hours="7") {
myColor.setRGB(0x0033ff);
} else if (Hours="8") {
myColor.setRGB(0x0066ff);
} else if (Hours="9") {
myColor.setRGB(0x0099ff);
} else if (Hours="10") {
myColor.setRGB(0x00ccff);
} else if (Hours="11") {
myColor.setRGB(0x00ffff);
} else if (Hours="12") {
myColor.setRGB(0x00ffcc);
} else if (Hours="13") {
myColor.setRGB(0x00ff99);
} else if (Hours="14") {
myColor.setRGB(0x00ff66);
} else if (Hours="15") {
myColor.setRGB(0x00ff33);
} else if (Hours="16") {
myColor.setRGB(0x00ff00);
} else if (Hours="17") {
myColor.setRGB(0x00cc33);
} else if (Hours="18") {
myColor.setRGB(0x009966);
} else if (Hours="19") {
myColor.setRGB(0x006666);
} else if (Hours="20") {
myColor.setRGB(0x003366);
} else if (Hours="21") {
myColor.setRGB(0x003333);
} else if (Hours="22") {
myColor.setRGB(0x000033);
} else if (Hours="23") {
myColor.setRGB(0xCCCCCC);
} else if (Hours="24") {
myColor.setRGB(0xCCCCCC);
}
Jubba
December 10th, 2002, 11:31 PM
i would use an array to store the colors and then do something like:
myColor.setRGB(nColor[Hours]);
nColor being the name of the array and Hours being your time variable....It would get rid of all of those if/else statements...
morse
December 11th, 2002, 12:46 AM
Well, I'v never used an array, and the AS dictionary doesn't help much, but is this the right format???
nColor = new Array();
myArray[0] = "0x000066;"
//and so on
morse
December 11th, 2002, 12:55 AM
ok how is this? Remember, its my first array, ever...
myColor = new Color(MC);
Time = new Date();
Hours = Time.getHours();
myColor.setRGB(nColor[Hours]);
//
nColor = new Array();
nColor[0] = "0x000066;";
nColor[1] = "0x003366";
nColor[2] = "0x000099";
nColor[3] = "0x003399";
nColor[4] = "0x003399";
nColor[5] = "0x0000cc";
nColor[6] = "0x0033cc";
nColor[7] = "0x0000ff";
nColor[8] = "0x0033ff";
nColor[9] = "0x0066ff";
nColor[10] = "0x0099ff";
nColor[11] = "0x00ccff";
nColor[12] = "0x00ffff";
nColor[13] = "0x00ffcc";
nColor[14] = "0x00ff99";
nColor[15] = "0x00ff66";
nColor[16] = "0x00ff33";
nColor[17] = "0x00ff00";
nColor[18] = "0x00cc33";
nColor[19] = "0x009966";
nColor[20] = "0x006666";
nColor[21] = "0x003366";
nColor[22] = "0x003333";
nColor[23] = "0x000033";
::edit:: oops i spotted an error myself, a big one lol. Ok, I fixed it. Waddya think?::/::
lostinbeta
December 11th, 2002, 01:20 AM
nColor = new Array();
nColor[0] = 0x000066;
nColor[1] = 0x003366;
nColor[2] = 0x000099;
nColor[3] = 0x003399;
nColor[4] = 0x003399;
nColor[5] = 0x0000cc;
nColor[6] = 0x0033cc;
nColor[7] = 0x0000ff;
nColor[8] = 0x0033ff;
nColor[9] = 0x0066ff;
nColor[10] = 0x0099ff;
nColor[11] = 0x00ccff;
nColor[12] = 0x00ffff;
nColor[13] = 0x00ffcc;
nColor[14] = 0x00ff99;
nColor[15] = 0x00ff66;
nColor[16] = 0x00ff33;
nColor[17] = 0x00ff00;
nColor[18] = 0x00cc33;
nColor[19] = 0x009966;
nColor[20] = 0x006666;
nColor[21] = 0x003366;
nColor[22] = 0x003333;
nColor[23] = 0x000033;
Time = new Date();
myHour = Time.getHours();
myColor = new Color(_root.MC);
myColor.setRGB(nColor[myHour]);
morse
December 11th, 2002, 01:22 AM
I think they both work...
morse
December 11th, 2002, 01:23 AM
Lost's is easier to understand, though.
morse
December 11th, 2002, 01:41 AM
Here is a product... Come back on the hour, and the color should change a little bit... :) Hope it works, have fun!
P.S. Thanks to <img src="http://8ballcreations.com/lostinbeta/images/lostinbetasmiley.gif"> Lost for a tad of help :)
morse
December 11th, 2002, 01:52 AM
well, a tad more than a tad lol.
Jubba
December 11th, 2002, 03:12 AM
You could also do this and only write nColor twice:
nColor = new Array()
nColor = ["0x000066","0x003399", etc etc etc]
pom
December 11th, 2002, 06:36 AM
Or once:
nColor = ["0x000066","0x003399",...]; pom :crazy:
Jubba
December 11th, 2002, 10:10 AM
I don't know why, but I like to define it as a new Array.
Makes me feel smart or stupid or something...not sure.
:P:P:P:P:P:P
lostinbeta
December 11th, 2002, 02:06 PM
Yeah, I knew you could do that....
But for editing by time... I think it would be a lot easier to edit if you do it the original way I did it.
In case you need to change the colors, that way you don't have to sit there and count each out until you get to where you want.
For the record... I do it Ilyas' way usually.
myArray = [0,1,2,3,4,5,6,7,8,9]
Jubba
December 11th, 2002, 02:26 PM
LiB: For the record :P
lol, I always define my variable as a new Array, helps me to remember while cruising through my code...
lostinbeta
December 11th, 2002, 02:38 PM
I was saying anything about your method Jubba. If it works, use it. I was just stating that I don't usually define my arrays the way I did for the code for morse.
alethos
December 11th, 2002, 02:42 PM
Ok I always have trouble with this, so if someone can help me out I'd appreciate it. If you don't think this is appopriate to your thread, Morse, just say so and I'll start a new one.
You guys are saying that you can declare an array and populate it simply by saying:
myArray = [a, b, c, d];
My question is, are square brackets used only in arrays? In other words, using the square brackets automatically states that myArray is a new Array() object?
Also, does anybody know if Flash lets you name your array elements? I forget what the term for this is (referential array? damn, can't remember), but it's when instead of referencing an array element like myArray[6], you can say myArray["age"] and that element would have the age of a person, for example.
-Al
lostinbeta
December 11th, 2002, 02:54 PM
Yes I do believe square brackets define arrays.
What I am wondering about that is if things like _root["ball"+i] constitutes as an array though.... not sure.
As for targeting a specific spot... Try something like this...
myArray = [];
myArray[0] = {realName:"Shane", age:"18", forumName:"Lostinbeta"};
trace(myArray[0].realName);
trace(myArray[0].forumName);
trace(myArray[0].age);
Note: The array is purposely out of order of the trace so you can see it doesn't just go in order.
Also Note: Don't blame me if the code doesn't work, it is untested.
pom
December 11th, 2002, 03:05 PM
Well yeah, _root["blabla"] constitutes an array, an array that contains everything that's in your _root.
And I think you're talking about associative arrays, Al: http://www.kirupaforum.com/showthread.php?s=&threadid=313
pom :crazy:
lostinbeta
December 11th, 2002, 03:47 PM
Ah, that is some cool stuff in that thread :)
Thanks for that link Ilyas.
alethos
December 11th, 2002, 03:50 PM
Thank you Ilyas, that's the stuff. :)
_root["movie"+i] acts as a pointer I think. But then again, I think I read somewhere that arrays ARE pointers.
pom
December 11th, 2002, 03:52 PM
Do you mean pointers like in C language?
lostinbeta
December 11th, 2002, 03:52 PM
I need to learn more about Arrays. I started a while ago, only did a little bit with it, then stopped for some reason.
I have no clue why I stopped, I just did. Time to start again, I am so far behind on my AS it is ridiculous.
alethos
December 11th, 2002, 05:41 PM
Yeah, pointers as in *p and stuff. Never mind, it's not important.
Marz
December 12th, 2002, 01:09 AM
Let's see.. C++.. Very cool language.. *p is a pointer that relays straight from the memory block... This is good for when you have programs that you wanna define a variable for use in all your C++ functions without that typical work bullcrpa that sdome of you know...
As for arrays.. They are extremely powerful when used right... I wonder if they have 3d arrays in FLash though..
Like..
apples[10][10];
Basically gives you a 10 x 10 block to work with.. Now that's ncie :-D hehehe
Marz
ahmed
December 12th, 2002, 02:11 AM
yep, ActionScript too does have multi-dimensional arrays:beam:
i got this quote tho over from a tutorial....
Actionscript, like Javascript, doesn't "officially" support multidimensional arrays. However, both languages DO allow you to simulate multidimensional arrays by letting you create "arrays of objects" and those objects themselves can be Arrays.
pom
December 12th, 2002, 09:19 AM
Originally posted by alethos
Yeah, pointers as in *p and stuff. Never mind, it's not important. Well, it can act as references more than pointers.
pom :crazy:
morse
December 12th, 2002, 04:29 PM
Hey, I got an unrelated question... What is i, i+, i++, and i<= ?
Jubba
December 12th, 2002, 05:50 PM
i is just a variable. The operators after it do different things.
i+ means you are going to add something to i "i + 10"
i++ increments the value of i, raises it by 1 each time that line of code is accessed. this is the same as "i = i + 1"
i<= means i is less than or equal to something "i <= 10"
alethos
December 12th, 2002, 06:51 PM
And just in case you see any of the following (which are very commonly used); keep in mind that you can substitute any variable for "i"...people just use "i" cause it stands for integer:
++i For all your intents and purposes, this is the same as i++
i+=10 (or any number) This is the same as saying i = i + 10. Similarly, i-=10 is the same as i = i - 10.
!= This means "does not equal". It's used in conditional statements (like If...Then).
>= Is "greater than or equal too".
lostinbeta
December 12th, 2002, 06:55 PM
Also for future reference.... i is the same as j, and j is the same as i.
Usually if the variable i is already used, the next letter after that would be j
abcdefgh<B>ij</B>klmnopqrstuvwxyz
Then of course some people just keep going down the line if they need more variables.
since i is just a variable, you could even call it iamyou if you wanted, but it is easier to type out i...lol.
Sorry, I really felt like babbling, but not the random thread spam kind of babble..... so don't mind me :beam:
pom
December 12th, 2002, 07:15 PM
Originally posted by alethos
++i For all your intents and purposes, this is the same as i++Well, not really. ++i is pre-incrementation, i++ is post-incrementation. To see the difference:
a=5;
trace (a++);
trace (++a);pom :)
morse
December 12th, 2002, 08:14 PM
Lost, I sure don't mind.
And pom, you always make us find stuff out for ourselves!!!:)
lostinbeta
December 12th, 2002, 08:15 PM
Finding out for yourself is the most effective way to learn :)
I am speaking from experience.
It is like.... stick your finger in an electrical socket.... it hurts right? Well, now you know not to do it again because you know exactly how it feels. You learn from your own experience :)
morse
December 12th, 2002, 08:41 PM
lol, fine with me to learn myself. And lol I never stuck my finger in a socket or plug, they always scared me when I was little. I stayed away :) (-:
alethos
December 12th, 2002, 08:50 PM
I was elecrto-electro-electro-electro-electro-electro-electro-electro-electrocuted once. 220V AC...it didn't hurt, but it felt....wrong.
Jubba
December 12th, 2002, 09:03 PM
yes. having a lot of electricity surging thru your body definately feels wrong...
::shudders::
morse
December 12th, 2002, 09:43 PM
:)
Could you guys figure what the HE [double hockey sticks] is wrong with this??? It seems fine to me...
_root.thing1.useHandCursor = false;
_root.thing1.hitArea = _root.hit;
_root.thing1.onRollOver = function() {
//_root.thing1.gotoAndPlay(1);
_root.thing1.play();
};
_root.thing1.onRollOut = function() {
_root.thing1.gotoAndPlay(53);
};
_root.thing1.onRelease = function() {
getURL("http://www.geocities.com/h4xx02");
};
When I rollOver, NOTHING happens.
morse
December 12th, 2002, 10:23 PM
Yea guys (and kit) I know its totally :crazy: but it doesnt work. I dunno why.
lostinbeta
December 12th, 2002, 10:36 PM
Why don't you just put this on your movie clip (thing1)?
on (rollOver) {
this.gotoAndPlay(1);
}
on (rollOut) {
this.gotoAndPlay(53);
}
on (release) {
getURL("http://www.geocities.com/h4xx02");
}
Movie Clips in Flash MX allow on handlers as well.
morse
December 12th, 2002, 11:16 PM
Yea, that what I thought, but I always get a blablabla about handlers only on buttons, so, until recently, I thought you couldn't. Maybe I have to re-install...
Thanks though Lost :)
lostinbeta
December 12th, 2002, 11:56 PM
In your publish settings make sure you are set to export to Flash 6.
If this is set to Flash 5 or below, then Flash MX syntax will not work.
morse
December 13th, 2002, 12:54 AM
Hymmm... I'm having trouble.... I'm gunna PM you ok?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.