I have an actionscript project which uses visual symbols from an SWC.
I have a CheckoutButton
which has the following class associated with it (compiled into the SWC in Flash CS3).
public class CheckoutButton extends SimpleButton {
public function CheckoutButton () {
this.addEventListener(MouseEvent.CLICK, checkoutClicked);
}
// click on the button and the alpha will go to 50%
public function checkoutClicked(e:MouseEvent):void {
this.alpha = .5; // take user to checkout
}
public function dispose ():void {
}
}
Important: The CheckoutButton.as
file is in the classpath for the actionscript project that uses the SWC.
I use the compiled SWC in an actionscript project and I have run the following scenarios :
1) I DELETE CheckoutButton.as
from the classpath for my actionscript project:
var x:CheckoutButton = new CheckoutButton();
addChild(x);
I get an instance of the visual symbol from my Flash CS3 file. When I click on it it's alpha goes to 50%. This again is exactly as i expected.
2) I run this code with CheckoutButton.as
in the classpath for my actionscript project:
var x:CheckoutButton = new CheckoutButton();
addChild(x);
Nothing happens at all. This is exactly as I expect - because I've basically overridden the class definition from the SWC with a SimpleButton
that has no visual functionality whatsoever.
Now I also have a timeline animation CheckoutAnimation
in my Flash file that just happens to contain an instance of the CheckoutButton
symbol.
3) I run the actionscript project after DELETING CheckoutButton.as
from the classpath:
var x:CheckoutAnimation = new CheckoutAnimation();
addChild(x);
The symbol in the animation picks up the class definition (as originally compiled into the SWC) and when I click on it the alpha of the symbol goes to 50%. This is exactly as expected.
4) I run the actionscript project with CheckoutButton.as
still in the classpath:
var x:CheckoutAnimation = new CheckoutAnimation();
addChild(x);
The checkout symbol appears in the animation, but clicking on it does nothing!!
WHY IS THIS! I DON'T UNDERSTAND! I don't understand why I don't get the same result as in (2) above, and I definitely don't understand why no code is executing. What is the conflict here?