Connecting mxml components
hello all first of all. i'm new to flex, just started
learning a couple of days ago. i did some mxml pages with different
forms and images and i want to know how to connect them. i have one
button in one mxml page and when i click that button i want the
second mxml page to be launched by the browser. what mxml functions
to use and how?
thanx in advance
the swf file is compiled from flex and run in a browser
FlashPlayer plugin and not like html. You can use swf loader
component inside one fles app, but most likely you take all you
mxml files and add to a project. Then in code select what you want
to show. Try the TabNavigator and put you buttons and images inside
each tab and you can switch view.
Similar Messages
-
Using salesforce connector in multiple mxml components
I am using Flex 2.0.1 and Salesforce as Database. My question
is i am creating login method in each component and application. I
want to use/pass salesforce connection from main application to all
sub component, how can i achieve this to avoid login for each
application/ component.
example: In my project i created main.mxml application and 3
mxml components in each component i am logining into the salesforce
database to retrieve data from the database. i want to avoid
creating multiple logins for the components instead of writing
login for each mxml component i want login for the first time in
main.mxml application and want to use the same connection in mxml
components. Can anyone tell me how can i achieve this
If you feel this is not sufficient information to solve this
problem then let me know i will post another message with sample
code.
Thanks in advance.The solution I ended up using was just to reference the CSS file at the root MXML application. Then I could just use .styleName on the Menu component and voila, it worked.
-
Converting MXML Components to ActionScript Classes
I'm in the process of converting most (if not all) of my MXML
components to Action Script classes. I've found this is easy, and
doesn't require a lot of extra code when extending a simple
container or control. However, several of my MXML components have
several nested containers and controls - i.e. a component that
contains several Labels, a ComboBox, a TextInput, a Button, and a
DataGrid, plus several other containers needed for layout. To code
the layout of all these containers and controls using MXML, it uses
about 16 lines of code. To code the layout in ActionScript, it
takes about 50+ lines of code (see attached).
I'm just wondering if there are any best practices for
creating ActionScript classes that include several (or even A LOT
OF) containers and controls. It's very easy to layout in MXML, and
is more visibly pleasing to look at and understand, but I feel it
is best practice to code components as ActionScript classes. I know
I should be using MVC, but it's a little late to rewrite the entire
application now.
Any thoughts?I can't specifically speak to how to write layout code in
ActionScript, but you can look at the generated code that Flex
creates to get an idea of how Flex does it. When you compile an
app, the Flex compiler takes your MXML input and converts it to
ActionScript classes before compiling the entire set of classes
into a SWF. Because of this, you can look at the interim
ActionScript code.
You do this by setting the keep-generated-actionscript
compiler option to true and looking in the /generated directory.
hth,
matt horn
flex docs -
Flex mxml components should be private by default
Flex mxml components should be private by default. Does adobe
plan to fix this in future versions?Just noticed this and I think he may have a valid point here.
But as well as reducing coupling the term I'd use to make this
argument is
encapsulation.
There's no way AFAIK to make MXML sub components invisible to
higher level components. This can sometimes reveal things
internally that you don't want messed with, within a custom
component. If you have a custom component that only requires
one property be set to configure it properly, you don't want
to be revealing all these extra sub-components just because they
had to have ids assigned to them inside the custom component.
This may be a headache for backwards compatibility, for
anyone who has assumed these components would be public by default,
but a simple "scope='public'" attribute should fix that. But even
having them public by default, and allowing us to set their scope
to private would be helpful at times. -
Connect MDM components (MDM, MDIS) with Oracle (MCOD)
Hello!
I successfully installed SRM-MDM Catalog with MDS and MDIS and MDM console
(scenario: SAP EHP4 ERP system with SRM server, SAP EP EHP1 and SRM-MDM Catalog).
Now I would like to integrate MDM with Oracle.
On the server I allready have 2 Oracle instances (SAP EHP4 ABAP and Portal).
So I have MCOD Oracle installation.
What are the technical steps (oralce steps) to connect MDM components with Oracle?
(editing tnsnames.ora, creating/modifying tablespaces)
kind regardsHi!
Thank you very much!
My current situation:
Oracle software was installed and updated to version 10.2.0.4 by previous ABAP and Portal system.
Now I installed MDM with MDM ans MDIS.
So I have ABAP, Portal and MDM components on the same windows server.
Now I would like to connect my MDM components to Oracle.
Questions:
1) Which oracle post installation steps do I need, when I allready installed Oracle and have 2 oracle separate instances on the same server (MCOD)?
a) modification of TNSNAMES.ORA
b) creation of new oracle users for MDM/modification of environment variables for MDM OS users
b) creation of new database instance or integration of MDM into existing ABAP or Portal oracle instance
Thank you very much!
kind regards -
Anyway to make MXML components static?
This isn't too important because I know how to do it well enough in ActionScript. But I like the readability and convenience of MXML components, so if anyone knows if there is a way to make them static, please let me know.
As best I understand it, there is no way to creation Static Classes in ActionScript 3 or MXML:
Class Modifier keywords are dynamic, final, internal, and public.
http://livedocs.adobe.com/flex/3/html/help.html?content=04_OO_Programming_06.html
The Static keyword is only for variables, constants, or methods:
http://livedocs.adobe.com/flex/3/langref/statements.html#static
If you want to create static variables, constants, or methods inside an MXML File do it in a script block, which is the same way you do it in an ActionScript 3 file. -
Mxml components not compiled into swc?
Hi, I am using Flash Builder(Flex 4) and i am having issues compiling mxml components into swc.
My scenario:
I created Flex Library project, added some mxml components and actionsript classes.
I created separate Flex project and added swc file to project's library path.
I can only import actionscript classes from my library.
ActionScript classes are compiled and bundled in the swc as expected, but all mxml components are not compiled into the swc.
Do you have the same issues compiling mxml components?
I am using Flash Builder Version 4.0 (build 253292).My team occasionally sees issues with missing classes in a similar setup, although I can't confirm that it has been limited to MXML (and no one has been able to reliably reproduce).
I suspect our problem is the "includeAllClasses" property in .flexLibProperties (Project->Properties->Flex Library Build Path->Classes->Include all classes from all source paths)--it seems to not reliably compile in newly added classes. Our workaround right now is to instead click "Select classes to include in the library" and toggle our source directory every time classes are added, at least until we script our own build tasks. Looking through Jira I see this is a common issue: https://bugs.adobe.com/jira/browse/FB-23514 (and a few others).
Hope this helps, -
Dynamically add custom MXML components in Actionscript
As there's no constructor for custom MXML components, how to
dynamically add it as a child using ActionScript?
I'm looking for some alternative to avoid the need to rewrite
the entire existent component in ActionScript just to add it this
feature (a constructor). PopManager is not an alternative...
Is there any way?
The case/situation:
I have a custom MXML component that needs to be dinamically
added to a NativeWindow created using ActionScript.
Thanks a lot!
Vicente Junior
Independent Web Developer
http://teclandoalto.blogspot.commxml classes get generated into AS classes with a default
constructor.
In fact, there is essentially no difference between an AS
component and an mxml component, they can be used exactly the same
way.
Tracy -
Architecting an Application With MXML Components
I have an application that has gotten lengthy and I want to
simplify it by architecting the Main Application with custom MXML
Components. The application as it is currently architected works
perfectly.
Currently, the application consists of "Canvas" containers
along Top and Left Side holding Navigation Buttons. The main
(changing) sections of the application will consist of a
"ViewStack" container holding a number of "Canvas" containers
stacked on top of one another. The navigation buttons along the top
and left side, when clicked, display in turn the content of each of
the several stacked "Canvas" containers. Because of the number of
stacked "Canvas" containers within the "ViewStack" and the content
of each, the main Application source code has become very long and
unwieldy, thus the need to use custom components for each of the
"Canvas" containers in the "Stack" and referencing them in the main
Application page.
I have tried several times to get this to work and I need to
clarify a couple of things.
1) After setting up custom components for the several
"Canvas" containers that are now in the "ViewStack" container, do I
first need to set up a custom component for the "ViewStack"
container with its own name space?
2) If the answer to 1) above is Yes then do I then reference
each of the custom components for the "Canvas" container with their
own name space designation within the "ViewStack" reference within
the main Application?
In the event I am completely off base then I would appreciate
any suggestions. If you wish I would be happy to email you the
current application page.
Thanks,
Joe
joe kHere is some code for an app built with components. You can
see how the pieces talk to each other a bit.
------------------------- ViewStack1.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:comp="components.*"
layout="vertical" width="100%" height="100%" >
<comp:TopBar />
<mx:HBox width="100%" height="100%">
<comp:LeftBar />
<mx:VBox width="100%" height="100%">
<mx:ViewStack id="myViewStack" borderStyle="none"
width="100%" height="100%">
<mx:VBox id="home" width="100%">
<comp:MainIntroText />
<mx:HRule width="50%" height="3"
strokeColor="0xCC3333"/>
<comp:MainSecondaryText />
<mx:HRule width="50%" height="3"
strokeColor="0xCC3333"/>
<comp:MainFinalText />
</mx:VBox>
<mx:VBox id="about" width="100%">
<comp:About />
</mx:VBox>
<mx:VBox id="contact" width="100%">
<comp:Contact />
</mx:VBox>
</mx:ViewStack>
</mx:VBox>
</mx:HBox>
</mx:Application>
------------------------------- About.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:VBox width="65%">
<mx:Text fontSize="14" width="100%" text="This page tells
you about us." />
</mx:VBox>
</mx:HBox>
----------------------------------- Contact.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:VBox width="65%">
<mx:Text fontSize="14" width="100%" text="This page tells
you how to contact us." />
</mx:VBox>
</mx:HBox>
------------------- LeftBar.mxml -------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="200" height="100%">
<mx:LinkButton label="Adobe Labs - Flex"
click="navigateToURL(new URLRequest('
http://labs.adobe.com/technologies/flex'),
'_blank');"/>
<mx:Spacer height="20"/>
<mx:Label fontSize="16" text="Flex Blogs"/>
<mx:LinkBar direction="vertical" width="90%"
itemClick="navigateToURL(new URLRequest(event.item.data),
'_blank');">
<mx:Object label="Adobe Flex Team Blog" data="
http://weblogs.macromedia.com/flexteam/"/>
<mx:Object label="Flex Blog Aggregator" data="
http://www.allyourflexarebelongtous.com/"/>
<mx:Object label="Adobe Flex Blog Aggregator" data="
http://weblogs.macromedia.com/mxna/index.cfm?query=byCategory&categoryId=5&categor yName=Flex"/>
</mx:LinkBar>
<mx:Spacer height="20"/>
<mx:Label fontSize="16" text="Example Flex Apps"/>
<mx:LinkBar direction="vertical" id="addlRscList"
width="90%" itemClick="navigateToURL(new
URLRequest(event.item.data), '_blank');">
<mx:Object label="Adobe Flex Store" data="
http://www.adobe.com/devnet/flex/samples/flex_store_v2/"/>
<mx:Object label="Adobe Dashboard Example" data="
http://examples.adobe.com/flex2/inproduct/sdk/dashboard/dashboard.html"/>
<mx:Object label="Buzzword Word Processor" data="
http://preview.getbuzzword.com/?s=true"/>
<mx:Object label="Adobe Style Explorer" data="
http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html"/>
<mx:Object label="Adobe Component Explorer" data="
http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html"/>
</mx:LinkBar>
</mx:VBox>
----------------------- MainFinalText.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Text width="100%" fontSize="12"
text="Here is the final text I want to show you." />
</mx:VBox>
--------------------------- MainIntroText.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Text width="100%" fontSize="12"
text="Here is the main text I want to show you." />
</mx:VBox>
----------------------- MainSecondaryText.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Text width="100%" fontSize="12"
text="Here is the secondary text I want to show you." />
</mx:VBox>
--------------- TopBar.mxml --------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Script>
<![CDATA[
private function goToViews(view:String):void {
if(view == "home"){
this.parentApplication.myViewStack.selectedChild=this.parentApplication.home;
if(view == "about"){
this.parentApplication.myViewStack.selectedChild=this.parentApplication.about;
if(view == "contact"){
this.parentApplication.myViewStack.selectedChild=this.parentApplication.contact;
]]>
</mx:Script>
<mx:LinkButton label="MySnazzyLogo" fontSize="20"
click="goToViews('home');" />
<mx:VBox width="100%">
<mx:HBox width="100%">
<mx:Spacer width="100%" />
<mx:LinkBar fontSize="14"
itemClick="goToViews(String(event.item.data));">
<mx:Array>
<mx:Object label="About Us" data="about"/>
<mx:Object label="Contact Us" data="contact"/>
</mx:Array>
</mx:LinkBar>
</mx:HBox>
<mx:HBox width="100%">
<mx:Spacer width="150" />
<mx:Label fontSize="25" text="Here is Some Additional
Text" />
</mx:HBox>
</mx:VBox>
</mx:HBox> -
I have a question about data between mxml components.
Product.mxml is the overview screen for the products and ProductDetail.mxml (it is a TitleWindow) the detail screen.
In the Product I define a value object ProductVo with all the data. When I click a record in the overview and click the button 'change' (changeProduct function) then a popup window appears with all the data in it.
Code in Product.mxml:
[Bindable]
public var myWin:ProductDatail;
private function changeProduct():void {
myWin = PopUpManager.createPopUp(this, ProductDetail, true) as ProductDetail;
myWin["btnSave"].addEventListener("click", save);
private function save(event:Event):void {
productVo.productId = myWin.ti_productnr.text;
productVo.name = myWin.ti_name.text;
productVo.ean = myWin.ti_ean.text;
...some code to save the data in the db...
Code in ProductDetail.mxml:
[Bindable]
public var productDetailVo:ProductVo;
<mx:Form>
<mx:FormItem label="Productnr" required="true">
<mx:TextInput id="ti_productnr" text="{productDetailVo.productId}" width="60"/>
</mx:FormItem>
<mx:FormItem label="Naam" required="true">
<mx:TextInput id="ti_name" text="{productDetailVo.name}" width="200"/>
</mx:FormItem>
<mx:FormItem label="Ean">
<mx:TextInput id="ti_ean" text="{productDetailVo.ean}" width="100"/>
</mx:FormItem>
<mx:FormItem direction="horizontal">
<mx:Button id="btnSave" label="Save"/>
</mx:FormItem>
</mx:Form>
So my question: the save function in Product.mxml, is it possible to do this in a easier way instead of linking all the data from the form into the value object? Something like productVo = myWin.productDetailVo, but that does not work.I just looked at the parsley framework and saw this code:
private function save():void
contact.firstName = firstName.text;
contact.lastName = lastName.text;
contact.email = email.text;
service.save(contact);
So, it is doing the same thing I'm doing.
I'm using Spring and hibernate on the server level, it is my own framework. -
Resource Module Help for localization in custom mxml components
HI again,
Ok I have my resource set up to load at run time, working
great.
But I have mxml components should they not use the same
loaded bundle, or should I make smaller component bundles and load
them as well.
Best Practice etc...
Thanks in advance.If you want the components to be decoupled and reusable with
ease, I vote for separate bundles. -
Passing VARs between MXML Application and MXML components!
Hi,
I'm trying to pass a variable between the MXML Application and the MXML Component with ValueObjects.
But when i call the variable on the MXML Component it is null!
ValueObject Class Code:
package valueObjects
[Bindable]
public class MyGlobalVars
public var NomeGaleria: String;
public function MyGlobalVars()
MXML Application Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="components.*" layout="vertical" height="100%" width="100%" >
<mx:Script>
<![CDATA[
import valueObjects.MyGlobalVars;
import mx.managers.PopUpManager;
import mx.core.Container;
[Bindable]
public var nomeGaleria:MyGlobalVars;
private function AbreGaleria():void{
nomeGaleria=new MyGlobalVars();
nomeGaleria.NomeGaleria = "Moda";
PopUpManager.addPopUp(new galeriaImagens(),this,true);
]]>
</mx:Script>
<mx:Panel height="673" width="839" verticalAlign="middle" borderStyle="none" layout="absolute">
<mx:Canvas id="SMGaleria" width="815" height="30" x="2" y="98"">
<mx:LinkButton x="474" y="5" label="moda" click="AbreGaleria()"/>
</mx:Canvas>
<mx:ViewStack id="content" height="440" width="815" borderStyle="none" x="2" y="128">
<comp:galeriaImagens id="GaleriaImagens" x="0" y="5" strGaleria="{nomeGaleria}"/>
</mx:ViewStack>
</mx:Panel>
</mx:Application>
MXML Component Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
showCloseButton="true" creationComplete="CenterMe()" backgroundColor="#000000" xmlns:components="components.*" >
<mx:Script>
<![CDATA[
import valueObjects.MyGlobalVars;
import mx.controls.Alert;
[Bindable]
public var strGaleria:String;
private function CenterMe(): void{
Alert.show(strGaleria);
]]>
</mx:Script>
</mx:TitleWindow>
On the MXML component the value of strGaleria is null! It would not have to be: Moda??You may need to change your code as follows:
<comp:galeriaImagens id="GaleriaImagens" x="0" y="5" strGaleria="{nomeGaleria.NomeGaleria}"/>
Previously you had set strGaleria to the value of the object, not the string within the object.
But I think you will still have a problem because function AbreGaleria will not be called until the user clicks the link button, and only then will NomeGaleria have a value, so I would set a default value as follows, otherwise at app launch it will be null:
public var NomeGaleria: String = "";
or if that does not work
public var NomeGaleria: String = " ";
Another possible problem is that you are calling this code at the component creationComplete, but the LinkButton has not been clicked yet, so the value object string value has not been set, so the alert will not display anything:
private function CenterMe():void{
Alert.show(strGaleria);
I think you need to reorganize some things here.
If this post answers your question or helps, please mark it as such. -
Calling custom mxml components
How to I call an mxml component from an mxml application
where the first called mxml component calls another mxml
component.Far as I know, your main mxml application needs to call the
component that contains your other component.
In the <application> tag of your main mxml, setup up a
reference point to correspond to the location of your components
(we'll call the reference 'comp1' and assume it points to a project
folder named 'components' which contains both of your components).
<application ... xmlns:comp1="components.*" ...>
Any time you need to include your first component in your
main application mxml, you can reference it as
<comp1:component_name .../> where component_name is the name
of your first component.
Now, within your first component (we'll assume it's base is
canvas, though it could be a number of containers such as HBox,
etc), you'll need to declare a reference point again in the same
fashion, except within your container's tag since it won't have an
application tag.
<canvas ... xmlns:comp2="components.*" ... >
Now that we've declared this, you can place your 2nd
component into your 1st component the same way you placed your 1st
component into your main application. This time specify the 2nd
component name
<comp2:component_name2 ... />
Hope this is what you are looking for -
Dispatch text between mxml components
Hi all,
i was just trying to pass some string to an mxml component
and i have been having a hard time i am relatively new to flex and
what i want to do is simply pass a user id string to this component
in order to retrieve data specific to this user can someone help me
out?
Thanks a lot. : )Simple declare the namespace where the file is located and create an instance of the component in the primary app.
If in the same folder as the main app MXML file:
xmlns:comp="*" where comp can be anything (myComponents, components, etc.)
If a sub-folder "components" of the main app MXML file:
xmlns:comp="components.*" where comp can be anything (myComponents, components, etc.)
<comp:MyFancyComponent id="myComp"/> declare an instance of the component.
Then do this:
myAppVar = myComp.myCompVar; -
Drawing Line to connect canvas components
I have drawings on canvas components which I have added to a frame. I would like to connect the drawings in the canvas components using a line to connect the drawings inside the canvas components together. If I draw a line in a new canvas and add this component to the frame, the rectangular background of this canvas will cover part of the drawings of the two canvas components I am trying to connect the line to. Is there a way to create a line component that does what I want?
just try this:
1. create a component in which you can put yours different canvases
2. create an image where you put in the actual display of the component (like a doublebuffer image (offscreenimage))
3. modifie this image
Maybe you are looking for
-
How to make an app a file receiver for images on iOS?
Hi, How to make an app a file receiver for images on iOS? I did it for the Android app.xml like this: <intent-filter> <action android:name="android.intent.action.SEND"/> <category android:name="android.intent.category.DEFAULT"/>
-
Help! I can't download updates or music to iPod Mini.
Up to last night my iPod mini has worked perfectly. Now today, I added more songs to my library and unchecked a number of songs within the library and tried to update my iPod with the revised music listing. However, no I get the following error messa
-
I want my old firefox back before I updated to 6.0. My plugins don't work
My Roboform and My Norton 360 Identity toolbars aren't showing
-
Video not exporting right from Adobe Flash CS6
I'm trying to export a new animation short that's 30 seconds with sounds in Adobe Flash CS6, but it comes out somewhat pixelated and the sound is way out of sync while in the flash file it's just perfect. I try making changes for the Quicktime file,
-
Hi, Can you please let me know how to select ROWID from the all_ind_expressions table? I have tried to execute the following SQL query on the Oracle version 10.2.0.3 but received the ORA-01445 error. select ROWID from all_ind_expressions where index_