0

I try to create a function to change border property of border container. To do that I create a function for each border container on my MXML.

But I'd to code better and to do a generic function.

Today my function is:

protected function bcContact_mouseOverHandler(event:MouseEvent):void { // TODO Auto-generated method stub bcContact.setStyle("borderVisible",true); bcContact.setStyle("borderWeight",2); bcContact.setStyle("borderColor",'#000099'); } 

bcContact is one border container Id.

I try to replace bcContact by this but it doesn't work.

Can you help me to solve this beginner mistake.

Thanks

2 Answers 2

2

U can use event.CurrentTraget and then use the compare functions, compare with ids and do the settings.

Sign up to request clarification or add additional context in comments.

Comments

1

You could extend the BorderContainer class (in Flash Builder, put in BorderContainer in the "Super class" text field)

Your class will look something like this:

import flash.events.MouseEvent; import spark.components.BorderContainer; package com.extensions.containers { class MyBorderContainer { function MyBorderContainer() { this.addEventListener(MouseEvent.MOUSE_OVER, changeStyle); this.addEventListener(MouseEvent.MOUSE_OUT, undoStyle); } private function changeStyle(e:MouseEvent):void { this.setStyle("borderVisible",true); this.setStyle("borderWeight",2); this.setStyle("borderColor",'#000099'); } private function undoStyle(e:MouseEvent):void { this.setStyle("borderVisible",false); this.setStyle("borderWeight",0); this.setStyle("borderColor",'#000000'); } } } 

This class will need to be in the file src/com/extensions/containers/MyBorderContainer.as

Then use this in your mxml as

<containers:MyBorderContainer> </containers:MyBorderContainer> 

where the namespace containers is set to point to com/extensions/containers

2 Comments

Thanks for this idea but it doesn't works. Indeed it's like eventlistener doesn't work.Do you know why
Ok I found where is the mistake. Indeed I create a class extend border Container and after I created an skin where host component is MyBorderContainer. In this case it doesn't work! But if I use MyBorderContainer without skin It works fine. thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.