jsutton's Forum Posts

  • Let me withdraw the question for now. I need to make a capx with a couple examples and share it.

  • Yes sir, ty. That is the name of the project. But the file? I can't find it anywhere without closing and load from location on cpu.

    On C2 the file was shown at the top of the program.

    (I usually save by the day [fileday1,2 3, etc.] just to have a backup, and without closing and reloading one really has no clue what file they are working in on the browser...that I've been able to tell. Which the other day I worked in the wrong file for most of the day, it was great :(

  • I know this this dumb, I feel dumb for asking.

    But, on C3 in a browser, how do you tell what file you have open???

  • savvito123

    I'm using php (transfer) and phpmyadmin (database), not sure what you're using.

    Using binary, filechooser, drawingcanvas, and ajax.

    filechooser to get the image and set a sprite from FileChooser.FileURLAt(0) (resize, etc)

    created drawingcanvas(dc) at the sprite x,y , drawingcanvas.paste, save as png

    On dc save set ajax response binary, then ajax request DrawingCanvas.SavedImageURL

    Once the ajax runs, set a variable to BinaryData.GetBase64. This variable can be used to pass the image.

    10mb phone pictures = 50kb base64 text, not tiny but much, much smaller and without much loss of quality.

    Later, when you need the image just pull the base64 string from server (using php) and load it into a sprite with BinaryData.GetBase64&ajax.lastdata

    If you want to save an actual file somewhere on the server, I'm not sure how to pass that in php but found a link.

    construct.net/en/forum/construct-2/how-do-i-18/save-json-file-server-119259

    (I ran into issues with passing this variable to the server because I didn't realize, in C3 an ajax "post to url", the URL line of ajax is a GET and the Data line is POST [meaning you have to adjust the $_GET and $_POST of the php file accordingly. Sending 50kb as a GET will be rejected by most servers (error 414 exceeds url length limit), but POST is allowed.)

  • Finally wrapped my mind around this. It requires a GET/POST using the c3 ajax post as binary

    (The URL line being the get and qualifier - for the POST [which is the binary data])

    Your job is done Ashley! lol, and thank you for the education.

    Unfortunately, for saving to server with php it will not work without some heavy manipulation. Which is fine, the drawingcanvas save feature works very well as an image compressor and base64 string is easy for php to handle.

    Thanks again for the information.

    PS

    "The protocol blob or Object-URLs can only be generated by browser and these URL's can only be accessed / managed in the same instance / browser , which generated them.

    Therefore, it is clear that PHP does not have access to URL created.

    On the other hand, you can send the file created by the xkeshi/image-compressor library via ajax ( XMLHttpRequest )."

    So it is something that can be done.

  • Pull up the templates: top down shooter, line of sight, and pathfinding.

    Those 3 cover everything you're looking to do.

  • Have you considered the car behavior with waypoints? The driving template has details and there are several nice tutorials.

  • Not sure if this is a general or a how do I question, more of a best practices type of question.

    I have a chat bar that has a icon (sprite) of the person posting the message before the text.

    If one uses a function to space the chat:

    call function, create sprite x,y, create text x,y and then loop

    create sprite2 & text.height + a spacer (setting the spacing for new sprites and new texts)

    the new sprites are created at the original x,y (due to the function happening in one tick and no time for the new x,y or height settings to apply. A loopindex, etc will not work either...same issue as above.)

    My question is this, other than doing a function & local variable, thus calling function 2, 3, 4 etc. or by long coding the chat. Is there any other way to get the proper spacing of newly created items?

    (Hopefully this question isn't too confusing. I've asked this question before and never gotten a definitive answer.) Regards

  • 99% of my sprites are user generated. Ended up using the drawingcanvas, let the user manipulate the sprite before they save it to the server. (cut down a 9mb upload to about 43kb) still big but much better.

    Just a note for anyone finding that sometimes the base64 files work properly and sometimes they fail to load...

    URLEncode is a wonderful little tool.

  • Is there a way to have construct 3 lower the quality of an imported image?

    (I read where the quality is png 32 and wonder if that can be changed to a jpeg 50 when importing? One can import the image, resize, paste to drawing canvas, and save it as a jpeg 50 but was curious if there is a simpler way?)

  • Well I learned something new today.

    I've used AJAX for 5 years (through C2) and never realized the URL line is a GET line only. Wasn't ever an issue before and never needed the POST. Now that I've figured that out, and CAN send, without issue, base64 to and from the server.

    This one is just out of curiosity and if you don't feel like responding no worries.

    What I do not understand:

    How does one specify where the binary data would end up (the specific cell inside the database_ using "Post binary to URL"?

    Binary to unspecified location (which is what I understand from your previous post).

    What I need to have happen, unfortunately this won't work, but hopefully you understand what I mean.

    (That is to say, there is no way to specify where the AJAX - POST binary to URL results should go.

    My normal way

  • Just to wrap this up.

    To send an image to the server using *.php via AJAX is doable.

    However, your server may limit the url to a certain number of characters (usually 8190 characters, this is to slow Denial Of Service (DOS) attacks against the server per Hostgator.) see 414 error*

    When retrieving data from the server, usually the url is unlimited (no need for them to worry about DOS when sending).

    The suggestion has been made to use a Blob, but the best I understand it, this is only done locally and is of no help when sending data over the internet.

    Using binary might reduce the url by 30%, but on a 5mb file, that is still well over the server threshold of characters and again makes the url too long to be sent.

    The only solution I see it to parse the data, send multiple AJAX post and just append the cell text that holds the picture data.

    Hope this information helps others.

    If anyone can add information to this, or sees an error please let me know. Thank you.

  • So the error I was getting is based on the server httpd file limitrequestline = 8190 and as such I'm unable to send the url of a picture in base64 that's larger than 8kb. Punt and look for a new method.

    (Just in case someone else has the issue. The way I figured this out was to copy the error url into the browser and it gave an error 414. But, at least one path has been thoroughly explored.)

  • After 5 days, this is what I can say for sure.

    When sending the ajax request with a small data set, it works just fine.

    When the file is larger it gets this error:

    rkJggg==' from origin 'https://preview.construct.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

    This should be working...this is the only error I can not account for.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley

    The buffer is 49k in length, so that's not looking at the url.

    The url is there, it's your blob preview option

    The float64(*) [personally I figured this should be 8, but 8 returns 0 so I used 1 and it returns what looks like the URL data in float64]

    Base64 reads and hold the actual file data, unfortunately the data amount is larger than the actual file.

    ***The only BinaryData.Get* that seems to return a value other than the URL is Base64.***

    (The best I can tell, base64 is also the only "Get" that can be stored in local storage and retrieved when the browser is close and reopened)