Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 499
  • Last Modified:

Simple .as file not working - what could be wrong?

I'm hopeing someone can point me in the right direction.

I am trying to re-create a demo by Lee Brimlow which he has on http://www.gotoandlearn.com/ called 'Introduction to Pixel Bender 2'

I have managed to create a basic PixelBender filter - all good so far.

The problem is this:

I can't get his simple ActionScript file to work. In his demo everything works smoothly, however when I run mine the screen is blank - doh!


The Pixel.as file I have has the following code:

package {

import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.net.*;

//Swf Metadata
[SWF(width="600", height="400", backgroundColor="#aa0000", framerate="30")]


public class Pixel extends Sprite
{

[Embed(source="image.jpg")]
public image:Class;

private var loader:URLLoader;
private var shader:Shader;
private var filter:ShaderFilter;
private var im:Bitmap;

// Constants:
// Public Properties:
// Private Properties:

// Initialization:
public function Pixel():void
{
im = new image() as Bitmap;
addChild (im);
}

// Public Methods:
// Protected Methods:
}

}


This prog should display the file 'image.jpg on' the screen but instead the screen is blank.
'image.jpg' is in the same directory as the .as file without a doubt.

I'm compiling the above with Flash CS4

Does anyone know why this doesn't work?

Any help really appreciated.
Many thanks

Sci-Fi Si
0
Sci-Fi-Si
Asked:
Sci-Fi-Si
  • 5
  • 2
1 Solution
 
blue-genieCommented:
are you actually able to compile without errors?

try fix this bit

public var image:Class;
NOT public image:Class;
0
 
Sci-Fi-SiAuthor Commented:
Excellent, that's a step closer, many thanks for the reply.

I have no idea how to compile this in Flash CS4, so I'm trying mxmlc.exe that comes with the Flex SDK.

The screen output from the command line compile are as follows:

C:\Program Files (x86)\Adobe\Flex Builder 3\sdks\3.0.0\bin>mxmlc.exe pixel.as >
err.txt
C:\Program Files (x86)\Adobe\Flex Builder 3\sdks\3.0.0\bin\Pixel.as(19): col: 22
 Error: Type was not found or was not a compile-time constant: Shader.

                private var shader:Shader;
                                   ^

C:\Program Files (x86)\Adobe\Flex Builder 3\sdks\3.0.0\bin\Pixel.as(20): col: 22
 Error: Type was not found or was not a compile-time constant: ShaderFilter.

                private var filter:ShaderFilter;
                                   ^

If I try to compile Pixel.as from within Flash, I don't get any errors, but then I don't think it's including the .as file because the resulting .swf is only 1k and the image I'm trying to embed is over 60k.

Many thanks for your help! Do you know how I could get any further?

Sci-Fi Si
0
 
Sci-Fi-SiAuthor Commented:
Got Flash CS4 trying to compile but getting the following errors with the resulting .swf blank screen:

pixel..bmp
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Sci-Fi-SiAuthor Commented:
Thanks for your help blue-genie much appreciated, am I just being daft?

from the last attempted compile is looks as though Shader is not being understood but I don'tt know how to solve this.

Any thoughts?
0
 
blue-genieCommented:
i have no idea with CS4 but it seems like you're missing some packages.
go back to the site and check the downloads of if it mentions you need to download some external packages
0
 
Sci-Fi-SiAuthor Commented:
Indeed I was,

Didn't know what all these packages were about but had a look round the net and found out how to add .as files to my library.

Got some stuff happening now. Many thanks for your input.

:)
0
 
Sci-Fi-SiAuthor Commented:
Many thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now