Member Avatar for Moirae

Hello everyone!
I'm making some rollover buttons in flash, and I could use some help. I have this button that has text on it e.g home, contact and stuff like that, and I would like to make this text an hyperlink. I couldn't find a tutorial for this :( .
Could you give me a hint, because I'm a bit stuck and deadline is near :'(

I'll attach the looks of the button (in OVER state).

P.s. I tried getURL but it doesn't work (or I didn't use it properly).
Thanks ;)
Cheers!

Member Avatar for iamthwee

Well what version of flash are you using?

What version of actionscript are you using?

Member Avatar for Moirae

Hi, I'm using Adobe Flash CS3 Professional with AS 3.0. Is that O.K.?

Member Avatar for Moirae

Thanks a lot, I will try it and let you know if i managed ;)

Member Avatar for rajarajan2017

I assumed that your button name as homeBTN and add the code in the timeline actions.

homeBTN.addEventListener(MouseEvent.CLICK,TestURL);

function TestURL(e:MouseEvent):void
{
	var serverpath:String="http://www.yahoomail.com";
	var urlrequest:URLRequest=new URLRequest(serverpath);
	navigateToURL(urlrequest,"_self");
}

You can use _blank instead of _self to open in new window.

Hope this helps!

Member Avatar for Moirae

Great stuff rajarajan, you helped me so much!!! iamthwee your linked also helped very much, thank you ;)

I assumed that your button name as homeBTN and add the code in the timeline actions.

homeBTN.addEventListener(MouseEvent.CLICK,TestURL);

function TestURL(e:MouseEvent):void
{
	var serverpath:String="http://www.yahoomail.com";
	var urlrequest:URLRequest=new URLRequest(serverpath);
	navigateToURL(urlrequest,"_self");
}

You can use _blank instead of _self to open in new window.

Hope this helps!

thanks for sharing nice code it help me lot

Member Avatar for Moirae

Oh, I noticed one thing - _self doesn't work in my case, only _blank, i tried _parent and _top also but only _blank seems to work, any ideas why??

Member Avatar for rajarajan2017

Are you checked with the browser or from flash?

Member Avatar for Moirae

If I check from Flash it opens in new window (tab) never mind what i wrote, but when I check in browser only _blank works

Member Avatar for rajarajan2017

Notice whether you used double quotes

Member Avatar for Moirae

I just C/P your example and rearranged link to work in my case, everything else is same as yours

Member Avatar for rajarajan2017

I checked twice, it is working for me. Something going wrong, please check with both "" and without "". Ensure you given _ (underscore) before self.

Member Avatar for Moirae

If I check from Flash it opens in new window (tab) never mind what i wrote, but when I check in browser only _blank works

So after some time I figured that it should be tested on someone else's computer so in the end it seems that I had some problems with Flash, I reinstalled it and it all works great now. Thanks!!

a query, now that the q is solved, I couldnt asnwer it so didnt waste anyones time
How big is the flash for this menu, in KB, ?

Member Avatar for Moirae

7.75 KB is the biggest button :)

7kb for 1 4state button, thats much less than thought,
but more than a css button, thats 125 bytes,
flash buttons look so good though
daydream, doodle, think,

can flash buttons be reused, same 'swf(?)' flash file different parameters

Member Avatar for Moirae

I think it cannot be reused in a way you described (not sure). CSS buttons are really cool I have to admit but if you have a page that is really boring (because user likes the boring colors e.g.) then I think it's good to break through the boring part with some extra buttons, that's why I used Flash :)

Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.