user input string

I have an application that allows the user to upload fies to the server and store the path in a database so they can be associated with a certain record; this part works fine.  Now I want the user to be able to add a short description.  I am planning to use a popup (or similar control) to display when the user clicks the file upload button.  The user will then enter a description of 300 characters or less and the application will then pass that string to the function that uploads the file, so it can be added to an array.

Can someone give me an example of how to do this?  My current code is below.
//button that calls upload function
<mx:HBox width="100%" height="10%" horizontalAlign="center" >
					<mx:Button label="Add Attachment" click="Program.upload();"/>
					<mx:Button label="Remove" click="{Alert.show('Other code here')}"/>
				</mx:HBox>

public static function upload():void 
		{
		
		CursorManager.setBusyCursor();
         // listen for the file selected event
         // listen for the upload complete event
         fileRef.addEventListener(Event.SELECT, selectHandler);
         fileRef.addEventListener(Event.COMPLETE, completeHandler);
         fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA   , uploadCompleteHandler);
         fileRef.addEventListener(IOErrorEvent.IO_ERROR, onIOError)

         // browse for the file to upload
         // when user selects a file the select handler is called
         try 
         {
             var success:Boolean = fileRef.browse();
         }
         catch (error:Error) 
         {
             Alert.show("Unable to browse for files.");
             CursorManager.removeBusyCursor();
         }
      	}

Open in new window

LVL 6
PsychoDazeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vindys80Commented:
Hi,

I think you need to send data from your description PopUp to your parent where you call the Pop Up. Right?

http://www.adobe.ca/livedocs/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=layouts_065_50.html
http://livedocs.adobe.com/flex/3/html/help.html?content=layouts_12.html

These two links will help you to get clear idea about the two ways to pass data from and to popUp.
Lets know if you need some more help on this.
Thanks,
Vindys
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sunsonmaheshCommented:
0
PsychoDazeyAuthor Commented:
Hi Vindys -

Yes, that is correct.  I have a button contained in an mxml file, when clicked I want it to open the popup then take the users input (must be <=300 characters) and pass that to my function, which is contained in  an .as file.  I am not really clear on the parent and how to pass the input to my function.

Thanks sunson, I will take a look.
0
Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

sunsonmaheshCommented:
Hi
use mx.core.application.Application to access any variable inside the main mxml file....
from the popup component ,u could use this.parentApplication

--mahe
0
PsychoDazeyAuthor Commented:
Thanks, worked like a charm!
0
vindys80Commented:
Hi,

This is the sample popup code

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
      <mx:Script>
            <![CDATA[
                  import mx.managers.PopUpManager;
                  import mx.core.Application;
                  private function sendDesc():void{
                        test1.setDescText(_desc.text);
                        PopUpManager.removePopUp(this);
                  }
            ]]>
      </mx:Script>
      <mx:TextArea maxChars="300" id="_desc" height="100%" width="100%"/>
      <mx:Button label="OK" click="sendDesc()" enabled="{_desc.text.length}"/>
</mx:TitleWindow>



This is the mxml file

<mx:HBox width="100%" height="10%" horizontalAlign="center" >
            <mx:Button label="Add Attachment" click="upload();"/>
          <mx:Button label="Remove" click="{Alert.show('Other code here')}"/>
    </mx:HBox>
      <mx:Button label="Add Description" click="openPopUp()"/>


This is the action script part

      private var myB:MyBox;
      private static var _descText:String = "";
      private static var  fileRef:FileReference;
      public static function upload():void
                {
               
         CursorManager.setBusyCursor();
         // listen for the file selected event
         // listen for the upload complete event
         //fileRef.addEventListener(Event.SELECT, selectHandler);
         //fileRef.addEventListener(Event.COMPLETE, completeHandler);
         //fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA   , uploadCompleteHandler);
         //fileRef.addEventListener(IOErrorEvent.IO_ERROR, onIOError)

         // browse for the file to upload
         // when user selects a file the select handler is called
         try
         {
               Alert.show(_descText);
             var success:Boolean = fileRef.browse();
         }
         catch (error:Error)
         {
             Alert.show("Unable to browse for files.");
             CursorManager.removeBusyCursor();
         }
        }
      private function openPopUp():void{
            myB = PopUpManager.createPopUp(this,MyBox) as MyBox;
            PopUpManager.centerPopUp(myB);
      }
      public static function setDescText(value:String):void{
            _descText = value;
      }


I usually write actionscript function in mxml file itself. So it will be something like this.
<?xml version="1.0"?>
<!-- DataGrid control example. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
	import mx.controls.Alert;
	import mx.managers.CursorManager;
	import mx.managers.PopUpManager;
	private var myB:MyBox;
	private static var _descText:String = "";
	private static var  fileRef:FileReference;
	public static function upload():void 
                {
                
         CursorManager.setBusyCursor();
         // listen for the file selected event
         // listen for the upload complete event
         //fileRef.addEventListener(Event.SELECT, selectHandler);
         //fileRef.addEventListener(Event.COMPLETE, completeHandler);
         //fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA   , uploadCompleteHandler);
         //fileRef.addEventListener(IOErrorEvent.IO_ERROR, onIOError)

         // browse for the file to upload
         // when user selects a file the select handler is called
         try 
         {
         	Alert.show(_descText);
             var success:Boolean = fileRef.browse();
         }
         catch (error:Error) 
         {
             Alert.show("Unable to browse for files.");
             CursorManager.removeBusyCursor();
         }
        }
	private function openPopUp():void{
		myB = PopUpManager.createPopUp(this,MyBox) as MyBox;
		PopUpManager.centerPopUp(myB);
	}
	public static function setDescText(value:String):void{
		_descText = value;
	}
	
]]>
</mx:Script>

	<mx:HBox width="100%" height="10%" horizontalAlign="center" >
		<mx:Button label="Add Attachment" click="upload();"/>
	    <mx:Button label="Remove" click="{Alert.show('Other code here')}"/>
    </mx:HBox>
	<mx:Button label="Add Description" click="openPopUp()"/>

</mx:Application>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Flex

From novice to tech pro — start learning today.