开发者

Android-Adobe Air: Placing an image (and sound) on the stage

My group and I are having a heck of a time trying to find some documentation on how to get an image to load into our AIR app. We're doing this in Pure AS3, using Flash Builder 4. We've tried using loaders, bitmaps, Image classes, nothing is working!

We're also trying to get sound to play as well. Here's our attempt at it...(this works as a Desktop app)

var sound:Sound = new Sound();
sound.load(new URLRequest("car-horn.mp3"));

    public fun开发者_高级运维ction playSound(event:MouseEvent.CLICK):void
    {
         sound.play();
    }

As i said, works on a desktop app, but can't get it to work for the Android app. Any help would greatly save us! Thanks!


Woot! Figured it out!

For sound:

import flash.media.Sound;
[Embed(source="/assets/car-horn-changed.mp3")]
private var soundClass:Class;

private var sound:Sound = new soundClass() as Sound;
private function someFunction(event:MouseEvent):void
{
      sound.play();
}

For images,

import flash.display.Bitmap;

[Embed(source="/assets/compLogo.png")]
private var logoLoaderClass:Class;
private var logoImage = new logoLoaderClass() as Bitmap;

private function someFunction2():void
{
     stage.addChild(logoImage);
}

Most of this came from looking @ http://livedocs.adobe.com/flex/3/html/help.html?content=Working_with_Sound_07.html

Once i figured out how to use the Metadata tag to embed them, I just had to figure out which classes to use.

Hopefully someone can benefit from this!


It can be use with images as well.

[Embed(source="../assets/images/image.png")]
private var _imageClass : Class;

protected function _onStage() : void
{
      var img : Bitmap = new _imageClass() as Bitmap;
      addChild(img);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