Daily Archives

Articles indexed Tuesday July 3 2012

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

  • How do I do Collisions in my JavaScript Game Code Below?

    - by Henry
    I'm trying to figure out how would I add collision detection to my code so that when the "Man" character touches the "RedHouse" the RedHouse disappears? Thanks. By the way, I'm new to how things are done on this site, so thus, if there is anything else needed or so, let me know. <title>HMan</title> <body style="background:#808080;"> <br> <canvas id="canvasBg" width="800px" height="500px"style="display:block;background:#ffffff;margin:100px auto 0px;"></canvas> <canvas id="canvasRedHouse" width="800px" height="500px" style="display:block;margin:-500px auto 0px;"></canvas> <canvas id="canvasEnemy" width="800px" height="500px" style="display:block;margin:-500px auto 0px;"></canvas> <canvas id="canvasEnemy2" width="800px" height="500px" style="display:block;margin:-500px auto 0px;"></canvas> <canvas id="canvasMan" width="800px" height="500px" style="display:block;margin:-500px auto 0px;"></canvas> <script> var isPlaying = false; var requestAnimframe = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame; var canvasBg = document.getElementById('canvasBg'); var ctxBg = canvasBg.getContext('2d'); var canvasRedHouse = document.getElementById('canvasRedHouse'); var ctxRedHouse = canvasRedHouse.getContext('2d'); var House1; House1 = new RedHouse(); var canvasMan = document.getElementById('canvasMan'); var ctxMan = canvasMan.getContext('2d'); var Man1; Man1 = new Man(); var imgSprite = new Image(); imgSprite.src = 'SpritesI.png'; imgSprite.addEventListener('load',init,false); function init() { drawBg(); startLoop(); document.addEventListener('keydown',checkKeyDown,false); document.addEventListener('keyup',checkKeyUp,false); } function drawBg() { var SpriteSourceX = 0; var SpriteSourceY = 0; var drawManOnScreenX = 0; var drawManOnScreenY = 0; ctxBg.drawImage(imgSprite,SpriteSourceX,SpriteSourceY,800,500,drawManOnScreenX, drawManOnScreenY,800,500); } function clearctxBg() { ctxBg.clearRect(0,0,800,500); } function Man() { this.SpriteSourceX = 10; this.SpriteSourceY = 540; this.width = 40; this.height = 115; this.DrawManOnScreenX = 100; this.DrawManOnScreenY = 260; this.speed = 10; this.actualFrame = 1; this.speed = 2; this.isUpKey = false; this.isRightKey = false; this.isDownKey = false; this.isLeftKey = false; } Man.prototype.draw = function () { clearCtxMan(); this.updateCoors(); this.checkDirection(); ctxMan.drawImage(imgSprite,this.SpriteSourceX,this.SpriteSourceY+this.height* this.actualFrame, this.width,this.height,this.DrawManOnScreenX,this.DrawManOnScreenY, this.width,this.height); } Man.prototype.updateCoors = function(){ this.leftX = this.DrawManOnScreenX; this.rightX = this.DrawManOnScreenX + this.width; this.topY = this.DrawManOnScreenY; this.bottomY = this.DrawManOnScreenY + this.height; } Man.prototype.checkDirection = function () { if (this.isUpKey && this.topY > 240) { this.DrawManOnScreenY -= this.speed; } if (this.isRightKey && this.rightX < 800) { this.DrawManOnScreenX += this.speed; } if (this.isDownKey && this.bottomY < 500) { this.DrawManOnScreenY += this.speed; } if (this.isLeftKey && this.leftX > 0) { this.DrawManOnScreenX -= this.speed; } if (this.isRightKey && this.rightX < 800) { if (this.actualFrame > 0) { this.actualFrame = 0; } else { this.actualFrame++; } } if (this.isLeftKey) { if (this.actualFrame > 2) { this.actualFrame = 2; } function checkKeyDown(var keyID = e.keyCode || e.which; if (keyID === 38) { Man1.isUpKey = true; e.preventDefault(); } if (keyID === 39 ) { Man1.isRightKey = true; e.preventDefault(); } if (keyID === 40 ) { Man1.isDownKey = true; e.preventDefault(); } if (keyID === 37 ) { Man1.isLeftKey = true; e.preventDefault(); } } function checkKeyUp(e) { var keyID = e.keyCode || e.which; if (keyID === 38 || keyID === 87) { Man1.isUpKey = false; e.preventDefault(); } if (keyID === 39 || keyID === 68) { Man1.isRightKey = false; e.preventDefault(); } if (keyID === 40 || keyID === 83) { Man1.isDownKey = false; e.preventDefault(); } if (keyID === 37 || keyID === 65) { Man1.isLeftKey = false; e.preventDefault(); } } function clearCtxMan() { ctxMan.clearRect(0,0,800,500); } function RedHouse() { this.srcX = 135; this.srcY = 525; this.width = 265; this.height = 245; this.drawX = 480; this.drawY = 85; } RedHouse.prototype.draw = function () { clearCtxRedHouse(); ctxRedHouse.drawImage(imgSprite,this.srcX,this.srcY, this.width,this.height,this.drawX,this.drawY,this.width,this.height); }; function clearCtxRedHouse() { ctxRedHouse.clearRect(0,0,800,500); } function loop() { if (isPlaying === true){ Man1.draw(); House1.draw(); requestAnimframe(loop); } } function startLoop(){ isPlaying = true; loop(); } function stopLoop(){ isPlaying = false; } </script> <style> .top{ position: absolute; top: 4px; left: 10px; color:black; } .top2{ position: absolute; top: 60px; left: 10px; color:black; } </style> <div class="top"> <p><font face="arial" color="black" size="4"><b>HGame</b><font/><p/> <p><font face="arial" color="black" size="3"> My Game Here <font/><p/> </div> <div class="top2"> <p><font face="arial" color="black" size="3"> It will start now <font/><p/> </div>

    Read the article

  • Drawing texture does not work anymore with a small amount of triangles

    - by Paul
    When i draw lines, the vertices are well connected. But when i draw the texture inside the triangles, it only works with i<4 in the for loop, otherwise with i<5 for example, there is a EXC_BAD_ACCESS message, at @synthesize textureImage = _textureImage. I don't understand why. (The generatePolygons method seems to work fine as i tried to draw lines with many vertices as in the second image below. And textureImage remains the same for i<4 or i<5 : it's a 512px square image). Here are the images : What i want to achieve is to put the red points and connect them to the y-axis (the green points) and color the area (the green triangles) : If i only draw lines, it works fine : Then with a texture color, it works for i<4 in the loop (the red points in my first image, plus the fifth one to connect the last y) : But then, if i set i<5, the debug tool says EXC_BAD_ACCESS at the synthesize of _textureImage. Here is my code : I set a texture color in HelloWordLayer.mm with : CCSprite *textureImage = [self spriteWithColor:color3 textureSize:512]; _terrain.textureImage = textureImage; Then in the class Terrain, i create the vertices and put the texture in the draw method : @implementation Terrain @synthesize textureImage = _textureImage; //EXC_BAD_ACCESS for i<5 - (void)generatePath2{ CGSize winSize = [CCDirector sharedDirector].winSize; float x = 40; float y = 0; for(int i = 0; i < kMaxKeyPoints+1; ++i) { _hillKeyPoints[i] = CGPointMake(x, y); x = 150 + (random() % (int) 30); y += 30; } } -(void)generatePolygons{ _nPolyVertices = 0; float x1 = 0; float y1 = 0; int keyPoints = 0; for (int i=0; i<4; i++){ /* HERE : 4 = OK / 5 = crash */ //V0: at (0,0) _polyVertices[_nPolyVertices] = CGPointMake(x1, y1); _polyTexCoords[_nPolyVertices++] = CGPointMake(x1, y1); //V1: to the first "point" _polyVertices[_nPolyVertices] = CGPointMake(_hillKeyPoints[keyPoints].x, _hillKeyPoints[keyPoints].y); _polyTexCoords[_nPolyVertices++] = CGPointMake(_hillKeyPoints[keyPoints].x, _hillKeyPoints[keyPoints].y); keyPoints++; //from point at index 0 to 1 //V2, same y as point n°2: _polyVertices[_nPolyVertices] = CGPointMake(0, _hillKeyPoints[keyPoints].y); _polyTexCoords[_nPolyVertices++] = CGPointMake(0, _hillKeyPoints[keyPoints].y); //V1 again _polyVertices[_nPolyVertices] = _polyVertices[_nPolyVertices-2]; _polyTexCoords[_nPolyVertices++] = _polyVertices[_nPolyVertices-2]; //V2 again _polyVertices[_nPolyVertices] = _polyVertices[_nPolyVertices-2]; _polyTexCoords[_nPolyVertices++] = _polyVertices[_nPolyVertices-2]; //V3 = same x,y as point at index 1 _polyVertices[_nPolyVertices] = CGPointMake(_hillKeyPoints[keyPoints].x, _hillKeyPoints[keyPoints].y); _polyTexCoords[_nPolyVertices] = CGPointMake(_hillKeyPoints[keyPoints].x, _hillKeyPoints[keyPoints].y); y1 = _polyVertices[_nPolyVertices].y; _nPolyVertices++; } } - (id)init { if ((self = [super init])) { [self generatePath2]; [self generatePolygons]; } return self; } - (void) draw { //glDisable(GL_TEXTURE_2D); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glBindTexture(GL_TEXTURE_2D, _textureImage.texture.name); glColor4f(1, 1, 1, 1); glVertexPointer(2, GL_FLOAT, 0, _polyVertices); glTexCoordPointer(2, GL_FLOAT, 0, _polyTexCoords); glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nPolyVertices); glColor4f(1, 1, 1, 1); for(int i = 1; i < 40; ++i) { ccDrawLine(_polyVertices[i-1], _polyVertices[i]); } // restore default GL states glEnable(GL_TEXTURE_2D); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); } Do you see anything wrong in this code? Thanks for your help

    Read the article

  • Applying Textures to Hexagonal Tiles Seamlessly

    - by PATRY
    I'm doing a tactical game (X-Com / Fallout style) for fun. I've decided to use a hexagonal map, but I'm having a graphic problem. My current map display is HUD-like, with only the border of the map cells displayed, without any texture. it's simple and allow for display of different types of informations by varying the color of the border. For exemple the "danger view mode" displays the borders with a color going from green (no damage possible) to red (prob of damage 90%). Now, It's a bit hard to differentiate the kind of tile the player is on. I could put a plain color (green is grass, pale blue is water...), but this is going to limit the possibilities. Thus, i would like to display a texture on my tiles. Since the map are generated, i can not use a picture for the whole map with the HUD over. So, my question is : does any one knows how i could generate the sealess hexagonal textures (algo or plugin), or if there is a site with some hexagonal tiles ?

    Read the article

  • Jquery canvas touch count

    - by user897764
    Can someone help me with a script I'm working with. http://jsfiddle.net/InVAMPED/XsG4e/4/ What I'm trying to achieve is placing a image where the user touches(ipad). There will be say 5 images that will each get attached once only. So first touch places img1, second touch imag2 etc untill all the images have been placed. Problem with my fsfiddle example is that when on ipad it doesnt count the first touch so you place the first image twice. it does duplicate the image on the second time just moves it to the second touches coordinates, then move on to 2, 3, 4, 5 as it should. any advice? or help to do this a better way? thanks

    Read the article

  • auto-scaling size with anchors - overlapping controls

    - by Shane.C
    I'm having some trouble with resizing and scaling of controls in a windows form. I've set anchors up so that the controls stay in ratio with the form, which works great. However, perhaps i was expecting too much when i thought that the control origin points would also scale and change with the form scaling, but this is not the case and i'm finding my controls overlapping. here's some screenshots; anyone know of an approach i can take to solve this problem? perhaps i need to set control origins to dynamic drawing points that scale, but then do these redraw on scaling the form, or only on creation?

    Read the article

  • How to encrypt the mobile configuration profiles in iOS (in OTA deployments)?

    - by user1353477
    I am trying to sign and encrypt .mobileconfig profiles for iOS devices. Signing works perfectly using openssl::pkcs7 sign function in ruby, however using encrypt function, I get an encrypted data but Safari fails to install the profile saying "Invalid Profile". There are two questions in this regard: Which data from the .mobileconfig profile is actually encrypted that goes into the .. section of the EncryptedPayloadContent ? Is the data in binary format (.der) or base64 encoded? Any help in this regard would be helpful as APPLE severly lacks any documentation in encrypting the profiles.

    Read the article

  • Excel Worksheet assignment in VB.Net doesn't compile

    - by Brian Hooper
    I'm converting a VB6 application into VB.Net and having trouble with the basics. I start off with:- Dim xl As Excel.Application Dim xlsheet As Excel.Worksheet Dim xlwbook As Excel.Workbook xl = New Excel.Application xlwbook = xl.Workbooks.Open(my_data.file_name) xlsheet = xlwbook.Sheets(1) but the last line doesn't compile; it reports Option Strict On disallows implicit conversion from 'Object' to 'Microsoft.Office.Interop.Excel.Worksheet' I can make this go away by replacing the line with xlsheet = CType(xlwbook.Sheets(1), Excel.Worksheet) but that does't look like the right thing to do to me. If the assignment is correct, I would have thought the object should naturally have the correct type. So: does anyone know what the correct thing I should be doing here?

    Read the article

  • MySql Join using 4 tables

    - by Ionut Flavius Pogacian
    I have 4 tables and i want to join them and extarct 4 values. I wrote the followig MySql Query, but it does not work. select `a`.`id`,`a`.`page` xpage,`a`.`action`, `b`.`header` xheader, `b`.`page_id`, `c`.`content` xcontent,`b`.`page_id`, `d`.`footer` xfooter,`d`.`page_id` join `header` b on `a`.`id`=`b`.`page_id` join `content` c on `a`.`id`=`c`.`page_id` and `a`.`id`=`d`.`page_id` join `footer` d on `a`.`id`=`d`.`page_id` where `a`.`page`='main'

    Read the article

  • Randomly Position A Div

    - by Connie
    I'm looking for a way to randomly position a div anywhere on a page (ONCE per load). I'm currently programming a PHP-based fantasy pet simulation game. One of the uncommon items on the game is a "Four Leaf Clover." Currently, users gain "Four Leaf Clovers" through random distribution - but I would like to change that (it's not interactive enough!). What I Am Trying To Do: The idea is to make users search for these "Four Leaf Clovers" by randomly placing this image anywhere on the page: (my rendition of a four leaf clover) I'd like to do this using a Java/Ajax script that generates a div, and then places it anywhere on the page. And does not move it once it's been placed, until the page is reloaded. I've tried so many Google searches, and the closest thing that I've found so far is this (click), from this question. But, removing the .fadein, .delay, and .fadeout stopped the script from working entirely. I'm not by any means a pro with Ajax. Is what I'm trying to do even possible?

    Read the article

  • Delete last 3 lines within while ((line = r.ReadLine()) != null) but not open a new text file to delete the lines?

    - by user1473672
    This is the code I've seen so far to delete last 3 lines in a text file, but it's required to determine string[] lines = File.ReadAllLines(); which is nt necessary for me to do so. string[] lines = File.ReadAllLines(@"C:\\Users.txt"); StringBuilder sb = new StringBuilder(); int count = lines.Length - 3; // except last 3 lines for (int s = 0; s < count; s++) { sb.AppendLine(lines[s]); } The code works well, but I don't wanna re-read the file as I've mentioned the streamreader above : using (StreamReader r = new StreamReader(@"C:\\Users.txt")) Im new to C#, as far as I know, after using streamreader, and if I wanna modify the lines, I have to use this : while ((line = r.ReadLine()) != null) { #sample codes inside the bracket line = line.Replace("|", ""); line = line.Replace("MY30", ""); line = line.Replace("E", ""); } So, is there any way to delete the last 3 lines in the file within the "while ((line = r.ReadLine()) != null)" ?? I have to delete lines, replace lines and a few more modications in one shot, so I can't keep opening/reading the same text file again and again to modify the lines. I hope the way I ask is understable for you guys .< Plz help me, I know the question sounds simple but I've searched so many ways to solve it but failed =( So far, my code is : using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication11 { public class Read { static void Main(string[] args) { string tempFile = Path.GetTempFileName(); using (StreamReader r = new StreamReader(@"C:\\Users\SAP Report.txt")) { using (StreamWriter sw = new StreamWrite (@"C:\\Users\output2.txt")) { string line; while ((line = r.ReadLine()) != null) { line = line.Replace("|", ""); line = line.Replace("MY30", ""); line = line.Replace("E", ""); line = System.Text.RegularExpressions.Regex.Replace(line, @"\s{2,}", " "); sw.WriteLine(line); } } } } } } Now my next task is to delete the last 3 lines in the file after these codes, and I need help on this one. Thank you.

    Read the article

  • How to handle authorization in the view layout

    - by mathk
    Authorize attribute are good to do some access control base on Action but suppose that I have some UI element in the layout that should note be output unless the user is authorize. I could possibly set some boolean in the ViewBag but that is not the good solution I guess. Somewhere in the Layout.cshtml: @if (ViewBag.IsAuthorized) { <li>@Html.ActionLink("Index", "Admin")</li> } Let me know if there is a better solution. Thanks.

    Read the article

  • "java.security.AccessControlException: access denied" executing a signet Java Applet

    - by logoff
    I have a little Java Applet and I have an annoying issue. I have signed my JAR with my own keystore using jarsigner tool (following these instructions). The Java Applet downloads a signed JAR and tries to launch it with an extended class of URLClassLoader. This JAR tries to execute this line of code: ClassLoader.getSystemClassLoader().getResource("aResource"); It fails with a large stack trace finished by: Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader") at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366) at java.security.AccessController.checkPermission(AccessController.java:555) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at java.lang.Thread.getContextClassLoader(Thread.java:1451) ... 21 more When the Java Applet is launched, the user is prompted to accept the certificate if he/she trusts the publisher: Even if I accept it, the exception occurred. Even if I install the certificate, and the prompt message is automatically accepted, the exception occurred. Any help would be appreciated!

    Read the article

  • hadoop implementing a generic list writable

    - by Guruprasad Venkatesh
    I am working on building a map reduce pipeline of jobs(with one MR job's output feeding to another as input). The values being passed around are fairly complex, in that there are lists of different types and hash maps with values as lists. Hadoop api does not seem to have a ListWritable. Am trying to write a generic one, but it seems i can't instantiate a generic type in my readFields implementation, unless i pass in the class type itself: public class ListWritable<T extends Writable> implements Writable { private List<T> list; private Class<T> clazz; public ListWritable(Class<T> clazz) { this.clazz = clazz; list = new ArrayList<T>(); } @Override public void write(DataOutput out) throws IOException { out.writeInt(list.size()); for (T element : list) { element.write(out); } } @Override public void readFields(DataInput in) throws IOException{ int count = in.readInt(); this.list = new ArrayList<T>(); for (int i = 0; i < count; i++) { try { T obj = clazz.newInstance(); obj.readFields(in); list.add(obj); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } But hadoop requires all writables to have a no argument constructor to read the values back. Has anybody tried to do the same and solved this problem? TIA.

    Read the article

  • Calling a non-activeX DLL in a VB6 application in Vista/Win7

    - by user1490330
    I have a VB6 app that utilizes a non-activeX DLL (non-registering). It's declared via the classic Public Declare Function "Function Name" Lib "Library.DLL" syntax. On my dev machine (XP) it works fine but when I deploy to Vista or Win7 I'm constantly greeted with a Run Time Error 48 - File Not Found for the DLL in question. I have tried copying that DLL to every directory I can think of including every environment path on the test machine and the app path too. These are all 32-bit test environments so it's not a SysWow64 issue. Possibly throwing a wrench into the mix is the fact that the application in question is an Outlook COM Addin. I managed to install VB6 on Win7 and was able to run a tiny sample app that utilizes this DLL (outside of the Outlook process) so I know it works PROVIDED the DLL is located in App path. If I call App.Path from my DLL when I run it on the test environment it shows, to no surprise, my installation directory however the DLL is there. I tried turning off UAC. I tried making the App.Path directory permissions open to everyone, still no dice.

    Read the article

  • handling filename* parameters with spaces via RFC 5987 results in '+' in filenames

    - by Peter Friend
    I have some legacy code I am dealing with (so no I can't just use a URL with an encoded filename component) that allows a user to download a file from our website. Since our filenames are often in many different languages they are all stored as UTF-8. I wrote some code to handle the RFC5987 conversion to a proper filename* parameter. This works great until I have a filename with non-ascii characters and spaces. Per RFC, the space character is not part of attr_char so it gets encoded as %20. I have new versions of Chrome as well as Firefox and they are all converting to %20 to + on download. I have tried not encoding the space and putting the encoded filename in quotes and get the same result. I have sniffed the response coming from the server to verify that the servlet container wasn't mucking with my headers and they look correct to me. The RFC even has examples that contain %20. Am I missing something, or do all of these browsers have a bug related to this? Many thanks in advance. The code I use to encode the filename is below. Peter public static boolean bcsrch(final char[] chars, final char c) { final int len = chars.length; int base = 0; int last = len - 1; /* Last element in table */ int p; while (last >= base) { p = base + ((last - base) >> 1); if (c == chars[p]) return true; /* Key found */ else if (c < chars[p]) last = p - 1; else base = p + 1; } return false; /* Key not found */ } public static String rfc5987_encode(final String s) { final int len = s.length(); final StringBuilder sb = new StringBuilder(len << 1); final char[] digits = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; final char[] attr_char = {'!','#','$','&','\'','+','-','.','0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','^','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','|', '~'}; for (int i = 0; i < len; ++i) { final char c = s.charAt(i); if (bcsrch(attr_char, c)) sb.append(c); else { final char[] encoded = {'%', 0, 0}; encoded[1] = digits[0x0f & (c >>> 4)]; encoded[2] = digits[c & 0x0f]; sb.append(encoded); } } return sb.toString(); } Update Here is a screen shot of the download dialog I get for a file with Chinese characters with spaces as mentioned in my comment.

    Read the article

  • How to navigate to a UITableView position by the cell it's title using indexing

    - by BarryK88
    I'm using a UITableView filled with a around 200 cells containing a title, subtitle and thumbnail image. I want to a have a selection method just like within the contact App from Apple where you can select a character from the alphabet. I'm at the point where I've drawn the selection interface (A,B,C etc), and via it's delegate I'm retrieving the respective index and title (i.e: A = 1, B = 2, C = 3 etc.). Now I want to navigate to the first cell, where the first character of the cell it's title is starting with the selected index character. Just like the contacts App. Can someone give me a direction for how to implement such functionality. - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index I filled my sectionIndex by means of - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { if(searching) return nil; NSMutableArray *tempArray = [[NSMutableArray alloc] init]; [tempArray addObject:@"A"]; [tempArray addObject:@"B"]; [tempArray addObject:@"C"]; [tempArray addObject:@"D"]; [tempArray addObject:@"E"]; [tempArray addObject:@"F"]; [tempArray addObject:@"G"]; [tempArray addObject:@"H"]; [tempArray addObject:@"I"]; [tempArray addObject:@"J"]; [tempArray addObject:@"K"]; [tempArray addObject:@"L"]; [tempArray addObject:@"M"]; [tempArray addObject:@"N"]; [tempArray addObject:@"O"]; [tempArray addObject:@"P"]; [tempArray addObject:@"Q"]; [tempArray addObject:@"R"]; [tempArray addObject:@"S"]; [tempArray addObject:@"T"]; [tempArray addObject:@"U"]; [tempArray addObject:@"V"]; [tempArray addObject:@"W"]; [tempArray addObject:@"X"]; [tempArray addObject:@"Y"]; [tempArray addObject:@"Z"]; return tempArray; }

    Read the article

  • Accessing both stored procedure output parameters AND the result set in Entity Framework?

    - by MS.
    Is there any way of accessing both a result set and output parameters from a stored procedure added in as a function import in an Entity Framework model? I am finding that if I set the return type to "None" such that the designer generated code ends up calling base.ExecuteFunction(...) that I can access the output parameters fine after calling the function (but of course not the result set). Conversely if I set the return type in the designer to a collection of complex types then the designer generated code calls base.ExecuteFunction<T>(...) and the result set is returned as ObjectResult<T> but then the value property for the ObjectParameter instances is NULL rather than containing the proper value that I can see being passed back in Profiler. I speculate the second method is perhaps calling a DataReader and not closing it. Is this a known issue? Any work arounds or alternative approaches? Edit My code currently looks like public IEnumerable<FooBar> GetFooBars( int? param1, string param2, DateTime from, DateTime to, out DateTime? createdDate, out DateTime? deletedDate) { var createdDateParam = new ObjectParameter("CreatedDate", typeof(DateTime)); var deletedDateParam = new ObjectParameter("DeletedDate", typeof(DateTime)); var fooBars = MyContext.GetFooBars(param1, param2, from, to, createdDateParam, deletedDateParam); createdDate = (DateTime?)(createdDateParam.Value == DBNull.Value ? null : createdDateParam.Value); deletedDate = (DateTime?)(deletedDateParam.Value == DBNull.Value ? null : deletedDateParam.Value); return fooBars; }

    Read the article

  • Android HttpsURLConnection and JSON for new GCM

    - by Ryan Gray
    I'm overhauling certain parts of my app to use the new GCM service to replace C2DM. I simply want to create the JSON request from a Java program for testing and then read the response. As of right now I can't find ANY formatting issues with my JSON request and the google server always return code 400, which indicates a problem with my JSON. http://developer.android.com/guide/google/gcm/gcm.html#server JSONObject obj = new JSONObject(); obj.put("collapse_key", "collapse key"); JSONObject data = new JSONObject(); data.put("info1", "info_1"); data.put("info2", "info 2"); data.put("info3", "info_3"); obj.put("data", data); JSONArray ids = new JSONArray(); ids.add(REG_ID); obj.put("registration_ids", ids); System.out.println(obj.toJSONString()); I print my request to the eclipse console to check it's formatting byte[] postData = obj.toJSONString().getBytes(); try{ URL url = new URL("https://android.googleapis.com/gcm/send"); HttpsURLConnection.setDefaultHostnameVerifier(new JServerHostnameVerifier()); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Authorization", "key=" + API_KEY); System.out.println(conn.toString()); OutputStream out = conn.getOutputStream(); // exception thrown right here. no InputStream to get InputStream in = conn.getInputStream(); byte[] response = null; out.write(postData); out.close(); in.read(response); JSONParser parser = new JSONParser(); String temp = new String(response); JSONObject temp1 = (JSONObject) parser.parse(temp); System.out.println(temp1.toJSONString()); int responseCode = conn.getResponseCode(); System.out.println(responseCode + ""); } catch(Exception e){ System.out.println("Exception thrown\n"+ e.getMessage()); } } I'm sure my API key is correct as that would result in error 401, so says the google documentation. This is my first time doing JSON but it's easy to understand because of its simplicity. Anyone have any ideas on why I always receive code 400? update: I've tested the google server example classes provided with gcm so the problem MUST be with my code.

    Read the article

  • Get Specific Data From Array, Based On Another Value

    - by A Smith
    I have an array that outputs these values: Array ( [0] => stdClass Object ( [ID] => 6585 [COLOR] => red [Name] => steve ) [1] => stdClass Object ( [ID] => 5476 [COLOR] => blue [Name] => sol ) [2] => stdClass Object ( [ID] => 7564 [COLOR] => yellow [Name] => jake ) [3] => stdClass Object ( [ID] => 3465 [COLOR] => green [Name] => helen ) ) Now, I will know the ID of the person, and I need the get the COLOR value for that specific value set. How is this best achieved please?

    Read the article

  • Variables variable and inheritance

    - by Xack
    I made code like this: class Object { function __get($name){ if(isset($this->{$name})){ return $this->{$name}; } else { return null; } } function __set($name, $value){ $this->{$name} = $value; } } If I extend this class (I don't want to repeat this code every time), it says "Undefined variable". Is there any way to do it?

    Read the article

  • Fullcalendar doesn't render color when using eventRender

    - by jaffa
    When I set-up fullCalendar and set eventRender function callback, I want to set the color of the event depending if LeadId is null or not. But this doesn't seem to work even though the documentation says so: http://arshaw.com/fullcalendar/docs/event_data/Event_Object/#color-options Is there any way to set the event color to change based on the data? calendar = $('#dayview').fullCalendar({ .... timeFormat: 'HH:mm', columnFormat: { agendaDay: 'dddd dd/MM/yyyy' }, eventClick: function (calEvent, jsEvent, view) { var leadUrl = "/Leads/" + calEvent.LeadId; window.location = leadUrl; }, eventRender: function (event, element) { if (event.LeadId != null) { event.eventColor = "#B22222"; event.eventBackColor = "#B22222"; } }, UPDATE: This is really strange. The event has all my properties returned for the event off the server. element is just the DOM element for the event. When I drag/move the event to somewhere else in the calendar, the event turns red, and if I inspect the event object it now has color set to Red. So the question is why isn't it applying on the 1st render, but on subsequent renders (i.e. after move) the colour gets applied?

    Read the article

  • Google I/O 2012 - Measuring the End-to-End Value of Your App

    Google I/O 2012 - Measuring the End-to-End Value of Your App Neil Rhodes, Nick Mihailovski, Mike Kwong We've rethought mobile app analytics from the ground up. If you are a mobile app developer, come see what's new from the land of Google Analytics; Understand how to measure the end-to-end value of your app, and improve its performance to drive usage and retention. For all I/O 2012 sessions, go to developers.google.com From: GoogleDevelopers Views: 69 4 ratings Time: 01:04:12 More in Science & Technology

    Read the article

  • Google I/O 2012 - Advancing Accessibility for the Web

    Google I/O 2012 - Advancing Accessibility for the Web Rachel Shearer, Dominic Mazzoni, Charles Chen This session will help you learn through code samples and real world examples how to design and test your web apps for complete accessibility coverage. We will review APIs such as the Text-to-speech (TTS) API, tools like ChromeVox and ChromeShades and how Google products implement solutions today for users with disabilities. For all I/O 2012 sessions, go to developers.google.com From: GoogleDevelopers Views: 61 3 ratings Time: 55:25 More in Science & Technology

    Read the article

  • Google I/O 2012 - Advanced Design for Engineers

    Google I/O 2012 - Advanced Design for Engineers Alex Faaborg, Christian Robertson Design isn't black magic, it's a field that people can learn. In this talk two elite designers from Google will give you an advanced crash course in interactive and visual design. Topics will include mental models, natural mappings, metaphors, mode errors, visual hierarchies, typography and gestalt principles. Correctly applied this knowledge can drastically improve the quality of your work. For all I/O 2012 sessions, go to developers.google.com From: GoogleDevelopers Views: 158 9 ratings Time: 55:50 More in Science & Technology

    Read the article

  • Finding Near-Earth Asteroids

    - by TATWORTH
    One of the puzzling aspects of hunting for Near Earth Asteroids is that more has been spent on Hollywood films about potential disasters should one hit the Earth than on finding them in the first place. While there are a number of on-going asteroid search programs, these are all Earth-based at the moment. The limitations of them are:Each telescope can only observe for a maximum average of 12 hours per day.As far as I am aware, all these programs are in the visible light only. (Once an asteroid is found, then radar tracking is possible when it is close.)Being Earth based they cannot see inside the Earth's orbit.The Asteroids being generally dark, do not show up well in visible light.A private group are proposing a radical alternative to this by orbiting an infra-red telescope in the orbit of Venus. In Infra-red, the asteroids are more readily seen. Here are some details: Source SPACE.com: All about our solar system, outer space and exploration

    Read the article

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