Welcome Guest, Not a member yet? Register   Sign In
Flash (AS3) execute a controller method
#1

[eluser]jentree[/eluser]
Hello all, I am getting ahead of myself I think. I have embedded a flash movie on my view.
When I click a button, I am calling a method on one of my controllers. (I have shortened my code to save everyone the pain of reading everything)
AS3:
Code:
var url_vars:URLVariables = new URLVariables();
var url_loader:URLLoader = new URLLoader();
var url_requeset:URLRequest;
var url:String = 'http://mysite.com/controller/myfunction';

url_requeset = new URLRequest(url);
url_requeset.method = URLRequestMethod.POST;

url_vars.myvar = myvar;  // this is just an ID that I have assigned to the MC
url_requeset.data = url_vars;    
url_loader.load(url_requeset);

Everything is working fine. Just wanted to show (some) of what I had.

php:
Code:
function myfunction()
{    
    error_log("id from flash: ".$_POST['myvar']);
    
    // query web service and database

    // return results

    $data['main_content'] = 'details';
    $this->load->view('templates/myview', $data);
}

I am able to see in my logs the id that I am passing in. But...that's as far as I get. I would like to load a view, but It seems I am unable to execute the entire method.

Am I getting ahead of myself and I am trying to execute something that just isn't possible? Do I need to look at an ajax approach?

If I use a "normal" html form & submit button, my controller loads everything as expected. So I know it's something to do with how I am using flash and calling the controller.

Has anyone called a method from flash? (which loads a view etc.)

Thank you for your time!
#2

[eluser]jentree[/eluser]
After a days worth of nothing... came across this.
Ajax/CodeIgniter/JQuery

As far as the flash goes, I used ExternalInterface to pass values from flash to javascript.
Code:
if ( ExternalInterface.available )
{
    ExternalInterface.call("myMethod", myParam);
}

Hope this helps anyone who finds this!




Theme © iAndrew 2016 - Forum software by © MyBB