Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

ColorTransform and Input Textfueld problem!

Hi;

I am having a huge problem with my code. I have created a draggable movieclip with an input text on top. Inside this, there is another draggable child which enables endless dragging and dropping.


Te textfield on top if working perfectly fine. However, when i (withing the aplication) click on a button to change the background of the movieclip, it changes the colour of textfield instead.

User can click on the box, it does write, but it wont be visible. I select all, copy and paste it on wordpad and i confirm the text input works.

I dont know how to get around this! Could anyone please help me?

My code for the draggable movieclip and the code to change the background colour of that movieclip is as below:



Many Thanks...


green_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);

function fl_MouseClickHandler_2(event:MouseEvent):void
{
var newColor:ColorTransform = green.transform.colorTransform;
newColor.color = 0x006666;
green.transform.colorTransform = newColor;
setChildIndex(green,numChildren - 1);

}

Open in new window

/* Drag and Drop
Makes the specified symbol instance moveable with drag and drop.
*/

card_stack_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_5);

function fl_ClickToDrag_5(event:MouseEvent):void
{
	card_stack_mc.startDrag();
	
/* Add Instance of card_stack from Library to the Stage*/

	var fl_MyInstance:card_stack_symbol = new card_stack_symbol();
	addChild(fl_MyInstance);
	fl_MyInstance.x=725.65; 
	fl_MyInstance.y=586.75;

}

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_5);

function fl_ReleaseToDrop_5(event:MouseEvent):void
{
	card_stack_mc.stopDrag();
}

Open in new window

0
iceboyx
Asked:
iceboyx
  • 4
  • 3
1 Solution
 
iceboyxAuthor Commented:
Could anyone help me with this please?

Thanks..
0
 
dgofmanCommented:
Hi,
I don't know how to help because from your example I can see only probelm in fl_ClickToDrag_5 function. You are creating new instance inside this class and adding to the stage but question what happend when user start drag again are you planing to create anew instance again?

Please can you save you FLA file as CS4 and attach to this ticket.
0
 
iceboyxAuthor Commented:
Hi;

Thank you for your respond. I was giving up as no one responded to my query.

I dont think i am allowed to share the file here on public as it is private. Would it be possible to email it to you instead? I have tried but i couldnt find a link to send anthe email!

Many Thanks...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
iceboyxAuthor Commented:
The instance is belong to another instance so there is a loop. Whenever a user drags a card, it creates an instance of it which is an instance of the other card. So there is always a loop.

Original card is in yellow colour and i can type text on it with no problem and the text colour is black. However, once i change the colour of the card to red, the font colour changes to red as well and so i cant see anything written on it. It still enables user to write on it but it wont be visible!

Could anyone please explain me the problem?

Many Thanks...
0
 
dgofmanCommented:
Please send me via email
david_gofman@yahoo.com
0
 
iceboyxAuthor Commented:
Many Thanks. I have just sent you the email... I appreciate your help...

Regards...
0
 
dgofmanCommented:
I can see many problems in your code
1) Instead tranform color you must draw background of your shape using Graphics API
2) You can grab color from buttons it will reduced duplications in your code
3) You don;t need to create more than one draggable objects
etc.
So, here is my changes

/* Drag and Drop
Makes the specified symbol instance moveable with drag and drop.
*/
					
var textGap:uint = 5;
card_stack_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_5);
card_stack_mc.x = 735; 
card_stack_mc.y = 610; 
card_stack_mc.textfield.type = TextFieldType.DYNAMIC;
card_stack_mc.textfield.selectable = false;
card_stack_mc.textfield.x = textGap;
card_stack_mc.textfield.y = textGap;
drawBackground(card_stack_mc, 0xDEC976);

var fl_MyInstance:card_stack_symbol;

function fl_ClickToDrag_5(event:MouseEvent):void
{	
	/* Add Instance of card_stack from Library to the Stage*/
	fl_MyInstance = new card_stack_symbol();
	fl_MyInstance.x = card_stack_mc.x; 
	fl_MyInstance.y = card_stack_mc.y;
	fl_MyInstance.startDrag();
	drawBackground(fl_MyInstance, card_stack_mc.backgroudColor);
	addChild(fl_MyInstance);
}

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseEventHandler);

function fl_ChangeColorEventHandler(event:MouseEvent):void
{
	var button:SimpleButton = event.target as SimpleButton;
	var bmp:BitmapData = new BitmapData(button.width, button.height, false)
	bmp.draw(button);
	drawBackground(card_stack_mc, bmp.getPixel(button.width / 2, button.height / 2));
}

function fl_ReleaseEventHandler(event:MouseEvent):void
{
	if(fl_MyInstance != null){
	   //Protect dropping new clip on the same place
	   if(card_stack_mc.hitTestObject(fl_MyInstance)){
			removeChild(fl_MyInstance);
	   }else{
		   fl_MyInstance.stopDrag();
		   stage.focus = fl_MyInstance.textfield;
	   }
	}
	fl_MyInstance = null;
}

function drawBackground(clip:MovieClip, color:Number):void{
	var g:Graphics = clip.graphics;
	g.clear();
	g.beginFill(color); 
	g.drawRect(0, 0, clip.width + (textGap * 2), clip.height + (textGap * 2)); 
	g.endFill();
	card_stack_mc.backgroudColor = color;
}

Open in new window


/* COLOUR PALETTES changes the colour of the card and bring the chosen colour to front*/

yellow_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);
green_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);
red_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);
blue_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);
pink_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);
orange_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);

Open in new window


green2_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);
red2_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);
blue2_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);
pink2_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);
orange2_btn.addEventListener(MouseEvent.CLICK, fl_ChangeColorEventHandler);

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now