Groups | Blog | Home
all groups > flash actionscript > august 2006 >

flash actionscript : Button click loads a new URL...HOW?


RSHerhuth
8/15/2006 4:32:47 PM
Sorry for the basic question but I am trying to get this Flash app done.

I have a button on the main timeline. I want to have the button cause a new
page to load in the current window. I tried this, but it didn't work...what is
the correct syntax to make this happen?

Thanks!
Ron

on (press)
{
_url = "EmployerSolutions_Main.aspx"
}
funkysoul
8/15/2006 4:39:01 PM
Give your button an unique instancename and on the root timeline put this code:

buttonName.onPress = function(){
getURL=("http://youradress.com","_self");
}
RSHerhuth
8/15/2006 5:13:18 PM
When i added the code you suggested I get the following error:
"**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 3: Type mismatch in
assignment statement: found String where Function is required.
getURL=("BusinessOpportunities_Main.aspx","_self");

Total ActionScript Errors: 1 Reported Errors: 1"



Code added to the main timeLine:
_btninstance1.onPress = function(){

getURL=("BusinessOpportunities_Main.aspx","_self");
}

Thanks!
Ron

Mr Helpy mcHelpson
8/15/2006 6:21:46 PM
just an extra = in there you don't need. getURL() is a function, so you just
need....

getURL("BusinessOpportunities_Main.aspx","_self");

I tend to use the onRelease instead of the onPress, (but it really doesn't
matter that much)...

_btninstance1.onRlease = function() {
getURL("BusinessOpportunities_Main.aspx","_self");
}
RSHerhuth
8/15/2006 6:34:52 PM
It still doesn't work. I replaced the code on the main timeline to:

_level0._btninstance1.onRelease = function(){

getURL("http://www.timeplus.com/BusinessOpportunities_Main.aspx","_self");
}

_level0._btninstance2.onRelease = function(){

getURL("http://www.timeplus.com/BusinessOpportunities_Main.aspx","_self");
}

_level0._btninstance3.onRelease = function(){

getURL("http://www.timeplus.com/BusinessOpportunities_Main.aspx","_self");
}

_level0._btninstance4.onRelease = function(){

getURL("http://www.timeplus.com/BusinessOpportunities_Main.aspx","_self");
}

_level0._btninstance5.onRelease = function(){

getURL("http://www.timeplus.com/BusinessOpportunities_Main.aspx","_self");
}

I click on the buttons but nothing happens.

Ron
Mr Helpy mcHelpson
8/15/2006 6:47:26 PM
whoops!!! typo on my part first of all.... onRelease = instead of onRlease.
But alas, you did that already.

Second, are you publishing preview in html, or in the flash player. When I
use

_btninstance1.onRelease = function() {
getURL("BusinessOpportunities_Main.aspx","_self");
}

it works, but it needs to be viewed in a browser, not the flash stand-alone.
nearestexit
8/15/2006 7:27:32 PM
RSHerhuth,

AddThis Social Bookmark Button