I am about to create a simple demo in flash where I have 3 layers, 3 keyframes.
Currently I am just use some simple gotoAndStop() to move to the next keyframe.
But now I need a custom event to do that but I can't create a class inside the action of a keyframe so I am not able to create a custom event.
I just have AS3 developing experience in flex so far.
Thanks in advance.
you can import any class to your flash ide application:
import com.warren.events.CustomEvent;
after this you just have to do the regular usage you would do in flex. Don't forget to have you Custom Event class in the source path folder as your fla, or to configure your fla to have the correct source path of your classes.
(Publish settings/Actionscript-settings...source path)
Related
I have one AS3 application which was developed entirely in AS3 without using single line of code in MXML. Of late I am realizing that MXML has some rich controls which are not provided in open source Apache Flex SDK. One library which is of most interest to me in mx.controls, it includes Label, DataGrid etc.
Now, I want to extend my AS3 application to call mxml compiled into swf file. I tried to import mx.controls inside my AS3 programs but it does not sense that. Please tell me if I am doing anything wrong. If I am able to import mx.controls inside as3 class it would save me a lot of time. Can I do this?
Alternatively, I am trying to write a few applications in mxml and then call (.swf) in AS3. Is it possible?
I tried Googling but all examples are pointing to using ActionScript inside MXML with [CDATA[]]. But I want the inverse. Calling MXML from ActionScript.
Please explain me at nuts and bolts level as I am struggling with this a lot.
thanks in advace
You can't do that because Flex, that uses MXML, is framework built on top of the Actionscript. But you can do reverse. In Flex MXML you can use Actioscript code, and you can also use Flash components like Sprite, MovieClip... by using UIComponent or SpriteVisualElement as their parent container.
How to use simple vector shapes from FLASH PRO in FLASH BUILDER?
I'm already using SWC method to export buttons and movieclips, but i cant find a way to export simple shape assets. I've converted them to Symbol-Graphic, but it does not work. I've tried to convert them to button/movieclip changing base class to shape, but it generates compilation errors :(.
I don't want to use hundrets of movieclips just to export simple icons for FLASH Builder (memory usage would be huge), is there any solution for exporting simple shapes to SWC and use them in FLEX?
Edit: I'm using CC versions.
If thosse desired shapes are simple, the best method would be to generate them with actionscript code. Just create custom classes whitch extends Shape class and then you can import them from compiled swc file or straight from included folder.
Maybe this can hel you too: link
Here's the situation:
Making an app in Flash CS6 that has 11 frames. Some frames have actions dependent to that frame and then there are some global actions. There are no external classes, everything is incorporated into one flash file.
Now I want to incorporate AdMob and found an offer that should work for me, but it calls for setting a document class linked to external AS file. Doing this messes up my timeline based actions.
I am more front-end that back-end when it comes to designing/programming. So, my question is: How can I incorporate this external admob actionscript into my flash document file without messing up my current scripts? Is there a way to remove it's package attributes and put it on the timeline?
Hope this description wasn't confusing.
Thanks!
Some brief about document class & classes & timeline :
Consider the whole stage as a movieclip. Now the document class would be a user defined, external class for the stage movieclip. When you don't specify the document class, flash uses a predefined one, which derives a plain movieclip class. The frames added from the IDE are converted as calls to addFrameScript and the script in the frames are scheduled to run at an interval as per the frame rate (timeline). Even the shapes you draw, images you add, everything goes in as code in the frame scripts of the stage movieclip.
Now if you add a movieclip onto the stage, the above process is repeated for it as well. You may set a class or derive from an existing class for any movieclip. The class will be initialized when the movieclip instance is created, Be it frame script or place the movieclip itself in the frame.
Now to your question.Any frame script can access the external class as well. So if you have an external class named AdMob in a file AdMob.as, lying next to the fla, you may call it anywhere, in any frame as:
new AdMob()
However you must take care of the package name & path. So if the package for AdMob is abc.bbc.AdMob then the location of the as file should be abc/bbc/AdMob.as
You may import the whole package as :
import abc.bbc.*;
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/
without getting too verbose....i have been learning AS3 over the last week by building a small Flash site. the navigation menu is constructed as a custom class rather than on a keyframe in the flash file itself. I now find myself simply needing to issue a command to control the main flash file's timeline in this manner...
pages.gotoAndPlay(framelabel);
from the custom class.
help.
The problem here you have is with scope.
There are two ways to do this in a simple way.
You can path to the timeline that you require to change using the parent property e.g. this.parent.parent.parent.gotoAndStop(...)
or just use the root value if the timeline you're trying to change is on the root
root.gotoAndStop(...)
or
stage.gotoAndStop(...)