nested loadMovie & duplicateMovieClip mess

  • om_optical
  • Newbie
  • Newbie
  • om_optical
  • Posts: 8

Post 3+ Months Ago

I've read a few posts on similar topics, and there's gotta be a work around somewhere, but nothing I've found in 12 hours searching has given any hints to a solution to this humdinger :

The App : Is a system to design shop floor layouts by dragging around MC's

The Architecture : php, mySQL + Flash

The Problem : All of the product images are stored on the server and uploaded via the web, when the flash app starts it hits a php script which tells it which images are appropriate for this store. I've got some preloaders and load in all of the images to container objects fine. After the preloading is finshed I then assign the container objects the functionality they need (drag and drop, legal placement, that kind of thing)

So far so good. Then I stash all of these objects off screen to be "minted" - duplicated when a user wants to place a new one in the store.

So, of course when I duplicateMovieClip the container, the innerMC containing the loaded image is not copied.

OK, plan B -
duplicatedMc.innerMc = originalMc.innerMc.duplicateMovie
no play

Plan C -

preload another array full of references just plain image movie clips, and then duplicate these into the innerMc's of the duplicate parents.

again, no joy.

It's starting to look like the only way to do this is to get the image from the server each time a user needs a new object, pause the system while it loads, add the functionality to it, and then resume the system. This can't be done though, as the images are all quite large (zooming plays a large part in this project), and there's 6 of em per product.

There's only way I can think of around this, and it's bad news :

do 50 loads of each product at initialisation phase and hope that the storekeeper doesn't want to only stock cornflakes, which would make for a long wait at initialisation, but no hang ups during run time

So, I'm stuffed...

Anyone know if it's possible to make a library object from one created via AS ? That would solve everything...

Or if anyone has any info about the way Flash caches loaded content this might make the load times bearable.

Any help much apppreciated.. come to think of it - if some one can be charitable here, I'll be charitable too and do a $50 donation to a charity of your choice once this project is put to bed :)
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

Whoooa! 50 bucks? Do you have any idea how many Budweiser I can get with that amount of money??? Obsene!!!

Well, jokes aside, I have a quick question:

Can you come up with a page in PHP that would load those files that you say are on the server, dynamically? PHP is not my forte, I prefer ASP, but if you can loadt hem in a PHP page (forget Flash for a mimute) then it should get easier down the road... Even if it's just $ 25... LOL... :)
  • om_optical
  • Newbie
  • Newbie
  • om_optical
  • Posts: 8

Post 3+ Months Ago

Hey - thanks for your tip -

Not entirely sure what you mean though - PHP tells flash which files to get, but doesn't actually send binary data (interesting approach... hmmm - wonder if this is possible)

Toyed with the idea of building swf's in MING, but they would have come a cropper when I tried to copy em too (what with the jpegs being in contaioner objects, and the need to dynamically size em, post load)

The "solution" turned out to be to preload everything which might be needed before letting the user see the movie. Then when they selected a new product create the movie clip from scratch ->

- create empty container MC
- load jpeg into child MC (with loader)
- add functionality and size once it's loaded

The delay problem wasn't as bad as I thought it would be, as flash does seem to mostly cache the images which I loaded at the initialisation phase. I think they're cached on disk though - rather than in ram, as they still take a little while to load.

Any ideas on how Flash caches dynamic content ?

Damn you Macromedia - that's a bit of an oversight not being able to duplicate Mc's formed by LoadMovie - or child Mc's... Or copy child MC's into other child MC's

I tell you, if the shop wasn't in Thailand I'd take my CD, and get my $3 back :)

Your game idea sounds wicked BTW... good luck with it, and let me know when there's something playable...

bests,

om
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

OK, here is something I made... Check out this link, look into the fla file and go from there:

http://www.worldkit.com/wknforum/forums/thread-view.asp?tid=6&posts=27

When playing with it, enter any number in the input box and hit the button... It should load dynamic images from the albums... I tried number 73, but any number should carry a pic...

Hope it helps... :) And thanks for the "wicked" thingy... LOL...
  • om_optical
  • Newbie
  • Newbie
  • om_optical
  • Posts: 8

Post 3+ Months Ago

Hey man, thanks for the tip, I probably shoudl have explained myself better, here's the code I use to load it some code :

