-
Load a swf into a cube-help needed
I have a red 50*50 SYMBOL cube called "RedCube" and i would like to load a swf into it called "A.swf" whilst still retaining the shape of the red cube.I dont want the newly loaded .swf to replace the cube but to appear as a background inside it.Can anyone help?
ALAN
Last edited by Alan Robotkin; 01-06-2009 at 07:28 AM.
-
Flactionscrish
I would load your A.swf into a brand new container, then call RedCube.addChild(A.swfContainer);
ktu[k-two]
he who hesitates is lost; so i guess i'll wander intently
Are you sure this is real?
Life is Love, Love is Blind, Blind we go through Life.
Life isn't hard, dealing with your self is.
The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.
-
Thanks For Interest But I Wanted To Keep To Actionscript
hi as i understood from your message it would involve using xml as append child is part of that language and if possible i was trying to solve the problem by just using actionscript
thanks
alan
-
Senior Member
Hi there!
To load an external .swf you can't import it into the library. You need to use the Loader class.
Also, we need to access the RedCube instance (the symbol in the library is just a class definition - we want to access the individual you've dragged onto the stage). So click on the RedCube on the stage and give it an instance name in the properties panel (under MovieClip, to the left of Swap....). I'll call it redCubeInstance because I'm so imaginative.
If you're coding into the timeline, this is what you put:
var ldr:Loader = new Loader();
ldr.load(new URLRequest("a.swf"));
//scale the.swf down to cube size.
//I'm imagining a.swf is 400x400
ldr.scaleX = 50/400;
ldr.scaleY = 50/400;
/* If the anchor point of the cube is at it's centre,
I need to replace a.swf */
ldr.x = -25;
ldr.y = -25;
redCubeInstance.addChild(ldr);
That should work. A couple of words of warning though:
Here, I've loaded a.swf assuming that it is in the same directory as your flash project. Otherwise you have to define the whole path to it. After that, if you move either .swf file, this will not work anymore. So if you upload your movie to the internet, it won't work, because it won't be able to find a.swf.
You'll have to upload a.swf somewhere, then in the line
ldr.load(new URLRequest("a.swf"))
you'll replace "a.swf" with the address for the uploaded a.swf, so something like
ldr.load(new URLRequest(""http://sites.google.com/site/myName/flashfiles/a.swf"));
It'll mean your flash movie won't be self-contained.
A far better technique would be to make your .swf just a MovieClip symbol in the library. Then in the properties panel for that symbol tick "export for ActionScript" and give it a class name (better than A - you want something descriptive like DogAnimation or something). Then the code will be much simpler:
var dogAnimationInstance = new DogAnimation();
//scale and place your DogAnimation
redCubeInstance.addChild(dogAnimationInstance);
and you movie will be self-contained.
I hope that made sense to you!
Last edited by Awoogamuffin; 01-07-2009 at 11:10 AM.
-
Re Thanks But No Thanks
hI THERE I DONT KNOW WHAT TO SY TO YOU.
Perhaps it is me and i am slightly paranoid at the moment cos i was expecting a relatively simple answer to my question.I have had a couple of other ideas that i could relate to like "Place an empty movie clip into the Red Cube which is the same size as the Red Cube i.e 50*50 and call that movie clip symbol A
and then load the .swf into that " , however i did try that but it did not work either.
I appreciate your help but it seems to me that the more you were trying to help me the more confusing it became.Or perhaps thats exactly what you had intended to acheive in the first place.Well maybee my paranoi is getting the better of me .As I have already explained i did not want to use append
child at all sinc ,and correct me if i a wrong,i thought that was just used in xml,whch i am trying to avoid.
I want an easy actionscript code to load a .swf into a 50*50 Red Cube so that the newly loaded movie just appears as its background within the 50*50 area but does not replace the clip.Am i too naive in beleiving that there must
be a simple ActionScript answer
p.s if you check out the very first thread in this list you may also note that my original and still unanswered question was something completely different
Alan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|