ImNew
ImNew

Reputation: 23

Im trying to write a program which loads external resources with metadata tags in As3

ive been given some work to do but i cant seem to understand why its not working.. I think im using a wrong approach, Im trying to load a picture and a movieclip on the same stage.. Though ive managed to display a picture, but when i try to display a MovieClip.. There arent errors though when i run i get the following:

TypeError: Error #1034: Type Coercion failed: cannot convert LoadingFiles_MovingStars1@2aba161 to flash.display.Bitmap. at LoadingFiles()[C:\Users\user\Adobe Flash Builder 4.5\LoadingFiles\src\LoadingFiles.as:28

Here is the code,

package
{
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.display.StageScaleMode;

[SWF(width = "800", height = "600", frameRate = "30", backgroundColor="#FFFF00")]
public class LoadingFiles extends Sprite
{
    [Embed(source="/../assets/Head.jpg")]
    protected var MovingStars:Class;

    [Embed(source="/../assets/water1.mp4", mimeType = "application/octet-stream")]
    public var MovingStars1:Class;

    public function LoadingFiles()
    {
        stage.scaleMode = StageScaleMode.NO_SCALE;

        // swf
                var myStars:Bitmap = new MovingStars(); 

        var myPic:Bitmap = new MovingStars1(); // 
        var yourPic:MovieClip = new MovingStars1();

        myStars.x = (stage.stageWidth-myStars.width)/2;
        myStars.y = (stage.stageHeight-myStars.height)/2;

        addChild(myPic as MovieClip);
        addChild(yourPic);
        addChild(myStars);
    }
}
}

Now ive written that code, but it doesnt work.. Im really stressing because im falling behind by a bit in class..

Help would greatly appreciated. Thank you.

Upvotes: 0

Views: 409

Answers (2)

Ivan Dyachenko
Ivan Dyachenko

Reputation: 1348

When you embedded image

[Embed(source="/../assets/Head.jpg")]
protected var MovingStars:Class;  

Your MovingStars is BitmapAsset class. This is class included in Flex SDK. So you need preload Flex SDK rsl's. Or configure Flex SDK libraries linking as merge in to code.

What IDE are you using?

Upvotes: 0

Creynders
Creynders

Reputation: 4583

You're trying to instantiate an embedded .mp4 file as a Bitmap or a MovieClip. That's not possible, you need to create a video player or use an already existing videoplayer component. Here's a more in-depth answer on that: How to make an AS3 Flash video player?

Upvotes: 1

Related Questions