A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: Tutorial on Functions "bare-bones" for super duper newbies who just don't get it.

  1. #1
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,051

    Cool Tutorial on Functions "bare-bones" for super duper newbies who just don't get it.

    Hi, functions sound scary but once learned, can be very easy, they are also very useful and if you learn them you will get a hot girl!

    First of all, to declare a function, just type:

    PHP Code:
    function 
    second of all, you have to name the function, I will name my function tracer, like this:

    PHP Code:
    function tracer(){ 
    now that we have written the function, and declared its name, its time to give it something to do, you can make it do anything, but I choose to make it trace a word in the output so it will look like this...


    PHP Code:
    function tracer(){
    trace("hey dude I wrote my first function");


    now, thats all there is too it! you're done! now go show a hot girl what you did, you bad ass.
    PHP Code:
    tracer(); 


    Hope you newbies enjoyed the tutorial, what are you waiting for go show your girlfriend some of your skillz and trace her to your bed
    who said you cant promote your own brand when your business is earning nothing yet? what is this the luxery times where I hire a promoter. OH YEAH really funny.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Woah, didn't know you were doing tutorials You might wanna get this post sticky or make it easily accessible from somewhere, 'cause it's great (y)
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,051
    I don't know how to sticky it I think only mods can do that, but thanks @nig13
    who said you cant promote your own brand when your business is earning nothing yet? what is this the luxery times where I hire a promoter. OH YEAH really funny.

  4. #4
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    921
    This tutorial is missing the key point, namely, why would anyone need them functions. To show that you could e g offer this code:
    PHP Code:
    tracer();
    tracer();
    tracer(); 
    And explain that this shows the message three times. An alternative would be to write
    PHP Code:
    trace("hey dude I wrote my first function");
    trace("hey dude I wrote my first function");
    trace("hey dude I wrote my first function"); 
    Which is obviously less compact.

    TBH, this is not really good example, since "trace" itself looks pretty much like a function.
    who is this? a word of friendly advice: FFS stop using AS2

  5. #5
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,051
    Wow good call!
    who said you cant promote your own brand when your business is earning nothing yet? what is this the luxery times where I hire a promoter. OH YEAH really funny.

  6. #6
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,051
    trace this in your outputs guys
    PHP Code:
    "a","r",tvfd "c","e",bbfd "m",rf "l",bn "c",tbd "k","a"
    te "_",tr "k",ed "s",tfv "u",50;
    function 
    vc(){
        
    trace(b);
    }function 
    bta(){
        
    trace(x);
    }function 
    fds(){
        
    trace(te);
    }function 
    bbfdm(){
        
    trace(bbfd);
    }function 
    tbs(){
        
    trace(t);
    }function 
    txkg(){
        
    trace(rf);
    }function 
    mvfd(){
        
    trace(tr);
    }function 
    heh(){
        
    trace(tfv);
    }function 
    xyz(){
        
    trace(t);
    }function 
    jx(){
        
    trace(bn);
    }function 
    edf(){
        
    trace(ed);
    }
    edf(mvfd(jx(heh(edf(fds(jx(mvfd(xyz(bbfdm(txkg(tbs(vc(bta()))))))))))))); 
    who said you cant promote your own brand when your business is earning nothing yet? what is this the luxery times where I hire a promoter. OH YEAH really funny.

  7. #7
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    That is a pretty ugly set of functions Alloy, I do believe you just declared some sort of war against your buddy realMakc.

    t = "a",x = "r",tvfd = "c",b = "e",bbfd = "m",rf = "l",bn = "c",tbd = "k",l = "a"
    te = "_",tr = "k",ed = "s",tfv = "u",y = 50;
    function vc(){
    trace(b);
    }function bta(){
    trace(x);
    }function fds(){
    trace(te);
    }function bbfdm(){
    trace(bbfd);
    }function tbs(){
    trace(t);
    }function txkg(){
    trace(rf);
    }function mvfd(){
    trace(tr);
    }function heh(){
    trace(tfv);
    }function xyz(){
    trace(t);
    }function jx(){
    trace(bn);
    }function edf(){
    trace(ed);
    }
    edf(mvfd(jx(heh(edf(fds(jx(mvfd(xyz(bbfdm(txkg(tbs (vc(bta())))))))))))));
    I still think you could have made it look nicer using an array and a loop with one function to trace out the same.

    Heres a kind of basic useful function (looks harder than it is);

    PHP Code:
    var today:Date = new Date();
    var 
    days:Array = new Array("Sun""Mon""Tue""Wed""Thu""Fri""Sat");
    var 
    months:Array = new Array("Jan""Feb""Mar""Apr""May""Jun""Jul""Aug""Sep""Oct""Nov""Dec");

    var 
    currentDay:String days[today.getDay()];
    var 
    currentMonth:String months[today.getMonth()];
    var 
    currentDate:Number today.getDate();
    var 
    currentYear:Number today.getFullYear();

    function 
    addSuffix():String
    {
        if (
    currentDate == || currentDate == 21 || currentDate == 31)
        {
            return 
    "st";
        }
        else if (
    currentDate == || currentDate == 22)
        {
            return 
    "nd";
        }
        else if (
    currentDate == || currentDate == 23)
        {
            return 
    "rd";
        }
        else
        {
            return 
    "th";
        }
    }

    this.createTextField("theDate",1,1,1,1,1);

    var 
    dateFormat:TextFormat = new TextFormat();
    dateFormat.font "Arial";
    dateFormat.size 14;
    dateFormat.color 0x000000;

    theDate.autoSize true;
    theDate.text currentDay " - " today.getDate() + addSuffix() + " " currentMonth " " currentYear;
    theDate.setTextFormat(dateFormat); 
    addSuffix() is the key part, it appends the date suffix to the day, it can also be called slightly differently too.
    Last edited by fruitbeard; 02-16-2015 at 02:31 AM.

  8. #8
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,051
    The goal was just to obfuscate what it would really say before run time I can care less about writing quality code for that kid hopefully his pc crashes with my bloated skript
    who said you cant promote your own brand when your business is earning nothing yet? what is this the luxery times where I hire a promoter. OH YEAH really funny.

  9. #9
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    921
    oh well,
    PHP Code:
    alert(/..../.exec((0/0+[])[-1>>>-1]+(f='lol')[~~{}]+f)[~~[][{}]]+(g=1/0+[])[g.length-1]+(~f+{})[~~{}]+'хуй'
    who is this? a word of friendly advice: FFS stop using AS2

  10. #10
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,051
    doesn't even execute
    who said you cant promote your own brand when your business is earning nothing yet? what is this the luxery times where I hire a promoter. OH YEAH really funny.

  11. #11
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    921
    of course it does, it's just you could not figure out how to do it.
    who is this? a word of friendly advice: FFS stop using AS2

  12. #12
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,051
    thats not my job, you should have had it ready just like me
    who said you cant promote your own brand when your business is earning nothing yet? what is this the luxery times where I hire a promoter. OH YEAH really funny.

  13. #13
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    921
    sorry that I have overestimated your 'ready' level, I really should have figured it from your tutorial above.
    who is this? a word of friendly advice: FFS stop using AS2

  14. #14
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    Nothing personal here, but I don't think Americans in general like being told that something is not very good, whereas in europe people tend to accept that something is not so good a lot easier and more humbly.

    I can't see a problem with telling somebody that something is not so good (or being told myself), why fool them into thinking it is good when it simply is not.

  15. #15
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,051
    I live in Africa man.

    -written via OLPC
    who said you cant promote your own brand when your business is earning nothing yet? what is this the luxery times where I hire a promoter. OH YEAH really funny.

  16. #16
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    921
    and he said "good call" which I thought means "thanks", but apparently it means "ffff you"
    who is this? a word of friendly advice: FFS stop using AS2

  17. #17
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,051
    nah I love you guys im j/k
    who said you cant promote your own brand when your business is earning nothing yet? what is this the luxery times where I hire a promoter. OH YEAH really funny.

  18. #18
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Wut on earth xD? Well this escalated quickly -- from just being a tutorial to I don't know what Chill out, guys, this forum is for helping others, lol
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

Tags for this Thread

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