-
1. Re: swf rotator
Ned Murphy Feb 14, 2010 12:57 PM (in response to k.loy)What will your swf rotator do?
-
2. Re: swf rotator
k.loy Feb 14, 2010 1:06 PM (in response to Ned Murphy)I want to build the rotator as part of my portfolio. So it would not auto-play.
Maybe I need something mor like a swf gallery??
I have about 5 different swf I would like to show.
Thanks
-
3. Re: swf rotator
Ned Murphy Feb 14, 2010 1:16 PM (in response to k.loy)You can use the Loader class to load swf files.
-
4. Re: swf rotator
k.loy Feb 14, 2010 3:19 PM (in response to Ned Murphy)Ok thanks. I'm using the UI loader.
I'm having 2 problems.
1. One of the swfs was made in a much older version of flash. When it comes in it's dimensions are distorted.
2. I'm having the opposite problem with another. It's dimesions are too big. It was made in Flash CS3. It will only play if it has room for it's specified dimensions. How can I get it to scale proportionally.
Is it as easy asmovie.swf.x = .5
movie.swf.y = .5???
I guess I'm confuse mostly because the elements that need scaling are not movie clips in the library.
Thanks
-
5. Re: swf rotator
Ned Murphy Feb 14, 2010 3:30 PM (in response to k.loy)To scale anything you use either the width/height properties or the scaleX/scaleY properties.
Instead of using the UILoader you should try using the Loader class. It will not confine your content to a specific size.
-
6. Re: swf rotator
k.loy Feb 15, 2010 1:18 PM (in response to Ned Murphy)I'm sorry. I'm so new at this and AS is EXTREMELY challenging for me.
I just want to get a few common and basic AS 's under my belt.
What I need is probably very simple. But I can't get it to work.
I just need to be able to load the swf when the user clicks the button.
This is the code, but it's wrong. Where? How? I'm not sure.Could you take a look?
Don't laugh.
Thanks!!!
--------------
ldr_mc.addEventListener(MouseEvent.CLICK, loaderCompleteHandler);
var swfContainer:MovieClip;
var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.
addEventListener(Event.COMPLETE, loaderCompleteHandler);function loaderCompleteHandler
(evt:Event): void {
swfContainer = swfLoader.content as MovieClip;
addChild(swfContainer);
}swfLoader.load(new URLRequest
('http://www.palettedesign.com/v_daystreamed.swf'));
swfContainer.x = 200;
swfContainer.y = 200; -
7. Re: swf rotator
Ned Murphy Feb 15, 2010 1:44 PM (in response to k.loy)No need to apologize, that was a nice attempt and I'd even say it probably would have worked. I think the only part that throws me off is the very first line. In any case, here's a slightly different approach that creates the swfContainer as what it sounds like it is... the place where you will load your files into. And in this example I load the loader into it rather than isolating the loader.content into it after the INIT event triggers... INIT happens after he COMPLETE event and indicates the swf file is ready to roll...
// create the container to house the loaded files
var swfContainer:MovieClip = new MovieClip();;
addChild(swfContainer);
swfContainer.x = 200;
swfContainer.y = 200;var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.INIT, loaderInitHandler);function loaderInitHandler(evt:Event): void {
swfContainer.addChild(swfLoader);
}swfLoader.load(new URLRequest('http://www.palettedesign.com/v_daystreamed.swf'));
This stuff is challenging for anyone, so don't feel like you're an oddball--we all suffer it at one time or another. That fact that you suffered thru it this far rather than just asking for a handout speak well of you.
-
8. Re: swf rotator
k.loy Feb 15, 2010 2:00 PM (in response to Ned Murphy)Thanks Ned. I have many books on AS and am taking a class at the moment so maybe one day
I'll actually get it. Anyway, that first line is there because...don't I have to define a clickable button so AS knows when the load the swf.
There are 4 I want to be able to load, so there will have to be 4 buttons right? How do you link the swf with the appropriate eventListener??
Thanks
-
9. Re: swf rotator
Ned Murphy Feb 15, 2010 2:17 PM (in response to k.loy)Okay. The function you were naming in it is what threw me off. That function gets called when the file finishes loading.
Try to think it thru. You need to create another function that will be called by clicking that particular button that will set the value of the URLRequest and initiate a new instance of the Loader to load the new file. So you want to have a function that the button calls to assign the URLRequest value. That function will call another function that defnes the new loader, assigns an INIT listener, and initiates the loading. And that INIT function will process the addition of the new file (and removal of the old).
-
10. Re: swf rotator
k.loy Feb 15, 2010 7:33 PM (in response to Ned Murphy)
OK, so If figure a good part of this out. The addChilds are working fine. Thought there are some things that need fixing.I'm using each button to addChild and removeChild. It's causing somekind of error.
---------
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at palette_swfLoader_fla::MainTimeline/unclickF2()-----------
There is another issue, but I'll see if I can fix it before I post
Here's the code.
---------------------------------------------------------------------
var swf1Request:URLRequest = new URLRequest("v_daystreamed.swf");
var swf1Loader:Loader = new Loader();
dogs_mc.addEventListener(MouseEvent.CLICK, clickF1);
ann_mc.addEventListener(MouseEvent.CLICK, unclickF1);
pop_mc.addEventListener(MouseEvent.CLICK, unclickF1);
lana_mc.addEventListener(MouseEvent.CLICK, unclickF1);function clickF1(event:MouseEvent):void{
swf1Loader.load(swf1Request);
swf1Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadNowF1);
function loadNowF1(event:Event):void{
mc_contain.addChild(swf1Loader);
}
}
function unclickF1(event:MouseEvent):void{
mc_contain.removeChild(swf1Loader);
}
var swf2Request:URLRequest = new URLRequest("featureDesigner_lanadelrey.swf");
var swf2Loader:Loader = new Loader();
lana_mc.addEventListener(MouseEvent.CLICK, clickF2);
ann_mc.addEventListener(MouseEvent.CLICK, unclickF2);
pop_mc.addEventListener(MouseEvent.CLICK, unclickF2);
dogs_mc.addEventListener(MouseEvent.CLICK, unclickF2);function clickF2(event:MouseEvent):void{
swf2Loader.load(swf2Request);
swf2Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadNowF2);
function loadNowF2(event:Event):void{
mc_contain.addChild(swf2Loader);
}
}
function unclickF2(event:MouseEvent):void{
mc_contain.removeChild(swf2Loader);
}
var swf3Request:URLRequest = new URLRequest("AnnArmstrong.swf");
var swf3Loader:Loader = new Loader();
ann_mc.addEventListener(MouseEvent.CLICK, clickF3);
lana_mc.addEventListener(MouseEvent.CLICK, unclickF3);
pop_mc.addEventListener(MouseEvent.CLICK, unclickF3);
dogs_mc.addEventListener(MouseEvent.CLICK, unclickF3);function clickF3(event:MouseEvent):void{
swf3Loader.load(swf3Request);
swf3Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadNowF3);
function loadNowF3(event:Event):void{
mc_contain.addChild(swf3Loader);
}
}
function unclickF3(event:MouseEvent):void{
mc_contain.removeChild(swf3Loader);
}var swf4Request:URLRequest = new URLRequest("popfla_template.swf");
var swf4Loader:Loader = new Loader();
pop_mc.addEventListener(MouseEvent.CLICK, clickF4);
lana_mc.addEventListener(MouseEvent.CLICK, unclickF4);
ann_mc.addEventListener(MouseEvent.CLICK, unclickF4);
dogs_mc.addEventListener(MouseEvent.CLICK, unclickF4);function clickF4(event:MouseEvent):void{
swf4Loader.load(swf4Request);
swf4Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadNowF4);
function loadNowF4(event:Event):void{
mc_contain.addChild(swf4Loader);
}
}
function unclickF4(event:MouseEvent):void{
mc_contain.removeChild(swf4Loader);
} -
11. Re: swf rotator
Ned Murphy Feb 15, 2010 8:00 PM (in response to k.loy)I haven't read back thru the whole story but I think you may be overdoing it with all the event listeners. You only need to rem9ove the child in mc_contain , if it has one, you don't need to know what child it is. Also, do not nest named functioninside other functions.
function clickF1(event:MouseEvent):void{
swf1Loader.load(swf1Request);
swf1Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadNowF1);
}function loadNowF1(event:Event):void{
if(mc_contain.numChildren == 1){
mc_contain.removeChildAt(0);
}
mc_contain.addChild(swf1Loader);
} -
12. Re: swf rotator
k.loy Feb 17, 2010 8:27 PM (in response to Ned Murphy)That worked like a charm. The only thing now is -one of them has sound. When one of the others are clicked the visuals go away but the sound remains. Is this something to do with the sound class? I've never used that.
Also, the imported swf are not cropping. What was on the pasteboard in the original files appears when they are loaded. I tried setting a width and height to mc_contain but it didn't work.
I've uploaded a copy of the swf
Thanks for your help. I really appreciate it.
-
palette_swfLoader.swf 37.8 K
-
-
13. Re: swf rotator
quirksmode Feb 26, 2010 7:07 AM (in response to k.loy)Hi,
just came across this thread, I am trying to build exactly the same thing and found reading through your posts very helpfull indeed so thanks for the great advice/questions. I am looking to load in some swfs for a portfolio banner and have buttons generate dynamically based on how many swfs are needing to be pulled in (They will be numbered buttons counting up 1, 2, 3). Based on what I have read I already have enough info to create this, but my one concern was reading about how your sounds carried on playing even after another swf was selected.
I am not sure i fully understand how the loader class deals with the swfs once they are loaded. Ideally you would want it to load them all into cache and then remove them all except the first, but when you click a button the desired swf would then load back instantly from cache completely removing the previous swf (removing the sounds), though still holding it in cache if that makes sense. Does the loader class do this automatically or will it require some complex coding? Is the loader class capable of removing the swfs so the sound would stop playing? Ideally you want to be able to have full control of how the swfs are loaded and unloaded, are there any tutorials available that go into detail or am I expecting too much from the loader class?
Any help is greatly appreciated,
Dave
(Let me know if you solve you sound problem, just out of interest are you declaring the sounds to the stage/root? If you declare the sounds to be local to the swf that might stop them when you change swfs?)


