Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Flash 5 Tutorial Seven Page 2

March 25, 2002

When you pass the cookie information from your Flash movie, you will be passing it in pairs. The first part of the pair is the cookie variable name. The second part of the pair is the value of that cookie variable. If you wanted to write a cookie named 'myname' with the value of 'Shawn Ryder' then you would call the cookit function as so: cookit('myname','Shawn Ryder').

Each additional cookie value that you need to write should be passed as an additional pair. Also, due to the ways that different browsers and platforms handle cookies, it is best to pass all your cookie values at once. Just add an additional pair of values when you call the cookit function from your Flash movie. Now you ask, 'how to call the cookit function from Flash?'

There are a number of different types of information that you may want to write as a cookie to be read later. For the sample FLA file included with this tutorial, we are writing two variables to a cookie from the Flash movie. The name blank is written as the txName variable and the txComment variable is for the comment blank. Take a look at the button action on the 'Click to Write Cookies' button. Here is how it is written:

on (release) {
getURL ("javascript:cookit('txComment','" add /:txComment add "')");
}

By calling a URL prefaced by 'JavaScript:' it tells the browser that you are running a JavaScript function. After this you call the cookit function, and then, you pass the variables. The Get URL command enacts the cookit function, and your visitor now has the information written on their computer for you to read next time they visit.

Next we are going to use some aspects of our previous tutorial from a couple of months ago that used the text boxes to display information that was read in using external text files. As you saw it is great for showing information, but now we are going to create a scroll bar so that if there is quite a bit of text read into the file it will allow the user to scroll through the text as we do with any other windows application. I must also say that in the new version of Flash there is the ability to create these scroll bars automatically using simple drag and drop!

Okay, first of all you'll need to make two buttons: up and down. They can be of any shape you want. You may want to give the buttons a big hit area so that the user can be slightly off the button and still be able to scroll. Of course you are going to need to make the text box to store the information, just as the previous tutorial showed.

Finally, place your text box and your two buttons on the main timeline, select everything, and press F8 to convert to a movie clip. Name it 'scroll_box' . Our setup is now done and we are ready to move ahead.

Note the use of onClipEvent(load) here. Everything that is placed inside a load clip event will be executed only once, when the clip is loaded.

Now that this is done, we have to figure out a way to keep track of whether we should scroll the text up or down, or do nothing at all. So we'll add these actions to the buttons:

Up button:

on( press ){
scrolling = "up";
}
on( release, releaseOutside ){
scrolling = 0;
}
Down button:
on( press ){
scrolling = "down";
}
on( release, releaseOutside ){
scrolling = 0;
}

So what's happening here is pretty simple, when one of the buttons is pressed, the variable 'scrolling' is set to 'up' or 'down', depending on the button that is selected. When the button is released, the variable is set to 0, which basically turns the scrolling function off.

We now know where we should scroll, it's time to actually do the scrolling. Dynamic text boxes have two properties called scroll and maxscroll, each of the text lines is numbered, starting with 1. The scroll property is the number of the first line that is shown; you can change its value to get a scrolling effect. Maxscroll is the maximum value of scroll, meaning the total number of lines minus the number of lines shown at once, which can't be set, just read automatically.

Now, we want the scrolling to occur at regular intervals, so we'll have to execute a few lines of code repeatedly, with a certain amount of time in between every execution. To do this, we'll use the useful 'onClipEvent' action. Everything that is inside an enterFrame clip event is executed every single frame of the movie clip.

Flash 5 Tutorial Seven
Flash 5 Tutorial Seven Page 3


Up to => Home / Authoring / Flash / Basic




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers