GaleForce
11-03-2007, 04:55 AM
I've been searching through the vast internet for hours on how to make a button in AS3. All results I've found have not been quite what I was looking for, as in maybe the syntax was right but it required me to make a separate AS file. Whatever the reason was, nothing satisfied my problem, but I'm the closest I've been yet to getting the button to work.
What the button should do: gotoAndStop("particle")
particle is what I named the destination frame
I have a button symbol, instance name cloud7
I don't want to use a movie clip
I don't want to have to make a separate AS file
I want to do ALL the programming for the button in the button's frame
Here is my code so far;
import flash.events.MouseEvent;
cloud7.addEventListener(MouseEvent.CLICK,cloudSeve nClick);
function cloudSevenClick(Event:MouseEvent)
{
gotoAndStop("particle");
}
When I try to compile this I get, as expected, an error in regards to 'cloud7' being undefined. The specific error is "1120: Access of undefined property cloud7." I've tried defining it with the code;
var cloud7:Button = new Button();
However AS3 has no idea what 'Button' is despite it being in the drop down menu of items you can place after "var cloud7:". I've searched everywhere for what to import so that the compiler knows what 'Button' is, however I can't find it.
So basically I need help finishing this code. I'm guessing if I can find the right file to import than my original defining code would work, but if anyone else has another suggestion please let me know. Thanks!
EDIT: Also, I know I can use the SimpleButton() function and define sprites for each of the four button states, but I've already put a lot of work into the button states in my actual button symbol. It has multiple images and sound clips so switching to the sprite method at this point would be a real headache.
What the button should do: gotoAndStop("particle")
particle is what I named the destination frame
I have a button symbol, instance name cloud7
I don't want to use a movie clip
I don't want to have to make a separate AS file
I want to do ALL the programming for the button in the button's frame
Here is my code so far;
import flash.events.MouseEvent;
cloud7.addEventListener(MouseEvent.CLICK,cloudSeve nClick);
function cloudSevenClick(Event:MouseEvent)
{
gotoAndStop("particle");
}
When I try to compile this I get, as expected, an error in regards to 'cloud7' being undefined. The specific error is "1120: Access of undefined property cloud7." I've tried defining it with the code;
var cloud7:Button = new Button();
However AS3 has no idea what 'Button' is despite it being in the drop down menu of items you can place after "var cloud7:". I've searched everywhere for what to import so that the compiler knows what 'Button' is, however I can't find it.
So basically I need help finishing this code. I'm guessing if I can find the right file to import than my original defining code would work, but if anyone else has another suggestion please let me know. Thanks!
EDIT: Also, I know I can use the SimpleButton() function and define sprites for each of the four button states, but I've already put a lot of work into the button states in my actual button symbol. It has multiple images and sound clips so switching to the sprite method at this point would be a real headache.