Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:46:12+00:00 2026-05-27T00:46:12+00:00

I have a image loaded in a sprite, the image is from a remote

  • 0

I have a image loaded in a sprite, the image is from a remote location “http://i.ytimg.com/vi/yre5nBXAxyk/0.jpg”. Once the image is loaded in the Loader Object i then want to create a reflection of the sprite that contains the image. Now this works when i run the application in flash IDE but when i embed this flash application inside a HTML page the reflection images do not work. Why is this, the code is below.

////////////////////////////////////////////

// Project: Flash 10 Coverflow
// Date: 10/3/09
// Author: Stephen Weber
////////////////////////////////////////////
package {

////////////////////////////////////////////
// IMPORTS
////////////////////////////////////////////
import flash.system.Security;

import flash.external.ExternalInterface;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Matrix;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.utils.setInterval;
import flash.utils.clearInterval;

public class Reflect extends MovieClip {
    ////////////////////////////////////////////
    // VARIABLES
    ////////////////////////////////////////////

    //reference to the movie clip we are reflecting
    private var _reflectionSprite:Sprite;

    //the BitmapData object that will hold a visual copy of the mc
    private var _bitmapData:BitmapData;

    //the BitmapData object that will hold the reflected image
    private var _reflectionBitmap:Bitmap;

    //the clip that will act as out gradient mask
    private var _gradientMask:MovieClip;

    //how often the reflection should update (if it is video or animated)
    private var _updateTime:Number;

    //the size the reflection is allowed to reflect within
    private var _bounds:Object;

    //the distance the reflection is vertically from the mc
    private var _distance:Number=0;

    function Reflect(args:Object) {


        _reflectionSprite=args.target;

        //the alpha level of the reflection clip
        var alpha:Number=args.alpha/100;

        //the ratio opaque color used in the gradient mask
        var ratio:Number=args.ratio;

        //update time interval
        var _updateTime:Number=args._updateTime;

        //the distance at which the reflection visually drops off at
        var reflectionDropoff:Number=args.reflectionDropoff;

        //the distance the reflection starts from the bottom of the mc
        var _distance:Number=args.distance;

        //store width and height of the clip
        var spriteHeight=_reflectionSprite.height;
        var spriteWidth=_reflectionSprite.width;

        //store the _bounds of the reflection
        _bounds = new Object();
        _bounds.width=spriteWidth;
        _bounds.height=spriteHeight;
        if (_bounds.width>0) {
            //create the BitmapData that will hold a snapshot of the movie clip
            _bitmapData=new BitmapData(_bounds.width,_bounds.height,true,0xFFFFFF);
            _bitmapData.draw(_reflectionSprite);

            //create the BitmapData the will hold the reflection
            _reflectionBitmap=new Bitmap(_bitmapData);
            //flip the reflection upside down
            _reflectionBitmap.scaleY=-1;
            //move the reflection to the bottom of the movie clip
            _reflectionBitmap.y = (_bounds.height*2) + _distance;
            _reflectionSprite.visible = true;
            //add the reflection to the movie clip's Display Stack
            var _reflectionBitmapRef:DisplayObject=_reflectionSprite.addChild(_reflectionBitmap);
            _reflectionBitmapRef.name="_reflectionBitmap";

            //add a blank movie clip to hold our gradient mask
            var gradientMaskRef:DisplayObject = _reflectionSprite.addChild(new MovieClip());
            gradientMaskRef.name="_gradientMask";

            //get a reference to the movie clip - cast the DisplayObject that is returned as a MovieClip
            _gradientMask=_reflectionSprite.getChildByName("_gradientMask") as MovieClip;
            //set the values for the gradient fill
            var fillType:String=GradientType.LINEAR;
            var colors:Array=[0xFFFFFF,0xFFFFFF];
            var alphas:Array=[alpha,0];
            var ratios:Array=[0,ratio];
            var spreadMethod:String=SpreadMethod.PAD;
            //create the Matrix and create the gradient box
            var matr:Matrix = new Matrix();
            //set the height of the Matrix used for the gradient mask
            var matrixHeight:Number;
            if (reflectionDropoff<=0) {
                matrixHeight=_bounds.height;
            } else {
                matrixHeight=_bounds.height/reflectionDropoff;
            }
            matr.createGradientBox(_bounds.width, matrixHeight, (90/180)*Math.PI, 0, 0);
            //create the gradient fill
            _gradientMask.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);
            _gradientMask.graphics.drawRect(0,0,_bounds.width,_bounds.height);
            //position the mask over the reflection clip
            _gradientMask.y=_reflectionSprite.getChildByName("_reflectionBitmap").y-_reflectionSprite.getChildByName("_reflectionBitmap").height;
            //cache clip as a bitmap so that the gradient mask will function
            _gradientMask.cacheAsBitmap=true;
            _reflectionSprite.getChildByName("_reflectionBitmap").cacheAsBitmap=true;
            //set the mask for the reflection as the gradient mask
            _reflectionSprite.getChildByName("_reflectionBitmap").mask=_gradientMask;

            //if we are updating the reflection for a video or animation do so here
            if (_updateTime>-1) {
                _updateTime=setInterval(update,_updateTime,_reflectionSprite);
            }
        }
    }


    public function setBounds(w:Number,h:Number):void {
        //allows the user to set the area that the reflection is allowed
        //this is useful for clips that move within themselves
        _bounds.width=w;
        _bounds.height=h;
        _gradientMask.width=_bounds.width;
        redrawBMP(_reflectionSprite);
    }
    public function redrawBMP(_target:Sprite):void {
        // redraws the bitmap reflection - Mim Gamiet [2006]
        _bitmapData.dispose();
        _bitmapData=new BitmapData(_bounds.width,_bounds.height,true,0xFFFFFF);
        _bitmapData.draw(_target);
    }
    private function update(_target:Sprite):void {
        //updates the reflection to visually match the movie clip
        _bitmapData=new BitmapData(_bounds.width,_bounds.height,true,0xFFFFFF);
        _bitmapData.draw(_target);
        _reflectionBitmap.bitmapData=_bitmapData;
    }
    public function destroy():void {
        //provides a method to remove the reflection
        _reflectionSprite.removeChild(_reflectionSprite.getChildByName("_reflectionBitmap"));
        _reflectionBitmap=null;
        _bitmapData.dispose();
        clearInterval(_updateTime);
        _reflectionSprite.removeChild(_reflectionSprite.getChildByName("_gradientMask"));
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:46:13+00:00Added an answer on May 27, 2026 at 12:46 am
    var request:URLRequest = new URLRequest ();
    request.url = "http://ServerB/images/foo.jpg";
    
    //This is important step..
    
    var loaderContext:LoaderContext = new LoaderContext ();
    loaderContext.checkPolicyFile = true;
    
    var loader:Loader = new Loader ();
    loader.load (request, loaderContext);
    
    //now you can draw.
    var bitmapData:BitampData = new BitmapData (200, 200);
    bitmapData.draw (loader);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have loaded image into a new, initialized Oracle ORDImage object and am processing
I have two BufferedImages I loaded in from pngs. The first contains an image,
So ... I have an image loaded into an NSBitmapImageRep object, so I am
I have an image loaded from an url and added to canvas as child.
I have something like that - image loaded from file to picturebox1: then after
I have an image loaded from disk as a texture, and a same-sized matrix
I have a UIImageView which has a png image sequence loaded into it. My
I Want to load Image size 2550X3300 (i.e 1.7 Mb size), i have loaded
I have a list of images that i’ve loaded with the Loader class, but
I have a web page that loads two images from a css sprite like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.