Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








How/may I Duplicate Or Clone The Contents Of A Loader Object?


I want to load some .swf files using the Loader class. I'm all set with that and got the image on screen but I wish to have multiple instances of it. Do I have to reload one for each that I intent on using?

For example say I'm attempting to load a power up's graphic from an .swf (i'll call it ex.swf). I load it and then put the image I loaded into the power up. But then I also want to have another power up of the same type somewhere else, and I want to use that same graphic. Neither adding the loaded ex.swf's contents or simply assigning the contents to a child of the power up will work obviously. So do I have to load a new copy every single time i want a new one, or can I just clone/duplicate the contents?

Elsewise, is there another way I should be doing this? I mean I know it must be common for games to have 100's of copies of the same graphic being used by different things, yet If I try to preload the amount I'd need it's not exactly flexibly and if I load them as I need them it seems bad practice.. i dunno, let me know what you guys do,
Thanks,
Bobby




ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 03-24-2008, 10:50 PM


View Complete Forum Thread with Replies

Sponsored Links:

Clone Loader Object?
Hello there!

Is there any way to clone a Loader object?

View Replies !    View Related
Duplicate Image Loaded Into Loader Object
I realize that I have to use the Loader object to load an external image. The problem I am having with the loader Object is that it doesn't support the addChild methods. Please correct me if I'm wrong. An example.

var sprite:Sprite = new Square(); //imagine a square class that draws a Square
var loader:Loader = new Loader("pic.jpg");

loader.addChild(sprite); //gives an error
//supposedly because the Loader object can only have one child which is pic.jpg

I am in a situation where I want to duplicate the picture that I have loaded into the Loader object, so I can have two instances on the stage doing different things. How would I do that?

also, I've tried doing something like this:

var loader2:Loader = new Loader();
loader2 = loader; //also give an error, because the loader get's something from a URL

Hopefully that's enough info to go on. THANKS!

View Replies !    View Related
How To Use An Image Twice? (or How To Clone / Duplicate One?)
Hi all,

I'm created a scrolling landscape banner (this banner) but now I'm making the images dynamic by adding them as a flash parameter.

So what I'm doing in my code is this:

ActionScript Code:
var image:Loader = new Loader();
image.load(new URLRequest("Landscape-MM-snow.jpg"));
loadpic.addChild(image);

var image2:Loader = new Loader();
image2.load(new URLRequest("Landscape-MM-snow.jpg"));
loadpic2.addChild(image2);

But since it's twice the same image my code is of course not efficient.

I tried something like:

ActionScript Code:
var image:Loader = new Loader();
image.load(new URLRequest("Landscape-MM-snow.jpg"));
loadpic.addChild(image);

var image2:Loader = image;
loadpic2.addChild(image2);

But this makes the first image ("image") disappear. Probably because I changed the reference instead of duplicating it for the "image2" var.

Anybody can give me a hint on how I could solve this?

Thanks a lot in advance and have a nice day!

Kind regards,

Jochen

View Replies !    View Related
Duplicate/Clone Runtime Drawn MC
Hello Everyone,

Need someone to help me with a "small" problem:

I can't seem to duplicate or clone a mc created at runtime, with a child mc inside, which is attached at runtime...

Here is my file:

http://petkind.com/Demo/HelpMePlease.fla

Thanks for all your help, i really need it.

Martha

View Replies !    View Related
Duplicate Movie With It's Contents
I'm trying to create a reflection of a movieclip and it's contents.

I have 2 movieclips, one named _root.mc that I'm trying to duplicate and one named _root.reflection

Now what I'm trying to do is create a duplicate of _root.mc and within _root.reflection and retitle the duplicated movieclip _root.reflection.mc2

I'm can attach movies from the library no problem, but when i start loading in dynamic content that's not gonna work to well as far as I can tell.

Does anyone know how to duplicate a movieclip along with it's contents?

View Replies !    View Related
Duplicate Entire Movie Symbol With Contents
Does anyone know how to duplicate an entire Movie Symbol (including the graphic and button symbols in it)? I would like to repeat a movie symbol but add some modification without having any relational links to existing symbols.

Any help is appreciated.

Thanks!

View Replies !    View Related
Duplicate Contents Of Current Frame Into Movie Clip
Is there a way, via script at runtime, to duplicate the contents of the current frame into a movie clip?

In order to print a frame of a movie, I need to scale it and I would rather handle the scaling where the user cant see it...

The name of the clip I'm trying to duplicate into is PrintContainer
Thanks

View Replies !    View Related
Loader Component Contents Disappearing In A Slideshow?
I have a simple looping slideshow on one of our sites that I built using the loader component, and it loads in a different SWF file on each frame. It just skips ahead step by step with a little pause script and each frame of the main timeline has a loader component in it. It works fine, but one thing that bugs me is between each frame, the contents of the last one vanishes for a second while the new one loads.

Does anyone know if there's a way to keep the contents of the previous frame always visible until it's time to show the next one?

I tried "stacking" the frames on different layers but it seemed that the movie would just freeze up after it unloads the first movie if there was a loader trying to load on top of another. Any ideas?

I'm using Flash CS3 but I'd like to export the movie down a couple of versions. We usually try and shoot for Flash 7.

If you'd like to see what we have you can check out the site, http://www.gutsywomentravel.com

View Replies !    View Related
Creating A Loader For A Movie Clip Which Has Dynamic Contents
I am currently working on a "Memory" game. In the movie clip "game_mc", I have created an empty movie clip named "placeCards_mc". Then, based on what the user previously selected as the number of cards they want (nCards), Flash then spits out those number of cards on screen using placeCards_mc.attachMovie (they're named card1_mc, card2_mc, etc. up to nCards number). Then Flash accesses PHP and MySQL to get the shuffled card data and video links and assigns them to the cards.

Now here's the question. Right now, it takes at least a few seconds for all the PHP content and video to load up and ready for each card. I don't want the user to be able to go clicking around on the cards until they're ready. How would I create a loader (I'm assuming it would be for the placeCards_mc) so that the cards aren't clickable until they're ready?

Many thanks in advance.

View Replies !    View Related
[F8] Displaying The Contents Of An Object
Hey.

If I set an object like this:

Code:
var dat:Object = new Object();
And set variables within it like this:

Code:
dat.size=5;
dat.open="asdf";
Is it possable to print them like this:

Code:
trace(dat);//its not
instead of like this:

Code:
trace(dat.size+" "+dat.open);

View Replies !    View Related
Problem Tracing Contents Of Display Object
Hi I am new here and also an actionScript newbie. I am going through the book Learning ActionScript 3.0 and have come upon a problem that for the life of me I can not figure out. The author shows a function that is supposed to trace the contents of any display object. In his example file he has several nested movie clips on the stage and everything works just as it should, this is the code.


ActionScript Code:
function showChildren(dispObj:DisplayObject):void {
    for (var i:uint = 0; i < dispObj.numChildren; i++) {
        var obj:DisplayObject = dispObj.getChildAt(i)
        if (obj is DisplayObjectContainer) {
            trace(obj.name, obj);
            showChildren(obj);
        } else {
            trace(obj);
        }
    }
}

showChildren(stage);

The problem I am having is that when I open a new actionScript 3 .fla and try to recreate the nested movie clips and use the same code I get these errors:


ActionScript Code:
line 3  1061: Call to a possibly undefined method getChildAt through a reference with static type flash.display:DisplayObject.   
var obj:DisplayObject = dispObj.getChildAt(i)

line 2  1119: Access of possibly undefined property numChildren through a reference with static type flash.display:DisplayObject. 
for(var i:uint = 0; i < dispObj.numChildren; i++){

I have tried to make sure everything is the same as the example file but maybe there is some obvious thing that I am just unaware of. I would appreciate any help. Thanks.

View Replies !    View Related
Preloading Contents Loaded By LoadVars Object
Hi guys,
I was trying to create a preloader that preloads content loaded by the LoadVars() Object. For some reason, the getBytesLoaded and getByetesTotal variables of the LoadVars object kept retuning a null value. Below's how I do it:


PHP Code:



var news_lv = new LoadVars();
var url = "news.aspx"
news_lv.load(url);

//////////////////////Preload Content///////////////////////////
var bytes_loaded = news_lv.getBytesLoaded();
var bytes_total = news_lv.getBytesTotal();
var getPercent = bytes_loaded/bytes_total;


this.loadBar._width = getPercent*100;

//loadText is the variable name of a textfield that 
//resides within the loadText_mov mc

loadtext_mov.loadText = Math.round(getPercent*100)+"% Loaded";

if ( Math.round(getPercent*100) >= 50 ) {
    my_color = new Color(loadBar);
    my_color.setRGB(0xFF0000);
}
if (bytes_loaded == bytes_total) {
    this.gotoAndPlay(3);
}
//////////////////////////////////////////////////////////////
news_lv.onLoad = function(success)
{
          if ( success )
         {    
           //some other codes
          }





Any clue what's wrong? Thanks in advance.

View Replies !    View Related
Preloading Contents Loaded By LoadVars Object
Hi guys,
I was trying to create a preloader that preloads content loaded by the LoadVars() Object. For some reason, the getBytesLoaded and getByetesTotal variables of the LoadVars object kept retuning a null value. Below's how I do it:


PHP Code:



var news_lv = new LoadVars();
var url = "news.aspx"
news_lv.load(url);

//////////////////////Preload Content///////////////////////////
var bytes_loaded = news_lv.getBytesLoaded();
var bytes_total = news_lv.getBytesTotal();
var getPercent = bytes_loaded/bytes_total;


this.loadBar._width = getPercent*100;

//loadText is the variable name of a textfield that 
//resides within the loadText_mov mc

loadtext_mov.loadText = Math.round(getPercent*100)+"% Loaded";

if ( Math.round(getPercent*100) >= 50 ) {
    my_color = new Color(loadBar);
    my_color.setRGB(0xFF0000);
}
if (bytes_loaded == bytes_total) {
    this.gotoAndPlay(3);
}
//////////////////////////////////////////////////////////////
news_lv.onLoad = function(success)
{
          if ( success )
         {    
           //some other codes
          }





Any clue what's wrong? Thanks in advance.

View Replies !    View Related
Duplicate The Content Loaded Into A Loader Instance?
This is probably so simple, but I'm trying to figure out how to use the visual assets from a Loader instance multiple times.

I'm creating a square with a cutout shape (which comes from the Loader instance); but because the square (button) is made up of multiple mcs with various Layer/Erase blendmode voodoo, I need three instances of the cutout.

While I'm sure I could make it work fine if I created, say, three separate Loader instances, I'd rather not -- I mean, surely there's a way to re-use the one Loader instance?

I couldn't find the equivalent of a clone() method, and quite frankly, I'm at a loss. I'd appreciate any help anyone can provide!

View Replies !    View Related
Duplicate Object Adjacent To The First Object
Hi guys,

I am creating duplicate on clicking a buton but it is puting the duplicate on the same place but i wanna put duplicate object adjacent to the first object , whether it's having any angle or straight.

Actionscript:

function dupMovie(targetitem, basewidth, baseheight, baserotation, x_base, y_base) {
itemcount += 1;
duplicateMovieClip(targetitem, ("item" + itemcount), (16384 + (itemcount + 2000)));
item += itemcount;
setProperty(("item" + itemcount), _x, x_base);
setProperty(("item" + itemcount), _y, y_base);
setProperty(("item" + itemcount), _width, basewidth);
setProperty(("item" + itemcount), _height, baseheight);
setProperty(("item" + itemcount), _rotation, baserotation);
itemWidth = basewidth;
itemHeight = baseheight;
itemRotation = baserotation;

}


I am geting width and height of every object but with every dragable item i wanna attach a text box having widht.

for reference download movie.

http://www.geocities.com/rajmultimedia/movie.fla

regards

raj

View Replies !    View Related
Duplicate Object
I know this sounds silly... but how do you define your duplicate preferences in Flash 5... I mean, if you want to duplicate a line exactly 5 pixels under the the one before it? By default it appears lower and to right hand side - surely there must be some dialogue box where you can define the Duplicate parameters? - I feel embarrassed I cannot find it.

View Replies !    View Related
Duplicate Object
Hi all,

I have been working on an animation where an object is supposed to vibrate and rotate on itself within a specific area of my stage. I have been successful in having the object vibrate, rotate and start at the specified location. What I am having trouble with, is creating about 60 instances of the same object to move in the area I specified. All I get instead, is the one object to vibrate about and rotate. I am using AS2 and the following is the code I have attached to the "particle_mc".


onClipEvent (enterFrame) {
this._rotation = (this._rotation + (3))%360;
}

onClipEvent (enterFrame) {
width = 330; // area where animation should be segregated into
height = 380;

this._x = 577 //Math.round(Math.random()*width);
this._y = 347; //Math.round(Math.random()*height);

cx = this._x;
cy = this._y;
}
onClipEvent (enterFrame) {
this._x = cx+(Math.random()*7);
this._y = cy+(Math.random()*7);
}



Also in Frame 1 I put this code

i = 0;
while (i<60) {
//duplicateMovieClip("particle_mc"+i, i);
particle_mc.duplicateMovieClip("particle_mc"+i, i);
i++;
}

hoping to get multiple instances of the object, but no success!

Any HELP would be greatly appreciated

Brutium

View Replies !    View Related
Duplicate Object
Help!!!! I am using Flash mx 2004 and I am trying to get the duplicate object command to work. I have created a movie clip called 'box' and when you click a button, I would like it to create a duplicate. This is the code I am using:

on(release){
duplicateMovieClip(box, box2, 1);
box2._x = 100
box2._y = 100
}

Flash cannot find an error in the code, but when i try it, nothing happens! What is wrong with this code?

View Replies !    View Related
HELP Duplicate Object
Hi all,

I have been working on an animation where an object is supposed to vibrate and rotate on itself within a specific area of my stage. I have been successful in having the object vibrate, rotate and start at the specified location. What I am having trouble with, is creating about 60 instances of the same object to move in the area I specified. All I get instead, is the one object to vibrate about and rotate. I am using AS2 and the following is the code I have attached to the "particle_mc".


onClipEvent (enterFrame) {
this._rotation = (this._rotation + (3))%360;
}

onClipEvent (enterFrame) {
width = 330; // area where animation should be segregated into
height = 380;

this._x = 577 //Math.round(Math.random()*width);
this._y = 347; //Math.round(Math.random()*height);

cx = this._x;
cy = this._y;
}
onClipEvent (enterFrame) {
this._x = cx+(Math.random()*7);
this._y = cy+(Math.random()*7);
}



Also in Frame 1 I put this code

i = 0;
while (i<60) {
//duplicateMovieClip("particle_mc"+i, i);
particle_mc.duplicateMovieClip("particle_mc"+i, i);
i++;
}

hoping to get multiple instances of the object, but no success!

Any HELP would be greatly appreciated

Brutium

View Replies !    View Related
Duplicate (movieclip/object)
hi friends,

i am new in action scripting. you can say that i dont know action scripting at all. but i want to learn. as i started flash, i got that action scripting is more diffrent than i thought. but a little hope from normal user and expert mode. here i want to ask one thing that from where can i get properties of all actions in action script. like duplicatemovieclip. how can i use this?. is this possible that we duplicate objectes? and is it possible that we duplicate movieclip after a specific time in loop? i mean as we can settimeout property in javascript. plz send me the code

View Replies !    View Related
How To Duplicate Object Movement?
well I have this frame as a movieclip called field. And inside it, there's another mc that is moved by the cursor keys called box. Now I have created another movie clip called boxclone. I want boxclone to make the same movement as the box in the field. I know it has something to do with localToGlobal but I don't know how to setup the code correctly...

View Replies !    View Related
[F8] How To Duplicate An Object Instance...
So I created an object and gave it a few default properties. Now I want to be able to duplicate that object when a new movieclip is created.

My problem is that if I do something like, var newObject:Object = oldObject; then when I change a property in one, it also changes the other. So it's not actually creating a new instance of the old object, but reflecting it.

Does anyone know how to duplicate an object?


Code:
var oldObject:Object = new Object();
oldObject.name = "ONE";

var newObject:Object = new Object(oldObject);

trace(oldObject.name+" - "+newObject.name);
// outputs "ONE - ONE"

newObject.name = "TWO";

trace(oldObject.name+" - "+newObject.name);
// outputs "TWO - TWO"

View Replies !    View Related
Duplicate Object And Drag It.
Hello, im new to the forum and relative new to actionscript but im learning more and more as the days go.

What i would like to know is how do i make a duplicated or attached object dragable?

What i want is, i push a button and it will place a MC on the scen and then i want to be able to drag and drop that MC.

View Replies !    View Related
How To Duplicate An Displayable Object?
HI are there any other possible ways to duplicate a displayable objects like Sprites for example?

I'm using that approach:
var GetInstance:Class = targetDisplayableObject["constructor"];

var copyOfTargetDisplayableObject:Sprite = new GetInstance();

Thanks

mloncaric





























Edited: 06/28/2007 at 03:56:42 AM by mloncaric

View Replies !    View Related
How To Duplicate Object Movement?
well I have this frame as a movieclip called field. And inside it, there's another mc that is moved by the cursor keys called box. Now I have created another movie clip called boxclone. I want boxclone to make the same movement as the box in the field. I know it has something to do with localToGlobal but I don't know how to setup the code correctly...

View Replies !    View Related
RecordSet Object & Duplicate Movie
Hi All,
I'm looking for an example on how to effectively use the duplicate movie and the Flash RecordSet object together.

My project involves duplicating some movie clips with values that are being populated by some coldfusion queries resulting in lists of values. We pass those to Flash, then loop the values into arrays and assign values to the movie clips based on position in the array.

piece-o-the-ColdFusion:

<CFSET STNNUM_LIST="">
<CFSET STNNUM_SUB_LIST="">
<CFSET STNID_LIST="">

<CFSET STNNUM_LIST=ListAppend(STNNUM_LIST,QE2.STNNUM,"|") >
<CFSET STNtype_LIST=ListAppend(STNtype_LIST,QE2.STNITMCOD ,"|")>
<CFSET LOCATION_LIST=ListAppend(LOCATION_LIST,QE2.STNLOCD SC,"|")>

piece-o-the-ActionScript:

// convert CF variables to Flash arrays
stnnum = stnnum.split("|");
stnnum_sub = stnnum_sub.split("|");
stnid = stnid.split("|");
slgstnid = slgstnid.split("|");

then later to assign the properties and dupe the clip:

for (k=0; k<(stnnum.length); k++) {
// this assures that coords are of a number value
xCoord[k] = Number(xCoord[k]);
yCoord[k] = Number(yCoord[k]);
// clone movie clip and name it
rClip = mcMaster.duplicateMovieClip("mc"+k, k);
// set position
rClip._y = initialy + (buttonheight * k);
rClip._x = initialx + (buttonheight * k);
rClip.tgtdsc = tgtdsc[k];
}
stop();


The big key for me has traditionally been, for example, that the 4th item in all of the arrays described the info for the 4th movieclip.

The method seems to be working well, but I'm a little unsettled about passing so many values through a string value...

I'm looking for a method to be able to extract usable variables from a recordset object to avoid having to use the loadVars approach. I get a great looking return from the NetConnection Debugger that confirms that I'm connected and returning propely. I get...

Result (object #2)
.....mRecordsAvailable: 3
.....serverinfo: (undefined)
.....uniqueID: 3
.....items (object #3)
..........[0] (object #4)
...............Activity: "Yes"
...............CUSNUM: 8699
...............PRYSID: 5
...............PTYID: 8333
...............RecentCount: 8
...............STNUM: 205
...............STNUM_SUB: "A"
...............StationItem: "Monitoring Regluar SVC"
...............StationType: "MON"
...............Status: "ACT"
...............WBHSTNID: 3
...............__ID__: 0
...............LastInspected (object #5)
...................."Sun May 4 00:00:00 GMT-0400 2003"
..........[1] (object #6)
...............Activity: "Yes"
...............CUSNUM: 8699
...............PRYSID: 5
...............PTYID: 8333
...............RecentCount: 3
...............STNUM: 100
...............STNUM_SUB: (undefined)
...............StationItem: "Monitoring Regluar SVC"
...............StationType: "MON"
...............Status: "ACT"
...............WBHSTNID: 1
...............__ID__: 1
...............LastInspected (object #7)
...................."Fri May 2 00:00:00 GMT-0400 2003"
..........[2] (object #8)
...............Activity: "Yes"
...............CUSNUM: 8699
...............PRYSID: 5
...............PTYID: 8333
...............RecentCount: 6
...............STNUM: 205
...............STNUM_SUB: (undefined)
...............StationItem: "Monitoring Regluar SVC"
...............StationType: "MON"
...............Status: "ACT"
...............WBHSTNID: 2
...............__ID__: 2
...............LastInspected (object #9)
...................."Sat May 3 00:00:00 GMT-0400 2003"
.....mTitles (object #10)
..........[0]: "WBHSTNID"
..........[1]: "StationType"
..........[10]: "STNUM"
..........[11]: "STNUM_SUB"
..........[2]: "StationItem"
..........[3]: "Activity"
..........[4]: "LastInspected"
..........[5]: "RecentTargetCount"
..........[6]: "Status"
..........[7]: "CUSNUM"
..........[8]: "PTYID"
..........[9]: "PRYSID"
.....views (object #11)
..........No properties

Which (though for the moment lacking positional x, y data) has all of the other attributes that I am trying to assign to my duplicated clips (aside from the inspected date which looks screwy to me)...

I've found that in flash I can use a couple of the recordset instructions that give me some summary info about the recordset:
//list of column names
rs.getColumnNames().join();
//The total number of records in the RecordSet
recordcount = rs.getLength();

But I'm feeling cornered by Recordsets otherwise. It seems great for presenting datagrids, but that's not really what I'm after. I need to use the values in that recordset to affect the appearance and elements of my movie...

I'm sure I'm just missing the boat here, anybody got an example or a method I can try here?

thanks,
Steve

View Replies !    View Related
Duplicate Movie Clip & Init Object
Hi all,

Has the duplicateMovieClip function been changed. a call such as


PHP Code:




for(i=0; i<=20; i++)
{
this.duplicateMovieClip("box"+i, i);
_parent["box"+i]._x = random(20);
}







This type of code used to work in duplicating movie clips. is the object declaration required with this call in flash mx 2004?

View Replies !    View Related
Duplicate Object Disappearing(simple Code)
i click to duplicate and i see it apear for a quarter second then it disappears.
what am i doing wrong?


Code:
onClipEvent (enterFrame) {
//make sure that duplicates dont move
if(this._name="Blue"){
this._x = _root.cur_x;
}}
onClipEvent (mouseDown) {
//duplicates blue and makes blue2
this.duplicateMovieClip("Blue2",1);
//puts blue2 at _x 50
_root.Blue2._x=50;
}
=Flash mx=

View Replies !    View Related
Array In Object Doesn't Duplicate Upon Instantiating
I guess I'm victim of my own misunderstanding of OOP but can somebody tell me why if I create two instances of an object which itself creates another array object, I end up referencing the same array ?

I've attached some oversimplified code to make things clearer. Why are both arrays containing the same data ? Aren't they different objects ?










Attach Code

class test
{
public var index:Array = new Array();


public function add(someValue:String):Void
{
this.index.push(someValue);
}

}


And then, here is the code in my .fla file

myTest1 = new test();
myTest1.add('abc');

myTest2 = new test();
myTest2.add('def');


trace(myTest1.index);
trace(myTest2.index);

The result I get is:

abc,def
abc,def


I was expecting:

abc
def

View Replies !    View Related
Hide Contents Of Swf? Is There Any Way Of Hiding The Contents Of My Main Swf?
When my main swf site is loaded in a browser, is there any way of hiding the contents of my swf from users? Right now, anyone can just go to the 'activity' window and download any of my pictures, scripts, etc....and i don't like that.
Thanks,
Dave

View Replies !    View Related
Loader Object For FLV, SWF
I'm trying to make a movie player of a sort that loads all the things in a folder and plays them one by one. This folder can contain images, flvs and swfs. Is this possible ? Anyone having some code or project lying around doing something similar, need help

View Replies !    View Related
[loader Object]
hey, i'm using a *stupid* loader that won't load certain pictures. yes, the path is correct. and yes, it will load other pictures in the same dir with very similar properties.

has anyone else run into this problem before???

View Replies !    View Related
Reusing Loader Object
Hi there

I am having some troubles with adding the same Loading object to the stage more than just one time. I am working on a project, where I need to use the same image several times at once. No problems loading the images, but I only want to load the one time off course!

Loading the images:

Code:
function loadImage():void
{
var imageLoader:Loader = new Loader();

imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageOnLoadHandler);
imageLoader.load(new URLRequest(urlArray[loadImageCounter]));

imageArray[loadImageCounter] = imageLoader;
}


Adding the images to the stage:

Code:
function addImagesToStage():void
{
for (var i:int = 0; i < imageArray.length; i++)
{
var imgDaysLoader:Loader = imageArray[i];
var imgHoursLoader:Loader = imageArray[i];

imgDaysLoader.x = 0;
imgHoursLoader.x = 200;

addChild(imgDaysLoader);
addChild(imgHoursLoader);
}
}

View Replies !    View Related
Loader Object Question
Lets say you are loading a image from a url into the loader object. How would you detect if that url is broken or the image doesn't exist then it would load a alternative image.

Thanks...

View Replies !    View Related
ButtonMode On Loader Object?
I'm using XML and a loader to dynamically load images (client logos) into my tesimonials page.

I want it so that when the user clicks on the image loaded into the loader, it takes them to the client's website.

Well, I have the link/click functionality working great...but there is no hand cursor when the user hovers over the image.....how can I set it so the loader shows the hand cursor when the user is over it???

I've already tried casting it as a MovieClip, but that throws me errors too...

View Replies !    View Related
ByteArray From Loader Object
Hello there!

With Loader.loadBytes(bytes:ByteArray) you can load a byte array into a loader object.

Is it somehow possible to get the ByteArray from a Loader object or from its LoaderInfo?

View Replies !    View Related
[object Loader] Not Reloading
hi, I have an XML image that I loaded into a sprite and then the sprite into an array, I'm trying to now retrieve the [object Loader] that is in the original array, and display it. however, I keep getting a blank space instead. Is there any particular way to do this?

View Replies !    View Related
Loader Object Hell
Not sure why, but I'm having trouble grasping the loader object's real functionality.

I understand images are children of the object and the object is a child of a sprite, but I'm still having problems and hopefully someone can walk me through this.

On my stage I have six sprites and in them I've loaded images. What I need to do is randomly fade one out and fade another in its place. The images need to fade completely out before fading in again.

I've got a timer setup for 3 seconds between image changes and in that time I'm having Flash choose the next sprite to replace and preload the image. The images are all very small so 3 seconds is long enough to preload.

My logic is this:

- choose a random sprite
- load the image
- timer elapses
- fade out sprite
- add loader to sprite
- fade in sprite
- repeat

How do I do this? Do I need two loaders for each sprite or just two for the whole movie?

Any help is appreciated.

:grimey

View Replies !    View Related
Object Loader Info
Hi--

I know I've done this before, but am having brain freeze or something and can't get it to work.

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:

var loader:Loader = new Loader();
var request:URLRequest = new URLRequest(imgPath+"1.jpg");
loader.load(request);
spriteArray[1].addChild(loader);



click function:


Code:

function click1(e:Event) {
trace (spriteArray[1].getChildAt(0).content);
}



my click1 function above returns [object bitmap]. I'd like something like to see "1.jpg". What am I missing?

Thanks!

:grimey

View Replies !    View Related
Loader Object Reference From MovieClip
Good afternoon coders. I'm trying to reference a loader Object on the maintime line from within a MovieClip. More clearly, when I press one of my buttons (myCars or myVideos) I need my transition movieclip named container to play. Once the movieclip reaches a particular frame, I need the code in that frame to run.


First, here's the code on the main timeline:


import flash.display.*;


var my_loader:Loader = new Loader();
addChild(my_loader);

var container:blue=new blue();
container.name = "myContainer";
container.x=10.0;
container.y=74.0;
this.addChild(container);


var lastLoaded:String;

myVideos.addEventListener(MouseEvent.MOUSE_DOWN, loadTheBaby);
myCars.addEventListener(MouseEvent.MOUSE_DOWN, loadTheCars);


function loadTheBaby (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay("motivate");

}
}

function loadTheCars (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay("motivate");

}
}

Now, here's the code I need to run when the movieclip named container reaches a certain frame:

stop();

//lastLoaded=e.currentTarget.name;
my_loader.load(new URLRequest(lastLoaded+".swf"));
my_loader.contentLoaderInfo.addEventListener(Progr essEvent.PROGRESS, loop);
my_loader.contentLoaderInfo.addEventListener(Event .COMPLETE, done);

function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(my_loader);
gotoAndPlay("closeup");
}



Here are the error messages:


1120: Access of undefined property my_loader.
1120: Access of undefined property lastLoaded.


the variable lastLoaded is on the main timeline, and the loader Object my_loader is also on the main timeline. So, I believe I need to reference the loader Object and the lastLoaded variable on the main timeline from within a movieclip. I tried root.my_loader; I tried parent.my_loader to no avail. I even tried to put the loader object and the lastLoaded var in the movieclip and ran into a laundry list of errors. Is there a new way to access objects and variables on the main timeline from within a movieclip? Please steer me in the right diirection. Thanks for reading.


xFLASHSTUDENTx

View Replies !    View Related
Dragging A Loader Object With StartDrag()
Is it possible to drag a Loader object with startDrag()? I have a dynamically loaded image I'm trying to make dragable. I get a "1061: Call to a possibly undefined method startDrag through a reference with static type flash.display:Loader." error. I assume it's because I can only drag MovieClips and Sprites.


ActionScript Code:
package {
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.events.Event;

    public class PhotoLoader extends MovieClip {

        public var photoDownloader:Loader = new Loader();

        public function PhotoLoader (event:Event):void {
            var url:String = "./files/" + fileReference.name;
            var photoUrl:URLRequest=new URLRequest(url);
            statusArea.text= fileReference.name + " loaded.";
            photoDownloader.mask = photoHolder;
            photoDownloader.load (photoUrl);
            addChild (photoDownloader);
        }
        private function onMouseDown (event:MouseEvent):void {
            stage.addEventListener (MouseEvent.MOUSE_UP, onMouseUp);
            photoDownloader.startDrag ();
        }
        private function onMouseUp (event:MouseEvent):void {
            stage.removeEventListener (MouseEvent.MOUSE_UP, onMouseUp);
            photoDownloader.stopDrag ();
        }
    }
}

View Replies !    View Related
Problem Loading In SWF Into Loader Object
Hi,

I need help (typical tight deadline so any help appreciated).

I have a Flash movie and on Frame 1 is my preloader, and on Frame 2 is a movieclip which has one frame within it.

The Movieclip then does some animation via AS3 and then creates a loader object and adds it to the display list. The AS3 code then attempts to load another SWF into the loader object (the SWF is in the same folder as the parent SWF).

I have a preloader that checks the loading of the loader object and that is running fine, but the SWF just doesn't load?

I don't know if this has anything to do with the line "var req:URLRequest = new URLRequest("Home.swf");" and the fact that im loading the SWF into the loader object which is within a movieclip?

My code for creating the loader object is as follows....



Code:
// First request the file
var req:URLRequest = new URLRequest("Home.swf");

// Next create a loader object
var loader:Loader = new Loader();

// Then tell the loader object to load the requested file
loader.load(req);

// Position the loader object
loader.x = 14;
loader.y = 14;
loader.width = 731;
loader.height = 451;
loader.alpha = 1;

// Now add the loader object to the stage
addChild(loader);

// Turn loading bar visibility on
mcLoadingBar2.visible = true;
mcLoadingBarBorder.visible = true;
loadingBar2.visible = true;

// Check the loading progress of the requested file (the data is stored in 'contentLoaderInfo')
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress);

// Run this event handler function every time the event listener is triggered
function checkProgress(p:ProgressEvent):void
{
var percent:int = (p.currentTarget.bytesLoaded / p.currentTarget.bytesTotal) * 100;
loadingBar2.text = String(percent + '%');
mcLoadingBar2.width = percent;

if(percent == 100)
{
removeChild(mcLoadingBar2);
removeChild(mcLoadingBarBorder);
removeChild(loadingBar2);
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, checkProgress);
}
}

View Replies !    View Related
Object Loader Loaded And Not Loading
hi, fancy title eh? hehe


anyhow, got a Q...

I loaded 5 JPG's into specific locations of an array via the URLRequest. So now when I trace my array:


ActionScript Code:
trace(getXMLlinkArray);
//[object Loader],[object Loader],[object Loader],,,,,,,,,,,,,,,,,[object Loader],[object Loader]

then later I'm looking to see if an index in an array (i.e., 10) is null and if it is, then I load it with another image. However, if NOT, then I want to take the existing [object Loader] and shove it into another array filled with sprites.


ActionScript Code:
var xmlImgHolder:Sprite;
var imgRotationHolder:Sprite;
var spriteHolderArray:Array = new Array();
var xmlImgHolder:Number = 0;

xmlImgHolder = new Sprite();
xmlImgHolder.addChild(getXMLlinksArray[imgHideRight]);
spriteHolderArray.splice(imgHideRight,1,xmlImgHolder);
imgRotationHolder.addChild(spriteHolderArray[imgHideRight]);

note: imgRotationHolder holds 5 xmlImgHolder's


THE PROBLEM: when I scan getXMLlinksArray and see that its NOT null, and i try to addChil to xmlImgHolder and then to spriteHolderArray, I just get a blank space.

The debuger is showing that spriteHolderArray contains some loader info and the appropriate URL up until I load it with the existing loader from getXMLlinksArray. Then it says it doesn't have any conentedLoadedInfo. Any ideas?

View Replies !    View Related
Adding Properties To A Loader Object
In theory a loader object inherits "object" for which you can add properties dynamically.
But you can't do that with a loader object...
Is this true?
//try to add a property "goobers" to loader object...
var pictLdr:Loader = new Loader();
var pictURL:String = "banana.jpg"
var pictURLReq:URLRequest = new URLRequest(pictURL);
pictLdr.goobers="goobers" //this fails
pictLdr.load(pictURLReq);
this.addChild(pictLdr);

View Replies !    View Related
Problem Loading In SWF Into Loader Object
Hi,

I need help (typical tight deadline so any help appreciated).

I have a Flash movie and on Frame 1 is my preloader, and on Frame 2 is a movieclip which has one frame within it.

The Movieclip then does some animation via AS3 and then creates a loader object and adds it to the display list. The AS3 code then attempts to load another SWF into the loader object (the SWF is in the same folder as the parent SWF).

I have a preloader that checks the loading of the loader object and that is running fine, but the SWF just doesn't load?

I don't know if this has anything to do with the line "var req:URLRequest = new URLRequest("Home.swf");" and the fact that im loading the SWF into the loader object which is within a movieclip?

My code for creating the loader object is as follows....









Attach Code

// First request the file
var req:URLRequest = new URLRequest("Home.swf");

// Next create a loader object
var loader:Loader = new Loader();

// Then tell the loader object to load the requested file
loader.load(req);

// Position the loader object
loader.x = 14;
loader.y = 14;
loader.width = 731;
loader.height = 451;
loader.alpha = 1;

// Now add the loader object to the stage
addChild(loader);

// Turn loading bar visibility on
mcLoadingBar2.visible = true;
mcLoadingBarBorder.visible = true;
loadingBar2.visible = true;

// Check the loading progress of the requested file (the data is stored in 'contentLoaderInfo')
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress);

// Run this event handler function every time the event listener is triggered
function checkProgress(p:ProgressEvent):void
{
var percent:int = (p.currentTarget.bytesLoaded / p.currentTarget.bytesTotal) * 100;
loadingBar2.text = String(percent + '%');
mcLoadingBar2.width = percent;

if(percent == 100)
{
removeChild(mcLoadingBar2);
removeChild(mcLoadingBarBorder);
removeChild(loadingBar2);
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, checkProgress);
}
}

View Replies !    View Related
How To Reference Loader Object Through Listener?
How do I reference Loader object through a listener?
for example:

ActionScript Code:
function Main():void{    var loader:Loader = new Loader();    loader.load(new URLRequest("image.jpg"));    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadCompleted);}function onLoadCompleted(e:Event):void{     //I have no access to loader here.    //How would i access it? So i could reposition, rotate, etc.     //ie. loader.x = 50;}

View Replies !    View Related
Tell Loader Object To Stop Loading?
how do I know if a Loader is loading something, and if it is, cancel/unload what it is doing and go back to it's initial state..

View Replies !    View Related
How Do I Make A Loader Object Into A Button?
I want to make a Loader object become a button. I am not sure how to give the Loader object button properties.
this is where I'm at:
Code:

var myArray:Array = new Array('zero.swf','one.swf','two.swf','three.swf');
for (var i:uint=0; i<myArray.length; i++) {
                var contentInitializeLoader:Loader = new Loader();
      contentInitializeLoader.name='containerMC_'+(i);
      myContent.addChild(contentInitializeLoader);
urlString=myArray[i];
contentInitializeLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, contentInitializeLoaded);
      contentInitializeLoader.load(new URLRequest(urlString));

function contentInitializeLoaded(e:Event):void {
trace('loaded');
var theMC=myContent.getChildAt(0);

// make theMC become a button

}



in AS 2, I would have done it like this:
Code:


theMC.onPress=function(){
trace(this.name);
}



thanks for any help.

Aubrey

View Replies !    View Related
Problem Loading SWF Into Loader Object
Hi,

I need help (typical tight deadline so any help appreciated).

I have a Flash movie and on Frame 1 is my preloader, and on Frame 2 is a movieclip which has one frame within it.

The Movieclip then does some animation via AS3 and then creates a loader object and adds it to the display list. The AS3 code then attempts to load another SWF into the loader object (the SWF is in the same folder as the parent SWF).

I have a preloader that checks the loading of the loader object and that is running fine, but the SWF just doesn't load?

I don't know if this has anything to do with the line "var req:URLRequest = new URLRequest("Home.swf");" and the fact that im loading the SWF into the loader object which is within a movieclip?

My code for creating the loader object is as follows....

Code:

// First request the file
         var req:URLRequest = new URLRequest("Home.swf");
      
      // Next create a loader object
         var loader:Loader = new Loader();
      
      // Then tell the loader object to load the requested file
         loader.load(req);
         
      // Position the loader object
         loader.x = 14;
         loader.y = 14;
         loader.width = 731;
         loader.height = 451;
         loader.alpha = 1;
         
      // Now add the loader object to the stage
         addChild(loader);
         
      // Turn loading bar visibility on
         mcLoadingBar2.visible = true;
         mcLoadingBarBorder.visible = true;
         loadingBar2.visible = true;
      
      // Check the loading progress of the requested file (the data is stored in 'contentLoaderInfo')
         loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress);
      
      // Run this event handler function every time the event listener is triggered
         function checkProgress(p:ProgressEvent):void
         {
            var percent:int = (p.currentTarget.bytesLoaded / p.currentTarget.bytesTotal) * 100;
            loadingBar2.text = String(percent + '%');
            mcLoadingBar2.width = percent;
            
            if(percent == 100)
            {
               removeChild(mcLoadingBar2);
               removeChild(mcLoadingBarBorder);
               removeChild(loadingBar2);
               loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, checkProgress);
            }
         }

View Replies !    View Related
Loader Object Reference From MovieClip
Good afternoon coders. I'm trying to reference a loader Object on the maintime line from within a MovieClip. More clearly, when I press one of my buttons (myCars or myVideos) I need my transition movieclip named container to play. Once the movieclip reaches a particular frame, I need the code in that frame to run.


First, here's the code on the main timeline:


import flash.display.*;


var my_loader:Loader = new Loader();
addChild(my_loader);

var container:blue=new blue();
container.name = "myContainer";
container.x=10.0;
container.y=74.0;
this.addChild(container);


var lastLoaded:String;

myVideos.addEventListener(MouseEvent.MOUSE_DOWN, loadTheBaby);
myCars.addEventListener(MouseEvent.MOUSE_DOWN, loadTheCars);


function loadTheBaby (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay("motivate");

}
}

function loadTheCars (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay("motivate");

}
}

Now, here's the code I need to run when the movieclip named container reaches a certain frame:

stop();

//lastLoaded=e.currentTarget.name;
my_loader.load(new URLRequest(lastLoaded+".swf"));
my_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);

function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(my_loader);
gotoAndPlay("closeup");
}



