A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Help me remake this mailer feature in Canvas (Adobe Animate)

  1. #1
    Member
    Join Date
    Jun 2006
    Posts
    55

    Help me remake this mailer feature in Canvas (Adobe Animate)

    Many moons later... Izlude rebuilds his flash website on the Canvas, and believe me, this was the biggest headache of the century! It's almost done, I just have 1 thing left... to get the e-card mailing feature working.

    Alright, so I don't know how many of you remember that e-card engine that originated here on flashkit so long ago. It's been a real joy using it and seeing others enjoy it, however this year it all has to change.

    I've been trying to convert this e-card engine to work on the canvas, however I've had no such luck. I do have leads though... first, here's the actual code we've all been accustom to.

    SendEcard php
    PHP Code:
    <? 
    register_globals( 'NGPCFRES' );

    $CreateEcard = date(U); 
    $filename = $CreateEcard.".txt"; 
    $ToEmail = $_POST["ToEmail"]; 
    $FromEmail = $_POST["FromEmail"]; 
    $ToName = $_POST["ToName"]; 
    $FromName = $_POST["FromName"]; 
    $Greeting = $_POST["Greeting"]; 
    $IntroMessage = $_POST["IntroMessage"]; 
    $EndMessage = $_POST["EndMessage"]; 
    $EcardSelect = $_POST["selected"]; 
    $Today = (date ("l dS of F Y ( h:i:s A )",time())); 
    $Created = "Ecard Created on $Today"; 
    $EcardNum = $_POST['EcardSelect'];
    $EcardText = "ToName={$_POST['ToName']}&ToEmail={$_POST['ToEmail']}&FromName={$_POST['FromName']}&FromEmail={$_POST['FromEmail']}&Greeting={$_POST['Greeting']}&IntroMessage={$_POST['IntroMessage']}&Created={$_POST['Created']}&"; 
    $fp = fopen( "dBText/$filename","w"); 
    fwrite($fp, $EcardText, 10000); 
    fclose( $fp ); 
    ######Email Card######## 
    ## You can change the subject and the message part around. 
    ## Make sure to change the Link as stated in the Tutorial. 
    ## (Change from 'someSite' to your actual site - leave the rest the same 
    $ToSubject = "E-card from $FromName"; 
    $Message = "$ToName,\nYou have recieved a Flash E-card from $FromName. \nClick the following link to view your card:\n\n http://www.MYSITE.net/SelectCard.php?EcardText=$CreateEcard&ENum=$EcardNum\n\n-----------------------------------\nHere is the message that was sent:\n$ToName,\n$Greeting\n$IntroMessage\n\n-$FromName\n\n\n-----------------------------------\nThis card was sent by Bunny and Panda\n\nMaking you smile a little more each time."; 

    mail($ToName." <".$ToEmail.">",$ToSubject, $Message, "From: ".$FromName." <".$FromEmail.">"); 

    ## This next line returns a success message to the movie. 
    print "_root.holder.Status=\n Copy the following link to view your card:\n http://www.MYSITE.net/SelectCard.php?EcardText=$CreateEcard%26ENum=$EcardNum\n"; 

    function register_global_array( $sg ) {
        Static $superGlobals    = array(
            'e' => '_ENV'       ,
            'g' => '_GET'       ,
            'p' => '_POST'      ,
            'c' => '_COOKIE'    ,
            'r' => '_REQUEST'   ,
            's' => '_SERVER'    ,
            'f' => '_FILES'     ,
            'n' => '_SESSION'
        );
        Global ${$superGlobals[$sg]};
        foreach( ${$superGlobals[$sg]} as $key => $val ) {
            $GLOBALS[$key]  = $val;
        }
    }
    function register_globals( $order = 'gpc' ) {
        $_SERVER;       //See Note Below
        $_ENV;
        $_REQUEST;
        $order  = str_split( strtolower( $order ) );
        array_map( 'register_global_array' , $order );
    }
    ?>
    In flash, all I would have to do is "loadvariablesnum" function and that's it... piece of cake. Each input textfield in flash had a "variable" and this php read those variables and printed them to the email as well as generated a txt file so that the e-card could also do "loadvariablesnum" and display the values on its dynamic textfields.

    On the canvas, I THINK I have to use ajax or load instead eg:
    Code:
    $.load()
    jQuery.

    I don't know how to this... looking for help! Now also, I'm thinking that I'm going to have to change the php in some ways. Perhaps it's supposed to generate js files instead of txt from now on? And then the e-card will have to load the generated js file "+filename+".js" type deal.. can't seem to get that working either... need help with that too...

    then there's the line:
    Code:
    print "_root.holder.Status=\n Copy the link etc....
    how should this work on the canvas if it's printing to dynamic text field? (no change?) or do you think it should be something like:
    Code:
    print "window.parent.this.Status.text=\n Copy the link etc...
    (i use window.parent because this whole process is all taking place on an iframe)

    And lastly, here's the big one. In flash, the text inputs had variable names that reflect the correct format in the current php. In the canvas, I don't know if I have to change them to reflect how they are in canvas.

    ToName, FromName, ToEmail, Greeting, IntroMessage on the canvas are component input text fields and referenced as:
    Code:
    ($('#IntroMessage')
    so do I have to change the php to reflect this? Basically asking an experienced person to change it up for me... I know I'll screw up.

    I'll only ask that much for now. Once the php actually loads up correctly and sends the email/generates the correct js file, then I'll come back and ask how to make the e-card load the generated js file. Thanks a million everyone!

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,817
    From what I understand, you're probably moving from as2 to as3 which is the problem for trying to use loadvariablesnum. You'll need to use URLLoader instead now. It'll also be handled differently because unlike loadvariablesnum URLLoader is an object, so you'll need a bit additional code to have it interact with everything else. https://help.adobe.com/en_US/FlashPl...URLLoader.html

    If you want more help then I'll need code to work off of. I could probably get this working but I'd have to play with code. If not then I could try making a basic example.
    .

  3. #3
    Member
    Join Date
    Jun 2006
    Posts
    55
    Hi thanks for the reply, also sorry for my late response. I'll also take a look at that link of yours. Thanks for the consideration. Here's a bit of code and references. I hope I'm giving the necessary info here x)

    -My send button
    -SendEcard php (posted already)
    -SelectEcard php (posted below now)

    Send Button:
    Code:
    this.sendbutton.addEventListener('click', bF.bind(this));
    function bF() {
    	if ($('#ToName').val() == "") {
    		this.Status.text = "please enter a to name";
    	} else
    	if ($('#ToEmail').val() == "") {
    		this.Status.text = "please enter a to email";
    	} else
    	if ($('#FromName').val() == "") {
    		this.Status.text = "please enter a from name";
    	} else
    	if (FromEmail = "") {
    		Status = "Please enter your email address";
    	} else
    	if ($('#Greeting').val() == "") {
    		this.Status.text = "please enter a greeting";
    	} else
    	if ($('#IntroMessage').val() == "") {
    		this.Status.text = "please enter a message";
    	} else {
    		this.Status.text = "Sending Ecard - Please Hold";
                    /*actual send function should either go right here,
                        or just on the frame it's about to jump to*/
    		this.gotoAndStop(2);
    	}
    }
    References:
    ToName, FromName, ToEmail, Greeting, and IntroMessage are all component text inputs
    with instance names of the same.

    FromEmail is a dynamic text box with my site's dummy (ecards@mysite) address pre-entered
    and not changeable.

    There's another dynamic text box called EcardSelect. Depending on what card is chosen, that box
    fills with a number that corresponds to the "case" found in the SelectEcard php file (you will see it in the example below).

    I also just added a new component input text field called Grab, and where the SendEcard php was originally supposed to "print" to Status, it should instead print to Grab so users can copy the preview link.


    Alright, so here is the SelectEcard php file's code. It's a shortened version with only 2 case examples.


    PHP Code:
    <HTML>
    <HEAD>

    <TITLE>Here's your Ecard - from Bunny & Panda E-Cards</TITLE>

    <?
    register_globals( 'NGPCFRES' );

    function register_global_array( $sg ) {
        Static $superGlobals    = array(
            'e' => '_ENV'       ,
            'g' => '_GET'       ,
            'p' => '_POST'      ,
            'c' => '_COOKIE'    ,
            'r' => '_REQUEST'   ,
            's' => '_SERVER'    ,
            'f' => '_FILES'     ,
            'n' => '_SESSION'
        );
        Global ${$superGlobals[$sg]};
        foreach( ${$superGlobals[$sg]} as $key => $val ) {
            $GLOBALS[$key]  = $val;
        }
    }
    function register_globals( $order = 'gpc' ) {
        $_SERVER;       //See Note Below
        $_ENV;
        $_REQUEST;
        $order  = str_split( strtolower( $order ) );
        array_map( 'register_global_array' , $order );
    }

    switch ($_GET['ENum']) {

    ## Birthday Cards

        case '1':
        $goto = "ecards/birthdaycards/birthday1.html?EcardText=".$EcardText;
        $Dimensions = "WIDTH=700 HEIGHT=564";
        break;

        case '2':
        $goto = "ecards/birthdaycards/birthday2.html?EcardText=".$EcardText;
        $Dimensions = "WIDTH=700 HEIGHT=564";
        break;

    }

    ?>

    <?php

    $url 
    'http://www.MySite.net/images/wallpaper.png';

    ?>
    </head>

    <body bgcolor="#FFFFFF" topmargin="0" leftmargin="0" rightmargin="0" marginheight="0" marginwidth="0">
    <br>
    <br>
    <br>
    <br>
    <center>
    <OBJECT
     <? print "$Dimensions";?>>
     <PARAM NAME=movie VALUE="<? print "$goto";?>"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="<? print "$goto";?>" quality=high bgcolor=#FFFFFF  <? print "$Dimensions";?></EMBED>
    </OBJECT>
    </center>
    <style type="text/css">
    body
    {
    background-image:url('<?php echo $url ?>');
    }
    </style>
    </BODY>
    </HTML>
    And finally, here's what the e-card used to use to get the values for its "dynamic text fields" of the same names as mentioned above

    Code:
    loadVariablesNum ("http://www.MySite.net/dBText/"+EcardText+".txt", 0);
    Thanks for taking the time to help. I do miss Action Script, but JS really doesn't seem too bad anymore. I'll be so grateful if this final piece of the puzzle is put into place.

  4. #4
    Member
    Join Date
    Jun 2006
    Posts
    55
    Update: Tried a bit of scrounging around how to use urlloader, still no joy -_- i'm bad at this lol. For forum viewers still looking at this topic, yes, I'm still looking for any kind of assistance. If my source FLA files are required, let me know.

  5. #5
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Quote Originally Posted by Izlude View Post
    Update: Tried a bit of scrounging around how to use urlloader, still no joy -_- i'm bad at this lol. For forum viewers still looking at this topic, yes, I'm still looking for any kind of assistance. If my source FLA files are required, let me know.
    What are you doing with the URLLoader?

  6. #6
    Member
    Join Date
    Jun 2006
    Posts
    55
    Hi there, I didn't need urlloader after all, I am indeed done with the bulk of this project. There's literally 1 last tiny tiny tiny bit to fix.... not sure if I should open a new topic, but I'll try here anyway:

    My HTML5 Canvas Animation loads a php file with the following code:

    Code:
        let params = new URLSearchParams(window.location.search);
        let EcardText = params.get("EcardText");
        return $.ajax({
            url: 'http://www.hugclub.net/HTML5/dBText/' + EcardText + '.php',
            type: 'POST',
            error: function () {
                console.log('error');
    Now that code isn't actually finished, I need it to "work together" with the php file that's loaded I think. I want the php to deliver its contents to dynamic text fields in the animation, they have instance names of ToName, FromName, Greeting, IntroMessage. The contents of php test I have is this test format, but so far nothing happens:

    <?
    $ToName = "Test";
    Echo $ToName;
    ?>
    I know I'm supposed to put something in the ajax code, just not sure what...

  7. #7
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    What reply is returned in the php file - is it "Test", or is it blank/not working at all?

    I'm not too sure about HTML5+JSS, and am more experienced with AS3, but it sounds like you need to return a JSON response in the PHP file to your ajax, which you could then use to get the value of the variables. According to the code here, you could use the following in the php file:

    header('Content-type: application/json');
    $data = ["ToName" => "Test", "FromName" => "Test", "Greeting" => "Test", "IntroMessage" => "Test"];
    echo json_encode($data);
    exit();

    Also, what's the point of EcardText? Is it a file that points to the ecard on your server, so that when a user creates an ecard it gets stored as a file? If that's the case, you'd be far better off using a database and a static url (e.g. ".../dbText/get_ecard.php") and passing the name/ID of the ecard as a parameter..

  8. #8
    Member Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    1,087
    You can host it in air as3 as well. Change the php url to your as3 testing air servers ip and port to see how php formatted it and and save the format you recieved to send the same format and nullbytes if any when mailing through an as3 client socket in your browser
    Each time I see a really good bulk deal I should buy, I remind my self my lifes craft from 24. 7'ing is barely worth a word so thats what motivates me to not buy it.

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