0 Replies Latest reply on Feb 28, 2012 11:51 PM by VijuSainy

    Calling function of swf in flex mobile (iPhone)


      Hi all,


      I have created a project to run in iOs (iphone).


      I loaded external swf which contain a method firstLoad() . When I run the application in flash builder then every thing works but when I install application in device it do not call the method firstLoad().


      Please all help to resolve this here is the sample code.








                                    private function loadSwfApplication():void


                                              // load the file with URLLoader into a bytearray

                                              var loader:URLLoader=new URLLoader();


                                              // binary format since it a SWF


                                              loader.addEventListener(Event.COMPLETE, onSWFLoaded);


                                              //load the file

                                              loader.load(new URLRequest("swf/funtionDemo.swf"));



                                    private function onSWFLoaded(e:Event):void {

                                              // remove the event

                                              var loader:URLLoader=URLLoader(e.target);

                                              loader.removeEventListener(Event.COMPLETE, onSWFLoaded);


                                              // add an Application context and allow bytecode execution

                                              var context:LoaderContext=new LoaderContext();



                                              // set the new context on SWFLoader

                                              sfwLoader.loaderContext = context;


                                              sfwLoader.addEventListener(Event.COMPLETE, loadComplete);


                                              // load the data from the bytearray




                                    // your load complete function

                                    private function loadComplete(completeEvent:Event):void {

                                              var swfApplication:* = completeEvent.target.content;

                                              swfApplication.firstLoad();  // this is a Function that I made it in the Root

                                              // class of swfApplication








                <s:SWFLoader id="sfwLoader" width="100%" height="100%" />



      Many thanks in advance