MXML component
I have an MXML component PR_PIECHART
1. Can one call as a variable the MXML component in AS ?
2. Can you show the var in the interface and which method to
use ?
Just need some confirmation here
You can reference ANY (mxml or as) component by its "id"
property.
I don't understand question 2.
Tracy
Similar Messages
-
Loading an "MXML Component" at run-time creates a null object.
Hello!
I have a simple Flex 3 project with an MXML application file (the parent) and an MXML component file (the child).
At run-time I create childs of this component, and I add it to the stage using a simple "this.addChild()" call.
Now, besides that, in the creation loop, after every
newChild = new mcComp();
I want to setup a few more custom parameters which belongs to this class. For example, now I want to set a label's text, this label is at the child.
The issue is that the label isn't created until I exit the creation function, and actually, until my code returns control to the Flash Player.
See my problem here?
With custom classes which resides at .AS files, when I instantiate them with the "new" operator, they run their constructure's code and eveything is fine.
But, when I do the same with those MXML components (which by the way are based over the Canvas class), their constructure do not execute and actually no other child of them is created.
Can anyone please advise? I must be missing some keyword here.. hopefully.Hi Natasha thanks,
The issue is that the creationComplete event doesn't dispatch even when I addChild() the object.
var child:mcChild = null;
for(var i:int; i < 3; i++)
child = new mcChild();
// setting some properties, labels' text etc'
this.addChild(child);
Try this and you'll see - the event doesn't dispatch until you got out of the code flow.
Anyway after looking at Flex's documentation I solved it differently;
After the addChild() call the child receives an "initialize" event. After that I could modify my label.
Thank you though! -
Interface not found in implements-attribute for MXML component
Hi,
I am trying to use the "implements" attribute for an
MXML-component in order to implement an interface from a library
like below (Flex 3). I get the error "Interface IClonable not
found". The compiler does not complain about " import
com.yworks.support.IClonable;", so the library is installed
correctly. I use the library in many places in my project, it just
does not find it in the "implements" tag. How can I fix this
without reimplementing the component in ActionScript?
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
implements="com.yworks.support.IClonable">
<mx:Script>
<![CDATA[
import com.yworks.support.IClonable;
]]>
</mx:Script>
</mx:VBox>"mavdzee" <[email protected]> wrote in
message
news:gldjg8$js8$[email protected]..
> Hi,
>
> I am trying to use the "implements" attribute for an
MXML-component in
> order
> to implement an interface from a library like below
(Flex 3). I get the
> error
> "Interface IClonable not found". The compiler does not
complain about "
> import
> com.yworks.support.IClonable;", so the library is
installed correctly. I
> use
> the library in many places in my project, it just does
not find it in the
> "implements" tag. How can I fix this without
reimplementing the component
> in
> ActionScript?
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
> implements="com.yworks.support.IClonable">
>
> <mx:Script>
> <![CDATA[
>
> import com.yworks.support.IClonable;
>
> ]]>
> </mx:Script>
>
> </mx:VBox>
I don't see anything where you're actually _implementing_ the
interface, but
I'd expect to see a different error if that's the problem.
Still, I'd go
ahead and implement the properties and methods in the
interface, just to
make sure.
HTH;
Amy -
Event Fired when a mxml component is shown on screen
hello,
I have following application structure nested up to 2/3 level.
Application
linkbar connected to viewstack
viewstack
NavigatorContent
mxml Component
NavigatorContent
mxml Component
mxml componet in turn has similar structure
componet
linkbar connected to viewstack
viewstack
NavigatorContent
mxml Component
NavigatorContent
mxml Component
and end component is form which is shown and actions performed
I want to execute specific code when the form is first time shown
which will collect data from server and will show for further actions.
User will edit/delete/update data with various button clicks.
I tried activate event on end component but it seems that it wont get
fired at all. End components are enclosed in BorderContainer or Group.
To test activate event I have used Alert.show only but popup is not shown
when I select link button on penutimate linkbar.
If I am doing something wrong please let me know as well please
guide me which event shall I use so that whenever linkbutton is
pressed on linkbar it will fire that event. In that event I can check
whether it has been called earlier by checking some variable which
will be null in creation complete and set in event fired when linkbutton is pressed.
Thanks and regards
RajaI think 'creationComplete' is the closest event to what you are looking for.
-
How to create custom MXML component accepting other MXML componenents as children
How can I create an MXML component that when I use it in the "main" MXML, accepts other MXML components...
For example:
<s:WindowedApplication>
<myComponent>
<otherMXMLcomponent></otherMXMLcomponent>
<otherMXMLcomponent></otherMXMLcomponent>
<otherMXMLcomponent></otherMXMLcomponent>
<otherMXMLcomponent></otherMXMLcomponent>
</myComponent>
<s:WindowedApplication>
How do you declare such a component?
Thanks in advanceBhè non so se ho capito .. ti spiego la prova che ho fatto io.. Dunque, io ho provato a creare un mio componente Custom e a metterci dentro degli oggetti miei di esempio.. Il componente di esempio si chiama mioComponenteCustom e all'interno è strutturato in questo modo:
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx">
</s:Group>
Al posto dei puntini ci metto quello che voglio.. nel tuo caso i tuoi 2 famosi pulsanti..
All'esterno chiamerò :
<mioComponenteCustom>
<s:DataGrid>
</s:DataGrid
</mioComponenteCustom>
Dove DataGrid è un componente a caso qualsiasi.. Ora, con questa struttura non ricevo errori e sembra andare bene..
Dimmi se ho capito bene o volevi fare altro..
Max -
Loading MXML Component Dynamically
Hi all,
I am new to Flex and was trying out small things . I created
a MXML Application and also MXML components.
I tried loading MXML component to application using xmlns and
it worked fine.(
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" backgroundColor="#ffffff" xmlns:mi="com.*">
<mi:base1 id="base1" />
<mi:base2 id="base2" />
This method is ok if we are loading 3-4 components .
but , if i have to load a mxml component dynamically how do I
do it?
for example ,if base1 and base2 are two components and i want
to load them based on some event performed.
I have tried the method which uses ViewStack and code
myViewStack.selectedChild=Container(myViewStack.getChildByName(selectedNode))
,where each child will have one component declared or initialized.
Following this method is not a feasible when we have hundred
of components to be loaded.
Can anyone help me on this??"srirama.83" <[email protected]> wrote in
message
news:gpkoui$g3u$[email protected]..
> Hi all,
> I am new to Flex and was trying out small things . I
created a MXML
> Application and also MXML components.
> I tried loading MXML component to application using
xmlns and it worked
> fine.(
> <mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
> layout="absolute"
> backgroundColor="#ffffff" xmlns:mi="com.*">
> <mi:base1 id="base1" />
> <mi:base2 id="base2" />
> )
> This method is ok if we are loading 3-4 components .
> but , if i have to load a mxml component dynamically how
do I do it?
> for example ,if base1 and base2 are two components and i
want to load them
> based on some event performed.
>
> I have tried the method which uses ViewStack and code
>
myViewStack.selectedChild=Container(myViewStack.getChildByName(selectedNode))
> ,where each child will have one component declared or
initialized.
>
> Following this method is not a feasible when we have
hundred of components
> to
> be loaded.
> Can anyone help me on this??
>
>
http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf
Q4 -
How to import MXML Component in ActionScript
Hello,
I'm having a structure similar to this:
root
- components
- subcomponents (MyCustomMXMLComponent)
- views
In views package I have a piece of AS where I want to instantiate an MXML Component from subcomponents.
In Views:
var data:DisplayObjectContainer=new components.subcomponents['MyCustomMXMLComponent'];
But that throws an error.
I need a syntax similar to the one above because I'm running a for loop and changing data variable to be a new MXML component on each iteration.
Any idea how I can solve this?
Thank you.OK, so:
var length:int=arrSubcomponents.length;
for(var i:uint=0;i<length;i++)
//Decide parent
var parent:IVisualElementContainer;
if(arrSubcomponents[i].group && arrsUbcomponents[i].group==1){parent=firstGroup;}
else{parent=secondGroup;}
//Add to parent
var childClassName:String='components.subcomponents.'+arrsUbcomponents[i].className;
trace(childClassName);//So far so good the path is correct, I checked.
var childClass:Class=Class(getDefinitionByName(childClassName));
trace(childClass);//It breaks here with the error below
var child:IVisualElement=new childClass() as IVisualElement;
trace(child);
parent.addElement(child);
The error:
ReferenceError: Error #1065: Variable FirstCustomMXMLComponent is not defined.
at global/flash.utils::getDefinitionByName() -
Hi all,
I am converting a asp.net website to Flex, I have five web pages which I designed as Five mxml components have buttons, grid, combos, text boxes etc.
my question is how do I move between these pages they are distinct in there looks and functionality. I read a lot about view states and I am confused whether view states will solve my issue.
Please tell me how do we handle this usually in flex applications.Hi,
Flex 4 or Flex 3 the answer remains the same, I have a state for each form then I place a container, be it a group a canvas or a panel, in each state to show how states work, the following is in flex 3
The Application
============
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" currentState="form1" xmlns:ns1="*">
<mx:states>
<mx:State name="form1">
<mx:AddChild position="lastChild">
<ns1:form1 horizontalCenter="0" verticalCenter="0">
</ns1:form1>
</mx:AddChild>
</mx:State>
<mx:State name="form2">
<mx:AddChild position="lastChild">
<ns1:form2 horizontalCenter="0" verticalCenter="0">
</ns1:form2>
</mx:AddChild>
</mx:State>
<mx:State name="form3">
<mx:AddChild position="lastChild">
<ns1:form3 horizontalCenter="0" verticalCenter="0">
</ns1:form3>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:Button label="Form 1" click="currentState='form1'" top="10" horizontalCenter="-150"/>
<mx:Button label="Form 2" click="currentState='form2'" top="10" horizontalCenter="0"/>
<mx:Button label="Form 3" click="currentState='form3'" top="10" horizontalCenter="150"/>
</mx:Application>
The Mxml Component Container (which is exactly what you said you had)
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300" title="First Form">
</mx:Panel>
You can navigate through your 'pages' however you want to, the first example I offered is pure flex the above code is pure flex only using the antiquated sdk which I would advise against for 'new' projects, flex 3 sdk maybe used in flashbuilder but I would only go to this for legacy purposes using the flex 4 sdk is by far the better option.
I try to help where I can, there is no reward for doing this, but I did answer your initial question about states, I hope you get to understand flex a little better with time.
David. -
How to add interface to customlize MXML Component when use Flex Builder 3?
How to add interface to customlize MXML Component when use
Flex Builder 3?David,
I don't believe you can add the interface via the creation
dialog in FlexBuilder 3. You can always manually add the
"implements" property to your MXML Component root tag. Something
like this: <mx:VBox implements="com.mycorp.IMyInterface">
If you want autogeneration of the interface, then create an
ActionScript class with that interface and then copy the generated
functions and setter/getters into the script block of your MXML
component. -
Dynamic addition of MXML Component
Is it possible to add an MXML component through an ActionScript.
I have a situation where I display multiple checkboxes and on click of each I show a subform. I am planning to make that subform as MXML component and add/remove it based on the user's checking/unchecking the checkbox..Is this possible?
Thanks
DharmeshHi Ben ..
Appreciate your quick response. This is my first Flex app. In a nut sheel here is a sample similar to what I am trying to achieve.
Consider my Mxml component as follows
<?xml version="1.0" encoding="utf-8"?>
<!-- myComponents/TempComponent.mxml -->
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
<mx:Button label="Hey there from component"/>
</mx:Canvas>
Now here he my app mxml file
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:temp="mycomponents.*">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
public function addRemove():void{
//How do i add that component to the Panel?
]]>
</mx:Script>
<mx:Checkbox id="cb" change="addRemove()" label="Check or Uncheck"/>
<mx:Panel id="testPanel" x="0" y="0" width="100%" height="200" layout="absolute" borderThickness="0" borderThicknessBottom="0"/>
Can you guide me what should go in the listener to add the component to the panel? -
How to extend an AS3 class in an MXML Component
Hello,
I have a few MXML Components based on the Spark Group.
They all use MXML for layouta and AS3 for logic.
They all have the same logic and I would like all to extend an AS3 class to have the same methods and properties isteand of declaring the same exact ones for each MXML Component.
How can this be done please?Hm, no, I'm not explaing this properly.
I have an MXML component based on the Spark Group.
It has a few form elements.
There are many such components.
I want all to have two public methods: getData() and setData() which get and set data from and to the input elements.
I don't want to write the exact same method for all of them.
I would like to at least interface the MXML components with an AS3 class forcing them to have those 2 methods. -
Add change event to a custom MXML component
I am building an MXML project in Flash Builder 4.5
I have a custom MXML component that contains a TextInput field. I want the custom component to have a change event that triggers a function in the main application.
I created a test project to try and solve this. At the moment, it appears to trigger an event once and then stops. Please take a look and let me know where I am going wrong. Many thanks.
customComponent.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
width="40" height="20">
<mx:Script>
<![CDATA[
[Bindable]
public var value:Number;
protected function inputBox_clickHandler(event:KeyboardEvent):void
if (event.keyCode == 38 ) {
keyUp();
if (event.keyCode == 40 ) {
keyDown();
protected function keyUp():void
value = value++;
dispatchEvent(new Event('change'))
protected function keyDown():void
value = value--;
dispatchEvent(new Event('change'))
]]>
</mx:Script>
<mx:Metadata>
[Event(name="change", type="flash.events.Event")]
</mx:Metadata>
<mx:TextInput id="inputBox" x="0" y="0" width="40" height="20"
text="{value}"
keyDown="inputBox_clickHandler(event)"
change="dispatchEvent(new Event('change'))"
/>
</mx:Canvas>
main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:CustomComponents="CustomComponents.*"
minWidth="955" minHeight="600" layout="absolute">
<mx:Script>
<![CDATA[
private function changeTestLabel():void
testLabel.text = String(myComponent.value);
]]>
</mx:Script>
<CustomComponents:customComponent x="180" y="183"
id="myComponent" value="0"
change="changeTestLabel()">
</CustomComponents:customComponent>
<mx:Label id="testLabel" x="165" y="206" text="Test label"/>
</mx:Application>I have found the solution to this...
The clue was that it worked the first time a change was made, changing the value to the default '0'.
The problem was that the var value is type Number and the inputBox.text is type String.
I therefore added the following function:
protected function textChange():void
value = Number(inputBox.text);
dispatchEvent(new Event('change'))
I also changed the change="dispatchEvent(new Event('change'))" property to
valueCommit="textChange()"
... and that fixed it..
Thanks to all those who took the trouble to look at this -
Refer to mxml component within the same package
Hello
How can I refer to the same mxml component both of which live in the same package? For example, I have myHbox and myTabNav in the same package named ui. I am already referring to the myHBox mxml class in the Application class through the line: xmlns:ui="ui.*" and that works fine. However, I want to use myTabNav within the myHBox mxml component?
Thanks in advance,
K4FlexYou can use the same namespace xmlns:ui="ui.*" in the myHbox.mxml too.
-
Flex link to internal mxml component
I have text.mxml component. that is showing me the following:
<mx:DataGrid id="dgShowHistory" width="100%">
<mx:columns>
<mx:DataGridColumn headerText="ID"/>
<mx:DataGridColumn headerText="Case Number"/>
<mx:DataGridColumn headerText="Group Number"/>
<mx:DataGridColumn headerText="Case Name"/>
<mx:DataGridColumn headerText="Status"/>
</mx:columns>
</mx:DataGrid>
Now the in the Case Number column I want to add a link to SearchCaseNumber.mxml...
So lets say the Case Number has the following:
Case Number
1234
1235
1236
I want these to be highlighted as link and when I click on these It takes me to the SearchCaseNumber.mxml put the 1234 automatically in search and if possible populate all the fields based on this.
In SearchCaseNumber.mxml
<mx:TextInput id="CaseSearch" width="81"/>I was trying to implement what you mentioned but I’m not an expert in the coding yet. Can you help me with the code and how it looks like?
Here is my code… text.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
width="1000"
height="800"
titleStyleName="popWindowTitle"
horizontalScrollPolicy="off">
<mx:Script>
<![CDATA[
import mx.formatters.DateFormatter;
import mx.managers.PopUpManager;
import mx.containers.TitleWindow;
import mx.controls.Text;
import mx.controls.ComboBox;
import mx.core.Application;
import mx.utils.ArrayUtil;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.dataGridClasses.DataGridColumn;
import com.component.coverage;
[Bindable]
private var CaseNumber:ArrayCollection = new ArrayCollection();
private function handle_recordCaseNumber(event:ResultEvent):void
CaseNumber = event.result as ArrayCollection;
]]>
</mx:Script>
<mx:RemoteObject id="CaseNumberCreate"
destination="ColdFusion"
source="Text.cfc.CaseNumber"
showBusyCursor="true">
<mx:method name="getCaseNumber"
result="handle_recordCaseNumber(event)"
fault="Alert.show(event.fault.message)"/>
</mx:RemoteObject>
<mx:DataGrid x="800" y="650" id="CaseNumberGrid" dataProvider="{CaseNumber}" creationComplete="{CaseNumberCreate.getCaseNumber()}"
height="639"
width="823">
<mx:columns>
<mx:DataGridColumn headerText="ID" dataField="ID"/>
<mx:DataGridColumn headerText="Case Number" dataField="Case_Number"/>
<mx:DataGridColumn headerText="Group Number" dataField="Group_Number"/>
<mx:DataGridColumn headerText="Case Name" dataField="Case_Name"/>
<mx:DataGridColumn headerText="Status" dataField="Status"/>
</mx:columns>
</mx:DataGrid>
</mx:TitleWindow>
My SearchCaseNumber.mxml looks like the following:
<mx:Label text="Enter Case Number Here:" fontWeight="normal" textAlign="center"/>
<mx:TextInput id="CaseSearch" width="81" fontFamily="Arial"/>
<mx:Button label="Search" click="findCase()"/>
private function findCase():void
if (CaseSearch.text == "")
Alert.show("Enter the Case Number", "Error");
else
roCreate.returnCaseInfo(CaseSearchSearch.text);
roCreate.returnGroupInfo(CaseSearch.text);
Please let me know if you can help me… Thanks… -
Passing a variable from an mxml component to the main mxml file
Hey guys,
I have a popup titlewindowt which is defined as a component in a separate mxml component file.
In the popup window i have an inputbox and a button
When i press the button in that popup window i want the text in the input box to be transfered across to a variable in my main mxml file
How can i do this?
Thanks
ChrisSince you are already tied in to the top level application then I would add a listener at the application level and in the component do a:
FlexGlobals.topLevelApplication.dispatchEvent(....)
However, I can't help but encourage you to decouple this functionality and pass events around rather than what you are currently doing.
There are a few ways you can do this. One is to use an MVC framework to model your application after.
A simpler approach even would be to have the component simploy dispatch events to itself and have whatever is creating the component listen for the events and do higher level functionality.
Good Luck! -
Error when using instantiated mxml component in popupmanager
Hi,
Im getting the following error when trying to create a popup:
Error #1007: Instantiation attempted on a non-constructor
The code looks as follows
var browserPop:CustomBrowser = new CustomBrowser();
browserPop.targetType = "file";
browserPop.fileType = "jpg";
var pop:TitleWindow =
PopUpManager.createPopUp(this,browserPop as Class, true) as
TitleWindow;
Where CustomBrowser is an MXML component extending
TitleWindow.
If i use:
var pop:TitleWindow =
PopUpManager.createPopUp(this,CustomBrowser, true) as TitleWindow;
it works fine but i need to be able to set some public
properties and therefore instantiate it first. Any help would be
appreaciated.
Thanks in advance
EricCreate you component using the popupmanager, then cast it to
the
specific type to access it's public methods and/or variables.
Like so for mxml component ExceptionPopup:
var popup:IFlexDisplayObject;
popup =
PopUpManager.createPopUp(_parentPanel,ExceptionPopUp,true,null);
(popup as ExceptionPopUp).addRecords(ev.errorMessage);
(popup as ExceptionPopUp).title = "title";
(popup as ExceptionPopUp).userText.text = "some user text"
PopUpManager.centerPopUp(popup);
Maybe you are looking for
-
I imported an hour of video into iMovie HD and cut it down to a 33 sec clip, and emptied the trash. When I save the project, the file size is 20Gb. How can I save just the 33 sec clip?
-
Officejet Pro 8000 wireless. Printer Exploded HELP!
Only had the machine 17 Months, it has now exploded! Ink everywhere, HELP! Spoke to HP technical support, they can't tell. (over the phone!) but think a tube might have come adrift, I cant tell, am a 66 year old dancing teacher! They suggested the f
-
Issue getting program to compile
Here is my code: import java.util.Scanner; public class Vowels static Scanner console = new Scanner(System.in); public static void main(String[] args) char ch; System.out.print("Enter a letter of the alphabet " +
-
Codepage coverting error utf-8 from System codepage to iso-8859-1 (PI 7.1)
Hello Experts, In our Prcess, we receive an Idoc from an IS-U system and then we send this Idoc with some Header-Information via http-Adapter to a Seeburger System. In the outbound communication Channel we have a XI Payload manipulation with xml-Code
-
How to optimize macbook pro for video editing and 3d animation
Hello Everybody - I've had a macbook pro for about 5 years now. It works great, havn't had any issues with it yet, but I've started doing more video editing and 3D animation work on it with FCP7 and Blender (usually using photoshop at the same time).