PDA

View Full Version : PopUpManager problem


jjj
03-22-2008, 01:53 PM
Hi all, I have:
test.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:local="*"
layout="absolute">
<local:Boxx/>
</mx:Application>
Boxx.as
package
{
import flash.display.Sprite;
import flash.events.*;
import mx.managers.PopUpManager;
import mx.core.UIComponent;
import nn.B;import nn.*;

public class Boxx extends UIComponent
{
private var tr:Sprite;
private var tr1:Sprite;
private var square:Sprite;
private var b:B;

public function Boxx()
{
tr1 = new Sprite();
tr1.graphics.beginFill(0xFF0000);
tr1.graphics.drawRect(0,49,55,150);
tr1.x=50;tr1.y=80;
addChild( tr1 );
tr1.addEventListener(MouseEvent.CLICK, MouseClickName);
tr = new Sprite();
addChild( tr );
b=new B();
tr.addChild (b);

}
private function MouseClickName(evt:MouseEvent) :void {
showLForm();
}
private function showLForm():void {
var LForm: LoginformTest = new LoginformTest();
PopUpManager.addPopUp(LForm, this, true);
}

}
}

B.as
package nn
{
import flash.display.Sprite;
import flash.events.*;
import nn.*;

public class B extends Sprite
{ private var square:Sprite;

private var thumb1:c;
private var thumb2:c;
private var thumb3:c;

public function B()
{
square = new Sprite();
addChild(square);

thumb1 = new c();
thumb1.x=60;thumb1.y=10
thumb2 = new c();
thumb2.x=thumb1.x+70;thumb2.y=100;
thumb3 = new c();
thumb3.x=thumb2.x+20;thumb3.y=200

square.addChild (thumb1);
square.addChild (thumb2);
square.addChild (thumb3);

}

}
}

c.as
package nn
{ import flash.display.Sprite;
import flash.events.*;
import mx.managers.PopUpManager;
import nn.*;
public class c extends Sprite
{ private var square:Sprite;
public function c()
{
square = new Sprite();
square.graphics.beginFill(0xFF000);
square.graphics.drawRect(40,40,180,60);
square.x=250;
addChild(square);
addEventListener(MouseEvent.CLICK, MouseClickName);
}
private function MouseClickName(evt:MouseEvent) :void {
showLForm();
}
private function showLForm():void {
var LForm: LoginformTest = new LoginformTest();
PopUpManager.addPopUp(LForm, this, true);
}
}
}

but i receive error:
"TypeError: Error #1034: Type Coercion failed: cannot convert nn::c@67d95b1 to mx.core.IUIComponent...."

what can I do ?

TruePatriot
03-22-2008, 06:37 PM
Instead of passing "this" to the parent argument in the show pop up command, try doing UIComponent(LForm.parentApplication).