dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Embedding General Question

  1. #1
    Senior Member
    Join Date
    May 2007
    Posts
    102

    Embedding General Question

    Hi,

    i wanted to ask, when using FlashDevelop to embed images in a class, the code lines,

    public class MyClass extends Sprite
    {
    [Embed(source='../lib/lancer_evo_bitmaps.jpg')]
    private var _imgClass:Class;
    private var _image:Bitmap = new _imgClass();



    .....

    What would the last 2 lines represent? and how does FlashDevelop know that it refers to the jpg image?

    Thanks

  2. #2
    Member
    Join Date
    Oct 2009
    Location
    Ontario
    Posts
    98
    Did you write this code yourself?

    I don't have much experience with FlashDevelop, but it looks like that image is being exported for ActionScript in the same way you would export a symbol from your Library in Adobe Flash. The _imgClass object may serve as this exported symbol.

    If that's not the case, it might be happening later on in the code, but I can't see that from here.

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    The line directly after the Embed tag is associated with the asset. That's just how it works. It defines a Class to represent the asset. The third line instantiates that class to get you a Bitmap instance from that class.
    It does work pretty much like exporting a symbol within Flash.

  4. #4
    Member
    Join Date
    Oct 2009
    Location
    Ontario
    Posts
    98
    That's interesting! I'll keep that in mind, for future reference. =)

  5. #5
    Senior Member
    Join Date
    May 2007
    Posts
    102
    Quote Originally Posted by 5TonsOfFlax View Post
    The line directly after the Embed tag is associated with the asset. That's just how it works. It defines a Class to represent the asset. The third line instantiates that class to get you a Bitmap instance from that class.
    It does work pretty much like exporting a symbol within Flash.
    Oh i see, thanks.

  6. #6
    Senior Member Awoogamuffin's Avatar
    Join Date
    Nov 2008
    Posts
    208
    Can this be used in Flash CS4 or is it a different compiler?

    I'm aware that you can do it in Flex, certainly...
    Check out my blog showing the development of my flash game, the Dregs of War

  7. #7
    Member
    Join Date
    Oct 2009
    Location
    Ontario
    Posts
    98
    I just gave this a try and this is what I got:



    So, we definitely need Flex. =)

  8. #8
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You need the flex compiler, but you don't have to have FlexBuilder or anything like that. The flex sdk is free to download and use.
    http://www.adobe.com/cfusion/entitle...cfm?e=flex3sdk

  9. #9
    Member
    Join Date
    Oct 2009
    Location
    Ontario
    Posts
    98
    Thanks, 5Tons!

  10. #10
    Senior Member Awoogamuffin's Avatar
    Join Date
    Nov 2008
    Posts
    208
    Hmm... I should look into that - it would allow for making a preloader that doesn't require any nonsense with the main timeline
    Check out my blog showing the development of my flash game, the Dregs of War

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center