Flex :: Adobe Calling MXML Functions?
Jul 16, 2010i allready searched abit around here and found the solution to call a fx:script function defined in a mxml from a AS class.
[Code]...
i allready searched abit around here and found the solution to call a fx:script function defined in a mxml from a AS class.
[Code]...
i have defined some functions in a component mxml file let us say addbutton() now i want to call this function in main mxml file.
View 2 RepliesHow can i call MXML components inside my ActionScript Class.
// filename.mxml
<mx:Canvas x="181" y="180" width="333">
<mx:Button styleName="LoginButton" id="loginButton" click="checkLogin();" x="160" y="261"/>
<mx:TextInput styleName="loginTextInput" id="username" x="160" y="161"/>
[code]....
I need to access the username and password fields of MXML in my ActionScript Class.
Flex newbie question: can MXML be generated on the fly, like HTML is generated by a server? If yes, is it ok to do so or am I missing an important Flex architectural principle.
View 4 RepliesIn my main application I have a viewstack with 3 child views. In the viewstack change handler, I programmatically change the selectedchild property.
I understand that the initialize method for the view is not called every time I change the selectedChild Property. So I tried to invoke the init method programmatically too..
view1.mxml
<fx:Script>
<![CDATA[
[Code].....
I have simple mxml code
<mx:DataGrid id="DGG"
editable="true">
<mx:dataProvider>
[Code]....
I want to add rows to my table datagrid how to do such thing?
How to add Column to Adobe flex mx:DataGrid in mxml and/or actionsctpt?
(You can put this code in Flash or AIR app - it will compile with no errors, but will not add any columns=( )
I am attempting to implement a layout in Adobe Flex 4.5 / MXML where I have multiple controls in an HBox that - in total - consume all available horizontal screen estate. Some use a relative with (percentage), some an absolute width (pixels) and one is supposed to consume whatever space is still left, such as:
+----------------------+-----------------------+------+
| 35% | fill parent | 10px |
+----------------------+-----------------------+------+
How would I achieve this in Flex (is there something comparable to Android's
layout_width="fillparent")?
Due to the fact that there are elements that have an absolute width I cannot easily calculate the width of the filler as a percentage a priori (as it varies with the screen width). Setting the filler's width to 100% also does not work as this will shrink the 35% area below 35%. Applying the updateDisplayList suggestion from www.Flextras.com's answer below yields the error "Call to a possibly undefined method updateDisplayList" at the line marked in the source excerpt below:
<?xml version="1.0"?>
<mx:HBox xmlns:fx="[URL]"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationPolicy="auto"
[Code] .....
I am trying to override the text setter in the Label component but it behaves weirdly sometime super.text works and sometimes not! and the traces show that there's no error with my code.
here's my code:
import spark.components.Label;
public class LabelXX extends Label
{
private var _initialText:String;
[Code]....
I am using progressive streaming with VideoDisplay, the HTTP URL provided gets buffered completely even if I have configured it to start playing the video when the buffering reaches 20%, the trace message shows that the playing started(using mozilla /Flashbug+Firebug), but it doesnot show the video till the buffercounter reaches 100% How can I get the video stream to play at the 20% of stream.Code Segment where the check takes place
var loadedPct:uint = Math.round(100 * (event.bytesLoaded / event.bytesTotal));
trace('waiting...');
mainVideoCanvas.addChild(LoadingImage);
VidLoadingLabel2.text = loadedPct.toString();
[code].....
I have a series of calculations i'm doing over a bunch of objects stored in a array. Each function is pretty CPU demanding but if you only run one function, it just works fine.
[Code]...
Is it not possible to call other functions from generic mouse event functions? Surely it is !!??ie....
Code:
_root.myButton.onPress = function(){
hide();
[code]........
Somewhere in the internets I stumbled across some kind of inline function for setting the color of a label.Something like this:color="{data >0 ? 0x006600 : 0xFF0000}Basically, this is exactly what I need in my ItemRenderer, but in an if-else if-else way.The script above says data > 0 then set color to green, else set it to red. What I need is an additional case, that is no change set color to gray.Is that accomplishable with this sort of "inline" function?
View 2 Replies[Code].....
getUser was already in UserService.java. I just created getUser2 and it's identical to getUser. When I try to call getUser2, i get the "Cannot invoke method" error. question: Do I need to specify getUser2 in some other file? like in some configuration file? if so, which one and how do I do it.
Does MXML get compiled down to as3 and then converted to flash bytecode? Also, is there a significant performance penalty to compiling mxml vs compiling as3?
View 3 RepliesI am working on a custom Flex 4 component which is an aggregation of two existing flex components. I would like to be able to specify my own custom properties for the component as well as access the existing public subcomponent properties via MXML. For instance I might want to adjust the font color or style for the label and text input. toy component which aggregates both a label and a text input:
<?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"
[code]....
I have a basic mxml app which looks like this
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="800" height="600">
<mx:Script>[code].........
this swf is loaded into another swf using Loader and added with addChild(loader).i then need to call the init function from the parent swf. how can i do this? just calling
loader.content.init();
fails.another question is, what is the exact classname of this mxml file?
I am trying to override a Button class, i have a few properties which i wish directly initialise with the mxml description of the component, like :[code]which function is triggered ( in order to override it ) when all properties with mxml description is fully initialised with their values ?
View 1 RepliesI currently have a basic application where we have multiple buttons, which have functions activated by "click" event listeners on those buttons. The issue is that each button does more or less the same function; just the data that is loaded for each button is different. How do I make it so I'm able to recycle the same function? In Javascript or AS3 something along these lines would be done...
<s:Button id="btn_1" x="378" y="601" label="Button 1" click="photoSwap(event,"image1.jpg")"/>
<s:Button id="btn_2" x="350" y="601" label="Button 2"
[Code].....
But that's obviously not how it works. I've tried trouble shooting the issue but haven't been able to find anything. It works when I have each button having its own function, but that seems really silly and shouldn't need to be done.
Can anyone help me in this regard? I have Actinscript file in which I have defined a function like below:
actionScript.as (file name)
import mx.controls.Alert;
public function abc():void{
Alert.show("Inside abc(): My Button Clicked");
}
Now I have a button in mxml and I am calling the above function in my buttion "click" attribute like below.
Importing script in mxml:
[Code]...
What I'd like to do: create an MXML component with some children, then extend it via MXML to create a new component with more children, without losing the original set.In other words
create a component bc.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
[code].....
I've always just developed my projects in as3 instead of mxml and I usually just setup my application to run a main actionscript file as my main doc root, sort of like how you do it in flash but in flash builder I do something like this:[code] how can I call place a call to that function hitme() within the call_from_outside() function between the <fx:Script> tags?The reason why I'm doing this is because I have some flash swfs that I load into another swf file and I can access the top level public functions of those flash swfs, however the top level of the flash builder/flex swfs is the main mxml file not my fake as3 class root. Of course I should think there is a way for me to access the as3 class methods of the mxml component but for keeping things with the same structure, I can bypass having to modify my loader scripts.
View 1 Repliesmain.mxml
[Bindable]
private var _dp:ArrayCollection = new ArrayCollection([
[code].....
If I have a function and I want to call a variable from another function (only 1variable), how do I do it? I know in the olden days you could set the variable to local or global, but that does not seem to work anymore. There is only 1 variable I need access to, but all the tutorials I have come across talk about making classes for multiple variables.
e.g. function2();
{
variable_b = variable_a;
}
[Code].....
I can't get it but, i'm coding in as3 and i can't target a function from a swf file loaded in the DisplayObject loader in any way. I don't want to create a class to make this function works. It's a simple function, made to change a picture every time the user navigates on another swf. Well. The point is, why in the name of God, the as3 cannot target another swf? How can i do it?
View 0 RepliesA Flex components values are initlized by init methord. In an application flow, How to refresh a mxml component data value ; as init is callled at the start up it self only.
eg. of mxml componet may be as simple as button label or text as complex as repeater whose data provider is a web service ( means a fresh quesy should be made to pull the data and refresh the dataprovider of repeater )
suppose i have 3 buttons(for example say, productin, marketing, sales ) on my main.mxml..once i click on one button it should take me to abc.mxml page with production data, once again if i click on second button it should take me to the same abc.mxml but with marketing data. same as for 3rd button also, how can i achieve this ?
View 2 RepliesI have made an event listener:text0_mc.addEventListener(MouseEvent.CLICK, showMe);showMe is a function, but I need it to call more than 1 function at once i.e. -ext0_mc.addEventListener(MouseEvent.CLICK, showMe1, showMe2, showMe3, showMe4, showMe5, showMe6, showMe7);Each function contains an if statment as below.
function showMe1(event:MouseEvent):void
{
if (shuffledArray[1]==orderArray[1]){
[code].....
Is there any way to call two functions concurrently at the same time in AS3? I have two functions which do very sensitive things, a difference of 0.1 second is considered failure.
View 2 RepliesI'm having some trouble calling a JavaScript function from the HTML file I've embedded my SWF in.
I'm currently using Flash 8.
I'm trying to to simply call a function which will open an alert window, but when I click my button, nothing happens.
Flash Code:
import flash.external.*;
testbutton.onRelease = function() {
ExternalInterface.call("testAlert", "Yay, it finally worked");
}
[Code].....
why the following does not work:
private function test():void
{
Parse1(textarea1.text);
Parse2(textarea2.text);[code].........
It seems only the first parse function is called and the rest is simply ignored.