Object Loader Info - Which Image Is In A Sprite When Clicked
Feb 3, 2009
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:
[Code]...
View 1 Replies
Similar Posts:
Sep 18, 2009
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:
[Code]...
View 1 Replies
Nov 30, 2010
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 :
imageLoader.contentLoaderInfo.addEventListener(Eve nt.COMPLETE, function( evt:Event)
{ imageLoaded( evt, sPhotosSprite )
} );
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.
View 1 Replies
Jan 14, 2010
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.
Code: sprContainer1.addChildAt(sprContainer2.getChildAt( 1),0);
Problem is when I run this code sprContainer2.numChildren is getting reduced by 1, which seems that this code removes a child from sprcontainer2.
View 2 Replies
Mar 23, 2011
I have a brick class where I have created a rectangle using flash.display.graphics.I am using this brick class to create a grid of 10 X 10 in another class called grid using new brick() in a for loop.I have another class called ball where I have created a circle with flash.display.graphics.The problem is that I want to remove / destroy individual bricks when the ball hits the bricks on Event.ENTER_FRAME which is not happening.the error I get is shown only for the last brick that is created in a for loop.ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at grid/ball_movement()// my function in enter frame event
The code I wrote in ENTER_FRAME is
[code].....
View 3 Replies
Mar 24, 2011
I have a brick class where I have created a rectangle using flash.display.graphics.I am using this brick class to create a grid of 10 X 10 in another class called grid using new brick() in a for loop.I have another class called ball where I have created a circle with flash.display.graphics.The problem is that I want to remove / destroy individual bricks when the ball hits the bricks on Event.ENTER_FRAME which is not happening.the error I get is shown only for the last brick that is created in a for loop.[code]
View 1 Replies
Nov 3, 2009
I've loaded an image with a loader, and if I add the loader to the stage, all is well, the image looks fine. Although if I add the loader inside a display object container, then the image gets distorted- and on top of that, trying to change the width and height once its in the container doesn't work either.
View 1 Replies
Aug 12, 2009
im working on an image viewer and im loading an image to a loader and then add the loader to the stage.I want the user to be able to drag and drop the image but since it's a loader i dont know how to do it.
I tried
imageLoader.startDrag = true;
imageLoader.content.startDrag = true;
but im getting an error on both.
View 2 Replies
Apr 1, 2010
This simple code:
var loa:Loader = new Loader();
loa.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loa.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
loa.loadBytes(someByteArray);
Sometimes works, but mostly doesn't. Neither 'onLoaderInit' nor 'onLoaderComplete' fire.
'someByteArray' is always a valid ByteArray, stored in a local SharedObject
View 1 Replies
Nov 10, 2009
I'm trying to use a custom class to create a mosaic type of gallery, and load jpegs in which some may have different dimensions. I'm using the Loader Class and I can get the content width value of the jpegs I'm loading, but I'm having trouble adding that value to the property of the (custom) object. Here is the Class:
package {
import flash.display.*;
import flash.events.*;
[code].....
View 0 Replies
Jun 23, 2009
my page contains a Loader to load the different parts of the site as swf but i also have a little intro, witch ist a .flv file. i knwo i can�t load a .flv file in the loader class so i can put it into a swf an load it this way. the thing ist, after the intro is completed my page should get the info to change
1. a var which will change the proberties of the loader
2. the color of the Header/Footer
3. initialize a little x tweening with the body
is there a way to get the onLoadComplete info out of the swf witch contains the flv file or do i have to change the loader to a flvplayback component and afterwards back to a loader
and if i have to do so - how do i implement the flvplayback component into my .as file -i tried it and i always get the message, that he cant find the class.
View 1 Replies
Oct 28, 2008
Version: CS3, Flash AS3.
I want to detect whether the mouse has been clicked outside of a sprite (ie. a mouse click event anywhere on the screen except the sprite).
The idea is that you click outside an activated sprite to deactivate it. This is how menus and comboboxes function, but I can't see any way of doing it in actionscript.
View 2 Replies
Nov 8, 2011
Lets say I want a mouse click event listener to trace (console print) the x coordinate of a sprite clicked. this is what Ive got, which is wrong.
public function field()
{
....
//nodes is an array containing node sprite objects
[Code]....
I believe this.x is referring to the classes property x, however i would like to refer to the single_node object. currently console is outputting 0, regardless of what sprite i click.
View 1 Replies
Dec 21, 2011
I want to get my star to use one of the loaded sprites, I manage to find the correct urlLoader in my loader, but are unsure what I should return to give it the sprite.[code]...
View 2 Replies
Jan 30, 2009
Loading a Sprite or MovieClip from the library to the Stage is simple. You just export the symbol and do the following code:
var mySp:Sprite1 = new Sprite1();
addChild(mySp)
assuming the exported sprite is called "Sprite1" and the base class is flash.display.Sprite
But what if you have many sprites and want to encapsulate this into a function with the sprite name passed as a string? What would the code in the function look like? Somehow you have to cast the string as the name of the sprite class defined in your export but I'm not sure how. I've seen a sample using the "as" keyword but try searching "as" in the help you you don't get much help.
Code:
function loadSpriteFromLibrary(sSpriteName:String)
{
//load the sprite with an exported name passed into sSpriteName onto the stage
//what would the code look like?
}
View 2 Replies
Jun 29, 2011
Do you know why this AS3 code works:
var loader = new Loader();
loader.load(new URLRequest("http://127.0.0.1/items/boing.png")));
var o:DisplayObject = addChild(loader);
o.x = 100;
o.y = 100;
But if I cast to sprite it doesn't work? Ie the sprite appears on (0, 0) instead of (100, 100):
var loader = new Loader();
loader.load(new URLRequest("http://127.0.0.1/items/boing.png"))
var o:Sprite = Sprite(addChild(loader));
o.x = 100;
o.y = 100;
How would I properly have a sprite instead of a DisplayObject? I need some sprite's features (drag'n drop, useHandCursor...), yet I wish I could still use the very quick writing with the loader.
View 2 Replies
Feb 25, 2010
I want to load an external image (dest) and display it on the stage, and i want to load another image (src) which will not be visible. When i hold the left mouse button on the image that appears on the stage, then a function that start copies the src image to the dest will be invoked. Actually i want to reproduce the scratch effect on an image that hides another underneath. here is my code [ the copypixels function is triggered on mouse_move event for debug purposes ]
package
{
import flash.display.Sprite;
import flash.display.BitmapData;
[Code]....
Although the two images are loaded into memory and the first one is shown on the stage, when the mouse_move events triggers the corresponding handlers the copy does not work.
View 1 Replies
Mar 25, 2010
So I have this Photo class than handles loading a pic, and dispatches an event when the loading is done with:[code]which is simple and works, but now I'd like to make something more advanced. I'd like to dispatch the load ratio.So far I have extended the Event class, with my own EventRatio class, and I can put properties on that class. Which is cool, but I need something more dynamic than just sending a fixed value.So, what is the best way to connect the Loader object of the Photo object, with the EventRatio object?
View 5 Replies
Jul 27, 2010
I'm loading some external assets with the Loader class. I've done this a lot over the years, but seem to be coming across a problem I haven't had before. I want to display two instances on the stage at the same time of a .png I'm loading externally. If I use the Loader instance's contentLoaderInfo.content object in more than one sprite, the bitmap just "moves" from the first instantiated sprite to the second. I've tried duplicating the sprite with Senocular's duplicateDisplayObject class, but for some reason, it's not working right. But shouldn't I be able to use multiple instances of an imported bitmap like this just as if it were in the library of the .fla? If so, what do I need to do?
View 3 Replies
Jan 28, 2012
I have this code which allows me to replace the mouse cursor with an image but i would also like to change the image when the mouse is clicked down using a different image. the code i am using for just replacing the mouse cursor is[code]...
i tried using a different code which i found but it failed to work with my project can anyone help me please
View 9 Replies
Jan 6, 2011
I'm wondering if there's any reasonable way to get a reference to an object in Flex, and look through everything in every sub object (every property and everything). That is, I want to know if I can completely map all of the data within an object, from another object. I'm aware that this wouldn't work for private (or protected) members, but for anything public, it should be possible, correct?
View 1 Replies
Jan 27, 2012
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.
View 1 Replies
Oct 26, 2011
How would I make an image I load using AS3's loader class into a button with an event handler on it? Below is what I have started. And below that is my error I get when I click the message.
AS:
//call function that starts loading my image
callButtons();
function callButtons():void {
[code]....
the error I am getting when I click the spanish.png on the stage is: ArgumentError: Error #1063: Argument count mismatch on MyVideoPlayer_CS4_fla::MainTimeline/playSpanish(). Expected 0, got 1.I NEEDED TO ADDED evt:MouseEvent
View 1 Replies
Apr 30, 2010
I have this piece of code to change images. I was trying to figure out how you could put a timer on the code, so if the image has been displayed for say 5 seconds it diverts to the next image automatically? Also if it's not to hard, when it has played to the end to divert to the 1st image.
[Code]...
View 1 Replies
Mar 22, 2011
[code]This script is for a loader image gallery in flash, as part of a class assignment. What happens is that in flash, when I open the swf file, the initial image (images/nair_evanescentautumn.png) will load fine. However, clicking on any thumbnail image (including the exact same images/nair_evanescentautumn.png), will result in an error saying the file cannot be found.I cannot figure out why it is doing this... I've tested it over. Clicking each thumbnail does go to the correct position in the two separate functions. All said full-size image links are in the folder images/, and replacing the initial loader image will load the other images in place of the default one. However, clicking on any thumbnail still results in URL not found, even though everything works correctly.[code]Before anyone asks why I'm putting this kind of content into a flash site, I'm not--this is only for a class assignment. I'm just trying to figure out why my images aren't loading right when I'm only doing the exact same thing in the functions as I am on the other pages.Of note, commissions.swf has the exact same feature, just with swf files loaded instead, and it works perfectly fine. home, traditional, digital, and photography all have the image gallery, and all have the same issue (I only referenced one page because if I can fix one page I should be able to fix all of them).As for the artworks, they are all my fiance's. The website design was built for her, and I used the website design for this project because I didn't want to have to build an entirely new interface design. Since the project also required a gallery, I felt that this interface would work just fine.
View 3 Replies
Nov 28, 2010
I've dynamically created a whole bunch of movieclips.
I've given each clip a name based on a variable number:
mc.name = "mc"+i;
I've also use addChild to add a couple of dynamic text fields to each movieClip, named myText1 and myText2.[code]...
View 3 Replies
May 26, 2010
conversion of htmlText ( which contains all the formatting info ) to an equivalent TextFormat object.. so that I can transfer the htmlText info ( with formatting ) to a TextFormat object and then apply them to any textfield..
You may wonder why this approach when it can be done directly using the htmlText? Cos I am trying to manipulate the text field by resizing it ( with a user-controlled handle )..It works fine when I use normal text, but when I use the html=true, the resize seems to go haywire... ( if any one has tried this earlier.. I would like to hear about getting around this )
I need to apply the formatting at the same time make it resizable ( by user ) as expected.. which could be done if the html formatting info can be applied as a TextFormat object to the text field.. rather than set the htmlText="someFormattedText".
In short, I am looking for a parser that would read the htmlText info and convert it to TextFormat object(s).
Working on AS2 - Flash 8.
View 1 Replies
Feb 23, 2010
I need to create a gallery to load images and display them. This part is fine:
/**
* @variable image_name to store the name of the selected item
*/
private function showimage(evt:Event):void
[Code].....
where imgMain is the id the image component.
But, I need a small twist. A transition image i.e. loading image should be displayed while the the image is being loaded.
View 1 Replies
Jun 24, 2010
I have some scrolling content (info). I've also made my own scroll bar.I want the scrollBar dragger to be positioned in relation to the info._y as the user scrolls info.I have created two vars: one that worsk out where info._y is as a percentage and the other that works out where the scroll._y dragger should be as a percentage...
Actionscript Code:
var scrollBarPercent = Math.round(scrollBar.dragger._y / [code]........
also onMouseWheel working too.I need a small bit of code that takes the % of info._y and moves the scrollBar dragger to the same % but in relation to the Stage.height...so if projectGalleryPercent = 50%, make dragger._y 50% of Stage.height using scrollBarPercent.
View 1 Replies
Jul 1, 2009
[code]The row object consists data for different columns of a datagrid. dp.push(row) pushes the data onto the datagrid.Columns with index 3 and 4 have type of "DATE" with whole time stamp being displayed. Is there any method in flex which will help me extract the monnth/day/year from date or timestamp for that matter.
View 2 Replies