Code: [ Select ]
    prodObj.childMc.loadMovie("http://212.100.238.153/etc/"+imgFilename);
    prodObj.isLoaded = false;
    prodObj.onEnterFrame = function() {
        if (!this.isLoaded) {
            var i1h = this.childMc;
            var i1Loaded = i1h.getBytesTotal()>0 && i1h.getBytesTotal() == i1h.getBytesLoaded();
            trace("*** loading : "+this.pName+" ("+i1h.getBytesLoaded()+" of "+i1h.getBytesTotal()+")");
            _root.statusTxt.text = "loading : "+this.pName+" ("+i1h.getBytesLoaded()+" of "+i1h.getBytesTotal()+")";
            if (i1Loaded) {
                this.isLoaded = true;
            }
            // wait till it's loaded so when I set the size the size it doesn't kill the parents size
            if (this.isLoaded) {
                _root.statusTxt.text = "loaded : "+this.pName;
                if (this.needsSchooling) {
                    sendToSchool(this); // assign drag and drop and other functionality to MC
                } else {
                    borstal(this);
                }
            }
        }
    }
  1.     prodObj.childMc.loadMovie("http://212.100.238.153/etc/"+imgFilename);
  2.     prodObj.isLoaded = false;
  3.     prodObj.onEnterFrame = function() {
  4.         if (!this.isLoaded) {
  5.             var i1h = this.childMc;
  6.             var i1Loaded = i1h.getBytesTotal()>0 && i1h.getBytesTotal() == i1h.getBytesLoaded();
  7.             trace("*** loading : "+this.pName+" ("+i1h.getBytesLoaded()+" of "+i1h.getBytesTotal()+")");
  8.             _root.statusTxt.text = "loading : "+this.pName+" ("+i1h.getBytesLoaded()+" of "+i1h.getBytesTotal()+")";
  9.             if (i1Loaded) {
  10.                 this.isLoaded = true;
  11.             }
  12.             // wait till it's loaded so when I set the size the size it doesn't kill the parents size
  13.             if (this.isLoaded) {
  14.                 _root.statusTxt.text = "loaded : "+this.pName;
  15.                 if (this.needsSchooling) {
  16.                     sendToSchool(this); // assign drag and drop and other functionality to MC
  17.                 } else {
  18.                     borstal(this);
  19.                 }
  20.             }
  21.         }
  22.     }


so, that's all fine...

the big headache was, then doing a

prodObj2Ref = duplicateMovieClip(prodObj, "prodObj2", newDepth);

and hey presto, someones run off with me child !

thanks for showing an interest though - the project is just about finished after another all nighter 8|

can't wait to put it to bed and do some proper work, like a game...

don't know how old you are, but,there used to be this cool game on the C64 called elite...

dreaming of online, multiplayer, flash based, space trading fighting thing :o

thanks again,

om
  • om_optical
  • Newbie
  • Newbie
  • om_optical
  • Posts: 8

Post 3+ Months Ago

oh also...

prodObj2Ref.childMc = duplicateMc(prodObj.childMC... etc)

don't happen either :( apparently you can't copy nested clips across MC's
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

True. You can't...

But, talking about the prior post, the code you are placing is basically no more than a preloader in my opinion, or am I missing something there...?

And what is a borstal function, unless it has nothing to do with this?

Never heard of some elite game, but just for peeps, I'm 40 and loved the C64s... :)

Another thing:
Instead of var i1h = this.childMc;
did you try _root.i1h = this.childMc; ? :)
  • om_optical
  • Newbie
  • Newbie
  • om_optical
  • Posts: 8

Post 3+ Months Ago

"And what is a borstal function, unless it has nothing to do with this?"

- you know how it is at four in the morning - the sendToSchool function taught the little object to do all the important things in its life :|

the borstal function is for those bad objects, who will never come to much...

you're right about the code - it was nothing more than a preloader - which is waht I did with everything... then I didn't load the object (during the running of the system) It works quite good now - there's a tiny glitch when it loads new products, but that's fine.

And - it's always the way - now I've finished the project (happy client too :) - I've thought of a way to stop it flickering - have one spare copy of each product MC ! Keeep if off screen, and once it's used, blap the spare one on and make another !

Perhaps Elite was a British thing... vector(ish) graphics and massive universe.

so, which charity am I to send the 50 Budweisers ? :) (budvars - surely !)
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

Hehehe...

A single greeting at my little site (or forum) is more worth than the 50 Buds... ;)

Besides, with the hurricane jeanne coming up my nostrils I had to stack up beer, I am sitting next to a pile of beer boxes as we speak (Publix... where the pleasure is saving... LMAO)... :)
  • gladden
  • Beginner
  • Beginner
  • gladden
  • Posts: 44

Post 3+ Months Ago

Hi,

I am not sure if this is what you’re looking for, but here is my advice. Create a class (in an action script file) that contains all the methods, i.e. enterFrame. Then create an empty movie clip and link it to your class. Then attach the movies to your movie clip.

What will happen is that the movies you load will all have the behavior you’d expect because they all link to the same class.


It’s not trivial action scripting but you’ve done the most part of it already
  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

Oh, well my friend...

You are on a different League, I didn't get to the chapter where you make your own classes... LOL :) Great idea there!
  • om_optical
  • Newbie
  • Newbie
  • om_optical
  • Posts: 8

Post 3+ Months Ago

gladden wrote:
Hi,

I am not sure if this is what you’re looking for, but here is my advice. Create a class (in an action script file) that contains all the methods, i.e. enterFrame. Then create an empty movie clip and link it to your class. Then attach the movies to your movie clip.

What will happen is that the movies you load will all have the behavior you’d expect because they all link to the same class.



Hi, thank you so much for the advice, which sounds as though it will work perfectly. Will try it over the weekend.

You *

thanks again :)
  • gladden
  • Beginner
  • Beginner
  • gladden
  • Posts: 44

Post 3+ Months Ago

Glad to hear that helped.

Post Information

  • Total Posts in this topic: 13 posts
  • Users browsing this forum: No registered users and 15 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.