I've been trying to use the Resource Bundle Class in Flex 2 to create
a Localitzation of IMGs and CSS. Now i've been stuck on the IMG
portion for a few days. 

I have followed the many examples given by Adobe's Live Docs @
http://livedocs.macromedia.com/flex/2/langref/mx/resources/ResourceBundle.html#getContent()


Class for the image (RedJpg.as)

package { 
        import mx.core.SpriteAsset; 
        
        [Embed(source='logo.gif')] 
        public class RedJpg extends SpriteAsset { 
        }
}

Class for Embedding the Image (MyClassesBundle.as)

package
{
        import mx.resources.ResourceBundle;
        
        public class MyClassesBundle extends ResourceBundle
        {
                public function MyClassesBundle () {
                        super();
                }
                
                override protected function getContent():Object
                {
                        var contentObj:Object = new Object();
                        contentObj.push("RedJpg", RedJpg);
                        //contentObj.push("hello", hello);
                        return contentObj;
                }
        }
}

Code to call it in the actual MXML:

        [ResourceBundle("MyClassesBundle")]
        private var rb:ResourceBundle;

        public function getIMG():void
        {      
                var sprite:SpriteAsset = SpriteAsset(rb.getObject("RedJpg"));
     
                testIMG.source = sprite;     
        }


To embed an JPG to a Class. Somehow i cannot get this to work. It
seems to fail at the MyClassesBundle class file, telling me that
"push" is not a function. Am i just blatantly missing something stupid
right here? Any help? Am i just missing an "Import" of some class? But
every example i look for online seems to just give these codes. Some
with even errors. Still if anyone has gotten this to work, any
guidence would be helpful.






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to