I'm new to Flash and I trying to do something as following:
I need the ability run several layers of animation (image sequences) in a single file (ex. SWF) which will be loaded and accessed dynamically by Flex - I need to change the content (image sequence) in runtime in order to customize my animation.
What would be the best approach in this case?
Is it the correct direction?
Should I consider creating a SWF for each animation and load it dynamically into my layered SWF?
When you say you need to adjust the image sequence, do you mean customise the order of individual frames, or simply select between a selection of set sequences?
If it's the former, the answer will be a bit more in-depth, if it's the latter and there aren't too many you're probably best off exporting as SWFs, or even as a video file to compress them, then loading them in dynamically. If they're small enough not to add significant weight to your SWF, you could export them as MovieClips in a SWC and create instances of them directly in the code without having to load them in.
Hope this helps (sorry if any of the above is confusing!) - could you give a bit more detail on what you're trying to achieve?
Related
What I want to Achive:
Toggling the appearance of an Item, where the components that describe the appearance are loaded dynamically, but common elements are not loaded multiple times.
Lets say, I have a list of elements with an icon (e.g. cover) and a title (e.g. music title).
When clicked/dragged, it shifts the shape, so additional information can be displayed (e.g. duration, artist, ...).
Finally I have a DropArea, in which I can drop those elements. Here I only want to display the icon.
As I am informed correctly, it is not advisable to have all three forms pre-loaded and only shift the visibility and other parameters of the additional objects, as the first list is a ListView.
Therefore I decided, to create multiple components, and then load them with a Loader.
On the other hand, this leads to some overhead, for I load and unload the Icon, that is common to all the components, each time, the shape shifts.
My solution so far is, to load the image outside of the components, re-parenting it each time, the shape shifts. This however feels odd, and I am not sure, if this might not be the less performing way, compared to the "loading everything at once and resetting visiblity and positioners"-approach
What is the proper way to do this?
For the efficiency aspect, the most performing one should be that only dynamically loads something that is really dynamic, and leaves other things static(or so called declarative). In your app, the icon should be declarative, I think.
Regarding with reparenting, actually re-parenting is quite common in Qt Quick programming, especially within dynamically loading context. The parent in Qt Quick is not the same concept of QObject. It's just visual management (not memory management). That's why you can see Qt Quick even provides ParentChange in State/Transition.
I have a very large image(10000*10000) and for several reasons I cannot modify it (like chop it into smaller tiles.)
I don't want to display the whole image but a small section of it to improve the GUI efficiency.
But when the user click and drag it around, new part of image will be displayed in the viewport.
So, how could I pull a section of image data on the fly?
I don't recall Qt providing any support for working with partial images in case of really high resolutions. Maybe look into libtiff.
Basically, the image will be composed of either strips or tiles, so you can use the tiffreadscanline() or tiffreadencodedstrip() respectively to load portions of the image. The from that you can compose another image with the appropriate resolution for your viewport.
Alternatively, you could take a look at the QTiffHandler class, it is a private class in Qt so it is not directly accessible, but you could just copy it and if necessary modify the source to expose its functionality. Internally it uses libtiff as well.
We need to create a single jpg image from a range of existing jpgs. The user can select a range of parts in the front end of our application using JQuery. We then need to take all the parts and flatten them to create a single image.
All the parts will exist in an image directory. For example part 1 is the base image which all other parts are overlaid on. We then may choose part 8 - will will always appear at a certain point on top of the base image. We may then choose part 15 which will also appear at a certain point. Other than the base image no part can ever intersect with any other part.
Any advice on how to achieve this? Any good Nuget packages etc that could help
Thanks
Graeme
It's all there for you in the System.Drawing namespace.
Start by creating a Bitmap to draw into. Create a Graphics object from that Bitmap.
Load each of your images. Then use DrawImage to draw each one onto the target. Finish with the Save method.
I just started out with Flex, and while I have worked with Actionscript2 for a few years, I'm still getting my head around Actionscript3. I've been diving into Flex for the past week, and can't figure this one thing out.
I am looking into the best way (or 'a' way) to allow me and other folks working on this project to easily create new themes for kind-of an video player. I show two videos, and need to be able to reposition them, style them, add images and anything else, really. I'm not looking to create a full-on templating engine, but if I could have a separate file/folder for each template, that would totally make my day.
I imagined having a solution in which I would have a folder inside src/templates/, and inside that folder I would have view.mxml that contains everything I need to display the videos. I would then be able to add other files such as images and such to make this template look the way it should.
Which template should be used should be defined by a variable in the main video file. This will either be provided to the swf file on playback, or provided by the video loading an external configuration file (but this is not part of my question :).
So, in short; How do I include mxml files that are inside one or two sub-folders inside src, and how do I do this in a way that the file I wish to include can be chosen via a variable.
Thanks so much in advance!
-Dave
You'd be surprised to what degree a Flex application can change its appearance through styling. Check out the following project:
http://www.fillcolors.com/
If you need more flexibility still, you could have an application with multiple views, one for each theme you want to show. An easy way to do this in Flex is to make use of the ViewStack component which basically layers view displays, showing only one at a given time.
As a very simple example, you could have something along these lines:
<mx:ViewStack selectedIndex="{currentIndex}">
<themes:CustomTheme1/>
<themes:CustomTheme2/>
<themes:CustomTheme3/>
</mx:ViewStack>
Here, currentIndex is a variable bound to the ViewStack, determining which of the three children is currently visible, each of which represent a custom MXML component (in your case, a theme).
Response to comment:
Yes, the above example is designed to do exactly that, but it's really not a feature of Flex, but of AS3. The CustomThemeX components are located using the themes namespace. The namespace is defined within the parent components root tag. In this example, the parent is a Canvas component:
<mx:Canvas xmlns:themes="themes">
This tells the compiler to look for these custom components within the themes sub-folder of your application; in other words, the src/themes folder, which contains the CustomThemeX components.
If the preceding paragraph didn't really sense to you, I'd recommend picking up a book/reading through the documentation about AS3/Flex and learning more about some of the core concepts of AS3 and object oriented programming. I wish I could help out more, but this question is starting to get a little too broad. I hope you understand. :)
I'm not an expert on Flex. But I've seen a tutorial on skins in Flex on gotoAndLearn.com. Maybe that kan give you some hints: Introduction to Flex: Part 3
Usually Flash and Flex applications are embedded on in HTML using either a combination of object and embed tags, or more commonly using JavaScript. However, if you link directly to a SWF file it will open in the browser window and without looking in the address bar you can't tell that it wasn't embedded in HTML with the size set to 100% width and height.
Considering the overhead of the HTML, CSS and JavaScript needed to embed a Flash or Flex application filling 100% of the browser window, what are the downsides of linking directly to the SWF file instead? What are the upsides?
I can think of one upside and three downsides: you don't need the 100+ lines of HTML, JavaScript and CSS that are otherwise required, but you have no plugin detection, no version checking and you lose your best SEO option (progressive enhancement).
Update don't get hung up on the 100+ lines, I simply mean that the the amount of code needed to embed a SWF is quite a lot (and I mean including libraries like SWFObject), and it's just for displaying the SWF, which can be done without a single line by linking to it directly.
Upsides for linking directly to SWF file:
Faster access
You know it's a flash movie even before you click on the link
Skipping the html & js files (You won't use CSS to display 100% flash movie anyway)
Downsides:
You have little control on movie defaults.
You can't use custom background colors, transparency etc.
You can't use flashVars to send data to the movie from the HTML
Can't use fscommand from the movie to the page
Movie proportions are never the same as the user's window's aspect ratio
You can't compensate for browser incompetability (The next new browser comes out and you're in trouble)
No SEO
No page title, bad if you want people to bookmark properly.
No plugin information, download links etc.
If your SWF connects to external data sources, you might have cross domain problems.
Renaming the SWF file will also rename the link. Bad for versioning.
In short, for a complicated application - always use the HTML. For a simple animation movie you can go either way.
You also lose external control of the SWF. When it's embedded in HTML you can use javascript to communicate with the SWF. If the SWF is loaded directly that may not be possible.
Your 100+ lines quote seems pretty high to me. The HTML that FlashDevelop generates for embedding a SWF is only around 35 lines, with an include of a single swfobject.js file. You shouldn't need to touch the js file, and at the most would only have to tweak the HTML in very minor ways to get it to do what you want.
In my experience not all browsers handle this properly. I'm not really sure why (or which browsers) but I've mistakenly sent links like this to clients on occasion and they've often come back confused. I suspect their browser prompts them to download the file instead of displaying it properly.
One upside I can think of is being able to specify GET parameters in the direct URL to the SWF, which will then be available in the Flash app (via Application.application.parameters in Flex, not sure how you'd access them in Flash CS3). This can of course be achieved by other means as well if you have an HTML wrapper but this way it's less work.
Why would you need 100+ lines of code? Using something like swfobject reduces this amout quite some (and generally you don't want to do plugin detection, etc. by hand anyway).
More advantages:
Light weight look cuz you can get rid of the header with all the tool bars that seem to accumulate there and even the scroll bar is not needed. This enhances the impact when you are trying to show a lot of action in a short flash.
The biggie: you get it in a window that you can drag larger or smaller and make the movie larger and smaller. The player will resize the movie to fill the window you have. This is great for things like group photos where everyone wants to enlarge to find themselves and their friends. I've done this for a one frame Flash production!
Downsides:
As with popups in general, if you are asking for multiple ones from the same site, and you want different size popups, the browsers tend to simply override the size you ask for in window.open and reuse whatever is up. You need to close any open popup so the window.open will do a fresh create. It gets complicated, and I have not been able to get it to work across pages in a website. Anyone who has done this successfully, pls post how!
Adobe should be ashamed of themselves with the standard embed, which defeats the puprose of convention over configuration. Check ^swfobject (as mentioned above) or swfin