ActionScript 3.0 :: Position A Loader Image Inside A Sprite?

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


Similar Posts:


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

ActionScript 3.0 :: Sending Current Sprite To Loader Function For Image Gallery?

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

Actionscript 3 :: Centering An Image Inside A Loader

Mar 17, 2011

I'm developing an ActionScript 3.0 app for Blackberry Playbook. I have a Loader with a fixed size of 240x240px. The images that can be loaded inside are smaller or bigger than 240x240px, and also they aren't squared. I use this code to resize that images:

[Code]...

View 1 Replies

ActionScript 3.0 :: Resizing Image From Loader Inside Movie Clip?

Jan 2, 2012

Ive found all sorts of answers but not the right answer. Im using the loader class to load images into a gallery. Im placing the image inside a movie clip. I want to resize the images as users will dynamically load them but width is not working. scaleY works and scaleX

[Code]...

View 2 Replies

ActionScript 3.0 :: Image Viewer And Im Loading An Image To A Loader And Then Add The Loader To The Stage?

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

Actionscript 3 :: Drawing - Cut A "hole" Inside A Rectangular Sprite To See The Sprite Underneath?

Feb 3, 2010

Everytime I google this question I see confusing information about masks and blends, none of which seems to directly apply to what I think should be an easy thing... There are three Sprites involved here...the lowest layer sprite is pretty much a background. I want to overlay a translucent Sprite on top of the background and then I want the third, top-most Sprite to act as a hole, so that the area inside the third Sprite is completely transparent, so that the background sprite is completely visible. How would I go about doing this dynamically (i.e. dynamically drawing the masking sprite and hole using the Actionscript graphics calls)?

View 4 Replies

ActionScript 3.0 :: Set The Height Of The Sprite Depending On The Height Of An Textfield Inside That Sprite?

Feb 2, 2009

Is it possible to set the height of the sprite depending on the height of an textfield inside that sprite? I'm creating a box with a textfield inside it, but I want the box to be sized depending of how much text it is in the textfield..

View 9 Replies

ActionScript 3.0 :: Get Loaded Sprite From Loader?

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

ActionScript 3.0 :: Sprite Loader From Library Onto The Stage?

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

Flash :: Convert From DisplayObject To Sprite With Loader?

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

Flash :: Copy To Bitmap Loaded In Sprite From Loader

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

Sprite Y Based On Mouse Position?

Jul 20, 2011

So I'm working on my portfolio and I got this problem. The code posted scrolls the sprite "cellContainer" based on the position of stage.mouseY. Perfect.Problem is that I want stage.mouseY to equal the entire cellContainer height. Kind of like how a small tablet equals a huge monitor. So when stage.mouseY = 0,cellContainer.y = 0 and when stage.mouseY = stage.stageHeight, cellContainer.y = stage.stageHeight - cellContainer.height. Right now, it scrolls, but it takes a while to scroll throught the entire height of cellContainer. I want it to be proportional to stage.mouseY.

Actionscript Code:
private function scrollStart(e:Event)[code]....

View 4 Replies

ActionScript 3.0 :: External Assets - Multiple Loader Sprite Instance

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

ActionScript 3.0 :: Set X And Y Position Of A Class That Inherits From Sprite?

Feb 15, 2009

I have a clas that inherits from sprite but i want to know when the x and y is set so i can make changes inside the instance, but i cant figure out how to do that...

i need it so that say if i set the x with the normal x property, it can set another variable or run a function.

View 2 Replies

ActionScript 3.0 :: Two Sprite Objects - Adjusting Position (X And Y)

Jan 23, 2012

I am trying to do adjustment of position (x and y) of display objects, relative to other display objects. In other words: I have two Sprite objects (rectangle and circle). The rectangle can have their width changed during execution. Yet the circle has a fixed size. What I do is this: regardless of the width of the rectangle, the circle is positioned at the far right of this rectangle.

I tried as follows:
ActionScript Code:
rectangle.width = someValue;
circle.x = rectangle.x + (rectangle.width-circle.width);

In theory it should work, but look what happens:
imageshack.us/photo/my-images/837/positionq.png

As the width of the rectangle increases the distance from the desired location also increases.
Using:
ActionScript Code:
trace (rectangle.width);

I realized that the value of property 'width' does not match the exact amount of pixels that the object is wide. I just did a test and realized that this problem only happens when the rectangle has edge. When the rectangle has only fill, this problem does not occur.

View 9 Replies

Actionscript 3 :: Force A Sprite To Position Children In Reference To 0,0?

Sep 26, 2010

I'm trying to add some scroll bars to a Sprite using ScrollRect. The Sprite starts empty and when I add something at 500, 500, it should scroll, as it is outside the viewport. Unfortunately, adding a 10x10 Sprite at 500, 500, doesn't make my Sprite change its size to 510, 510, but to 10, 10 ::- (.

We all know that DisplayObjectContainers resize according to what's put in them. But I didn't know up until today that if you put something at 500, 500, the Sprite / DObjContainer will NOT resize from 0, 0 to 500, 500, but simply jump directly at 500, 500. Annoying, as I cannot put Scrollbars on something whose content fluctuates so. I need 0, 0 to remain 0, 0 and if something is placed at 500, 500, the sprite's height should increase with 500 + that something's height.

View 3 Replies

ActionScript 3.0 :: Force A Sprite To Position Children In Reference To 0,0?

Sep 26, 2010

I'm trying to add some scroll bars to a Sprite using ScrollRect. The Sprite starts empty and when I add something at 500, 500, it should scroll, as it is outside the viewport. Unfortunately, adding a 10x10 Sprite at 500, 500, doesn't make my Sprite change its size to 510, 510, but to 10, 10 ::- (.

We all know that DisplayObjectContainers resize according to what's put in them. But I didn't know up until today that if you put something at 500, 500, the Sprite / DObjContainer will NOT resize from 0, 0 to 500, 500, but simply jump directly at 500, 500. Annoying, as I cannot put Scrollbars on something whose content fluctuates so. I need 0, 0 to remain 0, 0 and if something is placed at 500, 500, the sprite's height should increase with 500 + that something's height.

View 9 Replies

ActionScript 2.0 :: Fix The Position Of An Mc Loader

Oct 4, 2006

back with another question
I have a row of thumbnails with a simple rollover effect.( I load a swf for each thumbnail preview)
with the following code from the kirupa tuto.
on (rollOver) {
loadMovie ("mesimages/im1.swf", "dropzone");
}
it works fine BUT : my swfs are appearing in a crazy position even if I created an mc as indicated in the tuto..
Do have I to settle my self the position of my previews in the code ?
Thanks thanks thanks

View 2 Replies

ActionScript 2.0 :: Mc Loader And Swfs Loading And Position?

Oct 4, 2006

Here is the thing : on rollover on thumbnails ( buttons)its preview has to appear on the top of it.My corrected code works fine exepted that my swf don't load in a good way..they load at 60 kms from the thumbnail...and in a distorted size!I don't get it.I turn the thing in all ways but it is getting worth...What is my mistake?Code for each button ( thumb)

on (rollOver) {
_root.caption._visible = 1;
_root.caption.image_mc.loadMovie("images.swf");

[code].....

View 1 Replies

Professional :: Embed An Image / And Then Use That Image As Sprite?

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

Flex :: Add Uicomponent Inside A Sprite?

Apr 15, 2011

i want to add UIComponent inside a spite. here is the code:

private function make() : void {
var circle : Sprite = new Sprite();
circle.graphics.beginFill(0xFF0000, 0.2);[code]......

the problem is that button is added, but is not displayed. if i do reversed - add sprite to uicomponent - everything works fine, but this way it doesn't work. i tried to use invalidate functions for button etc... even tried making "circle" as UIMovieClip, but no luck - button is still invisible. also if i simply do "addChild( button );" - it is shown,how can i add a button inside a sprite?

View 2 Replies

Flash - Add Image Using Loader And Make Image A Button With Event Handler?

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

ActionScript 2.0 :: Image Loader Gallery - Put A Timer - Divert To The Next Image Automatically

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

Flash CS4 Loader Class: Image Loads Initially But Error Returned When Loading New Image

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

ActionScript 3.0 :: Input TextField Inside Sprite?

Sep 14, 2009

I have an array of rectangular Sprites and ann array of Text Fields. On a certain condition, I want to change the fill colour of some of these Sprites and make the TextFields inside these Sprites editable. I tried the following:

var outerBox_Arr:Array = new Array();
for(var j:int=0; j<8;j++)
{

[code]....

View 1 Replies

ActionScript 3.0 :: Adding A Shape Inside A Sprite?

Oct 23, 2009

I am trying to place a rectangle Shape inside a square Sprite, as its child. But, the child rectangle show up outside the sprite, instead.

Also, the click handler event of the sprite reports the error "The supplied DisplayObject must be a child of the caller".

Code:

package
{
import flash.display.Sprite;
import flash.display.Shape;

[Code].....

View 4 Replies

Actionscript 3 :: Prevent A Loader From Changing Apps Position And Size?

Nov 15, 2010

I load an SWF using a simple loader but it changes the main applications x/y position and size.Which loader do I use to load an swf that will maintain the position size of my app?

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, function handleInit(event:Event):void{
var UIDesigner:UIComponent = new UIComponent();

[code]......

View 3 Replies

Flex :: Adding Loader Image While The Image Is Loading?

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

ActionScript 3.0 :: Adding Scrollbar To Sprite Inside / Outside For Loop?

Nov 26, 2009

I'm currently having trouble on integrating a scrollbar that I downloaded from Warm Forest Flash. I built a XML gallery that is going out of the boundary of height of 466 pixels. The thumbnails that are out of the boundary are still visible. On top of that, I tried to add the scrollbar to the sprites inside and outside the for loop, but sadly it doesn't appear. For the height thing, can I set the size of the ULLoader? Or should I just use a mask or something?

Main.as
import flash.net.URLLoader;
import flash.net.URLRequest;
import fl.containers.UILoader;
import gs.*;
import gs.easing.*;
[Code] .....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved