views:

2083

answers:

2

Hello,

This may be very simple, but I have no idea how to do this.

I created a photo gallery in AS3, everything is on one keyframe. In this photo gallery I have a link to home. My goal is, when someone clicks the "home" link I want everything to start over. Any ideas on how to do this in AS3?

Appreaciate it.

L.

+1  A: 

call flash player container
usually the HTML page and use JavaScript to reload the flash player

flash.external.ExternalInterface.call(jsFuncRestart);

jsFuncRestart is a JavaScript function in the HTML file

and now in the js function just create a new object and replace the current flash object
with the new one

Shvilam
Shvilam,Based on your script above, the jsFuncRestart will call a javascript function that is on the HTML? I'm a bit confused.
Ole Media
yes it is a JavaScript file in the HTML but if you have other container different then the HTML you can do the same.
Shvilam
Aren't there security implications in certain scenarios using JS via Externalinterface to reload the page?
bzlm
you are just calling a JavaScript function the JavaScript will not reload the entire page just create a new flash object and make it rendering again
Shvilam
Having him reload the page all over again is not good practice. Proper planning can allow for this not to be an issue, merely use function to place and re-position your images. Inside this function setup whatever code you use to place the images. (I like a for loop nested in a for loop).
Brian Hodge
It is not a good idea to reload assets that are REUSABLE, rather set their visible property to false, re-assemble or do what needs to be done before making visible again, then merely make visible in its orinal state. Far to many devs waste resources they intend to reuse only to load them again.
Brian Hodge
A: 

You probably animate everything with as3, right? Then just make a reset function that puts all the images back to their original place and start the animation all over.

monkee
This didn't deserve a negative mark... If you were to apply each objects init position as an instance variable you could easily use this to return them. Though the best best would be to have a function place them initially and reuse this same function, there is no need to wipe and reload.
Brian Hodge