A Flash Developer Resource Site

Page 1 of 5 12345 LastLast
Results 1 to 20 of 91

Thread: [Resolved] [Resolved] [Resolved] [Resolved] textFormat example

  1. #1
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779

    Smile

    [swf width="550" height="300" background="#FFFFFF"]http://www.zh-webdesign.ch/zoa/autosize_text3.swf[/swf].

    Just an exammple of the textFormat object.

    Code:
    // Creating textfield text format
    fieldTextFormat = new TextFormat();
    fieldTextFormat.font = "Arial";
    fieldTextFormat.bold = false;
    fieldTextFormat.italic = false;
    fieldTextFormat.align = "left";		
    	
    // Creating the base textfield
    createTextField("mytext", 1, 200, 100, 200, 150);
    mytext.multiline = true;
    mytext.wordWrap = true;
    mytext.border = true;
    mytext.html = false;
    mytext.type = "input";
    mytext.selectable = true;	
    mytext.text = thetext;
    mytext.autosize = "left";
    mytext.borderColor = 0xaaaaaa;
    mytext.text = "Test the format object!";
    mytext.setTextFormat(fieldTextFormat);
    
    // Set labelös of the button components
    bold_button.setLabel("bold");
    italic_button.setLabel("italic");
    left_button.setLabel("LEFT");
    center_button.setLabel("center");
    right_button.setLabel("right");
    
    // Set font provider
    myfonts=TextField.getFontList();
    fontList.setDataProvider(myfonts);
    fontList.setSize(300);
    fontList.setSelectedIndex(20);
    
    // set font-size provider
    fontSizes =  new Array(6,8,10,12,14,16,18,20,24,28,32,40,48,56,64);
    fontSize.setDataProvider(fontSizes);
    fontList.setSelectedIndex(4);
    
    // change font when new one selected
    fontList.setChangeHandler("myHandler");
    function myHandler(component){
       fieldTextFormat.font = fontList.getSelectedItem().label; 
       mytext.setTextFormat(fieldTextFormat);
    }
    
    // change font-size when new one selected
    fontSize.setChangeHandler("myHandler2");
    function myHandler2(component){
       fieldTextFormat.size = fontSize.getSelectedItem().label; 
       mytext.setTextFormat(fieldTextFormat);
    }
    
    // Functions for the buttons
    function makeBold(){
    	if (fieldTextFormat.bold){
    		fieldTextFormat.bold = false;
    		bold_button.setLabel("bold");
    	} else {
    		fieldTextFormat.bold = true;
    		bold_button.setLabel("BOLD");
    	}
    	mytext.setTextFormat(fieldTextFormat);
    }
    function makeItalic(){
    	if (fieldTextFormat.italic){
    		fieldTextFormat.italic = false;
    		italic_button.setLabel("italic");
    	} else {
    		fieldTextFormat.italic = true;
    		italic_button.setLabel("ITALIC");
    	}
    	mytext.setTextFormat(fieldTextFormat);
    }
    function makeLeft(){
    	fieldTextFormat.align = "left";
    	left_button.setLabel("LEFT");
    	center_button.setLabel("center");
    	right_button.setLabel("right");
    	mytext.setTextFormat(fieldTextFormat);
    }
    function makeCenter(){
    	fieldTextFormat.align = "center";
    	left_button.setLabel("left");
    	center_button.setLabel("CENTER");
    	right_button.setLabel("right");
    	mytext.setTextFormat(fieldTextFormat);
    }
    function makeRight(){
    	fieldTextFormat.align = "right";
    	left_button.setLabel("left");
    	center_button.setLabel("center");
    	right_button.setLabel("RIGHT");
    	mytext.setTextFormat(fieldTextFormat);
    }
    Fredi

  2. #2
    Junior Member
    Join Date
    Dec 2000
    Posts
    16
    Wow! I'm totally impressed. Great stuff Subway.

  3. #3
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    Subway

    Nice work man. This is good stuff!

    Antibody

  4. #4
    Member
    Join Date
    Oct 2001
    Posts
    96

    Sounds good

    Looks good, now I'd make it into a Tutorial.

  5. #5
    FK Official Postman
    Join Date
    Apr 2001
    Location
    Rockville, MD / UCSanDiego
    Posts
    827
    Maybe with fl6 we can launch our own competitor to word.


  6. #6
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    PishPosh-

    Let us know when you get done making the tutorial.

  7. #7
    Flashkit's Cheerbud LEXGRAPHICS's Avatar
    Join Date
    Dec 2001
    Location
    Miami
    Posts
    250

    WOW!

    its amazing how MX can do all this stuff i think it is worth my Dollars!!! ill see if i buy it you think that you can make a print button that will print the dynamic text feild or input text feild whatever it is?

  8. #8
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779
    Thx, it will come much more about this from me later. That was just the start of it.

    Fredi

  9. #9
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    So you "WOULD" be able to print whatever you have in the TEXT box that will be changed?..That FONT?..That SIZE?....what about color??

    By the way..VERY NICE>..You have IMPRESSED me twice in 2 days! GREAT WORK!!

    -whispers-

  10. #10
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    gr8.

    but one more question regarding this ...

    can we do this ?

    while we goes [sets focus] in to new field by mouse / keyboard ... then if the field data is not valid then it should give some error ?

    let me know ...

  11. #11
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    one more question ....

    i also not found how to change effects of frames in tweening ... like to make alpha 0.

    i gets the effects is disabled every time ...

    plz help

  12. #12
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779
    Originally posted by aashu.com
    gr8.

    but one more question regarding this ...

    can we do this ?

    while we goes [sets focus] in to new field by mouse / keyboard ... then if the field data is not valid then it should give some error ?

    let me know ...
    I don't know what you mean, but you can set a textFormat object for every textfield. You can also set an onChanged handler for a textfield, so if something changes, you can make whatever you want.

    Much more on all this with the new version - later.

    Fredi

  13. #13
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    okay ...tell me if you found for form validation thing in flash while Focus is Killed by Keyboard or mouse of textbox then can we run function etc?

  14. #14
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779
    Originally posted by aashu.com
    okay ...tell me if you found for form validation thing in flash while Focus is Killed by Keyboard or mouse of textbox then can we run function etc?
    Yup!

    TextField.onKillFocus = function (newFocus) {
    statements;
    };

    Description

    Event handler; an event that is invoked when a text field loses keyboard focus. The onKillFocus method receives one parameter, newFocus, which is an object representing the new object receiving the focus. If no object receives the focus, newFocus contains the value null.
    Fredi

  15. #15
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    okay ... tonight i hav to work on it!

  16. #16
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779
    Just found an undocumented feature with Textfields.

    Will post an example of it later.

    Fredi

  17. #17
    caithness massiv
    Join Date
    May 2000
    Location
    denver
    Posts
    1,672
    Code:
    MovieClip.prototype.makeText = function(xPos,yPos,myText,myFont,mySize,myColor){
    	this.createEmptyMovieClip("empty",j++);
    	this.empty.createTextField("text_txt",j++,xPos,yPos,0,0);
    	this.empty.text_txt.autoSize = true;
    	this.empty.text_txt.text = myText;
    	this.empty.text_txt.selectable = false;
    	this.empty.myTextFormat = new TextFormat();
    	this.empty.myTextFormat.font = myFont;
    	this.empty.myTextFormat.size = mySize;
    	this.empty.myTextFormat.color = myColor;
    	this.empty.text_txt.setTextFormat(this.empty.myTextFormat);
    }
    just a prototype with simple formatting
    [Edited by agent vivid on 03-20-2002 at 03:52 AM]

  18. #18
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    gr8 code ....

    i think now we can make site user can select fonts ... of his own ...

    what do u think?

  19. #19
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779

    ALL HTML-FORMAT TAGS:

    The following HTML tags are supported in text fields:
    Code:
    <*A>, <*B>, <*FONT COLOR>, <*FONT FACE>, <*FONT SIZE>, <*I>, <*P>, and <*U>.
    (without the "*" of course)

    But how can we set leading, indent ... ?

    The way to do this is to use the "TEXTFORMAT" tag:

    Code:
    <*TEXTFORMAT LEFTMARGIN=\"1\" RIGHTMARGIN=\"1\" LEADING=\"2\"><*P ALIGN=\"CENTER\"><*FONT FACE=\"_sans\" SIZE=\"12\" COLOR=\"#000000\">Some text<*/FONT><*/P><*/TEXTFORMAT>
    (without all the "*" of course)

    Nice, isn't it?

    Fredi

    <TEXTFORMAT LEFTMARGIN=\"1\" RIGHTMARGIN=\"1\" LEADING=\"2\"><P ALIGN=\"CENTER\"><FONT FACE=\"Arial\" SIZE=\"72\" COLOR=\"#12aacc\"><B>SUBWAY FOREVER!!!!</B></FONT></P></TEXTFORMAT>^^^ real HTML text, not a swf ^^^^




  20. #20
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779
    I have recoded the hole puppy! It's not perfect (align not implemented), but you can write text, change the font, size, ... of the selected part of the text ...

    Things to come are:
    - align (of course)
    - font and size selector jumps to the right selections when you click into the textfield
    - some other bugs

    [swf width="550" height="300" background="#FFFFFF"]http://www.zh-webdesign.ch/zoa/autosize.swf[/swf].

    N'Joy!

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