views:

21

answers:

1

hi there,

as i am new to javascript with flash. i have a small requirement. like i am currently working on a games website in which whenever i open the game a flash preloader needs to open first and hide the game file while the flash preloader loads. once the flash preloader completes its loading then immediately the game content need to display. i heard it can be done using javascript,ajax. but how to do it? can anyone suggest me. for reference please see the below site: http://www.gamegape.com/en-2095-elemental-battles.html

A: 

You can use the ExternalInterface class to communicate between Flash & Javascript.

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/

      //inside your preloader
      private function loadComplete(event:Event):void
      {
         ExternalInterface.call("nameOfYourJSFunction");
      }
PatrickS
Thanks for your quick response patricks, but can you give me sample javascript code.coz i am a newbie for this flash and javascript world.
phphunger
well i don't know what you want to do. usually this procedure is handled within flash. a preloader movie clip loads another movie clip which is added to the stage as soon as the mc has completed loading. i assumed that for some reason you didn't want to add the loaded movie within the same object and maybe create some new js code for it. In such case , I would suggest to ask a new question aimed at the Javascript guys here. If you don't need the extra JS code, just replace the EInterface call by : addChild(event.currentTarget.content ); and the loaded MovieClip will be added to the stage.
PatrickS