//

Starcraft 2 is coming out

Starcraft Logo

Thats right, Starcraft II is finally in the works. After almost 10 years after the first release of Starcraft they finally decided to put their act together and get us the new version. Can't Wait!

Link: www.starcraft2.com

//

Dynamic sliders numero 2

Title: Dynamic Sliders Numero 2

After working with the previous version of the sliders -se previous post-. I had the opportunity to "upgrade" the sliders since there was a slight chance that the sliders had to react to only one button rather than two as originally planned. Needless to say it wasn't required to apply this update but it came out nice. Once again there was no need to update anything in the class but just 2 extra lines of code.

//

Dynamic Sliders

So I was working on a project where we needed some sliders, it was basically the same slider but in different sizes and positions. So today I was sitting there just wondering how I could make this more dynamic, and just put a small class together and created a small sample. Updating the sliders the way they were originally created took a long time but allowing the sliders take the parameters dynamically it took seconds to update.

Here is the sample and feel free to play with it :)

//

Actionscript count and trace the number or arguments passed to a function

ActionScript:
  1.  
  2. var totalArgs = arguments.length;
  3. trace("Number of Arguments passed = " + totalArgs);
  4. for (var i:Number = 0; i < totalArgs; i++) {
  5.    trace ("Argument "+i + ": " + arguments[i]);
  6. }
  7.  
//

Actionscript Round and keep decimals function

ActionScript:
  1. function formatDecimals2 (num, digits) {
  2.  
  3. if (num < 0 ) {
  4. num = 0;
  5. }
  6.  
  7. if (digits <= 0) {
  8. return Math.round(num);
  9. }
  10.  
  11. var tenToPower = Math.pow(10, digits);
  12. var cropped = String(Math.round(num * tenToPower) / tenToPower);
  13.  
  14. trace("digits:" + digits + " - " + cropped);
  15.  
  16. }
  17.  
  18. formatDecimals2( 35435.234234, 2);
  19. formatDecimals2( 35435.234234, 3);
  20. formatDecimals2( 35435.234234, 4);
//

We need ability to set multiple Masks

We need the ability to be able to set multiple masks on the fly.

If you do:

mc1.setMask(myMask);

and then you add
mc2.setMask(myMask);

mc1 gets unmasked, of course we can put mc1 and mc2 into one mc and create mc3 then we can mask mc3 as follows

mc3.setMask(myMask);

But I don't want to do it that way, period :)
Now since we are talking about masks, how about allowing us to fade masks? Yes I know that we can't do that right now but hey! wouldn't it be nice if we could do that too?

myMask._alpha = 50;

Well, lets just hope that AS3 brings some of these goodies or maybe Flash9... or Flash10?

//

Delete enhanced fill problem

Thats it! I am tired of getting the "Enhanced fill not supported in current player version" problem when I import fills from AI/FH/FW and you need to export to V7 or under, so once and for all I am putting a stop to it.

Here are 3 simple steps to get rid of this problem (of course this will be applied after you have imported a vector image with gradients to your stage).

1. Change your export settings to V8.
2. Pull the "Color Mixer" Palette.
3. Under Overflow select "Extend", take off the check mark from Linear RGB

That is it now you can change your export settings back to V7 or V6 or under and you should be fine. That is all you have to do and all your problems should go away, no more warnings no more asking you to fix your gradients.

Ah! but sometimes the gradient or Flash will be stubborn and still make fuss about the Fills. Well these are some things you can do..

If under the "Color Mixer" Palette your Overflow was selected as "Extend" and the Linear RGB was unselected, well just select Overflow again and check and uncheck the Linear RGB option. That will fix the stubbornness 99.9999999% of the time.

If you still have troubles after you have completed the steps above feel free to ask.

//

Trace selected text with TextMate

That is right, thanks to the guys from TextMate and their help I was able to get a small Macro that will trace the selected word in Flash.

What I mean is this:

1. Select a word
2. Run the Macro
3. the word you selected will appear in the next line as follows:

trace("the Word You Selected = " + the Word You Selected);

Neat uh?

Bind that to a short cut (in my case CMD-E) and anytime you need to trace a variable or an object you are set to go.

Interested in the macro?

Read the rest of this entry »

//

Complex Array combo

I haven't tested this kind of array usage against the processor so I am not sure how intensive it is but it definitely helps in case you want to keep your arrays very descriptive and you don't want to do a search on the array every-time you need a certain node.

So the regular way of using arrays is:

var myArray:Array = new Array();
myArray.push ("this", "this one", "this two");
myArray.push ("that", "that one", "that two");

so lets say you do a simple trace

trace( myArray);

you get a nice long list with all the items you have pushed into the array ("this,this one,this two,that,that one,that two"). So you want to organize the arrays in a way that you want to access "this one", well you can certainly do

trace(myArray[1]);

now lets try to get "that one"...

trace (myArray[4]);

That is because we know that the position of "that one" is the 4th position in the array. But all of the sudden you are running down your scripts trying to figure out the best way to access the information in your array without having to memorize the position of each of them. So then what do you do? You can create an array for each one of the items you need. like this:

var thisA:Array = new Array();
thisA = ["this one", "this two"];

var thatA:Array = new Array();
thatB = ["that one", "that two"];

Now lets say we need "this one" we can access that value by doing the following:

trace(thisA[0])

That is an easier way to know what we want and now we can refer to each array by their name. But lets pause for a second and think that maybe... MAYBE 3000 lines down your code you find yourself stranded trying to figure out if thisA[0] was "that one" or if it was thisA[1]... so what if we could name each one of those arrays with a specific name that we could remember later....

Hummmm... now we are talking.

lets do the following

var thisA:Array = new Array();
thisA = [{positionone: "this one", positiontwo: "this two"}];

eh?... lets taste it...

trace(thisA[0]["positionone"]);

and it works! So do I mean that if I want to access position two all i have to do is remember the name of the array "thisA" and the name of the value I am trying to access? of course... lets try the secnd one

trace(thisA[0]["positiontwo"]);

Sweet! there you have it, go wild! go crazy in the mean time I will find out how much processor we are eating with this approach.

Read the rest of this entry »

//

Password protected flash site Class

After seeing so many people requesting help with the easy Username and Password method for Flash I decided to write a small class.

Granted UserName and Password verification shouldn't be taken slightly, but many times you just want to make a section of your site "Pass Protected with flash", and in reality this is a very simple verification that should be used against the average joe, not the average geek-joe who knows about flash-deconstruction and such.

So have your Password-Protected flash site in 3 steps;

1. Download the class from here:

2. unzip the files in the directory where you are building your flash movie, so the file structure should look like this:

-root directory
--com
---helmutgranda
----PasswordProtect.as
3. on the root timeline of your flash movie write the following:

ActionScript:
  1. import com.helmutgranda.PasswordProtect;
  2. //(timeline, depth, x position, y position, username, password, gotoAndPlay what? # or label)
  3. PasswordProtect.main(this, 10, 25, 25, "helmut", "granda", 5);
  4.  
  5.  

Please do not write telling me geek-joe was able to break into my site! because this is not a bullet proof password verification, this is just a quick way of keeping the average joe from looking into any "secure" section of your site. I might write a more robust version with some PHP/mySQL/flash combo but for now this will do.