codes.creativebrain.ca Code References From All Around The Web.

14Jul/100

ImageLoader in AS3.0 to load any image (jpeg, png, gif) and swf file.

1. Create a box MovieClip on stage and name it as ImageLoader.

2. Inside ImageLoader MovieClip (MC) create another box MovieClip and name it as "_imgMask" and give the same instance name. This MC will be used for masking.

3. Now copy this code below and save it as ImageLoader.as

[as3]

package
{
/**
* ...
* @author                         : Andy Dohare
* @email                        : andy@creativebrain.ca
* @developer                    : CreativeBrain.ca
* ...
*/

import flash.display.BlendMode;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;

public class ImageLoader extends MovieClip
{
//----------- Declaring Variables -----------\\
private var _imgSource    :    String;
private var _imgXpos    :    Number;
private var _imgYpos    :    Number;
private var _imgWidth    :    Number;
private var _imgHeight    :    Number;
private var _imgAlpha    :    Number;
private var _imgBlendmode    :    String;

private var _imgSrcLoader :    Loader;

//        private var _imgMask    :    MovieClip;
private var _loadingTXT    :    TextField;

//----------- Declaring Constructor Function -----------\\
public function ImageLoader(_src:String, _x:Number, _y:Number, _width:Number, _height:Number, _alpha:Number, _blendMode:String = BlendMode.NORMAL)
{
_imgSource        = _src;
_imgXpos        = _x;
_imgYpos        = _y;
_imgWidth        = _width;
_imgHeight        = _height;
_imgAlpha        = _alpha;
_imgBlendmode    = _blendMode;

//            trace("A.D. ImageLoader ||  SRC : " + _imgSource);

generateImageLoader();
}

//----------- Declaring Methods -----------\\
private function generateImageLoader():void
{
_imgSrcLoader = new Loader();

this.x = _imgXpos;
this.y = _imgYpos;
_imgMask.width = _imgWidth;
_imgMask.height = _imgHeight;
this.alpha = _imgAlpha;
this.blendMode = _imgBlendmode;

_imgSrcLoader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
_imgSrcLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);

_imgSrcLoader.load(new URLRequest(_imgSource));
addChild(_imgSrcLoader);

// Create a mask on _imgSrcLoader.
_imgSrcLoader.mask = _imgMask;

}

private function onInit(evt:Event):void
{
var _loaderInfo:LoaderInfo = LoaderInfo(_imgSrcLoader.contentLoaderInfo);
_loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);

trace("A.D. ImageLoader || onInit() : LoaderInfo URL ------> " + _loaderInfo.url);
trace("A.D. ImageLoader || onInit() : LoaderInfo Width : " + _loaderInfo.width);
trace("A.D. ImageLoader || onInit() : LoaderInfo Height : " + _loaderInfo.height);
}

private function onProgress(evt:ProgressEvent):void
{
_loadingTXT.text = "Loading.. (" + evt.bytesLoaded + " of " + evt.bytesTotal + ")";

trace("A.D. ImageLoader || onProgress() :: bytesLoaded :: " + evt.bytesLoaded);
trace("A.D. ImageLoader || onProgress() :: bytesTotal :: " + evt.bytesTotal);
}

private function onIOError(evt:IOErrorEvent):void
{
_loadingTXT.text = "IO Error : " + evt;

trace("A.D. ImageLoader || ioError() : IOError :: " + evt);
}

}
}

[/as3]

4. Now right click the ImageLoader MovieClip in library and select properties. Select Export to ActionScript under Linkage and type "ImageLoader" in Class field.

5. Remove everything from Base class field.

6. Now open the document class file and call ImageLoader by using the following code.

[as3]

private var _myImageLoader : ImageLoader

// ImageLoader params are as follows:
// ImageLoader(_src:String, _x:Number, _y:Number, _width:Number, _height:Number, _alpha:Number, _blendMode:String = BlendMode.NORMAL)
// _src = Image file location
// _x = X value
// _y = Y value
// _width = Mask width
// _height = Mask height
// _alpha = Alpha value of image
// _blendMode = Image blend value. Check this link for various blending options "http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#blendMode"

_myImageLoader= new ImageLoader("ImageFileName.png", 0, 0, 763, 549, 1);
addChild(_myImageLoader);

[/as3]

11Jun/10Off

Free ActionScript applications and scripts

Another good website for good and free actionScript applications and scripts.

http://www.free-flash-scripts.com/

10Mar/10Off

Snapshot of my Portfolio

Just added a snapshot of my flash based portfolio.

Here's the link.

Andy D

25Nov/09Off

Good links to keep it handy for Papervision 3D

These are few good links I found for Papervision 3D.

  1. http://archive.pv3d.org/?page_id=29
  2. http://www.madvertices.com/2008/01/papervision-3d-training-videos.html
  3. http://www.madvertices.com/search/label/Papervision%203D
  4. http://content.madvertices.com/articles/
  5. http://pv3d.org
  6. http://www.rozengain.com/blog/2007/04/05/papervision3d-tutorial-part-2-basic-shapes-movement-and-segments/
  7. http://www.flashmoto.com/blog/flash-galleries/papervision3d-flash-gallery-tutorial/
  8. http://blog.tartiflop.com/first-steps-in-papervision3d/
  9. http://sebleedelisle.com/tutorials-guides/papervision3d-simplified/
  10. http://dev.papervision3d.org/

I will add more if I find few good ones.

http://dev.papervision3d.org/

19Nov/090

Papervision3d 2.0 The great white from the ground up

One of the best papervision 3D  explanation is by Paul Tondeur. Click on the link below;

http://www.paultondeur.com/2008/02/05/papervision3d-20-the-great-white-from-the-ground-up/

22Sep/09Off

Protected: How to build a Flash Actionscript 3.0 Videoplayer Part 2

This post is password protected. To view it please enter your password below:


22Sep/09Off

Protected: How to build a Flash Actionscript 3.0 Videoplayer Part 1

This post is password protected. To view it please enter your password below:


22Sep/09Off

How To Make Money With Your RIA

This presentation from David Heinemeier Hansson is a great presentation for people who want to make money from their rich Internet application.

 

Via CNET.

18Sep/090

free Flash, Flex & AIR Video Tutorials

Link for nice Flash, Flex and AIR Video Tutorials. Some video tutorials are for advance AS3 users.

http://as3.metah.ch/

3Sep/09Off

public group { Flash / Flex / ActionScript Group }

Feel free to join Flash, Flex and ActionScript community to share any issues, questions, suggestions, advices, for anything and everything related to Flash, ActionScript. Just add  group218198@groupsim.com to your msn live messanger or yahoo messanger.

Pages

Categories

Blogroll

Archive

Meta