A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Need help with scripting

  1. #1
    Your site goes here RedAbode's Avatar
    Join Date
    Apr 2002
    Posts
    828

    Need help with scripting

    I was thinking of getting into a new part of flash i never really think about too much, but is probaly the biggest part..

    I want to start with scripting.. for my first real scripting.. i want to know if anyone can help me make a simple button and text feild that when u push the button [Generate] it will go 6 12 18 24 ect.. (multipl. of 6)

  2. #2
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi there..

    Here is a very simple button action that will do what you are asking..

    Create a dynamic textfield:
    The variable name of the text field is addMe

    Create a button:
    add code to the button:
    Code:
    on (release){
    	addMe = addMe + 6;
    }
    That will do it.

    Whats happening:

    on the release of the button, the code says that the variable name
    addMe now equals the variable addMe plus 6.

    So each time the button is pushed six is added to the total of the addMe variable..

    Want to remove 6 from the total?
    Code:
    on (release){
    	addMe = addMe - 6;
    }
    Hope it helps...

  3. #3
    Your site goes here RedAbode's Avatar
    Join Date
    Apr 2002
    Posts
    828
    thank you

  4. #4
    Your site goes here RedAbode's Avatar
    Join Date
    Apr 2002
    Posts
    828
    do you know any others u can maybe share?
    Last edited by RedAbode; 10-16-2002 at 09:33 PM.

  5. #5
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Well,
    if you tell me what you need Ill see what I can do..

    Thats just very basic actionscript..
    I suggest picking up a book about actionscript and leafing through it...

    I also suggest reading up on basic javascript and php..

    Go to:
    www.php.net
    for information about php.

    This will help your actionscript abilities a lot..


    3PRIMATES

  6. #6
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hello again..

    I know you said you want to learn actionscript, but Im going to give you a php example to show you how much they look alike.


    The following could all be done in flash, but for simplicity, we will do the same thing that we did in the above post, but using php instead.

    Create your buttons and text field like I described above:
    Replace the button code with this code:
    Code:
    on (release){
    loadVariablesNum ("echoTest.php",0,"POST");
    }
    Now create a blank text file in the same folder as your flash:
    Add this code to the text file:
    PHP Code:
    <?php
    $addMe 
    $addMe +6;
    echo 
    "addMe=$addMe";
    ?>
    Now save your text file as: all files >> echoTest.php

    Upload your new php file and your flash to the same directory on your server and test it by going to your flash page.

    You should see the same result as the previous actionscript example.

    A few things you should know about PHP:

    ** Variables in PHP start with a $ (dollar sign).

    ** Variables passed from flash to PHP are reffered to with a $ (dollar sign).

    ** variables that are going to be returned to flash cannot have a $ (dollar sign).

    ** anything inside of " " is output, no math can be performed inside.

    Example: if I put echo "addMe=$addMe +6";
    what would be returned to the flash text field is:6 +6

    This cannot be tested on your machine unless you are running a server with php.
    In order for this to work PHP must be running on the server you upload this to... Most hosts offer PHP by default, but not all.

    I bet you can now see a few new options opening up for you.
    Using PHP along side Flash and ActionScript is a very good way to learn very quickly about writing code.

    I tried to make this a simple as I could..

    Hope it helps you out some..

    3PRIMATES
    Last edited by 3PRIMATES; 10-17-2002 at 02:08 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center