convert PHP button to Flash.
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: convert PHP button to Flash.

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    6

    convert PHP button to Flash.

    Hello,

    Here is my button, which does the "add to cart" function in my web page.
    Problem is that, that I need to make exact button in flash, which does the same thing.
    I would be grateful if someone could help me.

    Sorry for my bad English

    PHP Code:
    <form action="/index.php/sample-sites-2/product/updatecart" method="post" name="hikashop_product_form_2_hikashop_category_information_module_130" enctype="multipart/form-data">
                        <
    div class="hikashop_product_stock">
                        <
    span class="art-button-wrapper"><span class="art-button-l"> </span>
                        <
    span class="art-button-r"> </span>
                        <
    input type="submit" class="btn button hikashop_cart_input_button art-button" name="add" value="Pievienot grozam" onclick="var field=document.getElementById('hikashop_product_quantity_field_1');
                        if(hikashopCheckChangeForm('item','hikashop_product_form_2_hikashop_category_information_module_130'))
                                   { return hikashopModifyQuantity('2',field,1,'hikashop_product_form_2_hikashop_category_information_module_130','cart',130); }
                                   return false;" 
    />
                        </
    span>
                                   <
    input id="hikashop_product_quantity_field_1" type="hidden" value="2" class="hikashop_product_quantity_field" name="quantity" />                
                                   </
    div>
                            <
    input type="hidden" name="hikashop_cart_type_2_130" id="hikashop_cart_type_2_130" value="cart"/>
            <
    input type="hidden" name="product_id" value="2" />
            <
    input type="hidden" name="module_id" value="130" />
            <
    input type="hidden" name="add" value="1"/>
            <
    input type="hidden" name="ctrl" value="product"/>
            <
    input type="hidden" name="task" value="updatecart"/>
            <
    input type="hidden" name="return_url" value="aHR0cDovL2thdGFsb2dzLm5ldDg0Lm5ldC9pbmRleC5waHAvc2FtcGxlLXNpdGVzLTIvY2F0ZWdvcnkvMTItZWluenVnc2thc3Rlbg%3D%3D"/>
        </
    form

  2. #2
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    PHP Code:
    var _lv:LoadVars = new LoadVars();
    //when you click the submit button
    submit_btn.onRelease = function()
    {
        
    //any input variables are added as properties of the LoadVars object
       
        
    _lv.add "Pievienot grozam";
        
    _lv.quantity 2;
        
    _lv.hikashop_cart_type_2_130 "cart";
        
    _lv.product_id 2;
        
    _lv.module_id 130;
        
    _lv.add 1;
        
    _lv.ctrl "product";
        
    _lv.task "updatecart";
        
    _lv.return_url "aHR0cDovL2thdGFsb2dzLm5ldDg0Lm5ldC9pbmRleC5waHAvc2FtcGxlLXNpdGVzLTIvY2F0ZWdvcnkvMTItZWluenVnc2thc3Rlbg%3D%3D"
        

        
    //send info!
        
    _lv.send("http://katalogs.net84.net/index.php/sample-sites-2/product/updatecart""POST");


    I was able to make code, but it still doesn't work.

  3. #3
    _____________ fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    787
    Hi,

    well it takes me to here
    is that what its supposed to do ?

    maybe you are not allowing for same domain in your flash embed code

    <param name="allowScriptAccess" value="sameDomain" />
    Last edited by fruitbeard; 02-21-2013 at 12:09 PM.

  4. #4
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    Hi there, thank you for response.
    It should add product to the basket, but it seems it isn't working.


    I made quick button, just regular square and now it gives me errors:

    Scene 1, Layer 'Layer 1', Frame 1, Line 4 1119: Access of possibly undefined property onRelease through a reference with static type flash.display:SimpleButton.
    Scene 1, Layer 'Layer 1', Frame 1, Line 2 1046: Type was not found or was not a compile-time constant: LoadVars.
    Scene 1, Layer 'Layer 1', Frame 1, Line 2 1180: Call to a possibly undefined method LoadVars.

    But this isn't priority, fact that you were able to run it, but it didn't add product to the cart, there is a mistake in code.
    I'm new at ac, so I don't really understand what I am doing :\
    Last edited by kapis555; 02-21-2013 at 01:00 PM.

  5. #5
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    http://katalogs.net84.net/index.php/...sk=updatecart&return_url=aHR0cDovL2thdGFsb2dzLm5ldDg0Lm5ldC9pbmR leC5waHAvc2FtcGxlLXNpdGVzLTIvY2F0ZWdvcnkvMTItZWlue nVnc2thc3Rlbg%3D%3D
    Okay I was able to put html form in URL, but my flash app is in different location from location where is "add to cart" button, and when I press button with this URl it redirects me to place where my button is, but I need to stay where my flash app is. I tried to put flash app's URL in "return_url" but then i get 404 error.

  6. #6
    _____________ fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    787
    Hi,

    I might be right/wrong in thinking that flash will interpret the url wrongly?

    return_url=aHR0cDovL2thdGFsb2dzLm5ldDg0Lm5ldC9pbmR leC5waHAvc2FtcGxlLXNpdGVzLTIvY2F0ZWdvcnkvMTItZWlue nVnc2thc3Rlbg%3D%3D

    %3D%3D might be read as ==

    so some encoding might be the way to go via your php

  7. #7
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    okay i did some research and I came up with this code:

    PHP Code:
    var submitListener:Object = new Object();
    submitListener.click = function(evt:Object) {
      
        var 
    send_lv:LoadVars = new LoadVars();
         
    send_lv.product_id "2";
        
    send_lv.module_id "130";
        
    send_lv.add "1";
        
    send_lv.ctrl "product";
        
    send_lv.task "updatecart";
        
    send_lv.sendAndLoad("http://katalogs.net84.net/index.php/sample-sites-2/product/updatecart"result_lv"POST");
    };

    submit_button.addEventListener("click"submitListener); 
    I putted it on 1. layer, made simple button with instance name "submit_button", but when I test my scene, nothing happens, when I click on button, even when I upload it to my homepage.

    fruitbeard - I talked to my professor, he said that cURL isn't option, and said to use LoadAndSend function, but he's bussy man so i don't want to disturb him with my problems.
    Last edited by kapis555; 02-23-2013 at 02:22 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

Poll by Flashkit.com