Creating a URL link button in AS3 when outside class is used.
I'm in need of some help!
Quick background -- I'm the guy at work who has the most basic, basic, basic understanding of Flash and has it installed. That makes me the "go to" guy now. I've been avoiding AS3 for a few years now because I'm not a software engineer and my coding knowledge is pretty limited. I could google around for an hour and getting something working in AS2. Not so much with AS3. We've recently upgraded to Flash CC and had all previous versions removed, so now I have no choice. I can follow directions but the technical jargon associated with AS3 is a steep learning curve for me when I do this kind of stuff maybe twice a year.
Now, what I'm trying to accomplish:
It's stupid simple. I have a flash web-banner. The background is a static PNG image. It has a countdown clock to a set date. I need the whole banner to function as a button so when you click it, it takes the user to a website. That's it. That's all I need. I've been able to do this in AS2 before without too much of a fight.
So I've accomplished the countdown timer using the script from this site:
http://blog.anselmbradford.com/2009/08/03/creating-a-date-countdown-timer-in-actionscript-3-flash/
It works by referencing outside scripted classes. It took me a little bit of tinkering, but I got it working, no problem.
So then I go to make a button. I create a button object. Make it invisible, set it on a layer above everything else. I apply this code to the actions:
MyButton.addEventListener(MouseEvent.CLICK,f);
function f(e:Event){
navigateToURL(new URLRequest("http://www.adobe.com")); // use the url of your choice.
}
And then it breaks. The SWF throws errors and won't compile.
First it says:
1180: Call to a possibly undefined method Event.
So I import flash.events.Event. Then I get:
1180: Call to a possibly undefined method navigateToURL.
1180: Call to a possibly undefined method URLRequest.
1180: Call to a possibly undefined method addFrameScript.
1120: Access of undefined property MouseEvent.
So I add:
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.events.MouseEvent;
That clears all errors except the 1180: addFrameScript. From what I've read, when there's an outside class being used, I can't apply action script in a frame on the timeline?
This is so far above my head. I tried for hours yesterday to figure out a way to add in the button script to the main class but the closest I got was compile errors about my button never being defined. I have no idea what I'm doing here and why it's so hard to make two things work at the same time in AS3. I'm just frustrated with the whole thing now.
Could someone take pity on me and explain to me what I need to do to get this button working? Try to use small words and talk to me like I'm the village idiot, which is how I'm feeling right now.
Thanks!
