i made a simple test example in as2. This contains two buttons with the following handlers.
_root:
on (release)
{
this.loadMovie("AS3.swf");
}
_root.test.testmc:
on (release)
{
test.testmc.loadMovie("AS3.swf");
}
The AS3.swf is a video player(using youtube as3 api). If i load it into _root it works, but if i want to load it into any other place it doesn't. I searched and found this from adobe:
"SWF files written in ActionScript 1.0 or 2.0 cannot load SWF files written in ActionScript 3.0. This means that SWF files authored in Flash 8 or Flex Builder 1.5 or earlier versions cannot load ActionScript 3.0 SWF files.
The only exception to this rule is that an ActionScript 2.0 SWF file can replace itself with an ActionScript 3.0 SWF file, as long as the ActionScript 2.0 SWF file hasn't previously loaded anything into any of its levels. An ActionScript 2.0 SWF file can do this through a call to loadMovieNum(), passing a value of 0 to the level parameter."
Is the "_root part" of my code working because of the above "exception rule"? I am new to flash(yeah you could ask why i started with as2, unfortunately not my choice...) and i wonder if my thinking is right. Also if there is any sort of workaround(other than rewrite everything in AS3), let me know(maybe use of localconnection?).
Try this:
on root of as2:
test.testmc.loadMovie("AS3.swf");
or in the mc u want the as3 player:
this.loadMovie("AS3.swf");
Your second code is calling test.testmc.test.testmc because it is already placed in the "testmc" so you dont need to reference it with the full path. It's recommended that you use relative paths for things like this.
So, inside the mc testmc you just need to do this.loadmovie instead of searching for test.testmc INSIDE testmc.
Hope that was what you're looking for.
Related
I exported an Fla containing AS2 code to AS3 and generated an SWF that is supposed to contain the required object oriented codes.But after i added it to IntelliJ IDE and double clicking, i do not get any inner files.Nor im able to call any instances.What is going wrong here?
UPDATE:
My colleague tells me that if we drag and drop the exported swf into intellij we dont get any button names and stuff to work upon in the action script if its AS2.So he sets AS3 and exports the swf.It worked for other files when it comes to this file upon dragging and dropping it into intellij we don't get any button names to work upon. That is the problem
This is an example of a working swf upon clicking the swf
we get the fla folder and upon clicking on hg_11 or any of the sub files we are able to get the names of the buttons.But when clicking on the file im talking about nothing comes up.BTW I just started using IntelliJ and Flash today im a total noob in this stuff.The thing is the they want this animation with interactivity running on Android Devices.I just need to link 1 SWF to another on Click of a Button.
You are not reporting something that is possible.
When you say "I exported an Fla containing AS2 code to AS3" and then "that is supposed to contain the required object oriented codes".
It seems that you are somehow expecting a code conversion from AS2 to AS3 but that's just impossible. When you convert a former AS2 based .fla to a AS3 based .fla the conversion gets rid of all AS2 code and that's the end of it. It's not gonna write or convert anything to AS3 because that's just impossible to do automatically since those 2 languages are too different.
There's no such thing as automatic code conversion from as2 to as3. The only thing that could happen with a AS2 project is that the new AS3 based .fla file gets rid of every single line of AS2 code.
So your question can safely be removed since it is based on the idea that something magical happens inside .fla files and old AS2 code gets transformed into new and shinny AS3 code. It does not happen and it will never happen.
I added a sound to the Flash Professional CC library and had the program convert it to MP3. If I create a layer and drag-and-drop the sound onto the stage the sound plays fine (even after passing it through Swiffy), however that is all I am able to do so far.
I need some way to control when the sound plays as well as volume. I tried the giving the sound a class (Sound Properties -> ActionScript -> Export for ActionScript and assigned a class name mySound).
Then added this ActionScript to the first frame:
var myAudio:Sound = new mySound();
myAudio.play();
However, after passing it through Swiffy, I get the following errors:
The ActionScript class flash.media.Sound is not supported.
The ActionScript method flash.media.Sound.play() is not supported.
So I can't use the base Sound class in Flash? Is there another base class that can be used and is it compatible with the flash.media.Sound class? Is there some other way to control playback so that it can be played at a specific time -- such as on mouse roll-over or when something is clicked?
You could try using SoundJS. BTW, Flash Pro CC does have an HTML Canvas document type that uses CreateJS (which SoundJS is part of) under the hood. It won't convert AS3 to JS, though, you have to write the JS code yourself.
I am working on embedding a SWF that is just a converted PDF created with InDesign. The SWF is 15 pages, 1 page per frame. It does include TLF text and there is no way around that unless the document is completely recreated in Flash. The problem is that when I load the SWF into my application, I never have access to the root MovieClip.
this.loader = new Loader();
this.loader.contentLoaderInfo.addEventListener( Event.INIT, this.loaderInitHandler );
this.loader.contentLoaderInfo.addEventListener( Event.COMPLETE, this.loaderInitHandler );
this.loader.load( new URLRequest( "assets/doc.swf" ) );
When I look at the loader after both the INIT and COMPLETE events as well as later on by stopping the app in debug mode, I do not see a MovieClip. Instead, the loader.content is of type doc_fla.MainTimeline__Preloader__ which contains two children, an empty Shape and another Loader. That loader, when checking INIT and COMPLETE events results in the exact same situation and it appears to be a never ending line of Loaders whose contents are "Preloaders".
Could anyone shed some light as to what is causing this or how I might fix it? I've poured a good 2 hours into solving this and I am no closer to a solution than when I started.
ActionScript Mobile project
Compiling using AIR 3.6
Testing in emulator as well as on iPad and on Nexus 7
I recompiled the SWF and embedded the TLF libraries (under ActionScript settings, just set the TLF swc which was already there to be embedded) in it and this seems to have fixed the issue. I swear I had tried that before to no success, but it worked this time.
I develop a project in FlashBuilder. The graphics and UI elements i create in the Flash IDE and give them Export Classnames. then I put the SWC in the library paths of the FlashBuilder project and create the UI elements by instanciation.
Now I want to add a Preloader for the application. I follow this article, which works:
http://pixelpaton.com/?p=4642
My question is now: I also need some graphics for the preloader. But how do I ensure that the graphics for the preloader will be loaded first, such that the preloader class can start as soon as possible?
The compiler will figure out the dependencies for your preloader class, and load them first.
For example:
public function Preloader()
{
addChild(new UIElementFromFlash());
}
Flash Builder will know UIElementFromFlash needs to be loaded before Preloader. It will also load Preloader before your main class and its dependencies as long as you have the Frame metadata tag from the article.
I'd suggest to make 2 swf files if it's possible. Make a loader.swf which loads your application swf and displays the progress and your loading animation/graphics.
See an example here: http://www.republicofcode.com/tutorials/flash/as3preloader/
Then you'll have to add URLLoader class and load your application.swf.
Try looking here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html
Like Gio suggested, having two SWF files is the best practice.
However, one other solution is to use the -frame two argument of the Flex compiler. All your definitions (code and assets) will be added to the second frame of the movie, allowing your main class to listen for the loading progress of the application and display animations.
Be careful to not reference anything from the main application in your first frame, to prevent adding more weight to it.
More detail on this technique here:
http://www.andymoore.ca/2009/08/flexsdk-3-3-how-to-make-a-flash-preloader-in-as3/
I can't find the line in the Adobe samples for a maze game where the actual .as code is included into the project. This is fundamental, since my own implementation is just using include "file name";, which isn't working. I also can't use import, since I then can't access the elements placed on the stage. Help, please? The files are available here http://download.macromedia.com/pub/developer/flash_as3_sample_game_1.zip
I tried to debug the code, but I can't even find the point where the constructor is called. The execution starts at "stop()" in frame 1 and then if you step into it, calls the enter frame event handler.
I guess Document Class is the thing you are looking for.
It is an entry point, the class which is instantiated once Flash Player loaded your SWF.