Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Feb 2009
    Location
    Worcester
    Posts
    172
    Thanks
    13
    Thanked 6 Times in 6 Posts

    Question Flex help? Change text colour on MouseOver?

    Hi all!

    This is my first post here so hi everyone

    I've recently started playing around with Flex 3, i've always been interested in Flash development but never really found the time to sit down and do some learning, until now

    So my understanding of AS3 is very poor, i'm picking it up slowly but everyday is an uphill climb!

    So i'm having a play around in Flex and was wondering if it's possible to change the text colour of a label or simular on MouseOver?

    I have this so far:
    Code:
    <mx:Label text="simple text" id="myLabel" color="#000000" click="currentState='stateOne'"/>
    Now obviously this is going to be acting as a link so the user can visit the 'stateOne' state, but i would like it to change colour on rollover so that the user can see it's a link, I don't want buttons all over the place.

    So i thought that maybe this would do the trick:
    Code:
    <mx:Label text="simple text" id="myLabel" color="#000000" click="currentState='stateOne'" mouseOver="text.color = #ffffff"/>
    But it didn't, i just get a syntax error 1093. So then i thought i'd try and add a private function for the mouseOver event, but that just went horribly wrong! As i said my AS3 is terrible!

    So i was just wondering if anyone out there knows a little Flex or AS3 that i could use in-line. If you're going to suggest using a function i'm afraid you'll have to bear with me and explain it a little as i'm still a total newbie!!

    Many thanks in advance to anyone who offers help, all suggestions will be gratefully received!

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Welcome, and this belongs in the Flex forum here just for future notices.

    Try this, otherwise my suggestion is to always google the error code. I found this nice article

    http://curtismorley.com/2007/08/25/f...s3-error-1093/

    Code:
    <mx:Label text="simple text" id="myLabel" color="#000000" click="currentState='stateOne'" mouseOver="text.color = 0xffffff"/>
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    Regular Coder
    Join Date
    Feb 2009
    Location
    Worcester
    Posts
    172
    Thanks
    13
    Thanked 6 Times in 6 Posts
    mmm... getting an odd error now:

    Access of undefined property text

    Why would this be happening if it's in line?

  • #4
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Sorry I should have been more clear, I don't know Flex. But the error says that there is no property 'text' so it should not be included.

    Code:
    mouseOver="color = 0xffffff"/>
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #5
    Regular Coder
    Join Date
    Feb 2009
    Location
    Worcester
    Posts
    172
    Thanks
    13
    Thanked 6 Times in 6 Posts
    Ha, now it's not happy about the color property lol, it's the same error but this time says 'color'. Maybe it just can't be done to text? I've search the Adobe Flex help and found no reference to changing color on rollover.

    Maybe it's time to admit defeat... ???

    Or perhaps it could be done through a function..... I'll do some more Googling, if i find the answer i'll post back so others can see how to do it.

  • #6
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    http://livedocs.adobe.com/flex/3/htm...eevents_2.html

    Might be a good start, perhaps you have to have a listener instead?
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #7
    Regular Coder
    Join Date
    Feb 2009
    Location
    Worcester
    Posts
    172
    Thanks
    13
    Thanked 6 Times in 6 Posts
    Right, after a few days of self teaching with functions etc, i have come up with this:

    Code:
    private function initilizeApplicationFunction():void
    			{
    				myButton.addEventListener(MouseEvent.CLICK, myClickHandler);
    				messageLabel.addEventListener(MouseEvent.MOUSE_OVER, textChange);
    				messageLabel.addEventListener(MouseEvent.MOUSE_OUT, textChangeback);
    			}
    		
    			private function textChangeback(event:MouseEvent):void
    			{
    				messageLabel.text = 'Label';
    			}
    		
    		
    			private function textChange(event:MouseEvent):void
    			{
    				messageLabel.text = 'Click to visit...';
    			}
    So obviously you need to call the initilizeApplication (initApp) at start up, but the basics is that the text will chage to 'Click here to visit....etc etc.

    For some reason i can't access the color property of the label in the function, is there a specific property that provides the colour? It's really starting to bug me now

    Any suggetions would be great! If not don't worry, at least there's a possible solution for people to see here

  • #8
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Try this.

    Code:
    private function initilizeApplicationFunction():void
    			{
    				myButton.addEventListener(MouseEvent.CLICK, myClickHandler);
    				messageLabel.addEventListener(MouseEvent.MOUSE_OVER, textChange);
    				messageLabel.addEventListener(MouseEvent.MOUSE_OUT, textChangeback);
    			}
    		
    			private function textChangeback(event:MouseEvent):void
    			{
    				messageLabel.setStyle("color", 0xFF00FF)
    			}
    		
    		
    			private function textChange(event:MouseEvent):void
    			{
    				messageLabel.setStyle("color", 0x00FFFF)
    			}
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #9
    Regular Coder
    Join Date
    Feb 2009
    Location
    Worcester
    Posts
    172
    Thanks
    13
    Thanked 6 Times in 6 Posts
    You are my hero!!!! That works a treat, thank you!

    So much to learn... didn't even cross my mind to use a style, got too caught up in functions and properties

    You're a star, thanks!

    Just for future reference, where is the Flex forum here? I've had a quick look and can't see it, just for future posts (no doubt they'll be many lol).

    Thanks again!

  • #10
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Awesome, I might just go and start to learn Flex too

    Its a subforum of the Flash, so go to Flash forum and its at the top.

    http://www.codingforums.com/adobe-flex/
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #11
    Regular Coder
    Join Date
    Feb 2009
    Location
    Worcester
    Posts
    172
    Thanks
    13
    Thanked 6 Times in 6 Posts
    It's an amazing program! Takes a little getting used to, but the things you can do with it.... amazing.

    I've always liked flash but found the process very long winded, Flex eliminates that to a certain extent, and has various predefined elements that save you a lot of time developing!

    Just found out how to talk to ColdFusion with it too, and now i'm one very happy bunny!

    Look out world!!!

    Oh, thanks for the link too
    Last edited by loki421; 02-20-2009 at 11:27 AM. Reason: Very forgetful :p

  • #12
    Senior Coder jerry62704's Avatar
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    1,100
    Thanks
    13
    Thanked 87 Times in 87 Posts
    Quote Originally Posted by jeremywilken View Post
    Awesome, I might just go and start to learn Flex too

    Its a subforum of the Flash, so go to Flash forum and its at the top.

    http://www.codingforums.com/forumdisplay.php?f=63
    Start here.
    .
    .
    ...and gladly would he learn and gladly teach

    Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls

  • #13
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    you can code in mxml directly

    don't need to add into as3 script, you can code in mxml directly


    <s:Lable mouseOver="{this.setStyle('color', 0xDC5A82)}" mouseOut="{this.setStyle('color', 0xFFFFFF)}" text="TEST" />


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •