This is G o o g l e's cache of http://www.flashsandy.org/forum/index.php?act=Print&client=printer&f=17&t=156 as retrieved on 1 Aug 2007 20:33:55 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:a21qhElhKh0J:www.flashsandy.org/forum/index.php%3Fact%3DPrint%26client%3Dprinter%26f%3D17%26t%3D156+act%3DPrint+%22index+php%22+-lofiversion+site:www.flashsandy.org&hl=en&ct=clnk&cd=82


Google is neither affiliated with the authors of this page nor responsible for its content.
These search terms have been highlighted: index php 
These terms only appear in links pointing to this page: act print

Printable Version of Topic

Click here to view this topic in its original format

Sandy's Forum _ AS2 1.x versions _ how can load picture form URL for texture cube?

Posted by: lavlav Oct 26 2006, 11:02 PM

ref. to
http://www.flashsandy.org/forum/index.php?showtopic=19

I can make Cube with Lighting and alpha, I chagne code form his file
thx RichL

I want to load a picture form other web site to make the cube's texture
may be I am doing something wrong in the code
can teach me how to do it ?

CODE
import flash.display.BitmapData;
import flash.geom.ColorTransform;
import flash.filters.*;
import sandy.core.data.*;
import sandy.core.group.*;
import sandy.primitive.*;
import sandy.view.*;
import sandy.core.*;
import sandy.skin.*;
import sandy.util.*;
import sandy.core.transform.*;
import sandy.core.light.*;
import sandy.events.*;
import com.bourre.events.BasicEvent;

var rotint1:RotationInterpolator;
var ts1:TextureSkin;
var ct1:ColorTransform;

//load a jpg form URL ,and try to change to moveiclip to map to texture,but it is not correct
System.security.allowDomain("www.google.com.hk");
this.createEmptyMovieClip("holder_mc",this.getNextHighestDepth() );
loader = new MovieClipLoader();
loader.addListener(this);
loader.loadClip("http://www.google.com.hk/images/hp0.gif",holder_mc)

//photo
this.attachMovie("holder_mc",this.getNextHighestDepth());
this.holder_mc._alpha = 000;//to hide original (is this the best method?)
ct1 = new ColorTransform(1,1,1,1,0,0,0,-55);//to change alpha of photo texture

//filter array
var filterArray:Array = new Array();

//glow filter
//([color:Number], [alpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [inner:Boolean], [knockout:Boolean])
var glowf:GlowFilter = new GlowFilter(0xffffff,40,40,40,0.7,1,false,false);
filterArray.push(glowf);


function init (Void):Void
{    var ecran:ClipScreen = new ClipScreen (this.createEmptyMovieClip('ecran',1),500,500);
    var cam:Camera3D = new Camera3D(700,ecran);
    World3D.getInstance().addCamera(cam);
    var bg:Group = new Group();
    createObject3D_1(bg);
    World3D.getInstance().setRootGroup(bg);
    World3D.getInstance().render();
}
function createObject3D_1(bg:Group):Void
{    //Photo displaying, transparent and back of cube now there
    var o1:Object3D = new Box(150,150,150,'quad',1);
    ts1 = new TextureSkin(new BitmapData(this.holder_mc._width,this.holder_mc._height));
    ts1.texture.draw(this.holder_mc);
    ts1.texture.colorTransform(ts1.texture.rectangle,ct1);
    ts1.filters=filterArray;
    o1.setSkin(ts1);
    o1.setBackSkin(ts1);
    o1.enableBackFaceCulling=false;
    var tg1:TransformGroup = new TransformGroup();
    var tg2:TransformGroup = new TransformGroup();
    var translation:Transform3D = new Transform3D();
    var ease:Ease = new Ease();
    ease.linear();
    rotint1 = new RotationInterpolator(ease.create(),500);//changed
    rotint1.addEventListener( InterpolationEvent.onProgressEVENT, this , onRender );
    rotint1.addEventListener( InterpolationEvent.onEndEVENT, this , onEnd );
    translation.translate(0,0,500);//XX
    tg1.setTransform(translation);
    tg2.setTransform(rotint1);//new
    tg2.addChild(o1);
    tg1.addChild(tg2);
    bg.addChild(tg1);
}


function onEnd(e:InterpolationEvent):Void
{e.getTarget().redo();}

function onRender( e:InterpolationEvent )
{
    var difX:Number = 550 - _xmouse;
    var difY:Number = 550 - _ymouse;
    var dist:Number = Math.sqrt( difX*difX  + difY*difY );
    RotationInterpolator(e.getTarget()).setAxisOfRotation( new Vector( -difY, difX, 0 ) );
    RotationInterpolator(e.getTarget()).setDuration( 42000 / dist );
}    

