Can I put a Javascript link in a flash file?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Can I put a Javascript link in a flash file?

Post by legend986 »

I've designed a small flash menu system. I want some ajax function to be called. I wanted to ask if I can put a <a href="javascript:void()" onClick="function();"/> as the link in that flash file? Will it call the function?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

You can give any link to Flash, but why use AJAX? ActionScript is very similar to JavaScript, and has it's own "AJAX," so to speak.
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

Well, actually there's a flash file and I use Ajax to load content into a div tag. If its just links using HTML, then I can do it.. but if its Flash, i don't know how to do that...
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I'm definitely not understanding what you're doing... Have you tried putting an onclick into it yet?
suthie
Forum Commoner
Posts: 68
Joined: Sat Jun 09, 2007 10:46 am

Post by suthie »

I have never used javascript to do what you are doing... but I have used javascript and flash together many times. In my case, it was just to make popup windows with specified dimensions and such. But anyway, in my experience what works is to define the javascript function in your html page and then call it from flash. Hope that helps.
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

:( yeah I've tried that... Opera gives me the following error:

Code: Select all

JavaScript - http://127.0.0.1/css/index.html
Javascript URL thread: "javascript:void(0)" onclick="sendDetails('home');new Effect.Appear('bodycontent');"
Syntax error while loading: line 1 of unknown script : 
void(0)" onclick="sendDetails('home');new Effect.Appear('bod
PS: One thing is that the Program that I use to actually build this flash file allows me to input only a link. Its something like this:
Enter the URL:____________________________
target = _blank or _parent or _self or _top
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Then there's your answer. Just use links.
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Post by iknownothing »

superdezign wrote:Then there's your answer. Just use links.
Building on that, in your first post you used "javascript:void(0)" as your href, and "function()" as your onClick, as you may have some trouble using onClick within flash you can simply use "javacript:function();" as your href (or URL), if you didnt already know.
User avatar
legend986
Forum Contributor
Posts: 258
Joined: Sun Jul 15, 2007 2:45 pm

Post by legend986 »

I'm done :) I don't know how I missed upon that.. :) Thank you so much everyone...
Post Reply