May not have asked question correctly so I’m asking again. I’m using Flash AS3 with code in actions layer.
Main movieclip onstage is : design_mc. Within it is a movieclip already in place onstage with an instance name clipart_mc.
Now I’m also loading a ListBox to the stage and each time a selection is made from listbox myLoader9 is used to load selected .swf into design_mc.clipArt_mc.
Now within each of the .swf files loaded into design_mc.clipArt_mc there is a mc I’d like to color transform called color_mc.
So now the listbox is onstage and I make a selection that places heart.swf inside of design_mc.clipArt_mc. I want to access heart.swf so I did this:
var child:DisplayObject = myLoader9.content.contentLoaderInfo.content.color_mc;
var colorTrans3:ColorTransform = new ColorTransform();
var trans3:Transform = new Transform(child);
I still can not get to heart.swf. Can anyone help please?
Anne
I'm working with Embedded SWFs here, but I think it's the same. I can get my MovieClip from the Loader "content" property. Like this:
var myMC:MovieClip = MovieClip(myLoader9.content);
Try this way, instead of using "content.contentLoaderInfo.content".
:)
I got it. I gave the loader a name:
myLoader9.name = "currentClip";
Then I can target in main movie using:
var child:DisplayObject = MovieClip(parent).design_mc.clipArt_mc.getChildByName("currentClip").content.color_mc;
Related
How do I create the AS3 equivalent of a moviescript with multiple frames?
If I were using the Flash IDE, I would put whatever stuff I wanted on frame 1, other stuff on frame 2, etc. and step through the frames as the user clicks the "Next" button. Or perhaps put in keyframes and tweens and let the system play through the frames at a fixed rate.
I don't see a way to do this in AS3, even though all the descriptions I've seen say that Flash CS3 turns your timeline and frames into ActionScript, and I would like to know how to do the same without having the Flash IDE (e.g., working in Flex).
Let's take a simple example: I have 3 frames. Frame 1 contains the splash page (a lot of text and a button). Frame 2 contains one image, one label, and one button that says "Next". Frame 3 contains two images and one label.
How would you build that in AS3?
Flash CS
You will put your logic code in key frame, and do something with the text,button etc. It's hard for multi uses to edit and work on it.
AS3 use IDE like Flash Builder
Flash CS will is just used to make animation swf
Assume we have a swf named A.swf
A.swf
mySymbol (have a link name like com.mySymbol)
subSymbol1(named subSymbol1)
nameLabel(named label1)
addressLabel(named label2)
subSymbol2(named subSymbol2)
nameLabel(named label1)
addressLabel(named label2)
Here is how you use A.swf in flash builder
Class MyView {
public function MyView() {
var loader:Loader = new Loader();
var url:String = "A.swf";
var urlReq:URLRequest = new URLRequest(url);
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load(urlReq, loaderContext);
}
private function onLoadComplete(e:Event):void {
//now you can get defined symbols in A.swf
var c:Class = getDefinitionByName(" com.mySymbol");
//get a mySymbol instance
var mc:MovieClip = new c();
//add to parent
some.addChild(mc);
/*what you said you got three frames,
Just like set like subSymbol1 and subSymbol2 in this A.swf
add some text in subSymbol1 and other in subSymbol2 */
mc.subSymbol1.visible = false;
mc.subSymbol2.visible = true;
}
}
It could make the program and view indenpendent in a way.
You would most likely just create each of those frames as an individual Sprite.
When you want to switch between them, you'd use removeChild() to hide the old one and addChild() to show the new one.
If you want to get fancy you can add Tweens (either built-in or from a tweening engine). This would allow you to fade between the frames, or scale them in, or slide from left to right, or whatever.
If you need to do more complex sequenced animations you can look into something like TimelineLite to help with that.
I'm trying to convert an old project of mine to use Starling for some extra performance.
I've come to a problem when I'm loading my SWFs and trying to display them.
Here is the code I used before: (no Starling)
private function swfLoaded(e:LoaderEvent):void {
var spr:Sprite = new Sprite();
spr = e.currentTarget.content;
bitmapData.draw(spr ...);
}
The problem when I'm using Starling is that the currentTarget.content is a flash.display.displayObject.
cannot convert com.greensock.loading.display::ContentDisplay#90ffec1 to starling.display.Sprite
I want to find a way to "convert" the flash.display.displayObject into a starling Sprite.
I also want to be able to store the loaded swfs content into a array as a sprite.
Thanks in advance,
Tompa
You're overwriting spr with a different value immediately after you create it, for one thing.
After you do the bitmapData.draw() call:
var tex:Texture = Texture.fromBitmapData(bitmapData, false, false);
The new texture can then be used to create a Starling Image sprite.
I want access MovieClips Dynamically from the external flash file.
There are 5 MovieClips named Loader_1_mc, Loader_2_mc,.... Loader_5_mc like so. Each of this movieClip contain 5 movieClips by named acc_1,acc_2,...... acc_5 like.
How Can I access From the swf file. i tried few steps within nested loop
accChrome["Loader_"+bInd+"_mc"].["acc_"+sVal].y = 780;
and,
accChrome["Loader_"+bInd+"_mc"]["acc_"+sVal].y = 780;
and
MovieClip(accChrome["Loader_"+bInd+"_mc"])["mask_"+sVal].y = 780;
and
accChrome["Loader_"+bInd+"_mc.mask_"+sVal].y = 780;
i wont get it..
Please Help me...
Thanks in advance
Accessing Movieclips in movieclips (Stack Overflow Question)
var clipInClip:Acc; // class name is Acc in this case, but its whatever
clipInClip = ((this.Loader_1_mc as MovieClip).acc_1 as Acc);
clipInClip should properly hold acc_1 in this example. As for looping through using parts of strings, look at dthoughts post on this page... http://www.kirupa.com/forum/showthread.php?259717-eval-in-actionscript-3 (3rd post)
This isn't too great of an answer, so if you get stuck, ask!
I usually, use SWF Protection, to protect my swf's from decompiling.
It also adds a load bar to the swf.
The problem is that I have codes like this:
logo= new marca();
parent.addChild(logo);
logo.mouseEnabled=false;
I use parent, because I need to put the movie clip above everything, because my application allows the user to add a lot of things to the stage, so a don't want anything covering the logo.
The application works well while unprotected, but If I protect it using SWF Protection, then, I get just white screen. Nothing appears after loading.
Is there another way, to put a movieclip above everything, without being necessery to add a ON ENTER FRAME LISTENER, to update the movieclip deph, to keep it above everything?
You can use addChildAt instead of addChild to add your other clips to the stage under the logo's level.
var levelUnderLogo:uint = numChildren == 1 ? 0 : numChildren-2;
clipYouWantUnderTheLogo = new MovieClip();
addChildAt(clipYouWantUnderTheLogo, levelUnderLogo);
edit: You can also put every other clip inside another clip that is always under the logo.
var base = new MovieClip();
addChild(base);
var logo = new Logo();
addChild(logo);
// Add all your other objects into the "base" clip.
var someClipUnderTheLogo = new MovieClip();
base.addChild(someClipUnderTheLogo);
You are getting the white screen because the swf embed method is breaking in the javascript. Basically you have a javascript error.
Because you did not post code I can't help you much more. All I can say is put alerts in the javascript and see how far you get.
I have Loader object containing loaded swf. I don't know how the shape of this swf looks like - it's not necessarily rectangular.
I want to add some light reflection on it. I need to mask this reflection with Loader, but in the same time I need this Loader to be visible.
I don't want to load swf twice, because it may contain some dynamic, script-generated content, which can produce different results in each Loader.
And that's quite a problem, isn't it? Any ideas?
Image: http://www.freeimagehosting.net/uploads/12e6b9cd63.jpg
you could add your instance of the loaded swf to the stage, and for the reflection use he same movieclip/sprite and draw it to a new BitmapData. do the transformations needed and then add to stage.
Or imagine the following situation, instead of having the swf that is loaded adding it's own graphics to library you could do this from the loading application, so for instance, give the instance name of MyDisplayObject to the movieclip in the loaded swf and export to actionscript. After you load the swf you could use the following code to access the library, so you can add this object number of times you need, in you case 2.
here is the code (from adobe live docs)
function initHandler(e:Event) {
var applicationDomain:ApplicationDomain = e.target.applicationDomain; // e.target is the loaderInfo object
var testClip:Class=applicationDomain.getDefinition("testClip") as Class;
var clip = new testClip();
addChild(clip);
var reflection = new testClip();
addChild(reflection);
reflection.y= 100;
}
Hope this get's you on the right track.