init();


PS.I also upload the .fla and swf files


Attached File(s)
Attached File  test_03.fla ( 96k ) Number of downloads: 13
Attached File  test_03.swf ( 26.81k ) Number of downloads: 22

Posted by: lavlav Oct 27 2006, 07:31 PM

I find the method by myself now


old code

CODE
//load a jpg form URL ,and try to change to moveiclip to map to texture,but it is not correct
System.security.allowDomain("www.google.com.hk");
this.createEmptyMovieClip("holder_mc",this.getNextHighestDepth() );
loader = new MovieClipLoader();
loader.addListener(this);
loader.loadClip("http://www.google.com.hk/images/hp0.gif",holder_mc)

//photo
this.attachMovie("holder_mc",this.getNextHighestDepth());
this.holder_mc._alpha = 000;//to hide original (is this the best method?)
ct1 = new ColorTransform(1,1,1,1,0,0,0,-55);//to change alpha of photo texture


change to this
CODE
//load a jpg form URL ,and try to change to moveiclip to map to texturet
var loc5=new Object();
loader = new MovieClipLoader();
loader.addListener(loc5);
this.createEmptyMovieClip("holder_mc",this.getNextHighestDepth());
loader.loadClip("http://www.google.com.hk/images/hp0.gif", holder_mc);//change URL as you like
loc5.onLoadInit = function (holder_mc){
    init();
    }
this.holder_mc._alpha = 000;//to hide original (is this the best method?)
ct1 = new ColorTransform(1,1,1,1,0,0,0,-55);//to change alpha of photo texture


And the cube can load picture form other website

this time , I want to ask a question

when use flashIDE complier to swf , it will come a warning message
"WARNING: Sandy::QuadFace3D The perspective bitmap distortion may not be correct"
what is that mean ?

Posted by: kiroukou Oct 27 2006, 07:49 PM

Hi,
This message means that the perspective distortion can't be applied correctly whe the mode quad is enabled on your primitive object.

The scene would work, but the result can be strange, depending on your texture and the object distance from the camera.

Posted by: Petit Oct 27 2006, 10:21 PM

It's a good thing that you brought in the onLoadInit event handler here.
I can another possible problem here.
Strange as it may sound, you may not be able to use the loaded image this way,
once you place your Flash movie on your web site.
The Flash sandbox will allow you to load an image from another site, such as www.google.com.hk.
This is called cross domain loading of resources, and you might expect this not to be allowed, but it is.

What is not allowed is to *alter* the image, once it is loaded. At least this is true fro Flash 8.
That is to say, you may not be able to use the Bitmap.draw method.

There are two solutions to this problem:
1. The owner of the resource could allow the cross domain loading by placing a cross domain policy file on his site.
2. The owner of the resource could place a "shim SWF" on his site
3. If you don't have control over the source data site ( e.g. www.google.com.hk ), you can use a proxy on your own site ( see Adobe's http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16520 ).

Maybe you already knew all this - then someone else might not wink.gif
Good luck!

Posted by: lavlav Oct 28 2006, 06:26 PM

thx kiroukou
and thx Petit

I saw you web site before, and I hear the problem "cross domain loading of resources"
(because Petit web site is my first meet on flash 3D topic's tutorial)

I do this small project is for my own album's title use
and my album's photo say that is allow to link to other web site
now is not 100% sure can work with a cross domain policy ,I will test it later

would you mind explain why may not be able to use the Bitmap.draw method ?

and thx again

Posted by: lavlav Oct 30 2006, 11:17 PM

in this time , I want to use xml file to control the URL
but it is not success
and the error is the URL in xml didn't load into "nodes.attributes.image"

the code is here

CODE
.
.
.
.
var loc5=new Object();
loader = new MovieClipLoader();
loader.addListener(loc5);

var xml:XML = new XML ();     <<<< ADD
xml.ignoreWhite = true;          <<<< ADD
xml.load("test.xml");               <<<< ADD
xml.onLoad = function()          <<<< ADD
{

var nodes = this.firstChild.childNodes;            <<<< ADD
this.createEmptyMovieClip("holder_mc",this.getNextHighestDepth());
loader.loadClip(nodes.attributes.image, holder_mc);       <<<< let URL to xml file control
    
};

loc5.onLoadInit = function (_holder){
    init();
    }
this.holder_mc._alpha = 000;//to hide original (is this the best method?)
ct1 = new ColorTransform(1,1,1,1,0,0,0,-55);//to change alpha of photo texture
.
.
.


and the xml file here
CODE
<photos>
<Photo image="http://www.google.com.hk/images/hp0.gif"</Photo>
</photos>


I have try and error more more times
but I can't find the solution
can someone help me ?

Posted by: lavlav Nov 4 2006, 07:24 PM

I finally find the method to correct the problem;


var photos:Array = this.firstChild.childNodes;
i=1;
urls.push(photos[k].attributes.url);
loader.loadClip(urls[k],"holder_mc"+i);

and the xml file
change to
<Photo url="http://www.google.com.hk/images/hp0.gif"</Photo>

Posted by: Petit Nov 6 2006, 08:12 AM

QUOTE(lavlav @ Oct 28 2006, 07:26 PM) *

would you mind explain why may not be able to use the Bitmap.draw method ?


Well, I find this a bit strange really.
The so called Flash sandbox should be something like the Java Applet sandbox, which means that an Applet is allowed only load resources ( images or other ) from the same domain ( or web server ), that it comes from. This is a security system and can be overruled by using signed Applet:s.

I would expect the Flash sandbox to do the same.
There are two cases, which works differently.

1. You load the SWF from your own computer. In that case you can load anything from anywhere.
2. You load the SWF from a web server. Now you should not be able to load resources from another web server.

When I developed an http://petitpub.com/labs/media/flash/3dcube/, getting images from Flickr, I could load the images, but I couldn't use the Bitmap.draw method on images loaded from Flickr. This is an odd version of sandbox, and only Adobe/Macromedia can explain why wink.gif

I'll investigate this again, to see that I haven't drawn the wrong conclusion here.

Posted by: lavlav Nov 6 2006, 06:39 PM

veryvery thanks Petit

now I know more that what should I do in future do upgrade this project

and at this stage , I have not enough technology to do rewrite this programm
I will learn more in later

more thing I told you all, I use this AS , and use xml to control the image , it is work for me

1st , upload my image is in my album server
2nd , upload the swf file in my album server
3rd , xml file not allow to upload in my album server, then I upload the xml file to some free webhosting server

it is work for me

Posted by: lavlav Nov 6 2006, 09:37 PM

would you mind give me some hints using which to substitute for "Bitmap.draw" method ?

Posted by: kiroukou Nov 7 2006, 10:00 AM

Can you explain a bit more what do you want?smile.gif

Posted by: lavlav Nov 7 2006, 03:31 PM

sorry , I said not clear

Petit reply this

QUOTE
When I developed an image cube, getting images from Flickr, I could load the images, but I couldn't use the Bitmap.draw method on images loaded from Flickr. This is an odd version of sandbox, and only Adobe/Macromedia can explain why .


SO I want to ask if not use Bitmap.draw , then will use which function to replace it ?

thx

Posted by: lavlav Nov 7 2006, 07:39 PM

this time I put this swf upload to googlepages.com
and use the test.xml to control the photo
test.xml file also upload to googlepages.com

more question

1. I put the cross domain policy file in my root director(myname.googlepages.com/crossdomain.xml)
and write it
<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>
but finally , can't load image

2. I guess I can do is use "shim SWF"method,
so can help me to write the shim swf for me ?
or give me some hints to write the shim swf

thx

Posted by: kiroukou Nov 8 2006, 07:43 AM

Sorry I don't have the experience of your problem. I can't help you.
As this board exist to solve Sandy's problems, you should ask your question on a less specified forum i order to have some faster answers.

++ wink.gif

Posted by: Petit Nov 15 2006, 10:41 PM

QUOTE(lavlav @ Nov 7 2006, 04:31 PM) *

Petit reply this
SO I want to ask if not use Bitmap.draw , then will use which function to replace it ?


Well lavlav, you have to use the BitmapData.draw method to convert images you load into your SWF.

What I said was, that if you load images from another web server, than the one hosting your SWF, the Flash sandbox will not allow you to do that.

The solution is to have a proxy program on your server.
o You load the images by calling your own proxy.
o The proxy will fetch the images from the other server and Flash will think it comes from your own server.
o Then you can indeed use the BitmapData.draw method.

In my case I used a PHP script called crossdomain.php, written in PHP.
You can read about the different methods http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16520.

The proxy method is best if you only have access to your own server, where the SWF is.
To use the shim method, you must have access to the server hosting the images!

If this doesn't help, you'll have to ask elsewere, as this is not a Sandy problem, but a general Flash problem.
Good luck!

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)