| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Senior Member
Join Date: May 2005
Location: St Helens
Posts: 460
|
actionscript 3
now that you cant use actionscript on buttons, or loadmovie, flash is really wrecking my head. ive managed to get some on over events to work using: Code:
but i cant figure how to get a movie to load from the library into a holder. i keep coming across load(Loader) but have no idea how to use it. can anyone help? |
|
|
|
|
|
#2 (permalink) |
|
Senior Member
Join Date: May 2005
Location: St Helens
Posts: 460
|
ok forget the first post. ive got a version working, but not exactly how i need it to. this is my code. Code:
this method loads an external swf file: Code:
what i cant figure out is how to load a movieclip from the library. i have set the linkage options to export the movieclip for actionscript and given it a name "Image02" but cant get it to link. any ideas on this guys? |
|
|
|
#3 (permalink) |
|
Trailer Trash™
Join Date: Sep 2006
Posts: 852
|
do the usual linkage/export for actionscript malarkey, giving it a "Class" value, e.g. "Example", in the linkage dialog then do something like: Code:
cant find that monkey in the docs like, must be well buried or i'm blind... hth *obviously your scope for the addChild() can be specified, e.g. container.addChild(e) |
|
|
|
#4 (permalink) |
|
Senior Member
Join Date: May 2005
Location: St Helens
Posts: 460
|
i got it. var Image2:MovieClip = new Image(); addChild(Image2); Image2 is the instance name once its on the stage. Image is the linkage name. why cant they make it clear bloody coders! Last edited by dpc036 : 04-07-2007 at 12:17. |
|
|
|
#5 (permalink) |
|
Trailer Trash™
Join Date: Sep 2006
Posts: 852
|
dont want to piss on your parade but technically that's incorrect the compiler won't catch it since your Image class is inheriting from MovieClip; also, not sure how you're getting the instance name you infer above, it doesn't work for me - you have to specify the properties before adding the child (or when calling the constructor if you implement that i suppose, havent tried it) so: Code:
to be honest i thought the new compiler would be stricter in type checking... i wouldn't count on that behaviour |
|
|
|
#7 (permalink) |
|
Trailer Trash™
Join Date: Sep 2006
Posts: 852
|
Image2 is a reference var (which you are incorrectly typing as MovieClip) to your newly created object of class Image - not it's instance name. Check your Debug > List Objects ![]() Grab the FLA Last edited by proc355 : 04-07-2007 at 16:43. |
|
|
|
#9 (permalink) |
|
Trailer Trash™
Join Date: Sep 2006
Posts: 852
|
lol ok - it's easy to come across as "i'm bloody right and you aint" so please believe me that isn't what i'm saying, ok? last two things i'll say on this unless you need clarification 1) typing your var to MovieClip rather than Image negates the advantage of having strict typing - it works because your Image class inherits from MovieClip but it isn't correct; since everything inherits from the Object class you might as well just type all your variables/arguments to "Object" - you see where this is going? it's pointless. use it to your advantage. i spend most of my time dealing with ruby these days, which isn't strictly typed - much better imo - but, and it's a strong but, in languages where the compiler depends upon strict typing for some of it's functionality it's better to play by the rules, lest headaches and tears ensue - there are some cases in which you will not get away with it. you don't have to strictly type anything in flash, but in the advent of a bug you're giving the compiler less information to work with - you'll get less back in the way of information to fix it. you're making life harder for yourself. don't do it! be lazy! 2) your instance name is not being set to "Image2" as you said, it's being set to "instance2" which is just a generated name - if you expect to be in control then you have to explicitly name things - you still havent looked at your debug output or you'd see it yourself: Level #0: Frame=1 Movie Clip: Frame=1 Target="_level0.holder" Shape: Movie Clip: Frame=1 Target="_level0.holder.instance2" Shape: that's from your fla apart from syntax none of this has changed from AS2.0 - there's only a change in that you can now instantiate MovieClips and their descendents using the "new" keyword which is the way it's done for anything else (and the way it should be) - no more attachMovieClip shite. hth |
|
|
|
#10 (permalink) |
|
Senior Member
Join Date: May 2005
Location: St Helens
Posts: 460
|
you didnt come across like. not being an actionscript pro your initital solution didnt really make sense to me. then i couldnt see why my version wasnt technically correct, but worked. thanks again Last edited by dpc036 : 05-07-2007 at 11:43. |
|
![]() |