Embedding stuff other than @:bitmap

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Embedding stuff other than @:bitmap

Dinko Pavicic
Hi all,
I'm succesfully emebedding bitmaps with new @:bitmap but what about sounds, xml, json etc.
Is there any way to embed something other than bitmap in a same way?

It would be really useful to have something like Flash - 'Embed'  in haxe ( @:embed maybe ) that would be type agnostic.

Thanks,
D.

Reply | Threaded
Open this post in threaded view
|

Re: Embedding stuff other than @:bitmap

bruno baudry
 -res compiler directive for embeding resources is there for you.
http://haxe.org/api/haxe/resource
http://haxe.org/doc/advanced/resources


2011/9/21 Dinko Pavicic <[hidden email]>
Hi all,
I'm succesfully emebedding bitmaps with new @:bitmap but what about sounds,
xml, json etc.
Is there any way to embed something other than bitmap in a same way?

It would be really useful to have something like Flash - 'Embed'  in haxe (
@:embed maybe ) that would be type agnostic.

Thanks,
D.



--
View this message in context: http://haxe.1354130.n2.nabble.com/Embedding-stuff-other-than-bitmap-tp6815880p6815880.html
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Embedding stuff other than @:bitmap

Matthew Spencer-2
In reply to this post by Dinko Pavicic
There is http://haxe.org/doc/advanced/resources.

I do actually think it would be neat to have an @:embed tag version of -resource though.

--Matthew Spencer

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Embedding stuff other than @:bitmap

rammserker
In reply to this post by bruno baudry
You have the resource compiler option. Usage example:

[flash.hxml>>>>>>>>>>>>>>>>>>]
-swf test.swf
-swf-header 800:600:30:ffffff
-swf-version 10
-main Test

-resource my_xml.xml@xmlstring
-resource binary_data.bin@bindata
# -resource [name of file]@[identifier (for use it in your code)]
[flash.hxml>>>>>>>>>>>>>>>>>>]

[Test.hx>>>>>>>>>>>>>>>>>>]
class Test {
    public function new () {
        // You can get the XML data as a string in this way
        var myXml : String = haxe.Resource.getString ( 'xmlstring' );

        // And you can grab binary data as Bytes in this way
        var myData : Bytes= haxe.Resource.getBytes ( 'bindata' );

    }
        // Rest of the code ...
}
[Test.hx>>>>>>>>>>>>>>>>>>]

Max
0 1 0 | 0 0 1 | 1 1 1


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Embedding stuff other than @:bitmap

rammserker
In reply to this post by Matthew Spencer-2
Ah! I forgot this: You can list all embedded resources with haxe.Resource.listNames, and so you can iterate over all resources ;)

Max
0 1 0 | 0 0 1 | 1 1 1


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Embedding stuff other than @:bitmap

Dinko Pavicic
Hey, thanks for the quick answers!

I see in the docs that Resources are available for flash, flash9, neko, js, php, cpp targets.
How does it embed resources in web targets such as js / php?

Thanks in advance,
D.
Reply | Threaded
Open this post in threaded view
|

Re: Embedding stuff other than @:bitmap

Matthew Spencer-2

Base 64 string I believe.

Matthew Spencer

On Sep 21, 2011 10:31 AM, "Dinko Pavicic" <[hidden email]> wrote:
> Hey, thanks for the quick answers!
>
> I see in the docs that Resources are available for flash, flash9, neko, js,
> php, cpp targets.
> How does it embed resources in web targets such as js / php?
>
> Thanks in advance,
> D.
>
> --
> View this message in context: http://haxe.1354130.n2.nabble.com/Embedding-stuff-other-than-bitmap-tp6815880p6816222.html
> Sent from the Haxe mailing list archive at Nabble.com.
>
> --
> haXe - an open source web programming language
> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Embedding stuff other than @:bitmap

Franco Ponticelli
No encoding in php, it is just a separate file.

Franco

On Wed, Sep 21, 2011 at 4:00 PM, Matthew Spencer <[hidden email]> wrote:

Base 64 string I believe.

Matthew Spencer

On Sep 21, 2011 10:31 AM, "Dinko Pavicic" <[hidden email]> wrote:
> Hey, thanks for the quick answers!
>
> I see in the docs that Resources are available for flash, flash9, neko, js,
> php, cpp targets.
> How does it embed resources in web targets such as js / php?
>
> Thanks in advance,
> D.
>
> --
> View this message in context: http://haxe.1354130.n2.nabble.com/Embedding-stuff-other-than-bitmap-tp6815880p6816222.html
> Sent from the Haxe mailing list archive at Nabble.com.
>
> --
> haXe - an open source web programming language
> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org