-
Well this may not be correct, but check out the other thread in this forum about the syntax checker. Aparently, it does not work. If you compile your code you can see the real debugging, but just by using check syntax it will check it by using 2.0 standards (least thats my guess).
To my experience, i finally have (after 1 day) a working couple classes for a basic site, which compile fine. But if i use check syntax (or even auto formatting) it gives me tons of errors, all of which have "2.0" in them somewhere.
-
Senior Member
Originally Posted by Zeusbwr
Well this may not be correct, but check out the other thread in this forum about the syntax checker. Aparently, it does not work. If you compile your code you can see the real debugging, but just by using check syntax it will check it by using 2.0 standards (least thats my guess).
To my experience, i finally have (after 1 day) a working couple classes for a basic site, which compile fine. But if i use check syntax (or even auto formatting) it gives me tons of errors, all of which have "2.0" in them somewhere.
thats relieving, thanks.
-
Senior Member
Couple of important things:
1. properties like _x, _rotation are now written without the underscore: x, rotation.
2. _root is now root but read only. To refer to the stage you cannot use _root any more. If you extend Sprite or MovieClip you can use this.parent.
OTHERWISE FOR EVERYBODY: please stick to the main topic of this thread and if you have specific questions start a new thread.
Thanks
- The right of the People to create Flash movies shall not be infringed. -
-
Actually that is one thing I don't like about AS3 - It does seem pretty difficult to get to the the root now. .parent or .stage are only defined AFTER your sprite or movieClip have been added to the display list. In Flex you can use mx.core.Application.application, I think in Flash 9 there's some sort of equivalent using the Document object?
I can see why Macdobe might have tightened this up - too many flash projects end with scripts littered through the fla, all setting and changing properties on the root, so the root basically becomes an alternative global scope - nasty!
AS3 seems to go the too far the other way (as far as I can see).
IMHO the class that provides access to the display list should be globally available (perhaps read-only), but it really should have the same class identifier for both Flex and Flash projects.
Last edited by misuser; 09-06-2006 at 03:45 AM.
-
...In fact what I'd like to see is the Stage class implemented as a singleton so you could get the stage like this:
flash.display.Stage.instance
It is a natural singleton (like the highlander, "there can be only one") so why not?
-
Here's an idea : you can create a class with static stage and root properties. In your document class, you set these to reference the actual stage and root. Then you can access the stage and root from everywhere you want by using these static properties. Should work.
-
I never ran into the problems you address here but let's have a look. You are talking about the parent and stage object before a DisplayObject has been added to the display list. How can this be defined before you added the Object to the list or after you removed it. If there is no parent, how do you want to know about it? And why do you want to access it if it does not exist?
The stage singleton is a good idea but in fact you have to agree that there are also parts that do not belong to the stage which would gain access to it. So talking about the design of AS3 it would be just against what Adobe is currently trying to force the users. Clean code. If you really need the global access to the stage, then you may follow the idea of FallX.
Code:
public static class Global {
public static var stage: Stage;
public static function init( s: Stage, ... ): void {
stage = s;
}
}
But I have to say that I really like the clean order. Maybe you can post an example where no other solution exists?
-
Senior Member
Aieeeeeeeieieie
Originally Posted by cancerinform
download the example here, check the properties of the movieclips in the library.
http://flashas3.flashscript.biz/even..._bubbling.html
That is another thing not possible in AS2 but very useful, event bubbling.
Then the Delegate class is autonatically included in listeners, meaning the "this" word within functions refers to the class and not the listener object.
So that's, just, completely terrifying to me. I'm on OSX and still haven't gotten a copy of AS3 going, but I thought I'd be able to convert code. Forget it.
All my classes are full of constructs like
this.target_mc[button[x]].outerObj = this;
this.target_mc[button[x]].onPress = function() {
this.outerObj(class function)
}
Even though it's a memory drain, it works... I'm scared to death of converting. I'm halfway through a 6 month commercial DB project with a Flash front-end (using AMFPHP) and I could really use the speed boost when rendering two-page-long auto-generated forms with comboBoxes inside those Godawful scrollPanes (I have to swap their depths back before deleting them)...I guess I'll just start from scratch with v2.0 next year when AS3 is stable and the components are out, 'cause it sounds like there's no sound way to get this code across as it stands...sheesh.
-
@joa__
This is just off the top of my head...
Suppose for example you wanted to check the width of the stage from inside a control object (i.e. one that never gets added to the display list)? Sounds like the sort of thing that happens from time-to-time. As far as I understand it, the current situation is, for Flex projects you could use mx.core.Application.application.width but would have to use something different for Flash projects. This means I couldn't use such a control object in a swc that is designed for both Flash and Flex. Am I wrong (kind of hope so)?
Another example might be a singleton class that spawns display objects as children of the root - maybe they always appear on top of, or behind everything else. The beauty of a singleton is that is doesn't need to (and in fact can't) be bound a single location within the program.
Also I'm not keen on the Global class route - it would have to be manually initialised by the root document / application which just feels wrong and not at all modular.
-
I just had a look at the way Macdobe do it in the mx.control.Alert component - just the kind of thing that causes a problem. They do it like this:
parent = Sprite(Application.application);
Which is fine for Flex but would that work in flash 9?
-
@joshstrike
By "this.outerObj(class function)" I'm guessing you mean "this.outerObj.method()"? You want to call a method on a movieclip, not pass a function to its constructor, right?
I can't see why that wouldn't work in AS3.
btw, in both AS2 or AS3, you could just use variable scope to store the back reference for you:
var outerObject:MovieClip = this;
this.target_mc[button[x]].onPress = function() {
outerObj.method();
}
The variable outerObject and the function onPress share the same scope because they're created in the same scope.
-
This means I couldn't use such a control object in a swc that is designed for both Flash and Flex.
I haven't worked with flex yet (only flash 9), but I believe that once a clip has been compiled, the differences between flex and flash won't matter. But I guess we'll have to wait and see until F9 is fully released.
I guess I'll just start from scratch with v2.0 next year when AS3 is stable
AS3 is already stable and released.
Maybe you can post an example where no other solution exists?
The absense of Key.isDown() is an example that comes to mind. I wanted to mimic it, which was pretty easy, except that it requires a reference to the stage to add keyboard listeners to it. So my Key-class will not work until you give it a reference to the stage, which is no big deal, but it would be handy if I could reference it directly.
Last edited by Fall_X; 09-06-2006 at 10:45 AM.
-
...I believe that once a clip has been compiled, the differences between flex and flash won't matter.
Not sure if this contravenes the rules of the forum, but I've got 10 uk pounds that says the differences will matter, if you're interested...
-
I would take you on but I'm in a tight spot financially at the moment, so I'd better not make it any worse (even if it's just 10ukp)
It just seems to me that both flex and flash will compile to the same bytecode, so the results should be interchangeable. Off course, I could be completely wrong here
-
half as fun, double the price
Originally Posted by misuser
Not sure if this contravenes the rules of the forum, but I've got 10 uk pounds that says the differences will matter, if you're interested...
Both Flash 9 and Flex 2 use the same compiler to create the same bytecode in a resulting SWF that runs in AVM2 in the Flash 9 Player. The only difference in Flex SWFs is that they rely heavily on the mx framework - a collection of AS3 classes that work together to make Flex apps function. You can get this framework for free by downloading the Flex 2 SDK. You could then even create Flex apps in Flash 9 but you just wouldn't have the luxuries the Flex 2 IDE provides.
-
...and unfortunatley the only convientent way of getting the at the root (Application.application) is part of the mx framework not the core AS3 classes, so it might not make it into Flash 9 :-(
-
There is a difference between an Application and the Stage. While your Application may contain sub-applications but the stage is not able to hold any other sub-stages.
-
half as fun, double the price
You can recreate Application.application in about 5 lines of code using a document class called Application for Flash 9. The document class inherntly has stage access as well.
-
Yeah true - i was thinking Application.application seems the obvious place to access the stage from (for objects not already on the display list). Admittedly, I'd still need to write a custom stage getter method on the main appliactions class and, now I think about it, that's just as ugly as the global class thing fall_x suggested.
For now I'll just cross my fingers that I never have to code such a thing.
-
Cross your fingers that you never design your code to require such a construct. Better, eh?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|