Adobe Dreamweaver Forums



Last 10 THreads :         PS CS4 "Save As ..." format choices appear in duplicate (Last Post : Dan_Dill@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: Colour differences on the web (Last Post : g_ballard@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: SFW and date created (Last Post : Ann_Shelbourne@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: sRGB vs. Adobe (1998) RGB (Last Post : Neil_Keller@adobeforums.com - Replies : 0 - Views : 1 )           »          help my flash site opens pop ups? (Last Post : Awebus - Replies : 2 - Views : 3 )           »          Flash IDE randomly creating Symbols (Last Post : MediaMackenzie.com - Replies : 0 - Views : 1 )           »          Wishing I could make Sprite Symbols using F8 (Last Post : MediaMackenzie.com - Replies : 0 - Views : 1 )           »          3 overlapping background images on same page (Last Post : brad_goldstein - Replies : 8 - Views : 9 )           »          help me with adjustments layers in CS4 (Last Post : Ann_Shelbourne@adobeforums.com - Replies : 4 - Views : 5 )           »          Re: Help authenticating installer (Last Post : Awebus - Replies : 0 - Views : 1 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-04-2008, 09:02 AM
projectproofing
 
Posts: n/a
Diggs:
Default Passing a variable from an app to a component

Put simply, I need to pass a projectID to a pop up window (component) so it can us it when adding information to a database. Anyone know how to do this or where to find an example.


Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-04-2008, 09:02 AM
ericbelair
 
Posts: n/a
Diggs:
Default Re: Passing a variable from an app to a component

Just add a public variable to your TitleWindow and set it from the component
that pops the window.

Here's a very condensed version of what you need to do...

/* MyPopUp.mxml */
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
[Bindable]
public var projectId:int;
]]>
</mx:Script>
</mx:TitleWindow>

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

private var popUp:MyPopUp = new MyPopUp();

private function button_clickHandler():void
{
myPopUp.projectId = 1;

PopUpManager.addPopUp(myPopup, parent, true);
}
]]>
</mx:Script>

<mx:Button click="button_clickHandler();" />
</mx:Application>

Reply With Quote
  #3 (permalink)  
Old 11-04-2008, 09:02 AM
Greg Lafrance
 
Posts: n/a
Diggs:
Default Re: Passing a variable from an app to a component

Or you can access the data in the application using
Application.application.myDataVar.

----- components/CustomTitleWindow.as -----
package components
{
import flash.events.Event;
import flash.events.MouseEvent;

import mx.containers.TitleWindow;
import mx.controls.Button;
import mx.controls.Text;
import mx.core.Application;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;

public class CustomTitleWindow extends TitleWindow{

public function CustomTitleWindow(){
super();
this.setStyle("horizontalAlign", "center");
this.addEventListener(FlexEvent.CREATION_COMPLETE,
creationCompleteHandler);
this.title = "Info was Passed from Application";
var txt:Text = new Text();
txt.setStyle("fontSize", "12");
txt.setStyle("fontWeight", "bold");
txt.width = 300;
txt.text = Application.application.info;
this.addChild(txt);
var btn:Button = new Button();
btn.label = "Close";
btn.setStyle("fontSize","12");
btn.addEventListener(MouseEvent.CLICK, closeHandler);
this.addChild(btn);
}

private function closeHandler(event:MouseEvent):void{
PopUpManager.removePopUp(this);
}

private function creationCompleteHandler(event:Event):void{
PopUpManager.centerPopUp(this);
}
}
}
----- PopupPassInfo.mxml -----
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import components.CustomTitleWindow;
import mx.managers.PopUpManager;

public var info:String = "This is the information you will need!!!";

private function clickHandler():void{
PopUpManager.createPopUp(this, CustomTitleWindow, true);
}
]]>
</mx:Script>
<mx:Button label="Pass Text to Popup"
fontSize="12" click="clickHandler()"/>
</mx:Application>

Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:13 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk