Monday, August 17, 2009

The Impossible Magic Trick - Newgrounds


First of all for all of you that haven't seen it yet go check it out on Newgrounds!

This is an interactive magic trick made in Flash CS3. But it is coded in AS2.

This is the spoiler to the trick and how I accesesed your username via Flash.

The Magic trick itself is very easy. The trick starts with 6 Royal cards.

The cards are Queen of Hearts, King of Clubs, Queen of Spades, Jack of Diamonds, Jack of Clubs and King of Diamonds. I ask you to think of a card and press a button to continue.



Then in the second screen I show you 5 cards and claim that I took your card. Which is true! But I also took all the other cards. None of the cards that were in the first screen are shown in the second screen. I only show cards that look the same but are not the same. So there is a 100% chance of success, unless you forget your card.

Now many people have asked about how I pulled up your Newgrounds Gold Account. I was really impressed with the medal system and was just playing around with the HTML and I noticed that Newgrounds automatically uses Flash Vars to import the currently logged on Newgrounds Username. Newgrounds loads the username as the variable 'ng_username' of course since it isn't local you would have to use it as '_root.ng_username'. Please note that if the user is not logged in it would return 'null'. The actual code I used in the 'Impossible Magic Tric' is:


if(_root.ng_username==null)
usernameBox.text = "Dear Guest,";
else
usernameBox.text = "Dear " + _root.ng_username + ",";

For this to work the SWF must be uploaded and shown via Newgrounds, you must have a dynamic text box to display the Username. If the user is not logged in the text box will simply display "Dear Guest,"

There you go! The spoiler to the trick and some code! If you were wondering about how I did my name in the begining feel free to look at one of my earlier posts explaining the "Cool Flash Trick"

If you have any questions or feedback feel free to contact me!





Sunday, May 31, 2009

Free Online Web 2.0 Apps instead of offline expensive apps!

Check out this list of free online applications that can substitute expensive applications that you have to buy and/or download! Here is a list with the normal expensive application and the free online alternative!

Check them out!


Microsoft Office - Google Docs

Microsoft PowerPoint - Preezo

Adobe Photoshop - Splashup

Adobe Illustrator - Aviary

Adobe Flash - Ajax Animator

Instant Messenger Clients - Meebo

Camtasia - ScreenToaster

Windows Movie Maker - Jaycut

Quicken - Mint

Fax Software - FaxZero

Adobe Acrobat - PDF Escape

Saturday, May 30, 2009

Amazing AS2 Effect!!!

Check out this amazing effect!





This is a very simple but effective ActionScript 2 effect. All that we need for this is:
-Flash
-A Name or Text

Not much huh? Well lets get to it!

First start off by making a new file. You can use the default size (550x400) but for a better effect change the background to black. 

Now draw a circle without a boarder. Change the height and width (properties panel) to something like 5px by 5px (that's what I used). 

Convert that circle to a movie clip (F8). It doesn't matter what you call it, don't instance it.

Now select that movie clip with the circle and open up the Actions panel (F9). Once in the actions panel paste this code:

onClipEvent (load) {
x00 = _x;
y00 = _y;
MAAI = 400;}
onClipEvent (enterFrame) {
x0=_x
y0=_y
x=_root._xmouse
y=_root._ymouse
a=x-x0
b=y-y0
r=Math.sqrt(a*a+b*b)

quer_fugir_x=this._x-(a/r)*MAAI/r
quer_fugir_y=this._y-(b/r)*MAAI/r

quer_voltar_x=(x00-x0)/2
quer_voltar_y=(y00-y0)/2

this._x=quer_fugir_x+quer_voltar_x
this._y=quer_fugir_y+quer_voltar_y
}


[Don't paste this or below]
=================================

Now that we have our movie clip with our action script, its time to create our art! (Name or text or drawing or whatever you might think of)

Select your circle and duplicate it (CTRL+D). This may take some time... 

Make your name, a drawing or whatever by duplicating your circles, that way that your actionscript will be on all of them.  When you test your movie (CTRL+ENTER) it should look like mine.

If you don't really get it so well you can download my source code here:

-Pato

Monday, May 18, 2009

HTML/Javascript Trick! Printing Trick!

Does your website contain something that you might want your users to print? Some users might find it hard to print a webpage or image. So with this script you can make it super easy for all of the people that view your webpage to print it. This script will make a Javascript Alert asking the user if they want to print. An example can be found here.

The script is:

 

You can of course change what the alert will say by changing the text in between the quotations.

Friday, May 8, 2009

Newgrounds Username Variable for use in your games/movies!

If you have already published games/movies to newgrounds then this is something that you must add. It makes your games and movies way cooler and look more professional.

Newgrounds just added a function where your .swf file can recognize what user is playing your file.. Newgrounds automatically loads the username into your movie so the only thing you need to do is call it. The variable that NG loads is: _root.ng_username

Note that this only works if the user is logged in. So you have to make an if statement to see if the user is logged in.
An example is:

if (_root.ng_username == null)
{
textBox.text = "Hello there, how are you?";
{
textBox.text = "Hey, " + _root.ng_username + " how are you!";
}
}

This would make the textbox instanced 'textBox' show Hello there, how are you if the user is not logged in and it would show Hey exampleusername, how are you?

Flash Achievments Test

I was surfing the net trying to find good games and noticed that many games now have their own in-game achievement system. So I tried making my own version of achievments... You can try my attempt to make achievments here

What I simply did is I made a movie clip with two dynamic text boxes. And when a user does a specified action it makes the movie clip play and sends two variables to to the text boxes and it makes a movie-clip saying what achievment they did


If you would like the source code or explanation feel free to email me at:

plankenau@gmail.com

Tuesday, April 7, 2009

DANCE!

Make pictures on websites dance! Just make a new bookmarklet and in the page part just paste this code in!

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0);