0 Replies Latest reply on Apr 13, 2007 12:22 PM by igo88

    Creating components via pop up!

    igo88
      First of all...Hi everyone...

      I am new in Flex...i have been reading...and now i am doing one of my first applications...

      The problem is that, i have the mxml file...in which i load 3 images...
      then i have an .as file as source...in where i have some functions related with drag and drop...Then i have a button, that when you click it...a title window should be opened...but...i have got no parent reference to create it...thats the first problem....

      The second one is, how can i create a Box and display it on the same stage as the images loaded in the mxml file from the pop up window?...i think it is the same problem...I will post the code Beloew...Thank you :D

      THE MXML FILE:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[


      [Embed("C:/Igo/cancha5nk.jpg")]
      [Bindable]
      public var cilindro1:Class;

      [Embed("C:/Igo/14nn7ug.jpg")]
      [Bindable]
      public var cilindro2:Class;

      [Embed("C:/Igo/cilindrodeafuera1gc.jpg")]
      [Bindable]
      public var cilindro3:Class;
      public var correcta:String="";
      ]]>
      </mx:Script>
      <mx:VBox horizontalAlign="center" width="100%" height="100%">


      <mx:HBox horizontalAlign="center" width="100%" height="100%">
      <mx:Image
      id="Cilindro1" source="{cilindro1}"
      mouseMove="drag(event, 1);"
      height="200" width="200"
      horizontalAlign="left"

      />
      <mx:Image
      id="Cilindro2" source="{cilindro2}"
      mouseMove="drag(event, 2);"
      height="200" width="200"
      horizontalAlign="center"
      />
      <mx:Image
      id="Cilindro3" source="{cilindro3}"
      mouseMove="drag(event, 3);"
      height="200" width="200"
      horizontalAlign="right"
      />



      </mx:HBox>

      <mx:HBox width="100%" height="100%">


      <mx:HBox
      name="Cilindro2"
      borderStyle="solid" borderColor="#000000" backgroundColor="#FFFFFF"

      width="33%" height="150" horizontalAlign="center" verticalAlign="middle"

      dragEnter="dragEnterHandler(event);"
      dragDrop="dragDropHandler(event);"
      dragExit="dragExitHandler(event);"/>


      <mx:HBox
      name="Cilindro3"
      borderStyle="solid" borderColor="#000000" backgroundColor="#FFFFFF"

      width="33%" height="150" horizontalAlign="center" verticalAlign="middle"

      dragEnter="dragEnterHandler(event);"
      dragDrop="dragDropHandler(event);"
      dragExit="dragExitHandler(event);"/>

      <mx:HBox
      name="Cilindro1"
      borderStyle="solid" borderColor="#000000" backgroundColor="#FFFFFF"

      width="33%" height="150" horizontalAlign="center" verticalAlign="middle"

      dragEnter="dragEnterHandler(event);"
      dragDrop="dragDropHandler(event);"
      dragExit="dragExitHandler(event);"/>

      </mx:HBox>


      <mx:Button id="botonNuevo" label="Nuevo" click="new Wizard()"/>


      </mx:VBox>
      <mx:Script source="Funciones.as"/>
      </mx:Application>

      THE FILE WIZARD.AS:

      package Rodrigo

      {
      import flash.events.Event;
      import mx.events.*;
      import mx.containers.*;
      import mx.controls.ComboBox;
      import mx.states.AddChild;
      import mx.controls.Label;
      import mx.containers.HBox;
      import mx.containers.VBox;
      import mx.events.CloseEvent;
      import mx.managers.PopUpManager;
      import mx.controls.ComboBox;
      import mx.containers.TitleWindow;
      import mx.charts.chartClasses.IAxis;
      import mx.controls.Alert;
      import mx.events.DragEvent;
      import mx.containers.Box;
      import mx.controls.Button;
      import flash.events.MouseEvent;

      public class Wizard
      {
      public var rv:TitleWindow=new TitleWindow();
      public var imagenCorrecta:ComboBox=new ComboBox();
      public var vbox:VBox=new VBox();
      public var botonCrear:Button=new Button();
      public var hbox1:HBox=new HBox();
      public var hbox2:HBox=new HBox();
      public var labelImagen:Label=new Label();
      public var imagenes:Array=new Array("Cilindro1","Cilindro2","Cilindro3");
      public var correcta:String="";
      public function popUp():TitleWindow
      {
      imagenCorrecta.editable=false;

      //Agregar items al Combo

      labelImagen.text="Elegir imagen correcta";

      botonCrear.label="Crear";

      rv.width = 325;

      rv.height = 150;

      rv.title="Crear Nueva Drop Zone";

      rv.showCloseButton = true;



      hbox1.addChild(labelImagen);

      hbox1.addChild(imagenCorrecta);

      hbox2.addChild(botonCrear);

      vbox.addChild(hbox1);

      vbox.addChild(hbox2);

      rv.addChild(vbox);

      rv.showCloseButton=true;

      PopUpManager.addPopUp(rv,"Need reference here",true);

      PopUpManager.centerPopUp(rv);

      rv.addEventListener(CloseEvent.CLOSE,closeHandler);

      imagenCorrecta.addEventListener(Event.CHANGE,changeHanlder);
      botonCrear.addEventListener(MouseEvent.CLICK,agregar);

      return rv;
      }

      public function changeHanlder(evt:Event):void
      {
      correcta=imagenCorrecta.selectedItem.toString();
      }
      public function closeHandler(evt:CloseEvent):void
      {
      PopUpManager.removePopUp(rv);
      }

      public function agregar(evt:MouseEvent):void

      {

      }
      }
      }