Here are the error messages:


1120: Access of undefined property my_loader.
1120: Access of undefined property lastLoaded.


the variable lastLoaded is on the main timeline, and the loader Object my_loader is also on the main timeline. So, I believe I need to reference the loader Object and the lastLoaded variable on the main timeline from within a movieclip. I tried root.my_loader; I tried parent.my_loader to no avail. I even tried to put the loader object and the lastLoaded var in the movieclip and ran into a laundry list of errors. Is there a new way to access objects and variables on the main timeline from within a movieclip? Please steer me in the right diirection. Thanks for reading.


xFLASHSTUDENTx

View Replies !    View Related
Problem With Loader Object, Some Users Donīt See The Content
Iīm having a weird problem where a Flash is loading another swf object through the a Loader object. For a certain group of users (in a different location), this swf does not load, and no error message or anything is returned.

For me and others in my office, this works without a hitch. Iīve tried adding various event listeners to the Loader, but it appears that for these people no events are fired. The other content in the main swf works just fine. This does not appear to be caused by firewall/adblockers/popup blockers, etc.

Iīm fairly new to Flash development, and I really have no idea where to start debugging this. Anyone ever experienced something like this? The swf that is supposed to be loaded is a loader itself, which again loads another, final swf. Everything is served through a webpage, so itīs really weird to see this inconsistent behaviour.

If anyone can give me some tips on where to start, it would be greatly appreciated.

View Replies !    View Related
Copyright Đ 2005-08 www.BigResource.com, All rights reserved