hide side navigation
    5 most recent
    Web Services
    Library's
    Component's
    Applications
  Tree menu  Flex 2 Guestbook  Videobox  Simple mp3 player  Videoroom  Moving menu  Flash db board reader  Simple photo gallery  Simplecart and External Interface  Email in Flash II  Photo and Video gallery  New Store  Flash GuestBook V2  Flash-db Miniboard  ActionScript dictionary  Private chat with FlashCom  Flash Whois  An online store  Flash RSS reader  Net Tools - Whois in Flash  Flash Message Board  Flash GuestBook  Email in Flash  Sending Custom Ecards  Simple Live Counter with PHP
    Articles
Current Page (1) Next Page >>  View Article Example >> 1 | 2

Structure of movie

Details

Checkbox


a checkbox, or actually any kind of toggle button, can be built as a movieclip with two frames, showing the off and on states. Both frames will hace a
stop();

action. For a checkbox, both frames need to act as buttons. The button script is

 on(release) {
    
play();
    
_parent[this.name] = 'on';

for the first frame (clicking turns on) and

 on(release) {
    
play();
    
_parent[this.name] = '';

for the second frame. A property name set on the movieclip specifies the variable to set.

Here, the checkbox has an instance name cb1, and the varname is set to exist from frame action in the mailform clip

cb1.name = 'exist';

Radiobutton group

this is an empty movieclip with just a bit of actionscript as a frame action:

 function clicked(ob) {
    for(var 
j in this)
        if(
typeof(this[j]) == 'movieclip')
            if(
this[j] == ob)
            {    
ob.gotoAndStop(2);
                
_parent[this.name] = ob.value;
            }
            else
                
this[j].gotoAndStop(1);
}
// initilize
for(var j in data.btns)
{    
this[j].value data.btns[j];
}
if(
typeof(data.init) != 'undefined')
    
click(this[data.init]) 

In plain words: check all movieclips in the carrier - these are the radiobuttons. The one just clicked will change to frame 2 (on state) while all others will go to frame 1. Additionally, a varable defined by the carrier's name property will be set to the clicked button's value property
The mailform clip sets data for the radiocarrier (instance name rg1) as an object

rg1.data = {name:'recip',btns:{btn1:'support',btn2:'account'},init:'btn1'};

The initialize code inside the radiocarrier sets the values for the individual radiobuttons, which need to have instance names (here they are just btn1 and btn2) and sets the name item to the varname (in radiocarrier's parent, that is the mailform; the name used here is recip)
Additionally, the data may specify the name of one button as "init" - when the movie loads, a call to the click function will check this button and also set the variable.

Radiobutton

Send button

There are two similar versions of the button script

Flash 5 Style

MX style

the F5 variant requires that an empty clip (named data) is added (to the mailform clip)  
 on(release) {
    
data.name name;
    
date.email email;
    
data.message message;
    
data.recip recip;
    
data.exist exist;
    
data.loadVariables('mail.php''POST');
 on(release) {
    
mylv = new LoadVars();
    
myreply = new LoadVars();
    
mylv.name name;
    
mylv.email email;
    
mylv.message message;
    
mylv.recip recip;
    
mylv.exist exist;
    
myreply.onLoad = function(success)
    {    if(
success)
            
_parent.status this.status;
        else
            
_parent.status 'could not connect server';
    };
    
mylv.sendAndLoad('mail.php'myreply'POST');

Sending clip

Where players 6 and up have a nice way to perform some actions after a server call completes, there are a few - not so good - ways to achieve the same thing for flash 5. One way is to put this code

 onClipEvent(data) {
    
_parent._parent.status this.data;
}}

            

on the data clip. It is called in the context of the data clip, so the mailform is its _parent, and the status line is in the mailform's _parent.

Comment: it should be quite clear that the loadvars object is pretty much the same as the older empty movieclip used as a data abject

Current Page (1) Next Page >> 1 | 2