button URL actionscript

  • watino
  • Newbie
  • Newbie
  • watino
  • Posts: 6

Post 3+ Months Ago

Hi! I'm new to using flash on websites and am looking for some guidance. I downloaded a web template from hostgator. The template has a flash menu (menu.fla) where u choose Home, About Us, Services, etc. I was able to modify the template for the website I'm creating but am stuck on being able to click on the menu items (ie., About Us, Services, etc) and it getting the appropriate URL - AboutUs.html, Services.html. When you click on the menu item it does not do anything. I have the following actionscript tied to the bAboutUs button:

ACTIONSCRIPT Code: [ Select ]
bAboutUs.onRelease = function() {
   getURL("http://www.website-name.com/AboutUs.html", "_self");
};
  1. bAboutUs.onRelease = function() {
  2.    getURL("http://www.website-name.com/AboutUs.html", "_self");
  3. };


I saved the file, published it and loaded the .swf to the website server but it still doesn't work. I don't know if my code above is wrong (altho it compiles clean) or if I missing some step in loading it to the website. I tried to change the code to just: on (release) { but it won't let me. I'm using Adobe CS4 trial ver and I believe its Actionscript 1.0 & 2.0.

Thanks for any help you can offer!
Melissa
Moderator Remark: added bbcode
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

did you instanced your button name?
when you select the button, in the Properties panel, you have Insance name. There you should enter : bAboutUs for the about button.
This is the first case, when you place your actionscript code in a keyframe.
If you want to place your actionscript code on the button, select the button (just one click on the button, not double click), go to actionscript panel, and then write:
Code: [ Select ]
on(release) { getURL("http://www.website-name.com/AboutUs.html", "_self"); }

You should also make sure in the publish settings, that the actionscript is 2.0 and flash player higher than 6.

After you upload it on the server, also clean up the browser cache, sometimes it might just take the flash file from cache.
  • watino
  • Newbie
  • Newbie
  • watino
  • Posts: 6

Post 3+ Months Ago

Thanks!! Your tips have helped! I tried putting the code on the button. (Meaning, in the window Actions - Frame (from pressing F9) I click once on bButtons, <bAboutUs> which is under the section MenuGfx, which is under Symbol Definitions.) But I get the following compiler error now:

Symbol-menuGfx, layer=Buttons, frame=30, line 1: Mouse events are permitted only for button instances
on (release) {

That's with the red line in the Timeline area on Buttons or Effect. I googled that error and one site said I need to be in Actions-Button not Actions - Frame but I'm unable to find where that is since I'm not that experienced in CS4.

I did change my Publish Settings to Actionscript 2.0 and Flash Player 8 per your suggestion.

Thanks for any help! Is this really that hard or is it just because I'm so green? :( Seems like it should be so simple to say somewhere that when you push this button, open this .html page.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

hehe, you need to learn more. I suggest you do something very simple.
In flash, New -> Flash file (Actionscript 2.0).
Go to Tools, select the rectangle tool and draw a rectangle on the stage. Next select the rectangle you drew on stage and press F8 to transform it into a symbol.
In the popup window set the name btnTest, and the type MovieClip, then OK.
After that, press once on the stage on the rectangle, and go to Actions panel.
There enter this code:
Code: [ Select ]
on(release)
{
    getURL("http:\www.google.com");
}
  1. on(release)
  2. {
  3.     getURL("http:\www.google.com");
  4. }

Save your flash file, then publish it (press F12).

Now, step 2:
Delete the actionscript code from the button, select the button and go to properties, and in the instance name text field enter : btnTest

Then go to Timeline, add a new layer, press on the first frame of the new created layer, and go to actionscript panel and add this code:
Code: [ Select ]
btnTest.onRelease = function()
{
    getURL("http:\www.google.com");
}
  1. btnTest.onRelease = function()
  2. {
  3.     getURL("http:\www.google.com");
  4. }

Publish again and test.
If you did everything correctly, you should have the same result for both cases: pressing the button should take you to google site.

Now you should understand the difference between placing actionscript on a MovieClip / Button and placing the actionscript in a key frame.
  • watino
  • Newbie
  • Newbie
  • watino
  • Posts: 6

Post 3+ Months Ago

Thank you for taking time to write that up! That helped a TONS! I got the first one to work but not the second one. Mouse stays as an arrow... However, in applying my new knowledge to the templates, I noticed some things ....

1. The template has movie clips of each button in the library (just like your example 1). However when I click once on the stage on the menu text (your case was a rectangle) and hit F9 the Actions panel still says "Current selection cannot have actions applied to it". I wonder if it's b/c my button is a flash button where the button forms as the flash runs? Let me tell you the website name so I don't have to explain the flash part if that doesn't make sense (http://www.tptotalperformance.com - it's just a website for personal training). I am wondering if I need to add another layer in order to add the code? Which really leads to ur example 2 but I wasn't able to get that one to work.

Thank you so much! When I get this up and running, I will have to add a flash that thanks you! :)
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

one buttons, two buttons, 100 buttons, is the same, just change the instance name.
The difference between a button with actionscript on it, and a keyframe actionscript which controls the button: in the first case, you have one button to perform something, this means you need 10 buttons in your library to perform 10 different things.
In second case, you can use the same button from the library, but instantitate it 10 times on the stage.
Here, is a small examples with buttons (if you don't have Flash CS4 then don't bother to download it): http://www.awake.ro/test/btntest.fla
Btw, copy the link and paste it into a download manager, trying to go there by pressing will probably display the fla binary code ... yet you can probably save it as well using Save Page As (and make sure it's .fla and not .fla.html).
This is just an example, you can also create the buttons on the fly, without having to drag them on the stage, but that's another lesson :P
  • watino
  • Newbie
  • Newbie
  • watino
  • Posts: 6

Post 3+ Months Ago

Please don't give up on me . . . I know I'm going to have a Eureka moment soon! :o

I viewed btntest.fla. I also read some more on buttons and although one website said it wasn't proper coding to put AS on the button, I want to try that one. However using the exercise you showed me and stuff I still keep getting that compile error "Current selection cannot have actions applied to it". I don't understand why. I click once on the button in the library and then click once on the stage on the button (in this case text that forms on the button) and press F9 and place the code.
  • watino
  • Newbie
  • Newbie
  • watino
  • Posts: 6

Post 3+ Months Ago

I *finally* got it to work . . . one mistake was the button layer was locked and the other issue was the cache. Thank you Ice Cold for all your help!!!
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

Glad you figured it out.
I remember a few years ago when i wanted to make a preloader and all the examples found on the web didn't work for me and i was wondering what am i doing wrong. It was so frustrating, but eventually i figured it out (after a week or so of struggle :D)

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 19 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.