Hello Robert,
On 4/19/07, Robert Brisita <[EMAIL PROTECTED]> wrote:
The compiler says:
"**Error** Deck.as: There is no method with the name 'setDepthTo'.
this.setDepthTo(DepthManager.kTop);"
And from your code I don't see it either: this.setDepthTo or
this.filters. When you say "it works"
do you mean it compiles ok or that onPress the card acts the way it
should visually? Took a quick look at UIComponent and didn't see them
there either.. I wouldn't be surprised if you traced those two
calls and they would be undefined.
no, it really works in the sense that the clicked card
is displayed at the top, with a shadow underneath.
I've found a workaround: defined a dummy method
with the same name in the ("parent") Deck class:
private function setDepthTo() {
// dummy method to stop compiler from complaining
}
I think what's happening is that the compiler is too
dumb to realize that the Deck class method will be
called in the other scope (i.e. with "this" pointing
to card mc and not to a Deck object).
But at run-time the method is really called with card
(and thus the 2 methods won't be undefined)
Regards
Alex
--
http://preferans.de
PS: Below is my almost working code (the "card"
event doesn't dispatch yet for some reason,
but the rest works - card can be dragged etc.):
import flash.filters.DropShadowFilter;
import flash.filters.GlowFilter;
import mx.managers.DepthManager;
import mx.core.UIComponent;
[Event('card')]
class Deck extends UIComponent
{
static var symbolName:String = 'Deck';
static var symbolOwner:Object = Deck;
var className:String = 'Deck';
var shadow_array:Array;
var evt_obj:Object;
private var bb_mc:MovieClip;
private var cards_array:Array;
function Deck() {
}
private function init():Void {
super.init();
bb_mc.unloadMovie();
shadow_array = [ new DropShadowFilter(0, 90, 0x000000,
0.40, 16, 16, 1, 1, false, false, false) ];
cards_array = [];
evt_obj = {target: this, type: 'card'};
}
private function createChildren():Void {
for (var i:Number = 0; i <= 32; i++) {
var card:MovieClip = cards_array[i] =
this.createChildAtDepth(i, DepthManager.kTop);
card._xscale = card._yscale = 50;
card.onPress = raiseCard;
card.onRelease = card.onReleaseOutside = releaseCard;
}
size();
}
private function setDepthTo() {
// dummy method to stop compiler from complaining
}
function raiseCard():Void {
setDepthTo(DepthManager.kTopmost);
_rotation = Math.floor(Math.random() * 9 - 4);
_x -= 1;
_y -= 2;
_xscale = _yscale = 54;
filters = _parent.shadow_array;
startDrag(this, false, 0, 0,
_parent._width - this._width, _parent._height -
this._height);
}
function releaseCard():Void {
setDepthTo(DepthManager.kTop);
_x += 1;
_y += 2;
_xscale = _yscale = 50;
filters = [];
stopDrag();
_parent.evt_obj.x = this._x;
_parent.dispatchEvent(evt_obj);
}
private function size():Void {
super.size();
for (var i:Number = 0; i <= 32; i++) {
var card:MovieClip = cards_array[i];
card._x = Math.floor(Math.random() * (this.__width -
card._width));
card._y = Math.floor(Math.random() * (this.__height -
card._height));
card._rotation = Math.floor(Math.random() * 9 - 4);
}
invalidate();
}
private function draw():Void {
super.draw();
}
}
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com