Re: [BULK] Re: [Flashcoders] Unloading an SWF in Flash and controlling the loadedSWF

2008-09-02 Thread eric e. dolecki
hehe oops - .alpha = 0.2;

On Tue, Sep 2, 2008 at 1:11 PM, eric e. dolecki <[EMAIL PROTECTED]> wrote:

> I think you want to listen for the event of the loader being loaded & then
> use .content for it.
>
> loader.addEventListener( Event.COMPLETE, iAmLoaded_Drunk );
>
> function iAmLoaded_Drunk( e:Event ):void
>
> {
>
>  var lo:Loader = e.target as Loader;
>
>  lo.content.alpha = 20; // what you actually loaded
>
> }
>
>
>
> On Tue, Sep 2, 2008 at 12:55 PM, Lord, Susan, CTR, DSS <
> [EMAIL PROTECTED]> wrote:
>
>> Thanks Paul,
>>
>> I rewrote the code, so its easier to read:
>>
>> var request:URLRequest = new URLRequest("hotword.swf");
>> var loader:Loader = new Loader()
>>
>> function displayHotword(evt:Event):void {
>> loader.load(request);
>>addChild(loader);
>>loader.x = 100;
>>loader.y = 150
>> }
>>
>>
>> btClassified.addEventListener(MouseEvent.CLICK, displayHotword);
>>
>> My question is, how do I control the instance that is now on the stage?
>> Say I wanted to create a function that would change the opacity of that
>> movie or something like that. How do I reference that item. In the old
>> flash, I would create a movie clip that would hold the swf and reference
>> that instance name. With this new method, I have no instance name to
>> reference.
>>
>>
>> Also, I can't seem to "talk" to the file.  If they click a button within
>> the file (the close button), I want the popup removed from the stage.
>> Right now, I am hiding (visibility = false) the clip and putting the
>> code to hide it within the loaded swf.  I am not communicating with the
>> clip from the parent file.
>>
>> Any direction you could provide is very much appreciated!
>>
>> Thank you!
>> Susan
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [BULK] Re: [Flashcoders] Unloading an SWF in Flash and controlling the loadedSWF

2008-09-02 Thread eric e. dolecki
I think you want to listen for the event of the loader being loaded & then
use .content for it.

loader.addEventListener( Event.COMPLETE, iAmLoaded_Drunk );

function iAmLoaded_Drunk( e:Event ):void

{

 var lo:Loader = e.target as Loader;

 lo.content.alpha = 20; // what you actually loaded

}



On Tue, Sep 2, 2008 at 12:55 PM, Lord, Susan, CTR, DSS <
[EMAIL PROTECTED]> wrote:

> Thanks Paul,
>
> I rewrote the code, so its easier to read:
>
> var request:URLRequest = new URLRequest("hotword.swf");
> var loader:Loader = new Loader()
>
> function displayHotword(evt:Event):void {
> loader.load(request);
>addChild(loader);
>loader.x = 100;
>loader.y = 150
> }
>
>
> btClassified.addEventListener(MouseEvent.CLICK, displayHotword);
>
> My question is, how do I control the instance that is now on the stage?
> Say I wanted to create a function that would change the opacity of that
> movie or something like that. How do I reference that item. In the old
> flash, I would create a movie clip that would hold the swf and reference
> that instance name. With this new method, I have no instance name to
> reference.
>
>
> Also, I can't seem to "talk" to the file.  If they click a button within
> the file (the close button), I want the popup removed from the stage.
> Right now, I am hiding (visibility = false) the clip and putting the
> code to hide it within the loaded swf.  I am not communicating with the
> clip from the parent file.
>
> Any direction you could provide is very much appreciated!
>
> Thank you!
> Susan
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [BULK] Re: [Flashcoders] Unloading an SWF in Flash and controlling the loadedSWF

2008-09-02 Thread Lord, Susan, CTR, DSS
Thanks Paul,

I rewrote the code, so its easier to read:

var request:URLRequest = new URLRequest("hotword.swf");
var loader:Loader = new Loader()

function displayHotword(evt:Event):void {
loader.load(request);
addChild(loader);
loader.x = 100;
loader.y = 150
}


btClassified.addEventListener(MouseEvent.CLICK, displayHotword);

My question is, how do I control the instance that is now on the stage?
Say I wanted to create a function that would change the opacity of that
movie or something like that. How do I reference that item. In the old
flash, I would create a movie clip that would hold the swf and reference
that instance name. With this new method, I have no instance name to
reference.   


Also, I can't seem to "talk" to the file.  If they click a button within
the file (the close button), I want the popup removed from the stage.
Right now, I am hiding (visibility = false) the clip and putting the
code to hide it within the loaded swf.  I am not communicating with the
clip from the parent file.

Any direction you could provide is very much appreciated! 

Thank you!
Susan 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Unloading an SWF in Flash and controlling the loadedSWF

2008-09-02 Thread Paul Andrews

Hi Susan,

Check out the documention for the Loader() Class - you'll find that the 
loaded swf is a child of the loader.


AS3 won't unload instances while there are any references to them. You can 
try unloading the loader - it won't be unloadable while the 'i' variable is 
refering to the instance. I think it will be eligible for GC once I has been 
pointed at a new Loader instance.


It's usually helpful to type variables and give them meaningful names - for 
example var i = new Loader() might be written as var swfLoader:Loader = new 
Loader();


This will make the code  easier to follow especially since the compiler will 
know what the variable refers to (since you've specified the class) and can 
make sure that the variable is used correctly. I usually expect variables 
called 'i' to be counters of some kind.


Good luck!

Paul


- Original Message - 
From: "Lord, Susan, CTR, DSS" <[EMAIL PROTECTED]>

To: "Flash Coders List" 
Sent: Tuesday, September 02, 2008 4:53 PM
Subject: [Flashcoders] Unloading an SWF in Flash and controlling the 
loadedSWF





Hi there,

I have a newbie question for you. I posted this to the newbie list and
recieved no response. I am wondering if it might be too advanced for
that  list. For those of you who are on both lists, please excuse the
double post.

I have a pop-up box that I am loading as an external swf, using the
following code:

function displayHotword(evt:Event):void {
trace("in function");
var i =new Loader();
addChild(i);
i.load(new URLRequest("hotword.swf"));
i.scaleX = 1;
i.scaleY = 1;
i.x = 100;
i.y = 150
;
}
btClassified.addEventListener(MouseEvent.CLICK, displayHotword);


I am not sure how to unload the movie. I am also not sure on how to
control the movie when it is on the screen. In AS2, I always used a
movie holder so I had an instance... with this method, I don't know what
the movie instance would be.

Right now to close the loaded SWF, I am using following code within the
loaded swf file.

function closeHotword(evt:Event):void {
this.visible=false;

}
btClose.addEventListener(MouseEvent.CLICK, closeHotword);

And simply making it invisible from the swf file.

I am wondering if there is a better way to do this?  It seems like this
would cause some memory issues eventually as each time the student will
click on the link to load pop-up window, it would create a new instance
of the movie and just hide it, instead of unloading it.

I am new to AS3 and not sure how to approach this.

Any help you could provide is appreciated!

Thanks!




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders