header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
athi
Points:20
Posts:0

6/7/2010 11:59:24 PM

Title: sharing variable in one mxml to other mxml file


1. personal.mxml
text input 1 : nametxt
2: addresstxt

3. submit button

2. Family.mxml
text input 1 : fathernametxt
2: mothernametxt


ther user enter first personal.mxml
he give the name and address then he selects submit button

when submit button clicks it navigates
http://localhost:8080/StudentRegistration/html/Family.html(Family.swf)

then the user enter Fathername and mothername.
here i want to transfer to uservo.as file
nametxt, addresstxt,faternametxt,mothernametxt.
but i cant get nametxt and addresstxt in Family.mxml
remember nametxt,addresstxt ---> personal.mxml


anybody help me




1
Flash_Guy
Points: 850
Posts:0
6/8/2010 3:07:32 AM



when you move from one swf file to another , the data is not preserved until its stored in the server side and retrieved again. Why are you creating different swf files ? You should include all your forms in a single swf. On submit the form should disappear and the new form should be made visible . In this way you will not require to reload a new swf and hence the data of all the forms will be accessible.

2
Davis
Points: 780
Posts:0
6/8/2010 3:35:16 AM



you have created 2 different swf files, so the data of one swf file will not be accessible to other file until you transfer the data using some server technology or using querystring method. If you use querystring , then remember that it does not support more than 256 characters.you have to extract the querystring in the family.html and then submit all the variables along with the variables of the family.htm.

Its a long process, the recommended one is as told by Flash_guy. Create asingle swf and switch the forms on submit and on final submit get all the values. You can use states also if you have many number of pages in a single swf file.

3
athi
Points: 20
Posts:0
6/8/2010 3:40:23 AM



hi
my project requirement is tranfer the textinput value into another .mxml file
so i need
pls give some ideas

4
william
Points: 0
Posts:0
6/8/2010 4:20:44 AM



You can pass your values from personal.mxml to Family.mxml like this:On submit call the next url like this inside personal.mxml.
http://localhost:8080/StudentRegistration/html/Family.html?nameText=nametxt.text&addressText=addresstxt.text

In browser your url should appear like this

http://localhost:8080/StudentRegistration/html/Family.html?nameText=myName&addressText=myAddress

Now in Family.mxml read the previous variables using external interface. This is flex actionscript 3.0 code to read the querystring parameters


//call the below function to read the querystring from url and create array 
private var paramsFromUrl:Array;
private function readQueryStringVars():void
{
try
{
	var queryStringReceived:String = ExternalInterface.call("window.location.search.substring", 1);
	if(queryStringReceived)
	{
		var params:Array = queryStringReceived.split('&');
		var length:uint = params.length;
		var paramsLengthFromUrl:Number = length;
		
		for (var i:uint=0,index:int=-1; i<length; i++)
		{
			var variablesPair:String = params[i];
			if ((index = variablesPair.indexOf("=")) > 0)
			{
				var varRecieved:String = variablesPair.substring(0,index);
				var valueRecieved:String = variablesPair.substring(index+1);
				paramsFromUrl[varRecieved] = valueRecieved;
			}
		}
	}
}
catch(e:Error)
{
	trace("Error");
}
}
//After calling your "readQueryStringVars()" function you can read the variables in Family.swf 
private var nameRecieved:String=paramsFromUrl["nameText"]
private var addressRecieved:String=paramsFromUrl["addressText"]



Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 1+2 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions