parent.AddChild not working after protecting swf using SWFProtection! - actionscript-3

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.

Related

Assigning externally loaded image to movieclip

I have existing "replay_btn" movie clip. Initially, on stage it is blank. In as3 code, I'm loading an external image using xml.
Like this,
var replaySlideImage:Loader = new Loader();
replaySlideImage.y = 561;
replaySlideImage.load(new URLRequest(xmlPath.replayButton.icon));
addChild(replaySlideImage);
Now, when I run the swf file, the loaded image goes on top of the replay_btn move clip. I want to know,
how do I make the "replay_btn" tell that the loaded image is your background image.
Use addChildAt() rather than addChild() to assign a DisplayObject's index when adding it to the stage.
addChildAt(replaySlideImage, 0);

Replacing movieclip

I m currently working on converting one of my as2 game project into as3 (flash pro cs4). But there is a problem on the background movieclip.
I have a function called disposemc:
function disposemc(mcname:MovieClip):void{
mcname.parent.removeChild(mcname);
mcname = null
}
Another function called changelayer:
function changelayer(mcname:MovieClip,layer:MovieClip):void{
layer.addChild(mcname)
}
So in main timeline frame 2 I have a movieclip on stage (placed in IDE) with instance name "bg_mc", then on main timeline frame 3 I have a DIFFERENT mc on stage with the SAME instance name "bg_mc". The purpose of this is to replace the old bg_mc by the new one.
The problem is,
In frame 2, I applied changelayer function to bg_mc and moved it into a child mc of root by addChild, and then applied a function of my CPU image post processing framework and added the bg_mc into an array.
After some stuffs happened, I went nextFrame to frame 3, and found that the new bg_mc didnot replace the old one, instead it overlaps.
So I tried disposemc function when leaving frame 2 to get rid of the old bg_mc, and at frame 3 I applied changelayer to bg_mc and added bg_mc to my render array.
And I found that the old bg_mc is off the stage but it is still rendering onto my bitmap data, means it is not nullified like it suppose to be in disposemc function. And it is also hard to access it because the name overlaps. When I call bg_mc in frame 3 it is the new one, but the old one still exists, and from the rendered bitmap data it can see it is still playing.
Will making the old mc stop in disposemc function help?
Can anyone give any help? If my structure of making bg is bad, is there any other way to override an instance with a different mc in library?
The purpose of this is to replace the old bg_mc by the new one
You work with MovieClip and frames. So use keyframes by design. If you need to place different background in third frame, don't program it, place it. If you want program, don't use MovieClip with keyframes as main navigation instrument.
Main timeline could be easily swapped with very simple logic and several movie clips with only one frame
//Some MovieClips from the library, with only one frame, still designed in Flash IDE
var currentScene:DisplayObject;
var home: MyHove = new MyHove()
var intro:MyIntro = new MyIntro();
navigate(home);
//after some interaction from the user, go to another page
navigate(intro);
//It will work like gotoAndStop... but better, and give you more control
function navigate(scene: DisplayObject):void{
if(currentScene != null){
removeChild(currentScene);
}
currentScene = scene;
if(currentScene != null){
addChild(currentScene);
//apply logic for swapping background
}
}

Flash var Loader issue - animation changing

So, I've use a loader action script for a few banners I've been working on, and usually things go relatively smoothly (for Flash). However, the animation changes once I guide the image to the code. Has this happened to any one else? Below is the code I am using:
var imageLoader:Loader = new Loader();
var image:URLRequest = new URLRequest("http://972b6ac7e316515e1890-2848ccf658e0edc35f614dd3380d9fcb.r27.cf2.rackcdn.com/Background_othersizes.png");
imageLoader.load(image);
addChild (imageLoader);
I assume you have created animation in the Flash IDE with static image (linked from the library), and now you try to add image in runtime. Loading of the image is asynchronous process, so I would recommend account it in your animation and logic.
Also place in your MovieClip where image will be loaded, transparent shape as a background, of the same size as image, so environment will be aware of display object size, and all your transformations over MovieClip will be accounted accordingly. Also check placement and scaling of the image.

How to make a frame1 in the timeline, to be my startpage, when I already have a frame on the first timeline?

I have 3 layers in the timeline, and I want to make a new layer, and then use the new layer to be my first frame (like a startpage).
How do I do that?
Flash does not support show/hide of layers. Learn about working with Movieclips. You should find a lot by just searching for it.
myStartClip.visible = true;
A "shaking screen" means you probably have compile errors.
Don't use layers or frames (aside from the first frame where you put all your code as usual of course).
It's an AS3 exercise, which means you should be working mainly in AS3 code, and not in frames and layers.
You put the "start page" in a container, which can be a Sprite or a MovieClip.
The "start page" can contain for instance a background, a textfield with some instructions and a start button.
This means that you have to create a new container for instance
var startContainer:Sprite = new Sprite();
addChild(startContainer); // and maybe position it with x and y
Then you create the things you need on your start page
var infoTf:TextField = new TextField();
infoTf.text = "some game description and how to play";
var bg:SomeBackground = new SomeBackground();
var startBtn:SomeBtn = new SomeBtn();
startBtn.addEventListener(MouseClick.CLICK, handleMClick_startGame);
And then you add these things to the container.
startContainer.addChild(bg); // add the other things too of course
Then when you press the startBtn, you use removeChild on the entire container and don't forget to remove the eventListener for the startBtn
After that you add the content for the game either directly on the stage, or to another mainContainer if you so prefer.
And in the end you use the same technique for the game over page.

Trouble using Loader, can't access properties of loaded swf

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;