-
Button URL actionscript?
Hey all,
New to the sites here. I know this is a very basic generic newbie question i'm sure has been answered a million times but I'm kind of in a hurry and need a quick answer.
I'm new to flash 8, and only know a little from the days of flash 4. Back then i remember there was an option or field on a button that would set the URL the button linked to. Now I'm told you have to insert the actionscript for the URL. I think its geturl, but after plugging in various values I still am getting errors.
What is the EXACT syntax, or piece of code to say link to...
/index.aspx
In the same window, in otherwords _self. Also where should I have this actionscript? On the button "click area" layer?
Thanks. Seems it used to be easier, but maybe its just me.
-
ahhh, the memories .....flash 4 .... tell target
-
Locate the button clip. Right click on it > Actions (unless actions is already open then just left click)
Type into actions
on(press){
getURL("/index.php",_self);
}
Or you could do it on the main timeline
buttonInstanceName.onPress = function(){
getURL("/index.php",self);
}
replacing buttonInstanceName with whatever you named your button instance
-
Thanks very much for your help.
One quick thing...does it make a difference which way i do it? For example, if I put it in the main timeline will that affect loading, or allow for people to click the button before the animation is finished or something?
Ideally if that were the case, I'd like to have the option to let people internally who browse the site alot to be able to click the buttons quicker.
Either way, I can at least get it working for my meeting with the boss today.
-
FK's Official Mac Hater
There is no difference. Some people prefer to hav all of their scripts on the main timeline while some prefer to put everything on the object that it belongs to. I usually put everything on the object that it belongs to but by puting it on the main timeline you always know exactly where all of you scripts are going to be.
Jason L. Wright
I'm not that hard to imitate. Just make some random negative claim at Apple or anything else for that matter and then have nothing to back it up.
-
Flash, Mans greatest invention
correct 2.0 sytax as follows
button.onRelease = function ():Void{
getURL("http://www.yoursite.com/", _self);
}
in action script 2.0 all script should be placed on the main timeline its bad 2.0 pratice to place it on buttons and things.
-
FK's Official Mac Hater
Who says that it is bad syntax to place your code on the button?
Jason L. Wright
I'm not that hard to imitate. Just make some random negative claim at Apple or anything else for that matter and then have nothing to back it up.
-
Originally Posted by Dragonusthei
correct 2.0 sytax as follows
button.onRelease = function ():Void{
getURL("http://www.yoursite.com/", _self);
}
in action script 2.0 all script should be placed on the main timeline its bad 2.0 pratice to place it on buttons and things.
-
Flash, Mans greatest invention
Every top programmer there is find me one well known person who puts there code on buttons or movieclip in 2.0. Its very bad practice code goes in classes or on the main timeline this was the point of 2.0 to make alot of code organised into classes and the maintime line. organisation was one of the biggest goals of 2.0.
-
FK's Official Mac Hater
Originally Posted by Dragonusthei
find me one well known person who puts there code on buttons or movieclip in 2.0.
How about the programmers at Macromedia. In Flash 8 if you go to File>New and make a new document from a Template, all of the buttons and movieclips in the template will have the code on the object and not on the timeline. I looked at 4 or 5 of them and that is how they all were. The Help files also tell you to use:
on(release)
on a button....they just gave you another way of doing it.
Jason L. Wright
I'm not that hard to imitate. Just make some random negative claim at Apple or anything else for that matter and then have nothing to back it up.
-
Flash, Mans greatest invention
ok the guy who programmed AS1 and AS2 Gary Grossman check out any of his work what ya no know buttons or movie clips!
Colin Moock books o wait wheres the buttons.
joey lotts....... o no theres no buttons.
i can go on and on.
btw i just looked at some templates to see and they only have code in the main time line..... here the code form main time line for the presentation
forwardBtn.onPress = function () {
updateFrame(1);
}
// When the back button is pressed
backBtn.onPress = function () {
updateFrame(-1);
}
-
Ok so I assume the maintimeline is...just a layer somewhere on the normal timeline on the main scene?
Wow **** got complicated with buttons. I've been trying to figure out how to put the actiocode on the button layers, but finding the code and such is a huge pain. Ugh.
-
FK's Official Mac Hater
I didn't look at the presentation but I looked at the photo gallery and a few other templates and the only actions that were on the timeline were stop();
I also have Flash MX Training From The source and it tells you to put the actions on your buttons and MovieClips. I have a Collin Moock book too but I left it at work but I don't remember your way ever being mentioned in it. As you can see, even with high end developers, it is a matter of opinion.
This is out of the Photo gallery Template off of a button:
on (release, keyPress "<Right>") {
_parent.updateFrame(1);
}
on (keyPress "<Down>") {
_root.gotoAndStop(_root._totalFrames);
_parent.updateFrame();
}
Jason L. Wright
I'm not that hard to imitate. Just make some random negative claim at Apple or anything else for that matter and then have nothing to back it up.
-
Flash, Mans greatest invention
flash mx training from the soure......... thats flash mx not Actionscript 2.0 so of course the scripts on the buttons. they developed AS2 to stop things being placed there before that you had to so of course in a AS1 book the stuff will be placed on buttons and movieclips
-
FK's Official Mac Hater
All i'm going to say is that if you weren't supposed to put the actions on a button or MovieClip, then Macromedia would stop doing it.
Jason L. Wright
I'm not that hard to imitate. Just make some random negative claim at Apple or anything else for that matter and then have nothing to back it up.
-
Flash, Mans greatest invention
not saying your not supose to im saying its bad practice its fine for some one whos making a site that only contains 5 gotoandplays but when when your going into application dev it would be right job to stick things on buttons movieclips and random timelines inside movieclips insted of the main timeline and classes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|