https://linen.dev logo
Join Discord
Powered by
# ceramic
  • a

    ambitious-knife-25690

    02/27/2023, 1:01 PM
    I'm not meant to call
    load()
    I should
    add(asset)
    instead - but it seems like the images are already "added" so i'm meant to add it again?
  • a

    ambitious-knife-25690

    02/27/2023, 1:02 PM
    by "added" i mean, they're already in the asset list
  • b

    billowy-waiter-28954

    02/27/2023, 1:02 PM
    You should not call load() on a single asset, but you should call load() on the
    assets
    object
  • a

    ambitious-knife-25690

    02/27/2023, 1:03 PM
    ahh i see
  • b

    billowy-waiter-28954

    02/27/2023, 1:04 PM
    Copy code
    haxe
    var assets = new Assets();
    
    assets.addImage('some/image.png');
    assets.addImage('some/other/image.png');
    
    assets.onceComplete(this, success -> {
        if (success) ...
    });
    
    assets.load();
  • a

    ambitious-knife-25690

    02/27/2023, 1:05 PM
    I'm wondering if i should handle the loading internally or just leave that to the user 🤔
  • a

    ambitious-knife-25690

    02/27/2023, 1:05 PM
    for the user passed asset object
  • b

    billowy-waiter-28954

    02/27/2023, 1:06 PM
    Mmmmh no you can automate the loading as long as you have an asset path or name
  • b

    billowy-waiter-28954

    02/27/2023, 1:06 PM
    You could also do what I do on
    ceramic.ImageView
    (in
    ui
    plugin): https://github.com/ceramic-engine/ceramic/blob/fdf9f791f69aab873f45898beba26ad62043967a/plugins/ui/runtime/src/ceramic/ImageView.hx#L90-L112
  • b

    billowy-waiter-28954

    02/27/2023, 1:06 PM
    Basically an ImageView creates its own assets objects just to load the texture it needs
  • a

    ambitious-knife-25690

    02/27/2023, 1:07 PM
    that one might make more sense from a ui standpoint
  • b

    bright-gpu-74537

    02/27/2023, 1:18 PM
    i would defo say leave it to the user here personally
  • b

    bright-gpu-74537

    02/27/2023, 1:18 PM
    haxeui should, for the most part, be an addition to ceramic, not take it over
  • b

    bright-gpu-74537

    02/27/2023, 1:19 PM
    (HaxeUIApp on the other hand could - and maybe should - load the assets)
  • a

    ambitious-knife-25690

    02/27/2023, 1:20 PM
    i think i would agree here, it likely will result in situations where an image won't be loaded though
  • b

    bright-gpu-74537

    02/27/2023, 1:20 PM
    because the user hasnt loaded their own assets from their own project?
  • a

    ambitious-knife-25690

    02/27/2023, 1:23 PM
    yeah
  • b

    bright-gpu-74537

    02/27/2023, 1:25 PM
    that sounds like a user problem no? I dont think haxeui should be responsible for loading user assets if they havent
  • b

    bright-gpu-74537

    02/27/2023, 1:26 PM
    i guess the same applies to ceramic itself? Ie, a user trying to display their images, but they never loaded them
  • a

    ambitious-knife-25690

    02/27/2023, 1:29 PM
    yeah, i'm just wondering where the line is
  • a

    ambitious-knife-25690

    02/27/2023, 1:29 PM
    like if a user enters a filepath outside of the asset directory
  • a

    ambitious-knife-25690

    02/27/2023, 1:29 PM
    I think that makes sense to load the image from the backend
  • b

    bright-gpu-74537

    02/27/2023, 1:30 PM
    what would your backend have / need any images?
  • b

    bright-gpu-74537

    02/27/2023, 1:30 PM
    and if it did, why not let them use the haxe.Resource method?
  • a

    ambitious-knife-25690

    02/27/2023, 1:30 PM
    is that a thing? 🤔
  • a

    ambitious-knife-25690

    02/27/2023, 1:31 PM
    doesn't resource embed an image in the app and need to be added to the hxml?
  • b

    bright-gpu-74537

    02/27/2023, 1:32 PM
    well, yeah, as i mentioned, there are two ways that haxeui will attempt to load assets: first it will try to use some framework specific method (via getImageInternal), if it cant do that (
    callback(null)
    ) it will see if its a haxe resource, if it is, it will attempt to load it from bytes and turn it into something the backend understands
  • a

    ambitious-knife-25690

    02/27/2023, 1:33 PM
    huh, so theoretically i could just pass a filepath now and it would work? 🤔
  • b

    bright-gpu-74537

    02/27/2023, 1:33 PM
    if the filepath equates to a haxe.Resource, then yeah
  • b

    bright-gpu-74537

    02/27/2023, 1:33 PM
    haxe.Resource.list (i think) will show all resources and ids
1...828384...124Latest