labithiotis's Forum Posts

  • I tried that but wasn't sure if it was being used in normal browsers, also my normal ajax stops working. I will upload what i have done thus far

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi, if anyone can help me to make a ajax plug (working off default plugin) to do PUT and GET request with custom headers and header responses

    http://www.scirra.com/forum/topic66799_post410385.html#410385

  • Hi,

    I need an ajax plugin to handle using PUT method and to submit a GET request with a custom header and get the response header too.

    I have copied the oringal ajax plugin and got the PUT action, but i am trying to add a GET request with custom headers & response. I am struggling to get that to work.

    [b]Edittime.js[/b]
    AddStringParam("Tag", "A tag, which can be anything you like, to distinguish between different AJAX requests.", "\"\"");
    AddStringParam("URL", "The URL to put to.  Note: most browsers prevent cross-domain posts.", "\"http://\"");
    AddStringParam("Data", "The data to put, in query string form.  Be sure to URLEncode any user-entered data.");
    AddAction(3, 0, "Put to URL", "AJAX", "PUT <b>{2}</b> to URL <b>{1}</b> (tag <i>{0}</i>)", "Make a PUT request to a URL.", "Put");
    
    AddStringParam("Tag", "A tag, which can be anything you like, to distinguish between different AJAX requests.", "\"\"");
    AddStringParam("URL", "The URL to put to.  Note: most browsers prevent cross-domain posts.", "\"http://\"");
    AddStringParam("HeaderKey", "Header Key");
    AddStringParam("HeaderValue", "Header Value");
    AddAction(4, 0, "Request URL with Header", "AJAX", "Request <b>{2}</b> to URL <b>{1}</b> (tag <i>{0}</i>) with header: <i>{3}</i> with <i>{4}</i>", "Request URL with Header.", "RequestHeader");
    
    AddExpression(2, ef_return_string, "Get Header Responce", "AJAX", "HeaderResponce", "Get the header responce");
    
    [b]Runtime.js[/b]
    Acts.prototype.Put = function (tag_, url_, data_)
     {
         this.doRequest(tag_, url_, "PUT", data_);
     };
    
    Acts.prototype.RequestHeader = function (tag_, url_, headerkey_, headervalue_)
     {
         this.doRequest(tag_, url_, "GET", headerkey_, headervalue_);
     };
    
    Exps.prototype.HeaderResponce = function (ret)
     {
         var requests;
              
         this.xhr = sinon.useFakeXMLHttpRequest();
         this.xhr.onCreate = function(xhr) {
           ?requests.push(xhr);
         }
              
         ret.set_string(requests);
     };
    
    

    But when i added either of these the normal ajax call action stops working.

    Any help would be great.

    Need to have something working by end of day :(

  • Oh, Data.Hours & Minutes can actually take an argument for time, it doesn't show that when I use the expression so I just assumed it used current time only.

    Thanks

  • Format unix timestamp to a formatted time like HH:MM

    Those function produces a unix time stamp, not what I was asking for. (i.e. 1363058603023)

    I want some expressions to take that number (AN UNIXTIMESTAMP / 1363058603023 ) and convert it to HH:MM or indervidually to Hours, Mins, and seconds so I can display that stamp as a time in UI.

    1363058603023 --> 14:23 / 2:23pm

  • Can you add the ability to format unix timestamp to a formatted time like HH:MM, tried adding it myself but it didn't work.

    // create a new javascript Date object based on the timestamp
    // multiplied by 1000 so that the argument is in milliseconds, not seconds
    var date = new Date(unix_timestamp*1000);
    // hours part from the timestamp
    var hours = date.getHours();
    // minutes part from the timestamp
    var minutes = date.getMinutes();
    // seconds part from the timestamp
    var seconds = date.getSeconds();
    
    // will display time in 10:30:23 format
    var formattedTime = hours + ':' + minutes + ':' + seconds;
    
  • Hi,

    Very quick question, how would I be able to use thisJSON data in c2 easily if possible. I have tried using Hash table and no luck (doesn't help that it's not clear how to use that plugin). Using an ajax request btw.

    [
     {
      productid: 1,
      venueid: 1,
      categoryid: 4,
      product_name: "Name",
      product_desc: null,
      image_thumb_url: "URL",
      price: 10,
      tax_amount: 0,
      tax_included: true,
      in_stock: true,
      popularity: 0,
      product_modifiers: [{modifierid: 1, price: 1},{modifierid: 2, price: 1} ]},
     {
      productid: 2,
      venueid: 1,
      categoryid: 4,
      product_name: "NAME",
      product_desc: null,
      image_thumb_url: "URL",
      price: 15,
      tax_amount: 0,
      tax_included: true,
      in_stock: true,
      popularity: 0,
      product_modifiers: [{modifierid: 1, price: 1},{modifierid: 2, price: 1} ]
     }
    ]
    

    p.s. I can't change the JSON structure, just want to loop through these and store in array, and for the modifiers if possible to attached another array or c2 friendly json/string.

    Was hoping just to use hash table but so far i can't get anything useful from it, the example files don't help :(

  • I can only confirm for iOS, I will get a friend to try android later this week (if i get time).

    Sorry I can't help further, when i get some more spare time i will make a test IAP capx but really its more likely something outside of the capx that's wrong.

  • Put them into another layout and set them to global. Now just create them in the loader/default layout from the sheet.

  • Ludei just tweeted "#WebGL on every Android and iOS device, for the first time ever! ow.ly/jpnCS #HTML5 #games #GDC2013"

    Now if they could just support Windows 8 Phone and Blackberry, so it's a single eco system <img src="smileys/smiley27.gif" border="0" align="middle" /> <img src="smileys/smiley27.gif" border="0" align="middle" /> <img src="smileys/smiley27.gif" border="0" align="middle" />

  • Sounds great but would this work in CocoonJS, as that doesn't have a url if i'm not mistaken?

    <font size="1">Note. This is my 100th post, woo badge :)</font>

  • https://developer.apple.com/news/

    Starting May 1, new apps and app updates submitted to the App Store must be built for iOS devices with Retina display and iPhone apps must also support the 4-inch display on iPhone 5. Learn about preparing your apps by reviewing the iOS Human Interface Guidelines.

    Not sure how many of us that effects but does mean you need to make sure you apps are responsive to fit the different aspect ratios and have minimum size of 640x960. Don't think letter box scale will pass as it just renders a black bar.

  • I should state I'm aware of almost all the work arounds for my suggestion but I don't want to use a "work arounds". These are suggestion I'd like to see but don't have any rush for them.

    You can cut and paste global variables between event sheets. C2 will give you a great big warning that any related actions will be deleted, but they are undeleted when you paste the global variable back in. It's a really confusing prompt.

    hh that is confusing, When it showed my actions disappear I panicked and undid :)

    > Have a system expression to convert a number into a comma/dot separated string ( 2000 -> 20,000) , with maybe settings for zero padding (i.e. 3)

    > url=http://www.scirra.com/forum/display-number-as-currency-with-commas_topic56968.html]This could be done in C2 know and use this plus other events for doing graphical scores. Just be a nice to have a native system expression.

    Ability to disable and includes like events & actions. (currently I can just delete and re-add it) did mean the Include:Sheet event (In Events Tab Add Include). You can select it but you can't disable it, as a quick way to turn of sheets. You can quickly disable action and event with the shortcut D too.

    5 - Snap to grid and set the grid to 1,1It's a nasty work around, but ta.

    7 - You can load an array with JSON and set the JSON code to load while you play the gamehat's no different to just setting data in by actions/loops. Plus its fiddly to edit.

    2_ There is already a "FPS" system expression, as well as "objectcount". already use ChromeConsole, its excellent and works on Windows 8 and CocoonJS which is very handy. Don't see the point of Debug Panel. I already use FPS too.

    But the reason I say I would like a debug option is mostly for Object Collision HitBox (mostly for touch) and Object ID's

    3_ You shouldn't use "wait 0.01" (I'm not sure it even works) and rather do your own timer based on dt.here's load of places where I have had to use "Wait 0.01" becuase the next sequence in the code is expecting something and without it, it doesn't work. Could be the way I do things as I use a lot of functions and maybe they're called before the data is set. For example I have a function called "Reset Data" that add blank entries to arrays and then calls function "Save Data" which add's array as json to webstorage. But if I don't have a wait 0.01 before "Save Data" it doesn't work. Also have another for "Load Data" that has a wait 0.01 after a Load from JSON ExtraExpressions.decode(WebStorage.LocalValue("data")), so when I set data of other arrays it works.

    Guess I could try using Wait dt, but still feel and wait tick would be nicer. (I'll update my code and see how it goes)

  • You do not have permission to view this post

  • Yer would be nice to attached capx instead of using dropbox which does result in a lot of dead links but means Scrria's got to folk out a lot of dosh to host all of them (ain't cheap).