A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Help!!!!!!!!!!

  1. #1
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779
    I'm working on my WYSIWYG editor and have a big proplem with the comboBox component. Hope someone can help me out.

    This is the code for my textfield creating function:
    Code:
    // Creating textfield
    function createNewTextField(level, line, x, y, width, height, text, fontName, fontSize, bold, italic, align){
    	createTextField("mytext" + line, level, x, y, width, height);
    	fontArray[line-1] = fontName;
    	boldArray[line-1] = bold;
    	italicArray[line-1] = italic;
    	alignArray[line-1] = align;
    	this["mytext" + line].multiline = false;
    	this["mytext" + line].wordWrap = false;
    	this["mytext" + line].border = true;
    	this["mytext" + line].html = false;
    	this["mytext" + line].type = "input";
    	this["mytext" + line].selectable = true;	
    	this["mytext" + line].text = thetext;
    	this["mytext" + line].borderColor = 0x6699cc;
    	this["mytext" + line].text = text;
    	fontList.setEnabled(true);
    	fontList.setSelectedIndex(fontPos(fontName));
    	fontSize.setEnabled(true);	
    	fontSize.setSelectedIndex(fontSizePos(fontSize));
    	createNewFormat(line, fontName, bold, italic, align);
    	this["mytext" + line].setTextFormat(this["fieldTextFormat" + line]);
    	// set onChanged handler for actual textfield
    	this["mytext" + line].onChanged = function() {
    		this["mytext" + line].setTextFormat(this["fieldTextFormat" + line]);
    		//trace("max: " + _root["mytext" + line].maxhscroll + " hscroll: " + _root["mytext" + line].hscroll + " Line: " + line);
    		if (_root["mytext" + line].hscroll > 0){
    			createNewLine();
    		}
    	}
    }
    The problem are this lines:
    Code:
    	fontList.setEnabled(true);
    	fontList.setSelectedIndex(fontPos(fontName));
    	fontSize.setEnabled(true);	
    	fontSize.setSelectedIndex(fontSizePos(fontSize));
    Basicaly I wanna set the selection position of the font and fontSize list to the font and fontSize of the new textfield.

    The funny thing is that the code works on a button, but not in the function. I can check with getEnabled if the component is enabled - no problem, but I can't set the selection position. The "fontPos function works fine, so this is not the problem. The problem is the "setSelectedIndex"

    My thirst idea was, that the component was not ready at the time the function runs (1. frame) But then, the "getEnabled" would never give a "true" back.

    Any ideas?

    Fredi


  2. #2
    Senior Member
    Join Date
    Sep 2000
    Posts
    273
    Subway --

    Not to sound like a maroon, but would you e-mail me the .fla file so I can see exactly what you are talking about?

    Just by looking at the code snippet everything appears to be correct (AS wise), so if you could send over the .fla with a description of the exact problem and when it occurs I can see if I can help you track it down.

    Spyder

  3. #3
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779
    Thx, I just found a way to do it. It was really a timing problem. I placed the setEnabled part to frame 2 and it worked.

    Seams like this part of the comboBox component needs some time (1 frame) bevor you can set the selection position.

    Fredi

  4. #4
    Senior Member
    Join Date
    Sep 2000
    Posts
    273
    yeah a comboBox element must exist before before it can be called. Normal wait time is 1 frame, but sometimes using embeded functions and passing the object to the second function after creating it will work without requiring the wait time.

    Spyder

  5. #5
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779
    Yeah, this works on the first frame:

    Code:
    // Set fontList dataprovider and handler
    fontList.setDataProvider(myfonts);


  6. #6
    Information Architect Subway's Avatar
    Join Date
    Feb 2000
    Location
    Switzerland
    Posts
    4,779
    Btw, Flash MX crashed the first time for me, during this one - three times in a row.

    Fredi

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