# Calling flash function from javascript?

**URL:** <https://forum.kirupa.com/t/calling-flash-function-from-javascript/265537>\
**Category:** web dev\
**Created:** [July 10, 2008, 12:27am UTC](https://forum.kirupa.com/t/calling-flash-function-from-javascript/265537 "2008-07-10T00:27:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LSX\_438](https://avatars.discourse-cdn.com/v4/letter/l/8dc957/32.png) [@LSX\_438](https://forum.kirupa.com/u/LSX_438)\
**Post date:** [July 10, 2008, 12:27am UTC](https://forum.kirupa.com/t/calling-flash-function-from-javascript/265537/1 "2008-07-10T00:27:45Z")

</div>

[SIZE=2]I am buiding a script to screen scrape a website. [/SIZE]

[SIZE=2]The website in question has a FLASH login screen & I need to automate the login process.[/SIZE]

[SIZE=2]- I have been able to use the .SetVariable function (via client javascript) to set the username and password.[/SIZE]

[SIZE=2](I downloaded the SWF and used a component to extract the code, see variable names etc).[/SIZE]

[SIZE=2]However I now need to automate the button click (to “sign in”) on the same flash object.[/SIZE]  
[SIZE=2]My question therefore is: can I use a client side javascript method to execute a function in the flash object? I’ve tried tried something like this:[/SIZE]

[SIZE=2]var oFlash = document.getElementById(“movie”);[/SIZE]  
[SIZE=2]oFlash.SetVariable(“input1.text”, “username”);[/SIZE]  
[SIZE=2]oFlash.SetVariable(“input2.text”, “password”);[/SIZE]  
[SIZE=2]**oFlash.accountService.login();**[/SIZE]

[SIZE=2]- login() being a declared function in the flash file, called when the “button” is clicked. [/SIZE]

[SIZE=2]The variables/input box values seem to be set ok, but it is failing on the “login()” call.[/SIZE]  
[SIZE=2]I’ve tried searching far and wide; there is code suggesting this should work, but I just get an error **“login is null or not an object”** [/SIZE]

[SIZE=2]I must be missing something fundamental, about calling certain functions etc.[/SIZE]

[SIZE=2]Oh and btw, I can call oFlash.Play(), which seems to be working fine??[/SIZE]

[SIZE=2]Any ideas?[/SIZE]

[SIZE=2]thanks![/SIZE]

---

<div class="post-metadata">

**Author:** ![borrob](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@borrob](https://forum.kirupa.com/u/borrob)\
**Post date:** [July 10, 2008, 6:50am UTC](https://forum.kirupa.com/t/calling-flash-function-from-javascript/265537/2 "2008-07-10T06:50:19Z")

</div>

Yes i think you can only call standard commands from javascript ,

see:  
[http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash\_07.html](http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_07.html)

what you could do is call a specific frame in the movie where the function that you want to use resides and call  
the gotoframe function from javascript.

---

<div class="post-metadata">

**Author:** ![LSX\_438](https://avatars.discourse-cdn.com/v4/letter/l/8dc957/32.png) [@LSX\_438](https://forum.kirupa.com/u/LSX_438)\
**Post date:** [July 10, 2008, 9:14am UTC](https://forum.kirupa.com/t/calling-flash-function-from-javascript/265537/3 "2008-07-10T09:14:41Z")

</div>

thanks for the reply.

I see there are the following functions i can call

GotoFrame  
TCallFrame  
TCallLabel  
TGotoFrame  
TGotoLabel

Should i be using these to work out what part of the code to call and do that?
