naveenm_006
asked on
How to capture user credentials provide in flash swf file in flex?
How to capture user credentials of flash swf file in flex?
Here i am attaching snippet and swf files for your reference.
Regards,
Naveen.
sampark-bottom.swf
Here i am attaching snippet and swf files for your reference.
Regards,
Naveen.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="100%" width="100%">
<mx:SWFLoader id="loader1" source="assests/sampark_HR.swf" y="0" width="1300" height="1200" x="0"/>
<mx:SWFLoader id="loader2" source="assests/sampark_bottom.swf" y="490" width="1300" height="1200" x="0"/>
</mx:Application>
sampark-HR.swfsampark-bottom.swf
ASKER
Can you provide me some sample snippet for this. I looked into the link which you have provided but i didn't get any thing regarding my query.
Anyway i am sharing one swf file for your reference which is the first page of my application(hrhelpdesk).
Regards,
Naveen.
main.swf
Anyway i am sharing one swf file for your reference which is the first page of my application(hrhelpdesk).
Regards,
Naveen.
main.swf
Try this:
Warm Regards
Deepanjan Das
<?xml version="1.0"?>
<!-- controls\swfloader\SWFLoaderInteract.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
backgroundColor="gray"
height="200">
<fx:Script>
<![CDATA[
import mx.managers.SystemManager;
[Bindable]
public var loadedSM:SystemManager;
// Initialize variables with information from
// the loaded application.
private function initNestedAppProps():void {
loadedSM = SystemManager(myLoader.content);
loadedSM.application["loginButtonInstanceName"].addEventListener( MouseEvent.CLICK, doLogin, false, 0, true );
}
public function doLogin( event:MouseEvent ):void {
//"userTextFieldInstanceName" is the username text field instance name
var username:String = loadedSM.application["userTextFieldInstanceName"].text;
var password:String = loadedSM.application["passTextFieldInstanceName"].text;
//now call your request with the username and password parameter in flex to validate login credentials
}
]]>
</fx:Script>
<s:VGroup>
<s:Label id="lbl"/>
<mx:SWFLoader id="myLoader" width="300"
source="assests/sampark_bottom.swf"
complete="initNestedAppProps();"/>
</s:VGroup>
</s:Application>
Warm Regards
Deepanjan Das
ASKER
When i run/debug your application i am getting the following error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@5 213e81 to mx.managers.SystemManager.
at main/initNestedAppProps()[ D:\naveen. kumar\Docu ments\Flex Builder 3\hrhelpdesk\src\main.mxml :17]
at main/__myLoader_complete() [D:\naveen .kumar\Doc uments\Fle x Builder 3\hrhelpdesk\src\main.mxml :34]
at flash.events::EventDispatc her/dispat chEventFun ction()
at flash.events::EventDispatc her/dispat chEvent()
at mx.core::UIComponent/dispa tchEvent() [C:\autobu ild\3.5.0\ frameworks \projects\ framework\ src\mx\cor e\UICompon ent.as:944 0]
at mx.controls::SWFLoader/http://www.adobe.com/2006/flex/mx/internal::contentLoaderInfo_completeEventHandler()[C: \autobuild \3.5.0\fra meworks\pr ojects\fra mework\src \mx\contro ls\SWFLoad er.as:2064 ]
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::AVM1Movie@5
at main/initNestedAppProps()[
at main/__myLoader_complete()
at flash.events::EventDispatc
at flash.events::EventDispatc
at mx.core::UIComponent/dispa
at mx.controls::SWFLoader/http://www.adobe.com/2006/flex/mx/internal::contentLoaderInfo_completeEventHandler()[C:
The swfs that you are using are in AS2.
I though those were in AS3.0.
Then you have to use FlashInterface or ExternalInterface.
Warm Regards
Deepanjan Das
I though those were in AS3.0.
Then you have to use FlashInterface or ExternalInterface.
Warm Regards
Deepanjan Das
ASKER
ok thanks for your reply,
may i know what this piece of code tells
complete="initNestedAppPro ps();"
when it is going to invoke.
Regards,
Naveen.
may i know what this piece of code tells
complete="initNestedAppPro
when it is going to invoke.
Regards,
Naveen.
ASKER
which swf file you are saying to convert as3.There are two swf files.
1)sampark_HR.swf
2)sampark_bottom.swf
Both i need to convert or only one.If one which swf file need to convert from as2 to as3.
Regards,
Naveen.
1)sampark_HR.swf
2)sampark_bottom.swf
Both i need to convert or only one.If one which swf file need to convert from as2 to as3.
Regards,
Naveen.
Basically which ever files you want to communicate with flex must be AS3.0 if you want to avoid using FlashInterface and making it more complex.
Here sampark_bottom.swf is going to communicate with Flex, so if possible convert it tro AS3.0
This
complete="initNestedAppPro ps();"
means that on loading complete of the swf the function initNestedAppProps() will get called which have been defined above.
You can change the name of the function.
Warm Regards
Deepanjan Das
Here sampark_bottom.swf is going to communicate with Flex, so if possible convert it tro AS3.0
This
complete="initNestedAppPro
means that on loading complete of the swf the function initNestedAppProps() will get called which have been defined above.
You can change the name of the function.
Warm Regards
Deepanjan Das
ASKER
What are these below instances which you are used in the code? These are the instance names used in as3.0 am i right?
loginButtonInstanceName
userTextFieldInstanceName
passTextFieldInstanceName
Regards,
Naveen.
loginButtonInstanceName
userTextFieldInstanceName
passTextFieldInstanceName
Regards,
Naveen.
yes, exactly :).
The instance names used in the flash.
For e.g.
loginButtonInstanceName is the name of the login button.
Warm Regards
Depanjan Das
The instance names used in the flash.
For e.g.
loginButtonInstanceName is the name of the login button.
Warm Regards
Depanjan Das
ASKER
Hi now i am getting the following error after converting as2 to as3
TypeError: Error #1034: Type Coercion failed: cannot convert sampark_bottom_fla::MainTi meline@7a0 cf89 to mx.managers.SystemManager.
at main/initNestedAppProps()[ D:\naveen. kumar\Docu ments\Flex Builder 3\hrhelpdesk\src\main.mxml :15]
at main/__myLoader_complete() [D:\naveen .kumar\Doc uments\Fle x Builder 3\hrhelpdesk\src\main.mxml :30]
at flash.events::EventDispatc her/dispat chEventFun ction()
at flash.events::EventDispatc her/dispat chEvent()
at mx.core::UIComponent/dispa tchEvent() [C:\autobu ild\3.5.0\ frameworks \projects\ framework\ src\mx\cor e\UICompon ent.as:944 0]
at mx.controls::SWFLoader/http://www.adobe.com/2006/flex/mx/internal::contentLoaderInfo_completeEventHandler()[C: \autobuild \3.5.0\fra meworks\pr ojects\fra mework\src \mx\contro ls\SWFLoad er.as:2064 ]
Plz find the attachements.
Regards,
Naveen.
sampark-bottom.swf
TypeError: Error #1034: Type Coercion failed: cannot convert sampark_bottom_fla::MainTi
at main/initNestedAppProps()[
at main/__myLoader_complete()
at flash.events::EventDispatc
at flash.events::EventDispatc
at mx.core::UIComponent/dispa
at mx.controls::SWFLoader/http://www.adobe.com/2006/flex/mx/internal::contentLoaderInfo_completeEventHandler()[C:
Plz find the attachements.
Regards,
Naveen.
<?xml version="1.0" encoding="utf-8"?>
<!-- controls\swfloader\SWFLoaderInteract.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="gray">
<mx:Script>
<![CDATA[
import mx.managers.SystemManager;
[Bindable]
public var loadedSM:SystemManager;
// Initialize variables with information from
// the loaded application.
private function initNestedAppProps():void {
loadedSM = SystemManager(myLoader.content);
loadedSM.application["loginButtonInstanceName"].addEventListener( MouseEvent.CLICK, doLogin, false, 0, true );
}
public function doLogin( event:MouseEvent ):void {
//"userTextFieldInstanceName" is the username text field instance name
var username:String = loadedSM.application["userTextFieldInstanceName"].text;
var password:String = loadedSM.application["passTextFieldInstanceName"].text;
trace(username);
trace(password);
//now call your request with the username and password parameter in flex to validate login credentials
}
]]>
</mx:Script>
<mx:SWFLoader id="loader1" source="assests/sampark_HR.swf" width="1300" height="1200"/>
<mx:SWFLoader id="myLoader" source="assests/sampark_bottom.swf" y="482" width="1300" height="1200" x="0" complete="initNestedAppProps();"/>
</mx:Application>
sampark-bottom.flasampark-bottom.swf
ASKER
anyway i got successful output.But now the problem is how to do client side validations like if username and password not entered it should show some alert message saying username/password can not be empty.
How can we get this functionality.
Here i am sharing the code what i have made changes to that code.
Regards,
Naveen.
How can we get this functionality.
Here i am sharing the code what i have made changes to that code.
Regards,
Naveen.
loadedSM = myLoader.content;
loadedSM.addEventListener( MouseEvent.CLICK, doLogin, false, 0, true );
in doLogin() method check for blank values and show an alert in flex itself.
Warm Regards
Deepanjan Das
Warm Regards
Deepanjan Das
ASKER
can you provide me sample code.I have tried like this:
public function doLogin( event:MouseEvent ):void
{
//"userTextFieldInstanceNa me" is the username text field instance name
if(event.target.name == "loginButtonInstanceName") {
var username:String = loadedSM.userTextFieldInst anceName.t ext;
var password:String = loadedSM.passTextFieldInst anceName.t ext;
trace(username);
trace(password);
if(username.length<0)
{
Alert.show('username can not be empty');
}
if(password.length<0){
Alert.show('password can not be empty');
}
}
}
am i doing the correct?
public function doLogin( event:MouseEvent ):void
{
//"userTextFieldInstanceNa
if(event.target.name == "loginButtonInstanceName")
var username:String = loadedSM.userTextFieldInst
var password:String = loadedSM.passTextFieldInst
trace(username);
trace(password);
if(username.length<0)
{
Alert.show('username can not be empty');
}
if(password.length<0){
Alert.show('password can not be empty');
}
}
}
am i doing the correct?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Need to focus input textfield by default when the application launches so that user no need to manual point the cursor into the input textfield. This functionality i need how can we do this?
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f9c.html
Warm Regards
Deepanjan Das