ActionScript 3.0 :: Getting Embedded Image Into A Sprite?
May 22, 2011
I am trying to embed an image (PNG) in my SWF and display it with a Sprite. Below is my code, which displays nothing.
Code:
package
{
import flash.display.Bitmap;
[Code].....
I eventually want a class that extends Sprite and contains multiple embedded images, which I load randomly on every instantiation of that class.
I am working on a small project by writing .AS files in a text editor and compiliing from the command line with MXMLC. I have completed most of my project, but am stuck figuring out how to embed images and get them into a Sprite.
I have created a component that I want to add to all of my panels that allows It works reasonably well.The last (hopefully) issue that I have is that I want to embed the image in the class. Doing this causes the click event not to fire.If I us"this.source='assets/info.png'" everything works OK. If however, I embed the image as shown below, the image displays, but is not clickable.
Im quite new to actionscript and am in the process of making a simple platformer game. This is my first project and am still learning all the functions of actionscript.I am trying to embed an image, and then have a sprite have the appearance of that image ( I dont know how to word that any better...)[code]Im getting no errors, but the Sprite is still not showing the image i want it to.
I am trying to replace some code which loaded an external image and triggered and function once completed with code that uses and embedded image. The relevant code looks like this.
Code:
[Embed(source='globe.png')] public function Globe() { var imageLoader:Loader = new Loader();
[code]....
The commented out section is where it used to take the loaded image and apply it to a texturemap.I need to replace the lines of code in the first function with something that calls the second function correctly.
I have tried using function imageLoadComplete (e:Event = null)and calling it with imageLoadComplete(); in the first function but although it compile and runs without error, the program does not work properly. I suspect this is to do with the dispatchEvent(); line which I do not understand.
I'm trying to build a picture viewer that can be used in every way. So it's important for me to make everything dynamic. I have a xml file that I load and then I read all the images and I want a border surrounding the image. I've made a new sprite to load everything in, I made a second sprite to load the images and that second sprite should be behind every image but it will only show behind the first image.
<code> main_container = new Sprite(); main_container.x=containerX;
public function init():void { var mySprite:Sprite = new Sprite(); mySprite.graphics.beginFill(0x336699); mySprite.graphics.drawRect(100,100,150,50); addChild(mySprite
[Code]...
But how would I and a image to the sprite so the TouchEvent responds to touching the image?
I create a simple .As file with following score code: Code: package{ import flash.display.Loader; import flash.display.Sprite; import flash.events.MouseEvent; import flash.net.URLRequest; public class AS3_Project1 extends Sprite{ private var sprite:Sprite; [Code] ..... And the image wont appear but if i remove the sprite.width = 500; line and I can view the image? what going on?
I have two illustrator vector images "apple.ai" and "orange.ai" imported in the library. I create a new sprite in actionscript and want to assign apple.ai as the graphic for the sprite and on mouseover want to change the graphic to orange.ai. I don't want to use button but only sprite: basically i want to know if there is a way in actionscript to assign and change the graphic of a sprite.
I load an png image and add it to the display list. Now I want to add this image more than once, like a pinball game there could be 3,4,5 balls, all with the same image. But I cant add the same image reference more than once to the display list, right? So should I make a copy of it? How can I copy it and add to the display list without needing to load it from file more than once?
I tried using this: [URL] But didnt worked! I use the class Loader to load an png, and I use the Loader.content as a parameter of that function. When I add the result to the displaylist nothing appears!
I am trying to get an image object from one sprite container and adding it to another sprite container. But when I use GetChildAt for this, it will remove the object from the parent sprite and place it inside the other.
In AS3 / CS4 I'm trying to programmatically create a bunch of rectangular objects, let's call them 'cards', that will contain an image and a colored background and eventually some other elements like text. I want to create alot of these cards and move them around inside of a larger panel (also a Sprite) of sorts. I can successfully create colored rectangles in my cards and place the cards where I want in the panel, but whenever I try to add an image to a card, I can't seem to position the image inside the card's coordinate space, it ends up being placed inside the larger panel's coordinate space instead, even though I'm adding the image/loader as a child of the card. I thought maybe it had something to do with having to wait until the image loading was complete, so I added the listener as a test but that didn't work. Here's the code:
I've got a few spites on stage that are created dynamically and live in an array. I'm rotating images through these sprites and now need to know which image is in a sprite when clicked. My code: loading the images:
I've got a sprite object that gets a custom shape loaded into it, that gets used as a mask so as to cut out a custom shape from an image that is loaded in with a loader object - The loader(loada) and shape(lines) objects are both children of the sprite object - I've added code to save out the image from beneath the mask but when the save function is called nothing is saved out, and no errors are thrown.[code]
I've a slider class (SliderUI) and I'm passing slider and track images to that class as sprites.
What I'm trying to do is, passing one more image as sprite and changing its width for doing masking in slider. (It will expand or collapse as you move volume slider)
When I try to change width of sprite, it doesn't show up and I guess sprite is just container and resizing it makes it disappeared.
So how can I resize sprite with its child image (it's loaded by a Loader object by the way)?
first i have 2 sprite.. it`s mcproduct sprite and mcproductpane sprite . mcproductpane is a parent of mcproduct sprite.. so inside mcproductpane there a several mcproduct sprite.. this is a script of mc prodcut
[Code]...
The problem is i want to set a button in here(mcproductpane sprite), this button will unload / make dissappear an image that i load using loader class in mcproduct sprite.. when i want to make a button in mcproductpane sprite which the function of the button it`s to unload/make an image that i load using loader class in mcproduct sprite disappear..
I have set up a functioning xml image gallery with simple left and right arrows. I am now trying to make it an infinite looping gallery swapping the first and last sprites in an array and + and - their x value so they "physically" move in the photos container.
All of this works fine except for the actual loaded image. The xml data, name description, and image to be loaded are set up in one function and all the data is added to the sPhotoSprite (sprite) in this function. This All works perfectly..
A second function is then called to add the current image:
var currentImage:Loader = Loader(evt.target.loader); then currentSprite.addChild(currentImage); (the sprite is declared at the start)
The problem being that the sPhotosSprite is no longer reference-able. I've tried :
But this only ever returns the final sprite. The same problem of only ever returning the final sprite occurs when I try setting an external sprite to hold the current sprite in it and then referencing it in the second function.
So what I am curious about is if it is possible and how, to have an embedded video and capture the thumbnail. There are other sites that share video and I'd like to get the thumbnails from the embedded videos, but they use flash video players to show the video and likely use flashvars to pull up the right video.
I've been trying to automate some of the capture of thumbnails and embedded videos but have no clue how to get remote thumbnails from these videos.
I need to upload an image to a SWF, however I can't use ActionScript for it because the client wants drag-and-drop capability. I figure that I can make the upload button cause a popup, where there is JavaScript for drag-and-drop. The SWF allows for some photo manipulation, so the image needs to be uploaded, and be in the SWF for that use. how can I make that image accessible to the SWF file?
I'm making a Flex AIR application that will produce a giftcard from a webcam picture. This giftcard needs to be sent in an e-mail to a recipient provided in the program. Should I upload the picture to a server and use php to send the mail?
I need to create (with an App in php) a xmas card with an image and text in swf format..but without depending of xml file or sql db... just the swf file.
on my site I have a dynamic text field and text is coming in from XML files..in the xml I embedded an image. Every time you click a button on the menu it changes the text and the image to correspond with that xml file. So here is my problem. When you click on a button it first tries to load all the text then resizes it in order to accommodate the image causing this "flicker" effect everytime you click. [URL]
I have the img tag at the top of the xml in the "main" section flowed by the text..it wont let me paste the code here cause i havent been on long enough
want to preload the embedded swf's as you would images using javascript or css. I have so far been unsuccessful. I am trying to avoid having the great big white patches in the site while the menu or stocklist(on the stocklist page) load, and id prefer not to have a loading bar while it does. If possible id like to have all images and swf's loaded and cached before the page is displayed so it appears seemingly instantly. Is this possible?I first attempted to do this with a standard image preloading javascript and failed. Is it at all possible to preload swf's with javascript, if not what are my options?