Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-19-2006, 11:08 AM   #1
ljonny18
Registered User
 
Join Date: Oct 2006
Posts: 112
Default open MXML component + button click

Summary: open an MXML component from another MXML component on a button click


Hi,

I have an MXML component within my Flex 2 Application, and within this component I have a button which when clicked, I want to "go / link to" (open) another MXML component.... e.g.:

<mx:Application.......>
<mxanel............>
<mx:button label="open other page" click="open the other MXML component etc..."/>
</mxanel>
</mx:Application>


Additionally I want to be able to pass a variable (on the same button click) to the component that is being opened on the button click, and use this variable within the second component......

Could anyone suggest the best method of going about this?

Thanks,
Jon.
ljonny18 is offline   Reply With Quote
Old 10-19-2006, 01:45 PM   #2
flexy
Everything about me's...
 
Join Date: Aug 2006
Location: UK
Posts: 198
Default

The architecture of a component isn't quite like a web page, where you'd go from one to the other. Components are part of you application when you compile them, and you determine when and where to instance them within your app at runtime. If guess in this instance, you might be looking for a solution where a user clicks an object in one component, which in turn invokes the display of another component?

The LiveDocs might give you some more pointers: http://livedocs.macromedia.com/flex/...eateComps.html
flexy is offline   Reply With Quote
Old 10-19-2006, 03:34 PM   #3
ljonny18
Registered User
 
Join Date: Oct 2006
Posts: 112
Default

Yes... that is exactly what I want to do! .. :

"where a user clicks an object in one component, which in turn invokes the display of another component"

is this possible (I am sure it is) is there a best method / practive of going about doing this.. I have been reading about "Loosely Coupled Components" and "Broadcasting" / "Triggering" events etc.. dut have had no joy as of yet... am I on the right tracks????

yes, you are right - I need to stop thinking of the flex app as a website...


Thanks,
Jon.
ljonny18 is offline   Reply With Quote
Old 10-19-2006, 03:54 PM   #4
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

<mx:Button id="button0" label="show panel" click="panel.visible = true"/>
<mx:Panel id="panel" width="100" height="100" visible="false">

that the sort of thing?

as you can see the panel is not visible when its been created. clicking on the button sets its visisble prop to true.

You should also read up on States.
Tink is offline   Reply With Quote
Old 10-25-2006, 03:01 PM   #5
ljonny18
Registered User
 
Join Date: Oct 2006
Posts: 112
Default

Hi Tink....

I understand that... but I want to actually display a seperate component (MXML file) that is not related / linked to the current component (MXML file) - if that makes any sense....

when a button is clicked - I want to direct the user to another part of the application... e.g.:

<mx:button label="contact page" click="open / show contact.mxml etc"/>

and when the button is clicked - the contact.mxml is shown etc......


Thanks,
Jon.
ljonny18 is offline   Reply With Quote
Old 10-25-2006, 08:50 PM   #6
CDHBookingEdge
Registered User
 
Join Date: Oct 2006
Posts: 383
Send a message via MSN to CDHBookingEdge
Default Just reading this and thinking about it.

Ok first let's clarify something what is this "component"? I.e.: what type of component is it? Is it another view? Is the view currently visible but empty at the moment or do you want it to come up where the prior view (with the button) is?

I'm guessing from the sounds of it that it's not visible and you want it to appear in the same area as the view that the button existed in. Based on that sounds like you should check into view stacks. Look over some examples where that's used. I think that some looking thru the livedocs and some of the demos will give you some answers to this one.

Christopher
CDHBookingEdge is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio Button Component Problem - AS 2.0 Flash 8 saikiran Components 2 09-12-2007 09:28 PM
XML nodes--forward and back buttons, or next sibling, actionscript and xml. mahoganyhorizons Projectors and CDs 18 07-27-2006 03:34 PM
homemade pause button for MediaDisplay component barman008 Components 1 05-31-2006 04:34 PM
Button Component won't use my code... darthmahon Components 0 04-05-2005 09:19 PM
Writing a variable that sets doors to open and close upon the click of a button CFQTpye ActionScript 1.0 (and below) 6 03-22-2005 07:23 PM


All times are GMT. The time now is 02:10 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.