A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: Picture to illustrate my problem (probably simple)

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    43

    Picture to illustrate my problem (probably simple)

    I didn't have any luck with my last thread so I've tried to make my question clearer and give more info.

    I'm trying to dynamically change the text of something on my swf.

    It's a 'tab'. If you look at my first attachment you'll see the tab with dynamic text labelled as 'caption'. I want to be able to set the colour of that text.

    I've had an attempt at what I thought would work in the actionscript (again, I've attached a picture showing the script that I thought might work).

    I must mention that I'm a complete newbie to Flash and Actionscript so the answer to this question may be really really simple but I've tried to look it up on the net and only got as far as the script I've posted. I'd really like some help with this if you know what I'm doing wrong.

    Cheers

    John ;-))
    Attached Images Attached Images

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    I really didn't understand your problem, but to use setRGB, you need to target a movieclip, not a text field or its text! Another way would be to convert your text to html and then use the html tag to change color, example:

    Actionscript Code:
    my_txt.html = true;
    my_txt.htmlText = "<font color='#FF0000'>THIS TEXT IS RED</font>";
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Member
    Join Date
    Jul 2009
    Posts
    43
    Nig, a big thank you for your reply.

    The 'tab' has the word "caption" on it but when I run the swf it actually shows the text from the top of that actionscript I posted ie.

    Code:
    var tabArray:Array = new Array("Memorial", "Slideshow");
    
    tabContainer.createEmptyMovieclip("tabArea");
    If the script is somehow changing the actual text in the 'movieclip' then it there not a way to change the colour as well?

    Many thanks for your continued help with this, it is much appreciated (and also thank you for your patience!)

    Cheers

    John ;-)

    PS. What about something like this....

    Code:
    var tabArray:Array = new Array("Memorial", "Slideshow");
    
    tabContainer.createEmptyMovieclip("tabArea");
    
    for (i=0; i<tabArray.length; i++) {
    	var myTab = tabContainer.attachMovie("tabClip", "tabClip"+i, tabContainer.getNextHighestDepth(), {_x:i*112});
    
    // IF THE LINE BELOW SETS THE TEXT ON THE TAB - CAN I NOT SET THE COLOUR OF "myTab.caption" ?? SEE FURTHER DOWN	
    
    myTab.caption = tabArray[i];
    
    
    	myTab.onRollOver = function() {
    		//this.nextFrame();
    	};
    	myTab.onRollOut = function() {
    		//this.prevFrame();
    	};
    	myTab.onRelease = function() {
    		//this.prevFrame();
    		this.enabled = false;
    		render_tabs(this);
    		_root.close_all();
    
    		switch (this.caption) {
    			case "Memorial" :
    				_root.render_rotator();
    				break;
    			case "Slideshow" :
    				_root.gallery_swf.open_gallery();
    				break;
    		}
    	};
    
    // WHAT ABOUT SETTING THE CAPTION COLOUR LIKE THIS (IT DOESN'T WORK BTW BUT IS THERE SOMETHING SIMILAR THAT WOULD) ??
    
    	var tabTextColor = new Color(myTab.caption);
    	tabTextColor.setRGB(_root.background_swf.colourArray[2]);
    Last edited by JohnnyT74; 10-01-2011 at 04:42 PM.

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    is myTab.caption a Dynamic Text field's variable name?

    If it is, make another movieclip to have caption dynamic text field inside it, and then:

    Actionscript Code:
    var tabTextColor = new Color(myTab.caption); // now myTab.caption is a mc
    tabTextColor.setRGB(_root.background_swf.colourArray[2]);
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Member
    Join Date
    Jul 2009
    Posts
    43
    Sorry for my ignorance but I'm not 100% sure whether myTab.caption is a "Dynamic Text fields variable name".

    Please see the attached piccy. This is what I get when I look at "tab_mc"

    In the timeline it shows:
    actions
    text
    white_line
    shape

    If I click 'text' it draws a blue selection box around the text that says "caption". It's this text that gets changed by the tabArray and it's this text that I want to be able to change the colour of.

    Will your solution of making another movieclip to have 'caption' as a dynamic text field etc still work or is there a simpler way?

    I really hope there's a simpler way as I'm not sure how to implement your suggestion.

    Thanks again for all your support on this.

    Cheers

    John ;-)
    Attached Images Attached Images

  6. #6
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    myTab.caption refers to the text field in tabClip/tab_mc, which is definitely the Var(iable) name of that dynamic text field! Click on your caption text field, press F8 and convert it to a Movieclip, give the movieclip an instance name of caption_mc (click movieclip, open Properties Panel, type that in the Instance field), and then, change your code to this:

    Actionscript Code:
    var tabArray:Array = new Array("Memorial", "Slideshow");

    tabContainer.createEmptyMovieclip("tabArea");

    for (i=0; i<tabArray.length; i++) {
        var myTab = tabContainer.attachMovie("tabClip", "tabClip"+i, tabContainer.getNextHighestDepth(), {_x:i*112});

    // IF THE LINE BELOW SETS THE TEXT ON THE TAB - CAN I NOT SET THE COLOUR OF "myTab.caption" ?? SEE FURTHER DOWN

    myTab.caption_mc.caption = tabArray[i];


        myTab.onRollOver = function() {
            //this.nextFrame();
        };
        myTab.onRollOut = function() {
            //this.prevFrame();
        };
        myTab.onRelease = function() {
            //this.prevFrame();
            this.enabled = false;
            render_tabs(this);
            _root.close_all();

            switch (this.caption) {
                case "Memorial" :
                    _root.render_rotator();
                    break;
                case "Slideshow" :
                    _root.gallery_swf.open_gallery();
                    break;
            }
        };

    // WHAT ABOUT SETTING THE CAPTION COLOUR LIKE THIS (IT DOESN'T WORK BTW BUT IS THERE SOMETHING SIMILAR THAT WOULD) ??

        var tabTextColor = new Color(myTab.caption_mc);
        tabTextColor.setRGB(_root.background_swf.colourArray[2]);
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  7. #7
    Member
    Join Date
    Jul 2009
    Posts
    43
    Hi Nig,

    I've tried your suggestion but it doesn't seem to be working. The 'tabs' now just have the word "caption" written on them (as oppose to Memorial and Slideshow) and the colour hasn't changed.

    Any ideas why it might not be working?

    Many thanks

    John ;-)

  8. #8
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Does the caption text field have a variable name? Is it a Static Text or a Dynamic Text, if so, what is its variable/instance name? Did you give your newly created movieclip the instance name of caption_mc? If none these work, send FLA file of only the tab_mc
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  9. #9
    Member
    Join Date
    Jul 2009
    Posts
    43
    Hi Nig,

    This is what I've got....

    (see attached file)

    And I've updated the script as you said.

    I'll happily send you the fla file if this doesn't help.

    Cheers

    John ;-)
    Attached Images Attached Images

  10. #10
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Not the Movieclip's Name. After making the movieclip, click on it, open Properties Panel (CTRL+F3), and in the Instance field, type caption_mc
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  11. #11
    Member
    Join Date
    Jul 2009
    Posts
    43
    Nig13, You are a GENIUS!!

    Yep, I was only changing the name. Doh!

    I went back to basics and changed the properties box and then it sprung into life.

    I had to write the code like this though to get it working:
    Code:
    myTab.caption_mc.text = tabArray[i];
    
    as oppose to...
    
    myTab.caption_mc.caption = tabArray[i];
    Not sure why that is but the main thing is that it's working now.

    A massive thanks again for all your help sorting this out for me. It's very much appreciated.

    Cheers

    John ;-))

  12. #12
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    No problem, happy to hear that your problem is solved

    As for the .text part, you have to include that if you give your Dynamic Text field an Instance name, but if you give it a Variable name, then you have to write without .text

    Hope it makes sense
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  13. #13
    Member
    Join Date
    Jul 2009
    Posts
    43
    It's slowly starting to make sense (very slowly!)

    Thanks again for all your help ;-)

  14. #14
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Great, also, if you need more help, don't hesitate to post another topic
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  15. #15
    Member
    Join Date
    Jul 2009
    Posts
    43
    Be careful what you wish for my friend.... I'm sure I'll be bugging you to death now!!

    lol ;-))

  16. #16
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Are you kidding? You won't be lol, I think there are TOO few posts everyday (I check everyday for new topics to help people), so if you'd ask questions occasionally, you'd liven up this forum
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  17. #17
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    Nice Nig............ Just keep it UP.

    Have a Nice Day.


    arkitx

  18. #18
    Member
    Join Date
    Jul 2009
    Posts
    43
    Well... you asked for it Nig, there's another one posted for you to get yer teeth into! ;-))

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center