Forum Moderators: open
I have a little Flash movie. One scene. It's got a bunch of symbols and movie objects in it. I thought I would make top layer, put a big blue box over it, tune the Alpha down to 0, convert it to a symbol and add the following Actionscript:
on(release)
{
getURL("example.html");
}
But no! I get this annoying little message:
"Current Selection cannot have actions applied to it."
I get this even when I set the Actionscripting to 1.0 & 2.0
Does anyone know a simple way to add a link to a small Flash banner using CS3?
Thank you.
- Select the button and give it an instance name (myButton).
- Select the FIRST FRAME of the timeline, not the button.
- Paste the following:
myButton.onRelease = function() {
getURL("http://www.google.com");
}
If it doesn't work, use a full URL, as above.
You can also apply similar methods to a symbol that is a movie, as opposed to a button.
However, in IE and Opera, ....
This should mean those plugins are too old and don't support AS3. You can look into that, or just re-publish the SWF and set your publish settings to AS 2.0 as this function is compatible with all older versions. This approach won't work if other parts of your Flash use AS 3.0 programming.
Nonetheless, I am also getting these errors when I publish from Flash:
Description:
1119: Access of possibly undefined property onRelease through a reference with static type Class.
Source:
myButton.onRelease = function() {
Description:
1180: Call to a possibly undefined method getURL.
Source:
getURL("http://www.google.com");
What the hay. I used the code you gave me Rocknbil and I saved the symbol as a Button with "Export for Action Script". I left the other boxes unchecked. I then clicked on the first frame and added the code:
myButton.onRelease = function() {
getURL("http://www.google.com");
}
I also checked by browsers and my Flash player and everything is up to date.
What is happening?! :(
P.S. Can anyone recommend a good book for Flash CS3 and Actionscript 3.0?
Hard to say what is happening. Start with basics:
1. open new file. You should be able to do AS2 or 3.
2. Draw a box on the stage.
3. Select box, select convert to symbol, name it myButton, check Export for ActionScript, make sure the behavior is Button, not movie.
4. With the symbol selected, go to the properties pane and name this instance myButton. It's probably bad practice to name the instance and the symbol the same, but it will work. What's important is that the instance is named myButton.
5. Paste the code above in frame 1 of the movie.
Run the program, you don't even have to save it. There is no way this won't work. :-)
When you figure out why this one works and your live one doesn't, problem solved!
With that knowledge, I downgraded my movie to a Flash 8 file and it worked. At least I can get something online. I still want to know though why the AS3 is not working for me. I wonder if it has something to do with this.
When I convert the blue box to a symbol in AS3, I get this warning box: "A definition for this class could not be found in the classpath, so one will be automatically generated in the SWF file upon export."
Any ideas?
function gotoAuthorPage(event:MouseEvent):void
{
var targetURL:URLRequest = new URLRequest("http://google.com/");
navigateToURL(targetURL);
}
myButton.addEventListener(MouseEvent.CLICK, gotoAuthorPage);