Tuesday, January 30, 2007

[Flash] Simple navigation

Simple navigation using Flash

SWF (preview)
.FLA (click to download)

Start making three keyframes.

Put this stop script into each frame(select the frame and press F9 twice) :

stop();

Now make som content in each frame, for example:

write "Page1", "Page2" and "Page3" in frame 1,2,3.

Create a new button, Insert>New symbol, choose "button", and name it "next".

Create another one, and name it "prev".
Make a new layer and name it buttons(place it over the content layer, so the buttons don't disappear behind the content)
Open the library (Ctrl + L), and drag the buttons to the frames like this:
Frame 1 - Next button
Frame 2 - Next & Prev button
Frame 3 - Prev button


Frame1

Frame2


Frame3

Insert this code into the next buttons:

on(press){
nextFrame();
}
And this into the prev buttons:
on(press){
prevFrame();
}
Test your movie, and we are done! =)
The codes:
on(press){
}
This means that when you press the button, everything between { and } will happen.
Also try with on(release), on(rollOver)... =)
nextFrame();

Means that the movie will go to next frame.
And I don't think you need an explanation of the prevFrame(); code =D
djodin

Thursday, January 25, 2007

[Flash] Create a Passwordsystem UPDATED!

Create a simple Passwordsystem in Flash

-Download .fla HERE
-Click HERE to see the .swf
(username: user password: pass)

Make a New Flash Document,
insert two keyframes, and place this code into both of them:

stop();

Now, select the first keyframe and
make a input textfield, open the properties(F9), and do like this:

Text Type : Input Text
Text Font/Size/Color : Verdana / 10 / black
Var : username
Line Type : Singel line
And select " show border around text"

Make another:



Text Type : Input Text
Text Font/Size/Color : Verdana / 10 / black
Var : pw Line Type : Password
And select " show border around text"


Now, make a dynamic text field and set the var. to "error" :

Ok, now draw a button like this:

Select it, press F8, choose button and name it submit.







Goto frame two on the main stage and write something like "secret stuff",
go back to frame one and select the button, now press F9 twice and paste this code into it:

on(press){
var msg:String = "Wrong password and/or username";
if(_root.username == "user" && _root.pw == "pass"){

gotoAndPlay(2);
}
else{
output =(msg);
}
}


Now your username is "user" and your password is "pass",
press Ctrl+Enter to test! =D

You can also create a button to clear all text fields,
just paste this code into it:

on(release){
_root.output = "";
_root.pw = "";
_root.usern = "";
}

That's all! Enjoy your password protection! =D
Remember that this is NOT very safe! so don't use it to protect important stuff!


UPDATE!

If you right-click and select play, you will go to nextframe(the "protected" one), to remove this menu:

Open your .fla, go to File>Publish Settings, select the HTML tab and
deselect "display menu".
Now, press publish and you will get a html file in the save directory.
Open this and the menu are gone ;)

[Flash] Moving a MovieClip

The Basic of moving a movieclip

-Download the .fla HERE!

-Click HERE! to see the .swf

Create a New Flash Document,
Select the first keyframe and press F9 twice to open the Actions, and insert this code:


stop();

This will stop the movie on the selected frame.


Now, draw something like this:

Press Ctrl+A to select it, and press F8.


Name it "man" and choose "movieclip".





Done?
Ok, now select your movieclip and open the Properties (press F9),
and set the instance name to "man".





Then, press F9 again to view Actions,
and insert this code into the movieclip:

onClipEvent(enterFrame){


if(Key.isDown(Key.RIGHT)){
this._x += 5;
this._xscale = 100;
}


if(Key.isDown(Key.LEFT)){
this._x -= 5;
this._xscale = -100;
}


if(Key.isDown(Key.UP)){
this._y -= 5;
}



if(Key.isDown(Key.DOWN)){
this._y += 5;
}

}


Now, press Ctrl+Enter to test your movie!

To make it move smoother,
click anywhere on the grey area, press F9 to open the properties and set the Frame rate to about 30 fps ;)


Here`s a explanation of the codes:


onClipEvent(enterFrame){
This means that everything between { and } runs every time it goes to a new frame.

if(Key.isDown(Key.RIGHT)){
this._x += 5;
If the Right key is down, the movieclip will move +5 X.




and when the Left key is down, the movie clip will move -5 X, and +&- Y when the Up and Down keys are down.

this._xscale = -100;

This means that the movieclip will be scaled -100 X.

That`s all! :D