Search Results

Search found 338 results on 14 pages for 'mxml'.

Page 1/14 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Sharing variables between mxml components

    - by Kamo
    I have several mxml components in an app, all of which need the same variable called genericX. I've included that variable in the main mxml and made it public [Bindable] public var genericX:Number = 102; but I still can't access it from other mxml components. If I try to do this for example, it doesn't recognize the variable. <s:Button x="{genericX}" label="Click" />

    Read the article

  • Can I rename Main.mxml?

    - by Randyaa
    We have several Flash objects included in our project. We call each one a specific type of widget... For readability/debugging purposes I'd like to rename Main.mxml to something else. At first this seemed easy, as it would be just a setting in our maven configuration (we're using flex mojos to build our swf). However; changing the sourceFile from Main.mxml to MyWidget.mxml doesn't seem to do it. Any thoughts?

    Read the article

  • Rendering MXML component only after actionscript is finished

    - by basicblock
    In my mxml file, I'm doing some calculations in the script tag, and binding them to a custom component. <fx:Script> <![CDATA[ [Bindable] public var calc1:Number; [Bindable] public var calc2:Number; private function init():void { calc1 = //calculation; calc2 = //calculation; } ]]> </fx:Script> <mycomp:Ball compfield1="{calc1}" compfield2="{calc2}"/> The problem is that the mxml component is being created before the actionscript is run. So when the component is created, it actually doesn't get calc1 and calc2 and it fails from that point. I know that binding happens after that, but the component and its functions have already started and have run with the null or 0 initial values. My solution was to create the component also in actionscript right after calc1 and calc2 have been created. This way I get to control precisely when it's created <fx:Script> <![CDATA[ [Bindable] public var calc1:Number; [Bindable] public var calc2:Number; private function init():void { calc1 = //calculation; calc2 = //calculation; var Ball:Ball = new Ball(calc1, calc2); } ]]> </fx:Script> but this is creating all kinds of other problems due to the way I've set up the component. Is there a way I can still use mxml to create the component, yet control that it the <myComp:Ball> gets created only after init() is run and calc1 calc2 evaluated?

    Read the article

  • starting with flex - please let me know if the direction is right (ActionScript vs MXML separation)

    - by Piotr
    Hi, I've just started learning flex using OReilly "Programming Flex 3.0". After completing three chapters and starting fourth (ActionScript), and not having enough patience to wait till completing chapter 22 I started to practice :) One bit that I have most worries about right now is the the dual coding mode (MXML vs ActionScript) Please have a look at my code below (it compiles via mxmlc design.mxml, second file 'code.as' should be in same directory) and advise if the separation I used between visual design and code is appropriate. Also - if some smart guy could show me how to recode same example with *.as being a class file [package?] it would be highly appreciated. I got lost with creating directory structure for package - and did not find it most intuitive, especially for small project that has two files like my example. Code: design.mxml <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script source="code.as"/> <mx:VBox> <mx:TextInput creationComplete="initializeCalculator()" id="txtScreen"/> <mx:HBox> <mx:Button click="click('7')" id="btn7" label="7"/> <mx:Button click="click('8')" id="btn8" label="8"/> <mx:Button click="click('9')" id="btn9" label="9"/> <mx:Button click="click('C')" id="btnClear" label="C"/> </mx:HBox> <mx:HBox> <mx:Button click="click('4')" id="btn4" label="4"/> <mx:Button click="click('5')" id="btn5" label="5"/> <mx:Button click="click('6')" id="btn6" label="6"/> <mx:Button click="click('/')" id="btnDivide" label="/"/> </mx:HBox> <mx:HBox> <mx:Button click="click('1')" id="btn1" label="1"/> <mx:Button click="click('2')" id="btn2" label="2"/> <mx:Button click="click('3')" id="btn3" label="3"/> <mx:Button click="click('*')" id="btnMultiply" label="*"/> </mx:HBox> <mx:HBox> <mx:Button click="click('0')" id="btn0" label="0"/> <mx:Button click="click('=')" id="btnEqual" label="="/> <mx:Button click="click('-')" id="btnMinus" label="-"/> <mx:Button click="click('+')" id="btnPlus" label="+"/> </mx:HBox> </mx:VBox> </mx:Application> code: code.as public var res:int = 0; public var previousOperator:String = ""; public var previousRes:int=0; public function initializeCalculator():void{ txtScreen.text = res.toString(); } public function click(code:String):void{ if (code=="1" || code=="2" || code=="3" || code=="4" || code=="5" || code=="6" || code=="7" || code=="8" || code=="9" || code=="0"){ res = res*10 + int(code); txtScreen.text = res.toString(); } else if (code=="C"){ res = 0; previousOperator =""; previousRes = 0; txtScreen.text = res.toString(); } else{ calculate(code); } } public function calculate(operator:String):void{ var tmpRes:int; if (previousOperator=="+"){ tmpRes = previousRes + res; } else if (previousOperator=="-"){ tmpRes = previousRes - res; } else if (previousOperator=="/"){ tmpRes = previousRes / res; } else if (previousOperator=="*"){ tmpRes = previousRes * res; } else{ tmpRes = res; } previousOperator = operator; previousRes = tmpRes; txtScreen.text = previousRes.toString(); res = 0; if (previousOperator=="=") { res = tmpRes; txtScreen.text=res.toString(); } } PS. If you have comments that this calculator does not calculate properly, they are also appreciated, yet most important are comments on best practices in Flex.

    Read the article

  • Hidden Features of MXML

    - by Ole Jak
    What are some of the hidden features of MXML? MXML being used in Flex Framework became quite popular language (because Flash Player is something every PC has and Flash Builder, Flash Catalist are quite popular Adobe programms) So at least from the existing features, do you know any that are not well known but very useful. Of course, this question is along the lines of: Hidden Features of ActionScript Hidden Features of JavaScript Hidden Features of CSS Hidden Features of C# Hidden Features of VB.NET Hidden Features of Java Hidden Features of ASP.NET Hidden Features of Python Hidden Features of TextPad Hidden Features of Eclipse Hidden Features of HTML Please specify one feature per answer. Note that it's not always a great idea to use these hidden features; often times they are surprising and confusing to others reading your code.

    Read the article

  • Converting mxml Rect & SolidColor to actionscript

    - by touB
    I'm trying to learn how to use actionscript over mxml for flexibility. I have this simple block of mxml that I'm trying to convert to actionscript, but I'm stuck half way though <s:Rect id="theRect" x="0" y="50" width="15%" height="15%"> <s:fill> <s:SolidColor color="black" alpha="0.9" /> </s:fill> </s:Rect> I can convert the Rect no problem to private var theRect:Rect = new Rect(); theRect.x = 0; theRect.y = 50; theRect.width = "15%"; theRect.height = "15%"; then I'm stuck on the fill. What's the most efficient way to add the SolidColor in as few lines of code as possible.

    Read the article

  • MXML composite canvas component initialization error

    - by mkorpela
    I'm getting an odd error from my composite canvas component: An ActionScript error has occurred: Error: null at mx.core::Container/initialize()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\core\Container.as:2560] at -REMOVED THIS FOR STACK OVERFLOW-.view::EditableCanvas/initialize()[.../view/EditableCanvas .... It seems to be related to the fact that my composite component has a child and I'm trying to add one in the place I'm using the component. So how can I do this correctly? Component code looks like this (EditableCanvas.mxml): <?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="{init()}"> <mx:Script> <![CDATA[ private var _editable:Boolean; public function set editable(edit:Boolean):void { _editable = edit; } private function init():void { if(_editable){ addEventListener(MouseEvent.MOUSE_OVER, showEdit); addEventListener(MouseEvent.MOUSE_OUT, hideEdit); } } private function showEdit(event:Event):void { editTextImage.visible = true; } private function hideEdit(event:Event):void { editTextImage.visible = false; } ]]> </mx:Script> <mx:Image id="editTextImage" source="@Embed('/../assets/icons/small/process.png')" click="{dispatchEvent(EditPoiEvent.text())}" visible="false"/> </mx:Canvas> The code that is using the code looks like this: <view:EditableCanvas width="290" height="120" backgroundColor="#FFFFFF" horizontalScrollPolicy="off" borderStyle="solid" cornerRadius="3" editable="{_editable}"> <mx:Text id="textContentBox" width="270" fontFamily="nautics" fontSize="12" text="{_text}"/> </view:EditableCanvas>

    Read the article

  • How to deserialize MXML with PHP?

    - by Ivan Petrushev
    Hello, I have an array structure that have to be converted to MXML. I know of PEAR XML_Serialize extension but it seems the output format it produces is a bit different. PHP generated XML: <zone columns="3"> <select column="1" /> <select column="4" /> </zone> MXML format: <mx:zone columns="3"> <mx:select column="1" /> <mx:select column="4" /> </mx:zone> Is that "mx:" prefix required for all the tags? If yes, can I make the XML_Serialize put it before each tag (without renaming my data structure fields to "mx:something")? Here are my options for XML_Serialize: $aOptions = array('addDecl' => true, 'indent' => " ", 'rootName' => 'template', 'scalarAsAttributes' => true, 'mode' => 'simplexml');

    Read the article

  • MXML composite container initialization error

    - by mkorpela
    I'm getting an odd error from my composite canvas component: An ActionScript error has occurred: Error: null at mx.core::Container/initialize()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\core\Container.as:2560] at -REMOVED THIS FOR STACK OVERFLOW-.view::EditableCanvas/initialize()[.../view/EditableCanvas .... It seems to be related to the fact that my composite component has a child and I'm trying to add one in the place I'm using the component. So how can I do this correctly? Component code looks like this (EditableCanvas.mxml): <?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <mx:Image id="editTextImage" source="@Embed('/../assets/icons/small/edit.png')"/> </mx:Canvas> The code that is using the code looks like this: <view:EditableCanvas width="290" height="120" backgroundColor="#FFFFFF" horizontalScrollPolicy="off" borderStyle="solid" cornerRadius="3"> <mx:Text id="textContentBox" width="270" fontFamily="nautics" fontSize="12" text="{_text}"/> </view:EditableCanvas>

    Read the article

  • how to get mxml file in ActionScript class

    - by nemade-vipin
    hello friend I want to refer my mxml file into Actionscript class.My code is :- Mxml file is :- var User:Authentication; User = new Authentication(); User.authentication(); } ]] <mx:Panel width="100%" height="100%" layout="absolute"> <mx:TabNavigator width="100%" height="100%" id="viewstack2"> <mx:Form label="Login Form" id="loginform"> <mx:FormItem label="Mobile no:" creationPolicy="all"> <mx:TextInput id="mobileno"/> </mx:FormItem> <mx:FormItem label="Password:" creationPolicy="all"> <mx:TextInput displayAsPassword="true" id="password" /> </mx:FormItem> <mx:FormItem> <mx:Button label="Login" click="authentication()"/> </mx:FormItem> </mx:Form> <mx:Form label="Child List"> <mx:Label width="100%" color="blue" text="Select Child."/> </mx:Form> </mx:TabNavigator> </mx:Panel> Action script class is package SBTSBusineesObject { import generated.webservices.*; import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.rpc.events.FaultEvent; public class Authentication { [Bindable] private var childName:ArrayCollection; [Bindable] private var childId:ArrayCollection; private var photoFeed:ArrayCollection; private var arrayOfchild:Array; private var newEntry:GetSBTSMobileAuthentication; public var user:SBTSWebService; public var mxmlobj:SBTS =null; public function authentication():void { user = new SBTSWebService(); mxmlobj = new SBTS(); if(user!=null) { user.addSBTSWebServiceFaultEventListener(handleFaults); user.addgetSBTSMobileAuthenticationEventListener(authenticationResult); newEntry = new GetSBTSMobileAuthentication(); if(newEntry!=null) { if(mxmlobj != null) { newEntry.mobile = mxmlobj.mobileno.text ; newEntry.password=mxmlobj.password.text; } user.getSBTSMobileAuthentication(newEntry); } } } public function handleFaults(event:FaultEvent):void { Alert.show("A fault occured contacting the server. Fault message is: " + event.fault.faultString); } public function authenticationResult(event:GetSBTSMobileAuthenticationResultEvent):void { if(event.result != null && event.result._return>0) { if(event.result._return > 0) { var UserId:int = event.result._return; if(mxmlobj != null) { mxmlobj.loginform.enabled = false; mxmlobj.viewstack2.selectedIndex=1; } } else { Alert.show("Authentication fail"); } } } } }

    Read the article

  • How To Access Namespace Elements In MXML Using Actionscript

    - by Joshua
    In Actionscript... If I Have an XML variable that equals this: var X:XML=XML("<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:ns1="Tools.*" minWidth="684" minHeight="484" creationComplete="Init();" xmlns:ns3="Components.*" initialize="I()"/>"); And I try to list the attributes via: var AList:XMList=X.attributes(); The three namespaces, "xmlns:mx","xmlns:ns1", and "xmlns:ns3" aren't listed among the attributes! How can I access this information programmatically?

    Read the article

  • Selecting MXML siblings with actionscript, like javascript?

    - by duder
    I'm trying to get the sibling of an mxml tag similar to the way siblings are selected in javascript. Is this possible in Actionscript? For example, when I click the TextArea with id textarea1, I need it to tell me that the sibling has an id of rect1 so I can do further processing to it. <s:Group> <s:TextArea id="textarea1" click="getSibling(event)" /> <s:Rect id="rect1" /> </s:Group>

    Read the article

  • Issues with mx:method, mx.rpc.remoting.mxml.RemoteObject, and sub-classing mx.rpc.remoting.mxml.Remo

    - by Ryan Wilson
    I am looking to subclass RemoteObject. Instead of: <mx:RemoteObject ... > <mx:method ... /> <mx:method ... /> </mx:RemoteObject> I want to do something like: <remoting:CustomRemoteObject ...> <mx:method ... /> <mx:method ... /> </remoting:CustomRemoteObject> where CustomRemoteObject extends mx.rpc.remoting.mxml.RemoteObject like so: package remoting { import mx.rpc.remoting.mxml.RemoteObject; public class CustomRemoteObject extends RemoteObject { public function CustomRemoteObject(destination:String=null) { super(destination); } } } However, when doing so and declaring a CustomRemoteObject in MXML as above, the flex compiler shows the error: Could not resolve <mx:method> to a component implementation At first I thought it had something to do with CustomRemoteObject failing to do something, despite that (or since) it had no change except as to the name. So, I copied the source from mx.rpc.remoting.mxml.RemoteObject into CustomRemoteObject and modified it so the only difference was a refactoring of the class and package name. But still, the same error. Unlike many MXML components, I cannot cmd+click <mx:method> in FlashBuilder to open the source. Likewise, I have not found a reference in mx.rpc.remoting.mxml.RemoteObject, mx.rpc.remoting.RemoteObject, or mx.rpc.remoting.AbstractService, and have been unsuccessful in find its source online. Which leads me to the questions in the title: What exactly is <mx:method>? (yes, I know it's a declaration of a RemoteObject method, and I know how to use it, but it's peculiar in regard to other components) Why did my attempt at subclassing RemoteObject fail, despite it effectually being a rename? Perhaps the root, why can mx.rpc.remoting.mxml.RemoteObject as an MXML declaration accept <mx:method> child tags, yet the source of said class cannot when refactored in name only?

    Read the article

  • Flex Unit testing of library and mxml using FlexUnit

    - by user344722
    Hi, I have some software classes(library) to run commands on any mxml file. These classes(library) are wrapped in a SWC file. This SWC file is referenced by any sample mxml application (by adding as SWC file). My problem is that I want to test these software classes(library) against my sample mxml file using FlexUnit. That is, I should test methods run by software classes on the mxml file. How can I accomplish this? Thanks, Pradeep

    Read the article

  • How do you center a control in an MXML panel?

    - by George Edison
    Here is what I have: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="#ffffff"> <mx:VBox percentHeight="100" percentWidth="100" > <mx:Image source="@Embed('img.png')" percentHeight="100" percentWidth="100" /> </mx:VBox> </mx:Application> How can I center the mx:Image in the mx:Application?

    Read the article

  • Flex: Why does setting scaleX/Y in mxml effect the components size but setting it in actionscript do

    - by ChrisInCambo
    Hi, I'm playing around with the scaleX/Y in the canvas tag and have noticed some strange behaviour. When I set scale in in mxml the width and height of the canvas are adjusted accordingly. For example if I have a canvas like this: <mx:Canvas width="1000" height="1000" scaleX="0.1" scaleY="0.1" /> The canvas now appears on screen to have a width and height of 100 and if inside my creationComplete callback I check the width and height property they are indeed 100. But if I do exactly the same thing except I set the scaleX/Y property from actionscript the canvas on screen appears to have a width and height of 100 as expected, but when I check the width and height property of the canvas they are still at the previous values of 1000. Could anyone help me understand what is going on and also tell me if there is any method that will refresh the width and height values so that they are correct? Thanks, Chris

    Read the article

  • how to use 3D map Actionscript class in mxml file for display map.

    - by nemade-vipin
    hello friends, I have created the application in which I have to use 3D map Action Script class in mxml file to display a map in form. that is in tab navigator last tab. My ActionScript 3D map class is(FlyingDirections):- package src.SBTSCoreObject { import src.SBTSCoreObject.JSONDecoder; import com.google.maps.InfoWindowOptions; import com.google.maps.LatLng; import com.google.maps.LatLngBounds; import com.google.maps.Map3D; import com.google.maps.MapEvent; import com.google.maps.MapOptions; import com.google.maps.MapType; import com.google.maps.MapUtil; import com.google.maps.View; import com.google.maps.controls.NavigationControl; import com.google.maps.geom.Attitude; import com.google.maps.interfaces.IPolyline; import com.google.maps.overlays.Marker; import com.google.maps.overlays.MarkerOptions; import com.google.maps.services.Directions; import com.google.maps.services.DirectionsEvent; import com.google.maps.services.Route; import flash.display.Bitmap; import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.display.Loader; import flash.display.LoaderInfo; import flash.display.Sprite; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.MouseEvent; import flash.events.TimerEvent; import flash.filters.DropShadowFilter; import flash.geom.Point; import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.navigateToURL; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFormat; import flash.utils.Timer; import flash.utils.getTimer; public class FlyingDirections extends Map3D { /** * Panoramio home page. */ private static const PANORAMIO_HOME:String = "http://www.panoramio.com/"; /** * The icon for the car. */ [Embed("assets/car-icon-24px.png")] private static const Car:Class; /** * The Panoramio icon. */ [Embed("assets/iw_panoramio.png")] private static const PanoramioIcon:Class; /** * We animate a zoom in to the start the route before the car starts * to move. This constant sets the time in seconds over which this * zoom occurs. */ private static const LEAD_IN_DURATION:Number = 3; /** * Duration of the trip in seconds. */ private static const TRIP_DURATION:Number = 40; /** * Constants that define the geometry of the Panoramio image markers. */ private static const BORDER_T:Number = 3; private static const BORDER_L:Number = 10; private static const BORDER_R:Number = 10; private static const BORDER_B:Number = 3; private static const GAP_T:Number = 2; private static const GAP_B:Number = 1; private static const IMAGE_SCALE:Number = 1; /** * Trajectory that the camera follows over time. Each element is an object * containing properties used to generate parameter values for flyTo(..). * fraction = 0 corresponds to the start of the trip; fraction = 1 * correspondsto the end of the trip. */ private var FLY_TRAJECTORY:Array = [ { fraction: 0, zoom: 6, attitude: new Attitude(0, 0, 0) }, { fraction: 0.2, zoom: 8.5, attitude: new Attitude(30, 30, 0) }, { fraction: 0.5, zoom: 9, attitude: new Attitude(30, 40, 0) }, { fraction: 1, zoom: 8, attitude: new Attitude(50, 50, 0) }, { fraction: 1.1, zoom: 8, attitude: new Attitude(130, 50, 0) }, { fraction: 1.2, zoom: 8, attitude: new Attitude(220, 50, 0) }, ]; /** * Number of panaramio photos for which we load data. We&apos;ll select a * subset of these approximately evenly spaced along the route. */ private static const NUM_GEOTAGGED_PHOTOS:int = 50; /** * Number of panaramio photos that we actually show. */ private static const NUM_SHOWN_PHOTOS:int = 7; /** * Scaling between real trip time and animation time. */ private static const SCALE_TIME:Number = 0.001; /** * getTimer() value at the instant that we start the trip. If this is 0 then * we have not yet started the car moving. */ private var startTimer:int = 0; /** * The current route. */ private var route:Route; /** * The polyline for the route. */ private var polyline:IPolyline; /** * The car marker. */ private var marker:Marker; /** * The cumulative duration in seconds over each step in the route. * cumulativeStepDuration[0] is 0; cumulativeStepDuration[1] adds the * duration of step 0; cumulativeStepDuration[2] adds the duration * of step 1; etc. */ private var cumulativeStepDuration:/*Number*/Array = []; /** * The cumulative distance in metres over each vertex in the route polyline. * cumulativeVertexDistance[0] is 0; cumulativeVertexDistance[1] adds the * distance to vertex 1; cumulativeVertexDistance[2] adds the distance to * vertex 2; etc. */ private var cumulativeVertexDistance:Array; /** * Array of photos loaded from Panoramio. This array has the same format as * the &apos;photos&apos; property within the JSON returned by the Panoramio API * (see http://www.panoramio.com/api/), with additional properties added to * individual photo elements to hold the loader structures that fetch * the actual images. */ private var photos:Array = []; /** * Array of polyline vertices, where each element is in world coordinates. * Several computations can be faster if we can use world coordinates * instead of LatLng coordinates. */ private var worldPoly:/*Point*/Array; /** * Whether the start button has been pressed. */ private var startButtonPressed:Boolean = false; /** * Saved event from onDirectionsSuccess call. */ private var directionsSuccessEvent:DirectionsEvent = null; /** * Start button. */ private var startButton:Sprite; /** * Alpha value used for the Panoramio image markers. */ private var markerAlpha:Number = 0; /** * Index of the current driving direction step. Used to update the * info window content each time we progress to a new step. */ private var currentStepIndex:int = -1; /** * The fly directions map constructor. * * @constructor */ public function FlyingDirections() { key="ABQIAAAA7QUChpcnvnmXxsjC7s1fCxQGj0PqsCtxKvarsoS-iqLdqZSKfxTd7Xf-2rEc_PC9o8IsJde80Wnj4g"; super(); addEventListener(MapEvent.MAP_PREINITIALIZE, onMapPreinitialize); addEventListener(MapEvent.MAP_READY, onMapReady); } /** * Handles map preintialize. Initializes the map center and zoom level. * * @param event The map event. */ private function onMapPreinitialize(event:MapEvent):void { setInitOptions(new MapOptions({ center: new LatLng(-26.1, 135.1), zoom: 4, viewMode: View.VIEWMODE_PERSPECTIVE, mapType:MapType.PHYSICAL_MAP_TYPE })); } /** * Handles map ready and looks up directions. * * @param event The map event. */ private function onMapReady(event:MapEvent):void { enableScrollWheelZoom(); enableContinuousZoom(); addControl(new NavigationControl()); // The driving animation will be updated on every frame. addEventListener(Event.ENTER_FRAME, enterFrame); addStartButton(); // We start the directions loading now, so that we&apos;re ready to go when // the user hits the start button. var directions:Directions = new Directions(); directions.addEventListener( DirectionsEvent.DIRECTIONS_SUCCESS, onDirectionsSuccess); directions.addEventListener( DirectionsEvent.DIRECTIONS_FAILURE, onDirectionsFailure); directions.load("48 Pirrama Rd, Pyrmont, NSW to Byron Bay, NSW"); } /** * Adds a big blue start button. */ private function addStartButton():void { startButton = new Sprite(); startButton.buttonMode = true; startButton.addEventListener(MouseEvent.CLICK, onStartClick); startButton.graphics.beginFill(0x1871ce); startButton.graphics.drawRoundRect(0, 0, 150, 100, 10, 10); startButton.graphics.endFill(); var startField:TextField = new TextField(); startField.autoSize = TextFieldAutoSize.LEFT; startField.defaultTextFormat = new TextFormat("_sans", 20, 0xffffff, true); startField.text = "Start!"; startButton.addChild(startField); startField.x = 0.5 * (startButton.width - startField.width); startField.y = 0.5 * (startButton.height - startField.height); startButton.filters = [ new DropShadowFilter() ]; var container:DisplayObjectContainer = getDisplayObject() as DisplayObjectContainer; container.addChild(startButton); startButton.x = 0.5 * (container.width - startButton.width); startButton.y = 0.5 * (container.height - startButton.height); var panoField:TextField = new TextField(); panoField.autoSize = TextFieldAutoSize.LEFT; panoField.defaultTextFormat = new TextFormat("_sans", 11, 0x000000, true); panoField.text = "Photos provided by Panoramio are under the copyright of their owners."; container.addChild(panoField); panoField.x = container.width - panoField.width - 5; panoField.y = 5; } /** * Handles directions success. Starts flying the route if everything * is ready. * * @param event The directions event. */ private function onDirectionsSuccess(event:DirectionsEvent):void { directionsSuccessEvent = event; flyRouteIfReady(); } /** * Handles click on the start button. Starts flying the route if everything * is ready. */ private function onStartClick(event:MouseEvent):void { startButton.removeEventListener(MouseEvent.CLICK, onStartClick); var container:DisplayObjectContainer = getDisplayObject() as DisplayObjectContainer; container.removeChild(startButton); startButtonPressed = true; flyRouteIfReady(); } /** * If we have loaded the directions and the start button has been pressed * start flying the directions route. */ private function flyRouteIfReady():void { if (!directionsSuccessEvent || !startButtonPressed) { return; } var directions:Directions = directionsSuccessEvent.directions; // Extract the route. route = directions.getRoute(0); // Draws the polyline showing the route. polyline = directions.createPolyline(); addOverlay(directions.createPolyline()); // Creates a car marker that is moved along the route. var car:DisplayObject = new Car(); marker = new Marker(route.startGeocode.point, new MarkerOptions({ icon: car, iconOffset: new Point(-car.width / 2, -car.height) })); addOverlay(marker); transformPolyToWorld(); createCumulativeArrays(); // Load Panoramio data for the region covered by the route. loadPanoramioData(directions.bounds); var duration:Number = route.duration; // Start a timer that will trigger the car moving after the lead in time. var leadInTimer:Timer = new Timer(LEAD_IN_DURATION * 1000, 1); leadInTimer.addEventListener(TimerEvent.TIMER, onLeadInDone); leadInTimer.start(); var flyTime:Number = -LEAD_IN_DURATION; // Set up the camera flight trajectory. for each (var flyStep:Object in FLY_TRAJECTORY) { var time:Number = flyStep.fraction * duration; var center:LatLng = latLngAt(time); var scaledTime:Number = time * SCALE_TIME; var zoom:Number = flyStep.zoom; var attitude:Attitude = flyStep.attitude; var elapsed:Number = scaledTime - flyTime; flyTime = scaledTime; flyTo(center, zoom, attitude, elapsed); } } /** * Loads Panoramio data for the route bounds. We load data about more photos * than we need, then select a subset lying along the route. * @param bounds Bounds within which to fetch images. */ private function loadPanoramioData(bounds:LatLngBounds):void { var params:Object = { order: "popularity", set: "full", from: "0", to: NUM_GEOTAGGED_PHOTOS.toString(10), size: "small", minx: bounds.getWest(), miny: bounds.getSouth(), maxx: bounds.getEast(), maxy: bounds.getNorth() }; var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest( "http://www.panoramio.com/map/get_panoramas.php?" + paramsToString(params)); loader.addEventListener(Event.COMPLETE, onPanoramioDataLoaded); loader.addEventListener(IOErrorEvent.IO_ERROR, onPanoramioDataFailed); loader.load(request); } /** * Transforms the route polyline to world coordinates. */ private function transformPolyToWorld():void { var numVertices:int = polyline.getVertexCount(); worldPoly = new Array(numVertices); for (var i:int = 0; i < numVertices; ++i) { var vertex:LatLng = polyline.getVertex(i); worldPoly[i] = fromLatLngToPoint(vertex, 0); } } /** * Returns the time at which the route approaches closest to the * given point. * @param world Point in world coordinates. * @return Route time at which the closest approach occurs. */ private function getTimeOfClosestApproach(world:Point):Number { var minDistSqr:Number = Number.MAX_VALUE; var numVertices:int = worldPoly.length; var x:Number = world.x; var y:Number = world.y; var minVertex:int = 0; for (var i:int = 0; i < numVertices; ++i) { var dx:Number = worldPoly[i].x - x; var dy:Number = worldPoly[i].y - y; var distSqr:Number = dx * dx + dy * dy; if (distSqr < minDistSqr) { minDistSqr = distSqr; minVertex = i; } } return cumulativeVertexDistance[minVertex]; } /** * Returns the array index of the first element that compares greater than * the given value. * @param ordered Ordered array of elements. * @param value Value to use for comparison. * @return Array index of the first element that compares greater than * the given value. */ private function upperBound(ordered:Array, value:Number, first:int=0, last:int=-1):int { if (last < 0) { last = ordered.length; } var count:int = last - first; var index:int; while (count > 0) { var step:int = count >> 1; index = first + step; if (value >= ordered[index]) { first = index + 1; count -= step - 1; } else { count = step; } } return first; } /** * Selects up to a given number of photos approximately evenly spaced along * the route. * @param ordered Array of photos, each of which is an object with * a property &apos;closestTime&apos;. * @param number Number of photos to select. */ private function selectEvenlySpacedPhotos(ordered:Array, number:int):Array { var start:Number = cumulativeVertexDistance[0]; var end:Number = cumulativeVertexDistance[cumulativeVertexDistance.length - 2]; var closestTimes:Array = []; for each (var photo:Object in ordered) { closestTimes.push(photo.closestTime); } var selectedPhotos:Array = []; for (var i:int = 0; i < number; ++i) { var idealTime:Number = start + ((end - start) * (i + 0.5) / number); var index:int = upperBound(closestTimes, idealTime); if (index < 1) { index = 0; } else if (index >= ordered.length) { index = ordered.length - 1; } else { var errorToPrev:Number = Math.abs(idealTime - closestTimes[index - 1]); var errorToNext:Number = Math.abs(idealTime - closestTimes[index]); if (errorToPrev < errorToNext) { --index; } } selectedPhotos.push(ordered[index]); } return selectedPhotos; } /** * Handles completion of loading the Panoramio index data. Selects from the * returned photo indices a subset of those that lie along the route and * initiates load of each of these. * @param event Load completion event. */ private function onPanoramioDataLoaded(event:Event):void { var loader:URLLoader = event.target as URLLoader; var decoder:JSONDecoder = new JSONDecoder(loader.data as String); var allPhotos:Array = decoder.getValue().photos; for each (var photo:Object in allPhotos) { var latLng:LatLng = new LatLng(photo.latitude, photo.longitude); photo.closestTime = getTimeOfClosestApproach(fromLatLngToPoint(latLng, 0)); } allPhotos.sortOn("closestTime", Array.NUMERIC); photos = selectEvenlySpacedPhotos(allPhotos, NUM_SHOWN_PHOTOS); for each (photo in photos) { var photoLoader:Loader = new Loader(); // The images aren&apos;t on panoramio.com: we can&apos;t acquire pixel access // using "new LoaderContext(true)". photoLoader.load( new URLRequest(photo.photo_file_url)); photo.loader = photoLoader; // Save the loader info: we use this to find the original element when // the load completes. photo.loaderInfo = photoLoader.contentLoaderInfo; photoLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, onPhotoLoaded); } } /** * Creates a MouseEvent listener function that will navigate to the given * URL in a new window. * @param url URL to which to navigate. */ private function createOnClickUrlOpener(url:String):Function { return function(event:MouseEvent):void { navigateToURL(new URLRequest(url)); }; } /** * Handles completion of loading an individual Panoramio image. * Adds a custom marker that displays the image. Initially this is made * invisible so that it can be faded in as needed. * @param event Load completion event. */ private function onPhotoLoaded(event:Event):void { var loaderInfo:LoaderInfo = event.target as LoaderInfo; // We need to find which photo element this image corresponds to. for each (var photo:Object in photos) { if (loaderInfo == photo.loaderInfo) { var imageMarker:Sprite = createImageMarker(photo.loader, photo.owner_name, photo.owner_url); var options:MarkerOptions = new MarkerOptions({ icon: imageMarker, hasShadow: true, iconAlignment: MarkerOptions.ALIGN_BOTTOM | MarkerOptions.ALIGN_LEFT }); var latLng:LatLng = new LatLng(photo.latitude, photo.longitude); var marker:Marker = new Marker(latLng, options); photo.marker = marker; addOverlay(marker); // A hack: we add the actual image after the overlay has been added, // which creates the shadow, so that the shadow is valid even if we // don&apos;t have security privileges to generate the shadow from the // image. marker.foreground.visible = false; marker.shadow.alpha = 0; var imageHolder:Sprite = new Sprite(); imageHolder.addChild(photo.loader); imageHolder.buttonMode = true; imageHolder.addEventListener( MouseEvent.CLICK, createOnClickUrlOpener(photo.photo_url)); imageMarker.addChild(imageHolder); return; } } trace("An image was loaded which could not be found in the photo array."); } /** * Creates a custom marker showing an image. */ private function createImageMarker(child:DisplayObject, ownerName:String, ownerUrl:String):Sprite { var content:Sprite = new Sprite(); var panoramioIcon:Bitmap = new PanoramioIcon(); var iconHolder:Sprite = new Sprite(); iconHolder.addChild(panoramioIcon); iconHolder.buttonMode = true; iconHolder.addEventListener(MouseEvent.CLICK, onPanoramioIconClick); panoramioIcon.x = BORDER_L; panoramioIcon.y = BORDER_T; content.addChild(iconHolder); // NOTE: we add the image as a child only after we&apos;ve added the marker // to the map. Currently the API requires this if it&apos;s to generate the // shadow for unprivileged content. // Shrink the image, so that it doesn&apos;t obcure too much screen space. // Ideally, we&apos;d subsample, but we don&apos;t have pixel level access. child.scaleX = IMAGE_SCALE; child.scaleY = IMAGE_SCALE; var imageW:Number = child.width; var imageH:Number = child.height; child.x = BORDER_L + 30; child.y = BORDER_T + iconHolder.height + GAP_T; var authorField:TextField = new TextField(); authorField.autoSize = TextFieldAutoSize.LEFT; authorField.defaultTextFormat = new TextFormat("_sans", 12); authorField.text = "author:"; content.addChild(authorField); authorField.x = BORDER_L; authorField.y = BORDER_T + iconHolder.height + GAP_T + imageH + GAP_B; var ownerField:TextField = new TextField(); ownerField.autoSize = TextFieldAutoSize.LEFT; var textFormat:TextFormat = new TextFormat("_sans", 14, 0x0e5f9a); ownerField.defaultTextFormat = textFormat; ownerField.htmlText = "<a href=\"" + ownerUrl + "\" target=\"_blank\">" + ownerName + "</a>"; content.addChild(ownerField); ownerField.x = BORDER_L + authorField.width; ownerField.y = BORDER_T + iconHolder.height + GAP_T + imageH + GAP_B; var totalW:Number = BORDER_L + Math.max(imageW, ownerField.width + authorField.width) + BORDER_R; var totalH:Number = BORDER_T + iconHolder.height + GAP_T + imageH + GAP_B + ownerField.height + BORDER_B; content.graphics.beginFill(0xffffff); content.graphics.drawRoundRect(0, 0, totalW, totalH, 10, 10); content.graphics.endFill(); var marker:Sprite = new Sprite(); marker.addChild(content); content.x = 30; content.y = 0; marker.graphics.lineStyle(); marker.graphics.beginFill(0xff0000); marker.graphics.drawCircle(0, totalH + 30, 3); marker.graphics.endFill(); marker.graphics.lineStyle(2, 0xffffff); marker.graphics.moveTo(30 + 10, totalH - 10); marker.graphics.lineTo(0, totalH + 30); return marker; } /** * Handles click on the Panoramio icon. */ private function onPanoramioIconClick(event:MouseEvent):void { navigateToURL(new URLRequest(PANORAMIO_HOME)); } /** * Handles failure of a Panoramio image load. */ private function onPanoramioDataFailed(event:IOErrorEvent):void { trace("Load of image failed: " + event); } /** * Returns a string containing cgi query parameters. * @param Associative array mapping query parameter key to value. * @return String containing cgi query parameters. */ private static function paramsToString(params:Object):String { var result:String = ""; var separator:String = ""; for (var key:String in params) { result += separator + encodeURIComponent(key) + "=" + encodeURIComponent(params[key]); separator = "&"; } return result; } /** * Called once the lead-in flight is done. Starts the car driving along * the route and starts a timer to begin fade in of the Panoramio * images in 1.5 seconds. */ private function onLeadInDone(event:Event):void { // Set startTimer non-zero so that the car starts to move. startTimer = getTimer(); // Start a timer that will fade in the Panoramio images. var fadeInTimer:Timer = new Timer(1500, 1); fadeInTimer.addEventListener(TimerEvent.TIMER, onFadeInTimer); fadeInTimer.start(); } /** * Handles the fade in timer&apos;s TIMER event. Sets markerAlpha above zero * which causes the frame enter handler to fade in the markers. */ private function onFadeInTimer(event:Event):void { markerAlpha = 0.01; } /** * The end time of the flight. */ private function get endTime():Number { if (!cumulativeStepDuration || cumulativeStepDuration.length == 0) { return startTimer; } return startTimer + cumulativeStepDuration[cumulativeStepDuration.length - 1]; } /** * Creates the cumulative arrays, cumulativeStepDuration and * cumulativeVertexDistance. */ private function createCumulativeArrays():void { cumulativeStepDuration = new Array(route.numSteps + 1); cumulativeVertexDistance = new Array(polyline.getVertexCount() + 1); var polylineTotal:Number = 0; var total:Number = 0; var numVertices:int = polyline.getVertexCount(); for (var stepIndex:int = 0; stepIndex < route.numSteps; ++stepIndex) { cumulativeStepDuration[stepIndex] = total; total += route.getStep(stepIndex).duration; var startVertex:int = stepIndex >= 0 ? route.getStep(stepIndex).polylineIndex : 0; var endVertex:int = stepIndex < (route.numSteps - 1) ? route.getStep(stepIndex + 1).polylineIndex : numVertices; var duration:Number = route.getStep(stepIndex).duration; var stepVertices:int = endVertex - startVertex; var latLng:LatLng = polyline.getVertex(startVertex); for (var vertex:int = startVertex; vertex < endVertex; ++vertex) { cumulativeVertexDistance[vertex] = polylineTotal; if (vertex < numVertices - 1) { var nextLatLng:LatLng = polyline.getVertex(vertex + 1); polylineTotal += nextLatLng.distanceFrom(latLng); } latLng = nextLatLng; } } cumulativeStepDuration[stepIndex] = total; } /** * Opens the info window above the car icon that details the given * step of the driving directions. * @param stepIndex Index of the current step. */ private function openInfoForStep(stepIndex:int):void { // Sets the content of the info window. var content:String; if (stepIndex >= route.numSteps) { content = "<b>" + route.endGeocode.address + "</b>" + "<br /><br />" + route.summaryHtml; } else { content = "<b>" + stepIndex + ".</b> " + route.getStep(stepIndex).descriptionHtml; } marker.openInfoWindow(new InfoWindowOptions({ contentHTML: content })); } /** * Displays the driving directions step appropriate for the given time. * Opens the info window showing the step instructions each time we * progress to a new step. * @param time Time for which to display the step. */ private function displayStepAt(time:Number):void { var stepIndex:int = upperBound(cumulativeStepDuration, time) - 1; var minStepIndex:int = 0; var maxStepIndex:int = route.numSteps - 1; if (stepIndex >= 0 && stepIndex <= maxStepIndex && currentStepIndex != stepIndex) { openInfoForStep(stepIndex); currentStepIndex = stepIndex; } } /** * Returns the LatLng at which the car should be positioned at the given * time. * @param time Time for which LatLng should be found. * @return LatLng. */ private function latLngAt(time:Number):LatLng { var stepIndex:int = upperBound(cumulativeStepDuration, time) - 1; var minStepIndex:int = 0; var maxStepIndex:int = route.numSteps - 1; if (stepIndex < minStepIndex) { return route.startGeocode.point; } else if (stepIndex > maxStepIndex) { return route.endGeocode.point; } var stepStart:Number = cumulativeStepDuration[stepIndex]; var stepEnd:Number = cumulativeStepDuration[stepIndex + 1]; var stepFraction:Number = (time - stepStart) / (stepEnd - stepStart); var startVertex:int = route.getStep(stepIndex).polylineIndex; var endVertex:int = (stepIndex + 1) < route.numSteps ? route.getStep(stepIndex + 1).polylineIndex : polyline.getVertexCount(); var stepVertices:int = endVertex - startVertex; var stepLeng

    Read the article

  • How can we retrieve value on main.mxml from other .mxml?

    - by Roshan
    main.mxml [Bindable] private var _dp:ArrayCollection = new ArrayCollection([ {day:"Monday", dailyTill:7792.43}, {day:"Tuesday", dailyTill:8544.875}, {day:"Wednesday", dailyTill:6891.432}, {day:"Thursday", dailyTill:10438.1}, {day:"Friday", dailyTill:8395.222}, {day:"Saturday", dailyTill:5467.00}, {day:"Sunday", dailyTill:10001.5} ]); public var hx:String ; public function init():void { //parameters is passed to it from flashVars //values are either amount or order hx = Application.application.parameters.tab; } ]]> </mx:Script> <mx:LineChart id="myLC" dataProvider="{_dp}" showDataTips="true" dataTipRenderer="com.Amount" > <mx:horizontalAxis> <mx:CategoryAxis categoryField="day" /> </mx:horizontalAxis> <mx:series> <mx:LineSeries xField="day" yField="dailyTill"> </mx:LineSeries> </mx:series> </mx:LineChart> com/Amount.mxml [Bindable] private var _dayText:String; [Bindable] private var _dollarText:String; override public function set data(value:Object):void{ //Alert.show(Application.application.parameters.tab); //we know to expect a HitData object from a chart, so let's cast it as such //so that there aren't any nasty runtime surprises var hd:HitData = value as HitData; //Any HitData object carries a reference to the ChartItem that created it. //This is where we need to know exactly what kind of Chartitem we're dealing with. //Why? Because a pie chart isn't going to have an xValue and a yValue, but things //like bar charts, column charts and, in our case, line charts will. var item:LineSeriesItem = hd.chartItem as LineSeriesItem; //the xValue and yValue are returned as Objects. Let's cast them as strings, so //that we can display them in the Label fields. _dayText = String(item.xValue); var hx : String = String(item.yValue) _dollarText = hx.replace("$"," "); }//end set data ]]> </mx:Script> QUES : Amount.mxml is used as dataTipRenderer for line chart. Now, I need to obtain the value assigned to variable "hx" in main.mxml from "com/Amount.mxml".Any help would be greatly appreciated?

    Read the article

  • MXML Component Life Cycle

    - by Shruti
    Hi, I am new to flex. I am confused with how component life cycle goes when component build in MXML. and if MXML calls methods automatically then how to call any method in life cycle explicitly. Could anybody please explain me Thanks Shruti

    Read the article

  • createChildren Called Before Component's MXML Bracket Logic Is Evaluated

    - by Nalandial
    I have the following MXML: <mx:Script> var someBoolean:Boolean = determineSomeCondition(); </mx:Script> .... <foo:MyComponent somePropertyExpectingIDataRenderer="{ someBoolean ? new Component1ThatImplementsIDataRenderer() : new Component2ThatImplementsIDataRenderer() }"> </foo:MyComponent> I have also overridden the createChildren() function: override protected function createChildren():void { super.createChildren(); //do something with somePropertyExpectingIDataRenderer } My problem is: createChildren() is being called before the squiggly bracket logic is being evaluated, so in createChildren(), somePropertyExpectingIDataRenderer is null. However if I pass the component via MXML like this: <foo:MyComponent> <bar:somePropertyExpectingIDataRenderer> <baz:Component1ThatImplementsIDataRenderer/> </bar:somePropertyExpectingIDataRenderer> </foo:MyComponent> Then when createChildren() is called, that same property isn't null. Is this supposed to happen and if so, what other workarounds should I consider?

    Read the article

  • Getting TypeError: Error #1009: Cannot access a property or method of a null object reference.

    - by nemade-vipin
    hello friends, I have created small application for login in flex desktop application. In which I am refering webservice method for login for this have created the Authentication class. Now I want to refer different Textinput value for mobile no and Textinput value for password. In my Authentication class. for this I have created the object of mxml class.And using this I am getting the mobile no value and password value in My Action script class. This my code :- SBTS.mxml file xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" public function login():void { var User:Authentication; User = new Authentication(); User.authentication(); } ]] text=" Select Child."/ Action script class :- package src { import adobe.utils.XMLUI; import generated.webservices.*; import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.rpc.events.FaultEvent; public class Authentication { [ Bindable] private var childName:ArrayCollection; [ Bindable] private var childId:ArrayCollection; private var photoFeed:ArrayCollection; private var arrayOfchild:Array; private var newEntry:GetSBTSMobileAuthentication; public var user:SBTSWebService; public var mxmlobj:SBTS; public function authentication():void { user = new SBTSWebService(); if(user!=null) { user.addSBTSWebServiceFaultEventListener(handleFaults); user.addgetSBTSMobileAuthenticationEventListener(authenticationResult); newEntry = new GetSBTSMobileAuthentication(); if(newEntry!=null) { mxmlobj = new SBTS(); if(mxmlobj != null) { newEntry.mobile = mxmlobj.mobileno.text; // Getting error here error mention below newEntry.password= mxmlobj.password.text; } user.getSBTSMobileAuthentication(newEntry); } } } public function handleFaults(event:FaultEvent):void { Alert.show( "A fault occured contacting the server. Fault message is: " + event.fault.faultString); } public function authenticationResult(event:GetSBTSMobileAuthenticationResultEvent):void { if(event.result != null && event.result._return0) { if(event.result._return 0) { var UserId:int = event.result._return; if(mxmlobj != null) { mxmlobj.loginform.enabled = false; mxmlobj.viewstack2.selectedIndex=1; } } else { Alert.show( "Authentication fail"); } } } } } I am getting this error :- TypeError: Error #1009: Cannot access a property or method of a null object reference. at SBTSBusineesObject::Authentication/authentication()[E:\Users\User1\Documents\Fl ex Builder 3\SBTS\src\SBTSBusineesObject\Authentication.as:35] at SBTS/login()[E:\Users\User1\Documents\Flex Builder 3\SBTS\src\SBTS.mxml:12] at SBTS/___SBTS_Button1_click()[E:\Users\User1\Documents\Flex Builder 3\SBTS\src\SBTS.mxml:27] please help me to remove this error.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >