Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
frickteam

addItem adds always a second textField

Recommended Posts

Hi,

 

i try to create a layer manager wher i can push buttons to push selected items forward or backward on the canvas.

 

Now i use numChildrens() to see how many Childs are on the canvas. Then i have seen that allways i add a textField

to the Transformmanager theres another textField placed. But it is not visible.

 

Is it normal that Transformmanager placed always a second textField?

If i do that with movieclips this doesn´t happend.

 

Here is my code snippet from the function which placed a textField on the canvas:

 

public function textfeldPlatzieren() {

		tf = new TextField();

		leinwand.addChild(tf);

		trace("children1 "+leinwand.numChildren);
		for (var i:Number=0; i < leinwand.numChildren; i++)
		{
			if(leinwand.getChildAt(i) is TextField){

				var obj = leinwand.getChildAt(i);
				trace(i+" : " + obj + " - " + obj.text);
			}
		}

	        trace("children2 "+leinwand.numChildren);
		transformManager.addItem(tf);
		trace("children3 "+leinwand.numChildren);
	}

 

on trace "children2" is only one textField - on trace "children3" after addItem there is a second textField

Link to comment
Share on other sites

Yes, this is normal. It was necessary in order to get around some bugs in the Flash Player to use another TextField as a proxy of sorts. Long story, but it has to do with avoiding stretching/squishing the text and the behavior of TextField's transform.matrix property.

Link to comment
Share on other sites

o.k.

 

so if i want to change the textfield index to build my layer management

should i change also the index from the second textfield or doesn´t it matter?

or how can i handle that? is there anybody who wrote a script/function for layer management?

Link to comment
Share on other sites

The index of the hidden TextField(s) doesn't matter at all. Feel free to move them up or down in the display list (or not).

Link to comment
Share on other sites

  • 1 month later...

ok for example:

i have two textfields on my canvas

now i want to put the selected textfield one layer behind

 

so i catch the index of these two textfields and swap them with swapChildrenAt(selectedChildIndex,otherChildIndex)

than the selected textfield is in the back of the other textfield -> so everything works

 

but if i move the selected textfield after that action -> the other textfield disapears from the canvas

 

what could be the mistake?

Link to comment
Share on other sites

I'd need to see an example of what you're talking about - could you post an example (do not include the TransformManager classes please). The simpler the better.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×