Old 04-06-2007, 16:19   #1 (permalink)
Dirti
Professional Idiot
 
Dirti's Avatar
 
Join Date: Aug 2006
Location: Uk
Posts: 59
CS3 geturl buttons

I'm trying to get a button to link to a url in a new window and I keep getting syntax errors etc etc, I'm using:

mybutton.onRelease = function() {
getURL("http://www.adobe.com", "_blank", "GET");
};



"mybutton" is the symbols name.

I get the following error:

"Access of undefined property mybutton"
"call to a possibly undefined method getURL"

what the fucks wrong? I've defined mybutton and what not
  Reply With Quote
Old 05-06-2007, 02:21   #2 (permalink)
Tanel
Registered User
 
Join Date: Jan 2007
Posts: 28
Is this button inside some other mc? if yes then you need to use this code
_root.othermc.mybutton.onRelease = function() {
getURL("http://www.adobe.com", "_blank", "GET");
};
  Reply With Quote
Old 05-06-2007, 02:29   #3 (permalink)
Larixk
Senior Member
 
Larixk's Avatar
 
Join Date: Sep 2006
Location: Utrecht, Netherlands
Posts: 1,028
Send a message via MSN to Larixk
are you trying to compile AS2 as AS3?
  Reply With Quote
Old 05-06-2007, 04:24   #4 (permalink)
Dirti
Professional Idiot
 
Dirti's Avatar
 
Join Date: Aug 2006
Location: Uk
Posts: 59
It's AS3 and it's inside another mc. When I try that code I get the following error:

1087: Syntax error: extra characters found after end of program.
  Reply With Quote
Old 05-06-2007, 09:15   #5 (permalink)
Larixk
Senior Member
 
Larixk's Avatar
 
Join Date: Sep 2006
Location: Utrecht, Netherlands
Posts: 1,028
Send a message via MSN to Larixk
that means you've closed more brackets than you've opened.

It's not AS3 by the way:
You can't use onRelease in AS3 anymore. It's all eventDispatcher now.
Neither can you use getURL in AS3, it's URLRequest now.

Perhaps you're better off compiling it as AS2
  Reply With Quote
Old 05-06-2007, 13:49   #6 (permalink)
Dirti
Professional Idiot
 
Dirti's Avatar
 
Join Date: Aug 2006
Location: Uk
Posts: 59
Could you post the basic AS3 code just to link to a web url with a target as _blank in a stand alone file not embeded in another or anything fancy?


edit: ok got this out of the adobe documentation:

function gotoAdobeSite(event:MouseEvent):void
{
var adobeURL:URLRequest = new URLRequest("http://www.adobe.com/");
navigateToURL(adobeURL);
}

mybutton.addEventListener(MouseEvent.CLICK, gotoAdobeSite);



but i get the following error:

1120: Access of undefined property mybutton.


Why the fuck is it so difficult to make a basic link!?!

Last edited by Dirti : 05-06-2007 at 13:59.
  Reply With Quote
Old 05-06-2007, 14:34   #7 (permalink)
Larixk
Senior Member
 
Larixk's Avatar
 
Join Date: Sep 2006
Location: Utrecht, Netherlands
Posts: 1,028
Send a message via MSN to Larixk
did you give your button the right instance variable?
  Reply With Quote
Old 05-06-2007, 17:44   #8 (permalink)
Dirti
Professional Idiot
 
Dirti's Avatar
 
Join Date: Aug 2006
Location: Uk
Posts: 59
Don't think so, how do I do that?
  Reply With Quote
Old 05-06-2007, 18:24   #9 (permalink)
Larixk
Senior Member
 
Larixk's Avatar
 
Join Date: Sep 2006
Location: Utrecht, Netherlands
Posts: 1,028
Send a message via MSN to Larixk
properties window in flash/
The correct name would be "mybutton" in this case(without the quotation marks)
  Reply With Quote
Old 21-06-2007, 15:37   #10 (permalink)
isagooddaytodie
Registered User
 
Join Date: Jun 2007
Posts: 1
correction and step by step instruction

In reply to Dirti's comments,

URLRequest is an object,
where as getURL is a function.
navigateToURL() is the current getURL() which takes an URLRequest object instead of strings.

1. first create the button

2. then rename the button under properties tab of your property box usually located lower part of your screen on a Mac OS. Windows.... been so long i don't even remember.

3. then in the actionscript of the **current frame**, not the button object, you input:

function gotoAdobeSite(event:MouseEvent):void
{
var adobeURL:URLRequest = new URLRequest("Enter your URL here");
navigateToURL(adobeURL);
}

mybutton.addEventListener(MouseEvent.CLICK, gotoAdobeSite);

Where as "gotoAdobesite" is your event function, you can name it anything really instead of "gotoAdobesite", Just have to change them at both instances on the code above.

"mybutton" is the the name you assigned to the button in step 2.

You can directly create an object when you using navigateToURL functin like this:

navigateToURL(new URLRequest("Enter your URL here"));

which will replace:

var adobeURL:URLRequest = new URLRequest("Enter your URL here");
navigateToURL(adobeURL);

the fucntionality and steps are almost exactly the same in both causes, except first one have no referrence to the object created and save a few sec of typing hehe.

If you want to do more funky stuff, I would suggest googling "navigateToURL" and "URLRequest"

The new actionscript is basically java in my opinion hehe.

Happy coding folks,

ZW
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8