A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: scripting questions!!!

  1. #1
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549

    scripting questions!!!

    I need to know how to make a wait function in the javascripting, as well as making some thing appear in random places. I'm making a thing where i want an animation that is 20 frames in a 20fps movie to show in 1 place, and then, 1 second later be in 1 other place. The random function just made it rapidly appear on different frames in different places. I need it to go on only the X axis with a 48 x 48 movie.

    I barely know anything about javascript, so I have no clue what many things mean and/or do.


    I also would like to know how to display the percent of the movie loaded...especially as a number. I also would like to know how to display ACTUAL time.

    thanks!!!!

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Here is my functions that You can load into your startup script.

    To use the random number thing you call
    it root.randomRange(0,48) and get a random number between 0 and 48

    You Cannot really "wait" in the action script you'll need to think of another way to do that.


    I'm not sure I really understand what you are describing though.


    /*
    Some Functions for 3dfa Version 4
    written by Bret Lanius
    Free to use anyway you wish
    Please just give credit when you do

    */
    //*************************************
    //simple distance test
    //*************************************
    function distance(element1,element2)
    {
    a=element1.x - element2.x;
    b=element1.y - element2.y;
    return sqrt (a*a+b*b);
    }

    //*************************************
    //Circle Collide uses distance test function
    //*************************************

    function circleCollide(element1,element2)
    {
    //get width of both elements
    width1=(element1.getBounds().xMax-element1.getBounds().xMin)-6
    width2=(element2.getBounds().xMax-element2.getBounds().xMin)-6
    //get distance
    dist=distance(element1,element2);
    //account for different sizes
    width=(width1/2)+(width2/2);
    //check distance and size

    //return t/f
    return dist<=width
    }

    //*************************************
    //Randomrange Function
    //Function to get a range of random numbers
    //*************************************
    function randomRange(Min,Max){
    return random(Max-Min+1)+Min;
    }


    //*************************************
    //Get the Angle for rotation between object and mouse
    //
    //*************************************
    function angleToMouse(myelement)
    {
    angle=atan2((myelement.x-mouseX()),(myelement.y-mouseY()))
    return angle-90
    }

    //*************************************
    //Get the Angle for rotation between two objects
    //
    //*************************************
    function angleTo(myelement,myelement2)
    {
    angle=atan2((myelement.x-myelement2.x),(myelement.y-myelement2.y))
    return angle-90
    }

    //************************************************
    //Pass month from getMonth() and get back a Name
    //************************************************
    function monthName(m){
    monthname=new Array("Jan","Feb","March","April","May","June","Ju ly","Aug","Sept","Oct","Nov","Dec")
    return monthname[m]
    }

    //**************************************************
    //Pass the day from getDay() get back a name
    //**************************************************
    function dayOfWeek(d){
    days=new Array("Monday","Tuesday","Wednesday","Thursday","F riday","Saturday","Sunday")
    return days[d]
    }
    //***********************END************************ ***************

  3. #3
    Senior Member cyber reaper's Avatar
    Join Date
    Apr 2004
    Location
    israel
    Posts
    272
    god , im so happy you hadnt left bret ,hope youll keep an eye on that forum if you will
    ok....what ?

  4. #4
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244


    Hard to totally leave

    To expand on the message about if you want an element to appear to randomly in a 48x48 movie lets say once every 20 frames you use the above script pasted into your starting script

    then create an action, and set it to every 20 frames. For the example I'll assume your element is 5 pixels square.

    in this action you add a script as follows

    NOTE:getBounds returns different values in preview than it does on export, export is correct, preview is too large.
    code:


    boxSize=element("yourelement").getBounds()
    width=boxSize.xMax-xMin
    height=boxSize.yMax-yMin
    element("yourelement).x=root.randomRange(0+width,4 8-width)
    //we adjust for the width so it will always be fully on stage



  5. #5
    Senior Member
    Join Date
    Jan 2003
    Posts
    169
    Well, you HAD to admit to it.

    At least you're still around, even IF on occasion. >>>LOL<<<
    Jeffrey Davis (3DFA user since 2.x... or was it 3.x?) (Yes, I finally reveal the offline identity of JSDvs9172, being myself of course. Oh, and sorry for stealing your signature idea, blanius, which I see you stopped using.)

  6. #6
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    thanks so much!!!!!!!


    my only question now is...how do you display the month, or date, or time (by the way, are the dates and times the same thing as month, just with date and time?) on the screen?

  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    getDate give numerical day number
    getDay gives numerical day of the week
    getSeconds
    getMinutes
    getHours get the time

    simple thing would be to display time
    create editbox with timeNow as variable then in script every frame
    timeNow=getHours()+":"+getMinutes()+":"+getSeconds ()

    you might want to pad with zeros to make it look good.

    then for date you can use my functions above and:
    dateNow=root.dayOfWeek(getDay())+", "+getDate()+" "+root.monthName(getMonth())+" "+getFullYear()

  8. #8
    Senior Member
    Join Date
    May 2002
    Posts
    142
    I too am happy to see that you are still around. Are you also involved using Kool Moves? If so, how does it seem to compare?
    PW Ihms

  9. #9
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    3dfa is much easier to learn and use. And if all the functions worked it would be awesome and I would not be using anything else.

    Koolmoves is a little more flexible but a good deal harder to learn and you MUST learn to do basic scripting to do many things in KM. Once nice aspect of KM is that the AS code is more compatible with AS in Flash MX, not the new AS2.0 unfortunatly.

    There is a lot of scripting going on behind the scenes in 3dfa that makes it easier in many ways. This leads to a little bloat in the final output not not significant in my opinion.

    One of the most frustrating things in KM and Flash is that I'll get an example and it can take an hour or more just to find where the scripting is hiding since it can be in so many different places and refer to code hidden away somewhere else. the way 3dfa has scripts always visible for the most part makes looking over examples much easier.

    The product support over on the KM formun is better as one of the developers is usually answering questions, however I find that the answers are not always very complete and the main posters tend to be a bit short with basic questions.(and a litte grumpy), and all you get here is me and a couple of others

    I have heard a rumbling from down under and there may still be a pulse in 3dfa after all, but I will wait and see with the rest of you.

  10. #10
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    oh and there is an error in my code above move Sunday to the begining of the array in the day of the week function.

  11. #11
    Senior Member zoranvedek's Avatar
    Join Date
    Aug 2001
    Location
    Wagoner OK
    Posts
    893
    Originally posted by blanius
    3dfa is much easier to learn and use. And if all the functions worked it would be awesome and I would not be using anything else..................

    I have heard a rumbling from down under and there may still be a pulse in 3dfa after all, but I will wait and see with the rest of you.


    ...just heard something similiar myself(from a pretty reliable source<---must be lurking around here somewhere ). I think it was to the effect that a new version will be released soon.

    Like you I'm in the 'wait and see' mode.........

    -J

  12. #12
    Senior Member kusco's Avatar
    Join Date
    Nov 2001
    Posts
    681

    Pulse is strong...

    Hello everyone,

    Yes, I've had some contact with Rob and yes there are plans to release another version of 3DFA soon.

    I'll keep you posted with details as I get them too.

    I also told Rob that I would be posting to the forum my one and only victory at winning a game of pool against him....although I strongly suspect he let me win.
    Cheers,
    kusco
    (3DFA Support Team)

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