Search Results

Search found 364 results on 15 pages for 'mouseevent'.

Page 11/15 | < Previous Page | 7 8 9 10 11 12 13 14 15  | Next Page >

  • how to remove MouseListener / ActionListener on a JTextField

    - by mithun1538
    Hello everyone, I have the following code adding an ActionListener to a JTextField: chatInput.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { chatInputMouseClicked(evt); } }); Now how do I remove this MouseListener using chatInput.removeMouseListener(), since this function needs an argument?

    Read the article

  • Flash 4 BitmapImage and events

    - by tit
    Hi, I am trying to use BitmapImage spark class instead of mx image class. Imag loads the same, fine <s:BitmapImage id="img" source="sample.jpg"> </s:BitmapImage> But I have an issue with adding mouse events on it, eg: img.addEventListener(MouseEvent.CLICK,clicked); do not trigger any mouse events when clicking on the image Help! Thanks

    Read the article

  • Finding the closest object in proxmity to the mouse Coordinates

    - by Cam
    Hey there, i've been working on a problem for a while now, which involves targeting the closest movieClip in relation to the x y coords of the mouse, I've attached a nice little acompanying graphic. Each mc added to the stage has it's own sub-class (HotSpots) which uses Pythag to measure distance from mouse. At this stage i can determine the closest value from my Main class but can't figure out how to reference it back to the movieclip... hope this makes sense. Below are the two Classes. My Main Class which attachs the mcs, and monitors mouse movement and traces closest value package { import flash.display.*; import flash.text.*; import flash.events.*; public class Main extends MovieClip { var pos:Number = 50; var nodeArray:Array; public function Main(){ nodeArray = []; for(var i:int = 0; i < 4; i++) { var hotSpot_mc:HotSpots = new HotSpots; hotSpot_mc.x += pos; hotSpot_mc.y += pos; addChild(hotSpot_mc); nodeArray.push(hotSpot_mc); // set some pos pos += 70; } stage.addEventListener(MouseEvent.MOUSE_MOVE,updateProxmity) } public function updateProxmity(e:MouseEvent):void { var tempArray:Array = new Array(); for(var i:int = 0; i < 4; i++) { this['tf'+[i]].text = String(nodeArray[i].dist); tempArray.push(nodeArray[i].dist); } tempArray.sort(Array.NUMERIC); var minValue:int = tempArray[0]; trace(minValue) } } } My HotSpots Class package { import flash.display.MovieClip; import flash.events.Event; import flash.text.TextField; public class HotSpots extends MovieClip { public var XSide:Number; public var YSide:Number; public var dist:Number = 0; public function HotSpots() { addEventListener(Event.ENTER_FRAME, textUp); } public function textUp(event:Event):void { XSide = this.x - MovieClip(root).mouseX; YSide = this.y - MovieClip(root).mouseY; dist = Math.round((Math.sqrt(XSide*XSide + YSide*YSide))); } } } thanks in advance

    Read the article

  • bottom uicomponent does not receive mouse events

    - by firemonkey
    HI, I am sure this is very basic, however I am not able to find the solution. I have a base ShapeContainer(UIComponent). I add a uicomponent which has mouse down listener to ShapeContainer. the listener works great. When I add a simple sprite(draw square) on the ShapeContainer, The listener does not work any more. In the code, if I comment below lines, The event listener works fine. var square:Sprite = new Sprite(); square.graphics.lineStyle(4,0x00FF00); square.graphics.drawRect(0,0,20,20); square.mouseEnabled=false; shapeContainer.addChildAt(square,1); I have tried few things like, mouseenabled=false on top sprite. also tried to add addChildAt but non of them did any help. How can I draw a shape and also have the event listener work. enter code here protected function application1_creationCompleteHandler(event:FlexEvent):void { var shapeContainer:UIComponent = new UIComponent(); shapeContainer.x=100; shapeContainer.y=100; shapeContainer.width=200; shapeContainer.height=200; rawChildren.addChild(shapeContainer); var EventListenerShape:UIComponent = new UIComponent(); EventListenerShape.x=100; EventListenerShape.y=100; EventListenerShape.width=200;a EventListenerShape.height=200; EventListenerShape.graphics.clear(); EventListenerShape.graphics.beginFill(0xf1f1f1, 0.1); EventListenerShape.graphics.drawRoundRect(0, 0, 200, 200, 10, 10); EventListenerShape.alpha = 0; EventListenerShape.graphics.endFill(); EventListenerShape.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownfunc); shapeContainer.addChild(EventListenerShape); var square:Sprite = new Sprite(); square.graphics.lineStyle(4,0x00FF00); square.graphics.drawRect(0,0,20,20); square.mouseEnabled=false; shapeContainer.addChildAt(square,1); } private function mouseDownfunc(e:MouseEvent){ trace("mouse Down **"); }    ]]> </mx:Script> <mx:Canvas id="uic" width="100%" height="100%" backgroundColor="0xFFFFFF"> </mx:Canvas>

    Read the article

  • Accessing main class stage event listener.

    - by Hwang
    I wanted to remove an event listener from main class stage, but i get the error 1120: Access of undefined property stage. How do I actually access the stage? custom class: import main; main.disableVcam(); main class: public static function disableVcam():void { trace("disable"); stage.removeEventListener(MouseEvent.MOUSE_MOVE, movevC); }

    Read the article

  • Resize AIR app window while dragging

    - by matt lohkamp
    So I've noticed Windows 7 has a disturbing tendency to prevent you from dragging the title bar of windows off the top of the screen. If you try - in this case, using an air app with a draggable area at the bottom of the window, allowing you to push the top of the window up past the screen - it just kicks the window back down far enough that the title bar is at the top of what it considers the 'visible area.' One solution would be to resize the app window as it moves, so that the title bar is always where windows wants it. How would you resize the window while you're dragging it, though? Would you do it like this? dragHitArea.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void{ stage.nativeWindow.height += 50; stage.nativeWindow.startMove(); stage.nativeWindow.height -= 50; }); see what's going on there? When I click, I'm doing startMove(), which is hooking into the OS' function for dragging a window around. I'm also increasing and decreasing the height of the window by 50 pixels - which should give me no net increase, right? Wrong - the first '.height +=' gets executed, but the '.height -=' after the .startMove() never runs. Why? update - If you're curious, I'm programming an air widget with fly-out menus which expand rightwards and upwards - and since those element can only be displayed within the boundaries of the application window itself (even though the window is set to be chromeless and transparent) I have to expand the application's borders to include the area that the menu 'pops up' into. In the extreme case, with the widget positioned bottom left, and the menus expanded completely across to the right side and top edge of the screen, the application area could very well cover the entire desktop. The problem is, when it's expanded like this, if the user drags it up and to the right, it causes the 'title bar' area of the application window to move above the top edge of the desktop area, where it would normally be unreachable; and Windows automatically re-positions the window back below that edge once the .startMove() operation is completed. So what I want to do is continually resize the height of the application so that the visual effect will be the same for the user, but for the benefit of the operating system the window's title bar will never be above that top boundary of the desktop area.

    Read the article

  • Dragging Custom Node in JavaFX

    - by Karussell
    I cannot get it working although I am very close to an acceptable solution. I can drag the Dock if it is only a rectangle. But if I add a node (e.g. an image) to this dock I am not able to get a working solution. Do you have a code snippet, link or other advices for me? Here is my code: public class Dock extends CustomNode { // initialize this with an 64x64 image of your choice // via ImageView { image: Image {..}} public var content: Node[]; public var width = 64; public var height = 64; public var xOffset: Number = 0; public var yOffset: Number = 0; var imgX: Number = 0; var imgY: Number = 0; var distX: Number; var distY: Number; public var rasterX = function (n: Number): Number { var MAX = 4 * 64; if (n < 0) { return 0 } else if (n > MAX) { return MAX } else return n } public var rasterY = rasterX; override protected function create(): Node { Group { // if we place the translate here then the whole dock will flicker //translateX: bind imgX; //translateY: bind imgY; content: [ Rectangle { // ... and here 'content' won't be dragged translateX: bind imgX; translateY: bind imgY; height: bind height width: bind width fill: Color.LIGHTGRAY strokeWidth: 4 stroke: Color.BLACK }, content] onMousePressed: function (e: MouseEvent): Void { xOffset = e.x; yOffset = e.y; // Calculate the distance of the mouse point from the image // top-left corner which will always come out as positive value distX = e.x - imgX; distY = e.y - imgY; } onMouseDragged: function (e: MouseEvent): Void { // Find out the new image postion by subtracting the distance // part from the mouse point. imgX = rasterX(e.x - distX); imgY = rasterY(e.y - distY); } } }

    Read the article

  • Using methods from the "outer" class in inner classes

    - by devoured elysium
    When defining nested classes, is it possible to access the "outer" class' methods? I know it's possible to access its attributes, but I can't seem to find a way to use its methods. addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && //<-- Here I'd like to } // reference a method }); //from the class where //addMouseListener() is defined! Thanks

    Read the article

  • Getting the right result of mouse click event

    - by Jessy
    Hello, I'm curious why I got the "right" BUT "wrong"number of result when I click the mouse. I supposed to print on the console mouseClicked once everytimes the mouse is clicked. However I got many of them printed out everytimes I clicked the mouse ...sometimes 5 e.g. mouseClicked mouseClicked mouseClicked mouseClicked mouseClicked Instead of just mouseClicked Why? public void mouseClicked(MouseEvent arg0) { System.out.println("mouseClicked"); }

    Read the article

  • addEventListener() isn't detecting KEY_UP nor KEY_DOWN

    - by Zirenth
    My full code is import flash.events.KeyboardEvent; import flash.events.Event; //init some variables var speedX = 0; var speedY = 0; msg.visible = false; var curLevel = 2; var level = new Array(); var flagVar; var won = false; //Adding level platforms for(var i = 0; i < numChildren; i++) { if(getChildAt(i) is platform) { level.push(getChildAt(i).getRect(this)); } if(getChildAt(i) is flag) { flagVar = getChildAt(i).getRect(this); } } //Checking key presses var kUp = false; var kDown = false; var kLeft = false; var kRight = false; var kSpace = false; stage.addEventListener(KeyboardEvent.KEY_DOWN, kD); stage.addEventListener(KeyboardEvent.KEY_UP, kU); function kD(k:KeyboardEvent) { trace("Key down - " + k.keyCode); if(k.keyCode == 32) { kSpace = true; } if(k.keyCode == 37 ) { kLeft = true; } if(k.keyCode == 38) { kUp = true; } if(k.keyCode == 39) { kRight = true; } } function kU(k:KeyboardEvent) { trace("Key up - " + k.keyCode); if(k.keyCode == 32) { kSpace = false; } if(k.keyCode == 37) { kLeft = false; } if(k.keyCode == 38) { kUp = false; } if(k.keyCode == 39) { kRight = false; } } addEventListener(Event.ENTER_FRAME, loopAround); function loopAround(e:Event) { //horizontal movement if(kLeft) { speedX = -10; } else if(kRight) { speedX = 10; } else { speedX *= 0.5; } player.x += speedX; //horizontal collision checks for(var i = 0; i < level.length; i++) { if(player.getRect(this).intersects(level[i])) { if(speedX > 0) { player.x = level[i].left - player.width; } if(speedX < 0) { player.x = level[i].right; } speedX = 0; } } //vertical movement speedY += 1; player.y += speedY; var jumpable = false; //Vertical collision for(i = 0; i < level.length; i++) { if(player.getRect(this).intersects(level[i])) { if(speedY > 0) { player.y = level[i].top - player.height; speedY = 0; jumpable = true; } if(speedY < 0) { player.y = level[i].bottom; speedY *= -0.5; } } } //JUMP! if((kUp || kSpace) && jumpable) { speedY=-20; } //Moving camera and other this.x = -player.x + (stage.stageWidth/2); this.y = -player.y + (stage.stageHeight/2); msg.x = player.x - (msg.width/2); msg.y = player.y - (msg.height/2); //Checking win if(player.getRect(this).intersects(flagVar)) { msg.visible = true; won = true; } //Check for next level request if(kSpace && won) { curLevel++; gotoAndStop(curLevel); won = false; } } The section in question is //Checking key presses var kUp = false; var kDown = false; var kLeft = false; var kRight = false; var kSpace = false; stage.addEventListener(KeyboardEvent.KEY_DOWN, kD); stage.addEventListener(KeyboardEvent.KEY_UP, kU); function kD(k:KeyboardEvent) { trace("Key down - " + k.keyCode); if(k.keyCode == 32) { kSpace = true; } if(k.keyCode == 37 ) { kLeft = true; } if(k.keyCode == 38) { kUp = true; } if(k.keyCode == 39) { kRight = true; } } function kU(k:KeyboardEvent) { trace("Key up - " + k.keyCode); if(k.keyCode == 32) { kSpace = false; } if(k.keyCode == 37) { kLeft = false; } if(k.keyCode == 38) { kUp = false; } if(k.keyCode == 39) { kRight = false; } } This was working fine last night, but today I moved it to a new keyframe and now it's not working. I'm not getting any errors (even if I debug). It just won't move the character or even show up in output. I'm still quite new to as3, so I don't really know what to do. Thanks in advance. Edit: After playing with it a bit, I've found out that the reason it's not working is due to the menu. The menu has a single button and two text elements, which are fine. The code that I'm using on the menu is this: import flash.events.MouseEvent; stop(); var format:TextFormat = new TextFormat(); format.size = 26; format.bold = true; playGameButton.setStyle("textFormat", format); stage.addEventListener(MouseEvent.CLICK, playGame); function playGame(e:MouseEvent) { if(e.target.name == "playGameButton") { gotoAndStop(2); } } If I use just gotoAndStop(2); it works fine, but with everything else it just goes to the second frame, and nothing else works after that. Edit #2: I've narrowed it down even farther to the if statement itself. if(e.target == playGameButton) if(e.target.name == "playGameButton") Both of those don't work. If I just remove the if statement all together it works perfectly fine.

    Read the article

  • Simple question about operator ||

    - by Tristan
    HEllo, i try to do that in FlashBuilder (FlexProject) protected function btn_detail_view_clickHandler(event:MouseEvent):void { CurrentState="Statistiques" || "PartMarche"; } But it's not working, i guess this is not the right syntax but what's the right syntax ? Thanks

    Read the article

  • Flex, Papervision3d: basic scenes, cameras, planes issue

    - by user157880
    // Import Papervision3D import org.papervision3d.Papervision3D; import org.papervision3d.scenes.; import org.papervision3d.cameras.; import org.papervision3d.objects.; import org.papervision3d.materials.; public var scene:Scene3D; public var camera:Camera3D; public var target:DisplayObject3D; public var screenshotArray: Array;//array to store pictures public var radius:Number; public var image:Image; private function initPapervision():void { target= new DisplayObject3D(); camera= new Camera3D(target); 1067: Implicit coercion of a value of type org.papervision3d.objects:DisplayObject3D to an unrelated type Number. scene= new Scene3D(thisContainer); 1137: Incorrect number of arguments. Expected no more than 0. scene.addChild( new DisplayObject3D() , "center" ); } public function handleCreationComplete():void { image = new Image(); image.source = "one_t.jpg"; image.maintainAspectRatio = true; image.scaleContent = false; image.autoLoad = false; image.addEventListener(Event.COMPLETE, handleImageLoad); image.load(); initPapervision(); } public function handleImageLoad(event:Event):void { init3D(); // onEnterFrame addEventListener( Event.ENTER_FRAME, loop3D ); addEventListener( MouseEvent.MOUSE_MOVE , handleMouseMove); } public function init3D():void { addScreenshots(20); } public function handleMouseMove(event:MouseEvent):void { camera.y = Math.max( thisContainer.mouseY*5 , -450 ); } public function addScreenshots(planeCount:Number):void { var obj:DisplayObject3D = scene.getChildByName ("center"); screenshotArray = new Array(planeCount); var texture:BitmapData = new BitmapData(image.content.loaderInfo.width, image.content.loaderInfo.height, false, 0); texture.draw(image); // Create texture with a bitmap from the library var materialSpace :MaterialObject3D = new BitmapMaterial(texture); materialSpace.doubleSided = true; materialSpace.smooth = false; radius = 500; camera.z = radius + 50; camera.y = 50; for (var i:Number = 0; i < planeCount; i++ ) { screenshotArray[i] = new Object() <b>screenshotArray[i].plane = new Plane( materialSpace, 100, 100, 2, 2 );</b> 1180: Call to a possibly undefined method Plane. // Position plane var rotation:Number = (360/planeCount)* i ; var rotationRadians:Number = (rotation-90) * (Math.PI/180); screenshotArray[i].rotation = rotation; screenshotArray[i].plane.z = (radius * Math.cos(rotationRadians) ) * -1; screenshotArray[i].plane.x = radius * Math.sin(rotationRadians) * -1; screenshotArray[i].plane.y = 100; screenshotArray[i].plane.lookAt(obj); // Add to scene scene.addChild( screenshotArray[i].plane ); } <b>scene.renderCamera(camera);</b> <i>1061: Call to a possibly undefined method renderCamera through a reference with static type org.papervision3d.scenes:Scene3D.</i> } public function loop3D(event:Event):void { var obj:DisplayObject3D = scene.getChildByName ("center"); for (var i:Number = 0; i < screenshotArray.length ; i++ ) { var rotation:Number = screenshotArray[i].rotation; rotation += (thisContainer.mouseX/50)/(screenshotArray.length/10); var rotationRadians:Number = (rotation-90) * (Math.PI/180); screenshotArray[i].rotation = rotation; screenshotArray[i].plane.z = (radius * Math.cos(rotationRadians) ) * -1; screenshotArray[i].plane.x = radius * Math.sin(rotationRadians) * -1; screenshotArray[i].plane.lookAt(obj); } //now lets render the scene <b>scene.renderCamera(camera);</b> <i>1061: Call to a possibly undefined method renderCamera through a reference with static type org.papervision3d.scenes:Scene3D.</i> } ]]

    Read the article

  • Actionscript multiple file upload, with parameter passing is not working

    - by Metropolis
    Hey everyone, First off, I am very bad at flash/actionscript, it is not my main programming language. I have created my own file upload flash app that has been working great for me up until this point. It uses PHP to upload the files and sends back a status message which gets displayed in a status box to the user. Now I have run into a situation where I need the HTML to pass a parameter to the Actionscript, and then to the PHP file using POST. I have tried to set this up just like adobe has it on http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_7.html without success. Here is my Actionscript code import fl.controls.TextArea; //Set filters var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png"); var textTypes:FileFilter = new FileFilter("Documents (*.txt, *.rtf, *.pdf, *.doc)", "*.txt; *.rtf; *.pdf; *.doc"); var allTypes:Array = new Array(textTypes, imageTypes); var fileRefList:FileReferenceList = new FileReferenceList(); //Add event listeners for its various fileRefList functions below upload_buttn.addEventListener(MouseEvent.CLICK, browseBox); fileRefList.addEventListener(Event.SELECT, selectHandler); function browseBox(event:MouseEvent):void { fileRefList.browse(allTypes); } function selectHandler(event:Event):void { var phpRequest:URLRequest = new URLRequest("ajax/upload.ajax.php"); var flashVars:URLVariables = objectToURLVariables(this.root.loaderInfo); phpRequest.method = URLRequestMethod.POST; phpRequest.data = flashVars; var file:FileReference; var files:FileReferenceList = FileReferenceList(event.target); var selectedFileArray:Array = files.fileList; var listener:Object = new Object(); for (var i:uint = 0; i < selectedFileArray.length; i++) { file = FileReference(selectedFileArray[i]); try { file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, phpResponse); file.upload(phpRequest); } catch (error:Error) { status_txt.text = file.name + " Was not uploaded correctly (" + error.message + ")"; } } } function phpResponse(event:DataEvent):void { var file:FileReference = FileReference(event.target); status_txt.htmlText += event.data; } function objectToURLVariables(parameters:Object):URLVariables { var paramsToSend:URLVariables = new URLVariables(); for(var i:String in parameters) { if(i!=null) { if(parameters[i] is Array) paramsToSend[i] = parameters[i]; else paramsToSend[i] = parameters[i].toString(); } } return paramsToSend; } The flashVars variable is the one that should contain the values from the HTML file. But whenever I run the program and output the variables in the PHP file I receive the following. //Using this command on the PHP page print_r($_POST); //I get this for output Array ( [Filename] => testfile.txt [Upload] => Submit Query ) Its almost like the parameters are getting over written or are just not working at all. Thanks for any help, Metropolis

    Read the article

  • Flex 4: Traversing the Stage More Easily

    - by Steve
    The following is a MXML Module I am producing in Flex 4: <?xml version="1.0" encoding="utf-8"?> <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init()" layout="absolute" width="100%" height="100%"> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <fx:Style source="BMChartModule.css" /> <s:Panel id="panel" title="Benchmark Results" height="100%" width="100%" dropShadowVisible="false"> <mx:TabNavigator id="tn" height="100%" width="100%" /> </s:Panel> <fx:Script> <![CDATA[ import flash.events.Event; import mx.charts.ColumnChart; import mx.charts.effects.SeriesInterpolate; import mx.controls.Alert; import spark.components.BorderContainer; import spark.components.Button; import spark.components.Label; import spark.components.NavigatorContent; import spark.components.RadioButton; import spark.components.TextInput; import spark.layouts.*; private var xml:XML; private function init():void { var seriesInterpolate:SeriesInterpolate = new SeriesInterpolate(); seriesInterpolate.duration = 1000; xml = parentApplication.model.xml; var sectorList:XMLList = xml.SECTOR; for each(var i:XML in sectorList) { var ncLayout:HorizontalLayout = new HorizontalLayout(); var nc:NavigatorContent = new NavigatorContent(); nc.label = i.@NAME; nc.name = "NC_" + nc.label; nc.layout = ncLayout; tn.addElement(nc); var cC:ColumnChart = new ColumnChart(); cC.percentWidth = 70; cC.name = "CC"; nc.addElement(cC); var bClayout:VerticalLayout = new VerticalLayout(); var bC:BorderContainer = new BorderContainer(); bC.percentWidth = 30; bC.layout = bClayout; nc.addElement(bC); var bClabel:Label = new Label(); bClabel.percentWidth = 100; bClabel.text = "Select a graph to view it in the column chart:"; var dpList:XMLList = sectorList.(@NAME == i.@NAME).DATAPOINT; for each(var j:XML in dpList) { var rB:RadioButton = new RadioButton(); rB.groupName = "dp"; rB.label = j.@NAME; rB.addEventListener(MouseEvent.CLICK, rBclick); bC.addElement(rB); } } } private function rBclick(e:MouseEvent):void { var selectedTab:NavigatorContent = this.tn.selectedChild as NavigatorContent; var colChart:ColumnChart = selectedTab.getChildByName("CC") as ColumnChart; trace(selectedTab.getChildAt(0)); } ]]> </fx:Script> </mx:Module> I'm writing this function rBclick to redraw the column chart when a radio button is clicked. In order to do this I need to find the column chart on the stage using actionscript. I've currently got 3 lines of code in here to do this: var selectedTab:NavigatorContent = this.tn.selectedChild as NavigatorContent; var colChart:ColumnChart = selectedTab.getChildByName("CC") as ColumnChart; trace(selectedTab.getChildAt(0)); Getting to the active tab in the tabnavigator is easy enough, but then selectedTab.getChildAt(0) - which I was expecting to be the chart - is a "spark.skin.spark.SkinnableContainerSkin"...anyway, I can continue to traverse the tree using this somewhat annoying code, but I'm hoping there is an easier way. So in short, at run time I want to, with as little code as possible, identify the column chart in the active tab so I can redraw it. Any advice would be greatly appreciated.

    Read the article

  • [Flex 4 and .Net] Retrieving tables from SQL database

    - by mG
    Hi everyone, As the title says, I want to retrieve tables of data from a SQL database, using Flex 4 and .Net WebService. I'm new to both Flex and DotNet. Please tell me a proper way to do it. This is what I've done so far: Retrieving an array of string: (this works) .Net: [WebMethod] public String[] getTestArray() { String[] arStr = { "AAA", "BBB", "CCC", "DDD" }; return arStr; } Flex 4: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.rpc.events.ResultEvent; [Bindable] private var ac:ArrayCollection = new ArrayCollection(); protected function btn_clickHandler(event:MouseEvent):void { ws.getTestArray(); } protected function ws_resultHandler(event:ResultEvent):void { ac = event.result as ArrayCollection; Alert.show(ac.toString()); } ]]> </fx:Script> <fx:Declarations> <s:WebService id="ws" wsdl="http://localhost:50582/Service1.asmx?WSDL" result="ws_resultHandler(event)"/> </fx:Declarations> <s:Button x="10" y="30" label="Button" id="btn" click="btn_clickHandler(event)"/> </s:Application> Retrieving a DataTable: (this does not work) DotNet: [WebMethod] public DataTable getUsers() { DataTable dt = new DataTable("Users"); SqlConnection conn = new SqlConnection("server = 192.168.1.50; database = MyDatabase; user id = sa; password = 1234; integrated security = false"); SqlDataAdapter da = new SqlDataAdapter("select vFName, vLName, vEmail from Users", conn); da.Fill(dt); return dt; } Flex 4: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.rpc.events.ResultEvent; [Bindable] private var ac:ArrayCollection = new ArrayCollection(); protected function btn_clickHandler(event:MouseEvent):void { ws.getUsers(); } protected function ws_resultHandler(event:ResultEvent):void { ac = event.result as ArrayCollection; Alert.show(ac.toString()); } ]]> </fx:Script> <fx:Declarations> <s:WebService id="ws" wsdl="http://localhost:50582/Service1.asmx?WSDL" result="ws_resultHandler(event)"/> </fx:Declarations> <s:Button x="10" y="30" label="Button" id="btn" click="btn_clickHandler(event)"/> </s:Application>

    Read the article

  • How can I Implement KeyListeners/ActionListeners into the JFrame?

    - by A.K.
    I'll get to the point: I have a player in my game that you control with the keyboard yet the key methods in the player class and ActionListener w/ KeyAdapter in the Board class don't seem to fire. So far I've tried adding these key methods into the JFrame, doesn't seem to let me move him even though other objects that I have (enemies) can move fine. Here's part of the JFrame class with the event listeners: frm.addKeyListener(KeyBoardListener); public void mouseClicked(MouseEvent e) { nSound.play(); StartB.setContentAreaFilled(false); cards.remove(StartB); frm.remove(TitleL); frm.remove(cards); frm.setLayout(new GridLayout(1, 1)); frm.add(nBoard); //Add Game "Tiles" Or Content. x = 1200 nBoard.setPreferredSize(new Dimension(1200, 420)); cards.revalidate(); frm.validate(); } public KeyListener KeyBoardListener = new KeyListener() { @Override public void keyPressed(KeyEvent args0) { int key = args0.getKeyCode(); if(key == KeyEvent.VK_LEFT) { nBoard.S.vx = -4; } if(key == KeyEvent.VK_RIGHT) { nBoard.S.vx = 4; } if(key == KeyEvent.VK_UP) { nBoard.S.vy = -4; } if(key == KeyEvent.VK_DOWN) { nBoard.S.vy = 4; } if(key == KeyEvent.VK_SPACE) { nBoard.S.fire(); } } @Override public void keyReleased(KeyEvent args0) { int key = args0.getKeyCode(); if(key == KeyEvent.VK_LEFT) { nBoard.S.vx = 0; } if(key == KeyEvent.VK_RIGHT) { nBoard.S.vx = 0; } if(key == KeyEvent.VK_UP) { nBoard.S.vy = 0; } if(key == KeyEvent.VK_DOWN) { nBoard.S.vy = 0; } } @Override public void keyTyped(KeyEvent args0) { // TODO Auto-generated method stub } };

    Read the article

  • not able to show the file from the array...

    - by sjl
    Hi, i'm trying to do an image gallery. i was not able to display the thumbnails stored in the array. instead it keep showing the same thumbnails. anyone can help? very much appreciated.. // Arrays that store the filenames of the text, images and thumbnails var thumbnails:Array = [ "images/image1_thumb.jpg", "images/image2_thumb.jpg", "images/image3_thumb.jpg", "images/image4_thumb.jpg", "images/image5_thumb.jpg", "images/image6_thumb.jpg", "images/image7_thumb.jpg" ]; var images:Array = [ "images/image1.jpg", "images/image2.jpg", "images/image3.jpg", "images/image4.jpg", "images/image5.jpg", "images/image6.jpg", "images/image7.jpg" ]; var textFiles:Array = [ "text/picture1.txt", "text/picture2.txt", "text/picture3.txt", "text/picture4.txt", "text/picture5.txt", "text/picture6.txt", "text/picture7.txt" ]; // NOTE: thumbnail images are 60 x 43 pixels in size // loop through the array and create the thumbnails and position them vertically for (var i:int = 0; i <7; i++) { // create an instance of MyUIThumbnail var thumbs:MyUIThumbnail = new MyUIThumbnail(); // position the thumbnails on the left vertically thumbs.y = 43 * i;/*** FILL IN THE BLANK HERE ***/ // store the corresponding full size image name in the thumbnail // use the "images" array thumbs.image = "images/image1.jpg"; thumbs.image = "images/image2.jpg"; thumbs.image = "images/image3.jpg"; thumbs.image = "images/image4.jpg"; thumbs.image = "images/image5.jpg"; thumbs.image = "images/image6.jpg"; thumbs.image = "images/image7.jpg"; // store the corresponding text file name in the thumbnail // use the "textFiles" array thumbs.textFile = "text/picture1.txt"; thumbs.textFile = "text/picture2.txt"; thumbs.textFile = "text/picture3.txt"; thumbs.textFile = "text/picture4.txt"; thumbs.textFile = "text/picture5.txt"; thumbs.textFile = "text/picture6.txt"; thumbs.textFile = "text/picture7.txt"; thumbs.imageFullSize = full_image_mc ; // store the reference to the textfield in the thumbnail thumbs.infoText = info; // load and display the thumbnails // use the "thumbnails" array thumbs.loadThumbnail("images/image1_thumb.jpg"); thumbs.loadThumbnail("images/image2_thumb.jpg"); thumbs.loadThumbnail("images/image3_thumb.jpg"); thumbs.loadThumbnail("images/image4_thumb.jpg"); thumbs.loadThumbnail("images/image5_thumb.jpg"); thumbs.loadThumbnail("images/image6_thumb.jpg"); thumbs.loadThumbnail("images/image7_thumb.jpg"); addChild(thumbs); } below is my thumbanail. as package{ import fl.containers.; import flash.events.; import flash.text.; import flash.net.; import flash.display.*; public class MyUIThumbnail extends MovieClip { public var image:String = ""; public var textFile:String = ""; var loader:UILoader = new UILoader(); public var imageFullSize:MyFullSizeImage; // reference to loader to show the full size image public var infoText:TextField; // reference to textfield that displays image infoText var txtLoader:URLLoader = new URLLoader(); // loader to load the text file public function MyUIThumbnail() { buttonMode = true; addChild(loader); this.addEventListener(MouseEvent.CLICK, myClick); txtLoader.addEventListener(Event.COMPLETE, displayText); loader.addEventListener(Event.COMPLETE, thumbnailLoaded); } public function loadThumbnail(filename:String):void { loader.source = filename; preloader.trackLoading(loader); } function myClick(e:MouseEvent):void { // load and display the full size image imageFullSize.loadImage("my_full_mc"); // load and display the text textLoad("info"); } function textLoad(file:String) { // load the text description from the text file loader.load(new URLRequest(textFile)); } function displayText(e:Event) { //display the text when loading is completed addChild(infoText); } function thumbnailLoaded(e:Event) { loader.width = 60; loader.height = 43; } } }

    Read the article

  • How to suppress Flash migration warnings (1090)

    - by aaaidan
    I get "migration issue" warnings when I use mouse/keyboard input handler names such as onMouseDown, onKeyUp, etc. These names are perfectly legal, but sensibly, we are now warned that their use is no longer automatic in ActionScript 3. I want to suppress these warnings, but without suppressing all other warnings, which I find useful. E.g., when I use code like this: protected override function onMouseDown(e:MouseEvent):void { I get an annoying warning like this: Warning: 1090: Migration issue: The onMouseDown event handler is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( 'mouseDown', callback_handler). There are flex compiler (mxmlc) flags which can suppress actionscript warnings, or all warnings, but I don't want that. That's to general. Ideally I could suppress a specific error/warning number (Warning #1090). Halp?

    Read the article

  • ExternalInterface in flex calling javascript function works for mozilla/chrome but NOT IE

    - by Rees
    hello, i have a flex application that does a simple ExternalInterface.call("shareOptions"), which calls a shareOptions() javascript method and works absolutely fine with Mozilla and chrome, however when I test with IE i get the following error: Error: [object Error] at flash.external::ExternalInterface$/_toAS() at flash.external::ExternalInterface$/call() I looked at the adobe livedocs documentation but can't determine what the issue is with IE. is there something i'm missing?? if anyone knows, please let me know ASAP! thanks in advance. private function shareOptions(event:MouseEvent):void{ ExternalInterface.marshallExceptions = true; if (ExternalInterface.available){ ExternalInterface.call("shareOptions"); } } the javascript <script language="JavaScript" type="text/javascript"> function shareOptions() { myWin = window.open('http://www.mysite.shareOptions.php','yeee!','width=640,height=690,toolbar=no,location=0,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=yes,x=500,y=500'); myWin.moveTo(300,300); } </script>

    Read the article

  • Drawing Shapes in Flex 4/AS3 addchild issues

    - by Parris
    Hi All, I am simply trying to draw a rectangle inside of a panel using flex4. I am using spark instead of mx. It complains about addchild being replaced by addelement; however, addelement expects type ivisualcomponent. I think sprite should be of that type; however, it reports an error when trying to use the below code... I have tried a few different ways. I think I am missing something very basic about flex 4. Any enlightenment would be much appreciated! :-D private function drawRectangle(e:MouseEvent):void{ var s:Sprite = new Sprite(); s.graphics.beginFill(0x00ff00, 0.5); s.graphics.drawRect(e.localX,e.localY,50,50); s.graphics.endFill(); canvas.addChild(s); }

    Read the article

  • IPhone like scrolling on Silverlight ListBox

    - by Larsi
    Hi! I need a listbox with IPhone-like functionality for Silverlight. That is, animated scrolling, and click and drag to scroll. Scrolling will continue a bit after the mouse up event based on the "speed" of the dragging. I've search and found no control vendors providing this. So question is how should I build it? I need some hints to get started. There's two parts to this question: Part 1, How to get the animated scrolling of the listbox. Part 2, How to build a "draggable" scrolling, I guess I should put a canvas on top and track the mouseevent, and simulate some physics. Some hints here would have been great. Thanks Larsi.

    Read the article

  • Placement coordinates of bitmapData in AS3

    - by TheDarkIn1978
    i've programatically created a vector graphic (rect), repositioned the graphic, and set up an MOUSE_MOVE eventListener to trace color information of the graphic using getPixel(). however, the bitmapData is placed at 0,0 of the stage and i don't know how to move it so that it matches the graphic's location. var coloredSquare:Sprite = new GradientRect(200, 200, 0xFFFFFF, 0x000000, 0xFF0000, 0xFFFF00); coloredSquare.x = 100; addChild(coloredSquare); var coloredSquareBitmap:BitmapData = new BitmapData(coloredSquare.width, coloredSquare.height, true, 0); coloredSquareBitmap.draw(coloredSquare); coloredSquare.addEventListener(MouseEvent.MOUSE_MOVE, readColor); function readColor(evt:Event):void { var pixelValue:uint = coloredSquare.getPixel(mouseX, mouseY); trace(pixelValue.toString(16)); }

    Read the article

  • Multiple MCs, Single Listener, AsBroadcaster

    - by Brett
    I'm currently working trying to have multiple MCs inside a container MC which when they mini MCs are clicked will broadcast a message so that I can act upon them. This would be simple in AS 3 as it would be mc.addEventListener(MouseEvent.CLICK, obj); however, this is AS 2 and so I am semi-forced to use the broadcastMessage('myMessage'); and mc.addListener(obj); event handler. The main problem is that the broadcaster isn't broadcasting any messages. The second problem is that there are 5 MCs and when I click one of them, I get 5 trace messages about the click. I can't seem to keep the MC clicks unique even though they are all given separate instance names vie the properties panel. Any help would be appreciated. A link to my code is here (pastie.org #481511). Can you see anything wrong?

    Read the article

  • Flash Double-click an externally loaded SWF

    - by Trist
    OK. I've got a class (which extends MovieClip) that loads in an external SWF (made in pdf2swf). That is added to another class which has declared doubleClickEnabled = true and I'm listening for DOUBLE_CLICK events. Problem is when the SWF is loaded my code picks up no DOUBLE_CLICK events, only CLICK events. I've tried it without adding the SWF to the stage and it does pick up DOUBLE_CLICK events. Anybody come across this before? class ParentClass{ ... public function ParentClass(){ ... mcToLoadSWF = new MovieClip(); addChild(mcToLoadSWF); doubleClickEnabled = true; addEventListener(MouseEvent.DOUBLE_CLICK, doubleClickHandler); ... } } I've also tried adding the event listener to the mcToLoadSWF as well. No dice. Cheers Tristian

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15  | Next Page >