actionscript 3 - How to use VGroup or HGroup in pure actionscript3? -


I am developing a flash app by using the free flex SDK and text editor and compiling it in the command line.

I want to use VGroup or HGroup in my ActionScript to manage the status of DisplayObjects.

I have written the following code:

  Import SparkCancondant. * Import flash.text * Var Group: VGroup = New VGroup; Var text: textfield = new text field text.text = 'abc'; Var Phantom = New Sprite; Sprite.graphics.lineStyle (2, 0x000000); Sprite.graphics.drawRect (0, 0, 100, 100); Stage.addChild (group); Group.addElement (Sprite); // Runtime Error Group .addElement (text); // COLLECTION ERROR   


But Spat is a runtime error for VGroup:

  type error: error # 1034 : Typed rape failed: Flash.display can not change :: Sprite to mx.core.IVisualElement   


And adding a textfield to the VGroup causes the error to be compiled:

  Error: A value of Type Flash Forced Forced Text: textfield mx.core: IVisualElement for an unrelated type   


How to use VGroup or HGroup in pure AS3?
What is the difference between DisplayObject and IVisualElement?


Update:

I used the first method of www.Flextras.com, the Sprite Visual Element, and the StylteTextField.
I wrote the following code:

  package {import flash.display * Import spark.core.provisual element / import spark.comment. Support Classes. StylableTextField // Complex Error Import Spark.Comment VGroup Import Flash.Text * [SWF (background calver = 0 xff, width = 500, height = 500, framerect = 12)] Public class VGroupTest Sprite extension {function VGroupTest () {// var text: StyleableTextField = New StyleableTextField //text.text = 'Abc'; Var Sprite 1: Sprite Visual Element = New Sprite Visual Element; Sprite1.graphics.lineStyle (2, 0x000000); Sprite1.graphics.drawRect (0, 0, 100, 100); Sprite1.width = 200 sprite1.height = 200 var sprite2: Sprite Visual Element = New Sprite Visual Element; Sprite2.graphics.lineStyle (2, 0xff0000); Sprite2.graphics.drawRect (0, 0, 200, 200); Sprite2.width = 300 sprite2.height = 300 var group: VGroup = new VGroup; Group.gap = 10 groups.method = 400 group.height = 400 this.stage.addChild (group); // the following code do not show anything to //group.addElement; Group.addElement (sprite1); Group.addElement (sprite2); // The following code 2 rectangle shows // ths.stage.addChild (sprite1) //this.stage.addChild(sprite2)}}}   



  import spark.components.supportClasses.StyleableTextField   

caused the following error

  40 error: definition spark.components . Supportclasses: StyleableTextField could not be found   


and no spreitual element is shown on the screen. Am I missing something?

You are using the right ideological approach, however, a group (or VGUTP or HGUP ), Which will neither be implemented nor implemented.

You have to consider some options:

  1. Sprite; Or use instead of a TextField.
  2. Wrap Sprite or Textfield as a child of UICMAPPaint; Then use that UICMPonent as an element in that group.
  3. Use MX containers, such as HBOX or VB
  4. Use a UIComponent instead of a group.
  5. My priority is the first approach, after the fourth approach, you can write your own layout code in the updateDisplayList (). Approach2 adds a lot of extra coding, and the view is unwanted because of reliance on 3Mx / Halo architecture.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -