Hey all,
I have a function that finds the URL of an image, and after doing so, I try to resize it to 50×50. Now when I test this locally in the Flash IDE it always resizes the image, and works everytime, but when I test it on a website, the image won’t resize at all.
Does anybody know if you have to cache the image before i can resize it, and any other suggestions that would help me out or point me in the right direction would be great.
Inside a loaded function I basically just resize it by doing this:
e.target.content.width = 50; e.target.content.height = 50;
Thanks, Scott
- Exclusive Author
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 250 000 and 1 000 000 dollars
- Author was Featured
- Item was Featured
- Attended a Community Meetup
- Referred between 100 and 199 users
- Contributed a Tutorial to a Tuts+ Site
What is e.target referring too?
- Attended a Community Meetup
- Community Moderator
- Has been a member for 5-6 years
- United Kingdom
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Contributed a Blog Post
- Beta Tester
- Bought between 50 and 99 items
why not just use loader.width = 50 and loader.height = 50 ?
Yes the image is on a different domain, and I know about the security sandbox violation problem, but I know a way to get around that. The only problem is resizing the images that it uses.
why not just use loader.width = 50 and loader.height = 50 ?
I have tried that and I didn’t work either. Good suggestion though.
What is e.target referring too?
It refers to the image loader, when I traced it.
I run across same problem before.
It seems it is a restriction from flash player itself only occurs If the domain name of the image is different than the URL of the application.
As i remember, i was trying to get the image from different URL and using bitmap class, drawing it to an mc and resizing it. Couldn’t manage directly so i write a php script to copy the image to my server first, then get the images path… But this was a brute-force solution and not so flexible.
EDIT : And crossdomain.xml does not help about this problem.
Hey phantasmagoria,
Thanks for the reply, I do think that’s the exact problem I am having, and I also tried to assign it to a bitmap object and drawing it to a mc, but I couldn’t get it to work either. If there is a solution to this I would love to know.
Would adding it to a display object container or just the display object help?
Thanks
what is the contenrLoaderInfo.content’s height / width you trace in the complete listener ? If that is zero maybe add a enterframe listener try monitor it after.
And think the crossdomain restriction only effect on the bitmapData, but you can still change the content’s size.
When I trace imageLoader.contentLoaderInfo.width and height in the complete function, its still the original height and width of the image, not 50×50. I do the resizing of the image in the init listener, is that correct?
And think the crossdomain restriction only effect on the bitmapData, but you can still change the content’s size.
How would you change the contents size?
Scott
