Referencing objects inside an object

Beginning in Flash here!!!

Ive got a flash Document, that I have a command button on, which should set the contentPath of a loader component to an image, problem is, if he image component is on the same scene, it works great, however put it on a different scene, doesnt work at all

I tried to upload an example, but the extension isnt allowed!

HELP!!!!

Tony
tonelm54Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
julianopolitoConnect With a Mentor Commented:
the problem with scenes is that there are no scenes actually. Compiler turns scenes into labeled keyframes. When you create a keyframe every object in that keyframe is a newborn. So it is completely reinitialized . That's why you must not try to keyframe components or other dynamic objects, because flash has trouble keeping their state. So the best to do is really programmatic animation as suggested. But if you can't for some reason, and need to keep it with scenes, remember that everything you do in scene one to initialize the component , you must redo in scene 2, 3 or 4 so flash knows what you want. blue-genie solution might work well.

I would add to that :
//Scene 1 - frame 1
 stop();
var imgPath:String = "";
com_btn.onRelease = function() {
      imgPath = "img1.jpg";
      myLoader.contentPath = imgPath;
      nextScene();      
};
com2_btn.onRelease = function() {
      imgPath = "img2.jpg";
      myLoader.contentPath = imgPath;
      nextScene();      
};

//Scene 2 - frame 1
myLoader.contentPath = imgPath; //here you are just reloading the image. since it is already in the browser's cache, it will load almost instantaneously. Repeat it for every scene.


Also remember not to use keyframes in the layer where this component is during it's lifetime. If you do, you may need to do that of frame 1 for every keyframe, and depending on what you are doing it may not work.





0
 
trigger-happyCommented:
I would suggest that you avoid the use of scenes as it really gets in the way of how you are to use actionscript code. Another thing to note is that the component must really be on the same scene. If you need to hide the component from view, I would suggest that you just set the visibility property to false.

--trigger-happy
0
 
blue-genieCommented:
i agree with trigger-happy about using scenes but if you absolutely have to, look at this example.
I don't know what you're doing a you've not provided any clues in terms of code snippets.

assuming in scene1 i have the button, and scene 2 i have the loader component...
and you're trying to have the button in scene 1, when you click that it goes to scene 2 and the component loads what it needs to...
so in scene 1....

stop();
var imgPath:String = "test.gif";
com_btn.onRelease = function() {
      nextScene();      
};
 then in scene 2 ....
myLoader.contentPath = imgPath;

blu.
0
All Courses

From novice to tech pro — start learning today.